| 2019 |
|
# if not already in the diagram , then create the nodes
|
| 2020 |
|
print 'nodea type', nodea.__class__
|
| 2021 |
|
if not isinstance(nodea, ORMShape):
|
| 2022 |
|
self.canvas.CreateNode(self.canvas.pdc, nodea)
|
| 2023 |
|
print 'nodeb type', nodeb.__class__
|
| 2024 |
|
if not isinstance(nodeb, ORMShape):
|
| 2025 |
|
self.canvas.CreateNode(self.canvas.pdc, nodeb)
|
| |
2022 |
## # if not already in the diagram , then create the nodes
|
| |
2023 |
## print 'nodea type', nodea.__class__
|
| |
2024 |
## if not isinstance(nodea, ORMShape):
|
| |
2025 |
## self.canvas.CreateNode(self.canvas.pdc, nodea)
|
| |
2026 |
## print 'nodeb type', nodeb.__class__
|
| |
2027 |
## if not isinstance(nodeb, ORMShape):
|
| |
2028 |
## self.canvas.CreateNode(self.canvas.pdc, nodeb)
|
| 2032 |
|
# if not already in the diagram , then create the nodes
|
| 2033 |
|
print 'nodea type', nodea.__class__
|
| 2034 |
|
if not isinstance(nodea, ORMShape):
|
| 2035 |
|
self.canvas.CreateNode(self.canvas.pdc, nodea)
|
| |
2035 |
## # if not already in the diagram , then create the nodes
|
| |
2036 |
## print 'nodea type', nodea.__class__
|
| |
2037 |
## if not isinstance(nodea, ORMShape):
|
| |
2038 |
## self.canvas.CreateNode(self.canvas.pdc, nodea)
|
| 2092 |
|
## if debug: print 'round rectangle dimensions',x, y, box_w, box_h
|
| 2093 |
|
box_x = x - box_w/2
|
| 2094 |
|
box_y = y - box_h/2
|
| 2095 |
|
# dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,8)
|
| 2096 |
|
dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,5) # 6
|
| |
2103 |
|
| |
2104 |
if self.NodeA: # objectified fact type
|
| |
2105 |
box_w = role_box_width * self.NodeA.Target.Nary + left_margin + right_margin + 4
|
| |
2106 |
box_h = role_box_width + top_margin + bottom_margin
|
| |
2107 |
|
| |
2108 |
box_x = x - box_w/2
|
| |
2109 |
box_y = y - box_h/2 + 3
|
| |
2110 |
# dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,8)
|
| |
2111 |
dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,5)
|
| |
2112 |
start_text = top_margin + h # start text this far above the box
|
| |
2113 |
yy = box_y - start_text
|
| |
2114 |
else:
|
| |
2115 |
box_w = w + left_margin + right_margin
|
| |
2116 |
box_h = h + top_margin + bottom_margin
|
| |
2117 |
|
| |
2118 |
box_x = x - box_w/2
|
| |
2119 |
box_y = y - box_h/2
|
| |
2120 |
# dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,8)
|
| |
2121 |
dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,5)
|
| |
2122 |
start_text = 0 # only for objectified fact types
|
| |
2123 |
yy = box_y + top_margin
|
| |
2412 |
def OnTop(self):
|
| |
2413 |
print 'started ontop'
|
| |
2414 |
followers = self.GetFollowers()
|
| |
2415 |
object_type_shape = None
|
| |
2416 |
for f in followers:
|
| |
2417 |
if f.Subtype == 'ORMObjectTypeShape':
|
| |
2418 |
object_type_shape = f
|
| |
2419 |
break
|
| |
2420 |
if object_type_shape:
|
| |
2421 |
print 'found objectified'
|
| |
2422 |
if self.dcid < object_type_shape.dcid:
|
| |
2423 |
print 'reseting fact dcid'
|
| |
2424 |
dc = self.canvas.pdc
|
| |
2425 |
dc.RemoveId(self.dcid) # clear the old id
|
| |
2426 |
self.canvas.SetGraphic(dc, self, newid=True) # create new one
|
| |
2427 |
for f in followers:
|
| |
2428 |
print 'looking at', f
|
| |
2429 |
if debug:
|
| |
2430 |
print "object dcid, other dcid", f.dcid, object_type_shape.dcid
|
| |
2431 |
if f.dcid < object_type_shape.dcid: # if behind object type shape
|
| |
2432 |
dc.RemoveId(f.dcid) # clear the old id
|
| |
2433 |
self.canvas.SetGraphic(dc, f, newid=True) # create new one
|
| |
2434 |
|
| 3431 |
|
def OnPops04(self, event):
|
| 3432 |
|
self.log.WriteText("Popup seven\n")
|
| |
3486 |
def ObjectifyFact(self, event):
|
| |
3487 |
l = self.pdc.FindObjects(self.popupx, self.popupy, hitradius)
|
| |
3488 |
if l:
|
| |
3489 |
fact_shape = self.dcid_to_shape_xref.get(l[0])
|
| |
3490 |
fact_mo = fact_shape.Target
|
| |
3491 |
if fact_mo.GetList('ORMObjectType'):
|
| |
3492 |
if debug: print "trying to objectify an objectified fact type"
|
| |
3493 |
return # already objectified
|
| |
3494 |
# object_shape = self.AddNode('ORMObjectTypeShape', self.popupx, self.popupy)
|
| |
3495 |
object_shape = self.AddFollower('ORMObjectTypeShape', fact_shape)
|
| |
3496 |
x, y = fact_shape.GetCenter() # posx and posy should be the center, but aren't
|
| |
3497 |
object_shape.SetTempPos(x, y)
|
| |
3498 |
object_shape.CommitPos()
|
| |
3499 |
## object_mo = object_shape.Target
|
| |
3500 |
## object_shape.NodeAID = fact_shape.ID
|
| |
3501 |
## object_mo.FactTypeID = fact_mo.ID
|
| |
3502 |
fact_shape.OnTop() # move object type behind fact type
|
| |
3503 |
Data.SetUndo('Objectify Fact Type')
|
| |
3504 |
self.RedrawID(fact_shape.dcid)
|
| |
3505 |
self.RedrawID(object_shape.dcid)
|
| |
3506 |
|
| |
3507 |
def UnObjectifyFact(self, event):
|
| |
3508 |
pass
|
| |
3509 |
|
| |
3510 |
def OnPops04(self, event): # objectify fact type
|
| |
3511 |
if event.IsChecked():
|
| |
3512 |
self.ObjectifyFact(event)
|
| |
3513 |
else:
|
| |
3514 |
self.UnObjectifyFact(event)
|
| 4473 |
|
for id in self.GetSelection():
|
| 4474 |
|
self.MoveID(id, dx, dy)
|
| |
4555 |
for dcid in self.GetSelection():
|
| |
4556 |
|
| |
4557 |
# special handling of objectified fact types
|
| |
4558 |
# because moving object type should move the fact type, too
|
| |
4559 |
shape = self.dcid_to_shape_xref.get(dcid)
|
| |
4560 |
if shape.Subtype == 'ORMObjectTypeShape' and shape.NodeA:
|
| |
4561 |
if self.InSelection(shape.NodeA.dcid):
|
| |
4562 |
pass # move because follow is surpressed when both are selected
|
| |
4563 |
else: # move fact type
|
| |
4564 |
self.MoveID(shape.NodeA.dcid, dx, dy)
|
| |
4565 |
continue
|
| |
4566 |
|
| |
4567 |
self.MoveID(dcid, dx, dy)
|