| |
2597 |
class ORMSubtypeConstraintShape(ORMCircle):
|
| |
2598 |
''' '''
|
| |
2599 |
def Draw(self, dc):
|
| |
2600 |
orm_object = self.Get('Target')
|
| |
2601 |
x, y = self.GetPos()
|
| |
2602 |
## x = self.PosX # treat this as the center of the shape
|
| |
2603 |
## y = self.PosY
|
| |
2604 |
|
| |
2605 |
dc.ClearId(self.dcid)
|
| |
2606 |
if not orm_object: return # object has probably been undone
|
| |
2607 |
dc.SetId(self.dcid)
|
| |
2608 |
|
| |
2609 |
box_w = 14 # 20
|
| |
2610 |
box_h = box_w
|
| |
2611 |
box_x = x - box_w/2
|
| |
2612 |
box_y = y - box_h/2
|
| |
2613 |
|
| |
2614 |
pen = self.canvas.CachedPen(1, 1, wx.SOLID)
|
| |
2615 |
dc.SetPen(pen)
|
| |
2616 |
if self.GetSelected():
|
| |
2617 |
dc.SetBrush(self.canvas.CachedBrush((210,210,210)))
|
| |
2618 |
else:
|
| |
2619 |
dc.SetBrush(self.canvas.CachedBrush((254,254,254,128)))
|
| |
2620 |
# dc.SetBrush(self.canvas.CachedBrush('White'))
|
| |
2621 |
dc.DrawCircle(x,y,box_w/2)
|
| |
2622 |
|
| |
2623 |
r = wx.Rect(box_x,box_y,box_w,box_h)
|
| |
2624 |
r.Inflate(pen.GetWidth(),pen.GetWidth())
|
| |
2625 |
dc.SetIdBounds(self.dcid,r) # must set before self.AdjustEnd can be used
|
| |
2626 |
|
| |
2627 |
if orm_object.Operator in ('Total', 'Partition'): # inclusive
|
| |
2628 |
dc.SetBrush(self.canvas.CachedBrush('Black'))
|
| |
2629 |
dc.DrawCircle(x,y,box_w/4)
|
| |
2630 |
|
| |
2631 |
if orm_object.Operator in ('Exclusive', 'Partition'): # exclusive
|
| |
2632 |
xx, yy = self.AdjustEnd((box_x, box_y))
|
| |
2633 |
adjx = x - xx - 2
|
| |
2634 |
adjy = y - yy - 2
|
| |
2635 |
dc.DrawLine(x-adjx, y-adjy, x+adjx+1, y+adjy+1)
|
| |
2636 |
dc.DrawLine(x-adjx, y+adjy, x+adjx+1, y-adjy-1)
|
| |
2637 |
|
| |
2638 |
## dc.SetFont(self.canvas.GetFont())
|
| |
2639 |
## dc.SetTextForeground('Black')
|
| |
2640 |
## dc.SetTextBackground('White')
|
| |
2641 |
##
|
| |
2642 |
## w = 3; h = 2
|
| |
2643 |
## for i in range(len(lines)):
|
| |
2644 |
## line = lines[i]
|
| |
2645 |
## line_w, line_h = sizes[i]
|
| |
2646 |
## dc.DrawText(line, box_x+w, box_y+h)
|
| |
2647 |
## h += line_h
|
| |
2648 |
|
| 2768 |
|
'''Connects to Role box or to Subtype arrow.
|
| 2769 |
|
I have it wrong at present.'''
|
| |
2823 |
'''Connects to Fact Type at one or more Role boxes'''
|
| |
2824 |
def Draw(self, dc):
|
| |
2825 |
orm_object = self.Get('Target')
|
| |
2826 |
x, y = self.GetPos()
|
| |
2827 |
nodea = self.Get('NodeA')
|
| |
2828 |
nodeb = self.Get('NodeB')
|
| |
2829 |
|
| |
2830 |
dc.ClearId(self.dcid)
|
| |
2831 |
if not orm_object: return # object has probably been undone
|
| |
2832 |
dc.SetId(self.dcid)
|
| |
2833 |
|
| |
2834 |
enda = nodea.GetPos()
|
| |
2835 |
endb = nodeb.GetPos()
|
| |
2836 |
enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda)
|
| |
2837 |
|
| |
2838 |
minx = min(enda[0], endb[0])
|
| |
2839 |
maxx = max(enda[0], endb[0])
|
| |
2840 |
miny = min(enda[1], endb[1])
|
| |
2841 |
maxy = max(enda[1], endb[1])
|
| |
2842 |
|
| |
2843 |
box_w = maxx - minx + 6
|
| |
2844 |
box_h = maxy - miny + 6
|
| |
2845 |
|
| |
2846 |
pen = self.canvas.CachedPen(1, 1, wx.SOLID)
|
| |
2847 |
dc.SetPen(pen)
|
| |
2848 |
dc.DrawLine(enda[0], enda[1], endb[0], endb[1])
|
| |
2849 |
self.SetTempPos((enda[0]+endb[0]) / 2, (enda[1] + endb[1]) / 2)
|
| |
2850 |
|
| |
2851 |
r = wx.Rect(minx,miny,box_w,box_h)
|
| |
2852 |
r.Inflate(pen.GetWidth(),pen.GetWidth())
|
| |
2853 |
dc.SetIdBounds(self.dcid,r)
|
| |
2854 |
|
| |
2855 |
class ORMSubtypeConstraintConnectorShape(ORMConnector):
|
| |
2856 |
'''Connects to Subtype arrow'''
|
| |
3122 |
def ConstraintMenu(self, constraint, menu):
|
| |
3123 |
if self.rolelist:
|
| |
3124 |
menu.Append(self.popsID21, "Add Role List")
|
| |
3125 |
menu.AppendSeparator()
|
| |
3126 |
menu.AppendRadioItem(self.popsID22, "Set as Unique")
|
| |
3127 |
menu.Check(self.popsID22, (constraint.Operator == 'Unique'))
|
| |
3128 |
menu.AppendRadioItem(self.popsID23, "Set as InclusiveOr")
|
| |
3129 |
menu.Check(self.popsID23, (constraint.Operator == 'InclusiveOr'))
|
| |
3130 |
menu.AppendRadioItem(self.popsID24, "Set as Subset")
|
| |
3131 |
menu.Check(self.popsID24, (constraint.Operator == 'Subset'))
|
| |
3132 |
menu.AppendRadioItem(self.popsID25, "Set as Equality")
|
| |
3133 |
menu.Check(self.popsID24, (constraint.Operator == 'Equality'))
|
| |
3134 |
menu.AppendRadioItem(self.popsID26, "Set as Exclusion")
|
| |
3135 |
menu.Check(self.popsID24, (constraint.Operator == 'Exclusion'))
|
| |
3136 |
menu.AppendRadioItem(self.popsID27, "Set as ExclusiveOr")
|
| |
3137 |
menu.Check(self.popsID24, (constraint.Operator == 'ExclusiveOr'))
|
| |
3138 |
menu.AppendRadioItem(self.popsID28, "Set as Value")
|
| |
3139 |
menu.Check(self.popsID24, (constraint.Operator == 'Value'))
|
| |
3140 |
menu.AppendRadioItem(self.popsID29, "Set as Ring")
|
| |
3141 |
menu.Check(self.popsID24, (constraint.Operator == 'Ring'))
|
| |
3142 |
menu.AppendSeparator()
|
| |
3143 |
count = len(constraint.GetList('ORMConstraintList'))
|
| |
3144 |
if count > 0:
|
| |
3145 |
menu.Append(self.popsID41, "Delete Role List 1")
|
| |
3146 |
if count > 1:
|
| |
3147 |
menu.Append(self.popsID42, "Delete Role List 2")
|
| |
3148 |
if count > 2:
|
| |
3149 |
menu.Append(self.popsID43, "Delete Role List 3")
|
| |
3150 |
if count > 3:
|
| |
3151 |
menu.Append(self.popsID44, "Delete Role List 4")
|
| |
3152 |
|
| |
3153 |
def SubtypeConstraintMenu(self, constraint, menu):
|
| |
3154 |
menu.AppendRadioItem(self.popsID31, "Set as Exclusive")
|
| |
3155 |
menu.Check(self.popsID31, (constraint.Operator == 'Exclusive'))
|
| |
3156 |
menu.AppendRadioItem(self.popsID32, "Set as Total")
|
| |
3157 |
menu.Check(self.popsID32, (constraint.Operator == 'Total'))
|
| |
3158 |
menu.AppendRadioItem(self.popsID33, "Set as Partition")
|
| |
3159 |
menu.Check(self.popsID33, (constraint.Operator == 'Partition'))
|
| |
3160 |
|
| |
3189 |
self.popsID21 = wx.NewId()
|
| |
3190 |
self.popsID22 = wx.NewId()
|
| |
3191 |
self.popsID23 = wx.NewId()
|
| |
3192 |
self.popsID24 = wx.NewId()
|
| |
3193 |
self.popsID25 = wx.NewId()
|
| |
3194 |
self.popsID26 = wx.NewId()
|
| |
3195 |
self.popsID27 = wx.NewId()
|
| |
3196 |
self.popsID28 = wx.NewId()
|
| |
3197 |
self.popsID29 = wx.NewId()
|
| |
3198 |
self.popsID31 = wx.NewId()
|
| |
3199 |
self.popsID32 = wx.NewId()
|
| |
3200 |
self.popsID33 = wx.NewId()
|
| |
3201 |
self.popsID41 = wx.NewId()
|
| |
3202 |
self.popsID42 = wx.NewId()
|
| |
3203 |
self.popsID43 = wx.NewId()
|
| |
3204 |
self.popsID44 = wx.NewId()
|
| |
3223 |
self.Bind(wx.EVT_MENU, self.OnPops21, id=self.popsID21)
|
| |
3224 |
self.Bind(wx.EVT_MENU, self.OnPops22, id=self.popsID22)
|
| |
3225 |
self.Bind(wx.EVT_MENU, self.OnPops23, id=self.popsID23)
|
| |
3226 |
self.Bind(wx.EVT_MENU, self.OnPops24, id=self.popsID24)
|
| |
3227 |
self.Bind(wx.EVT_MENU, self.OnPops25, id=self.popsID25)
|
| |
3228 |
self.Bind(wx.EVT_MENU, self.OnPops25, id=self.popsID26)
|
| |
3229 |
self.Bind(wx.EVT_MENU, self.OnPops25, id=self.popsID27)
|
| |
3230 |
self.Bind(wx.EVT_MENU, self.OnPops25, id=self.popsID28)
|
| |
3231 |
self.Bind(wx.EVT_MENU, self.OnPops25, id=self.popsID29)
|
| |
3232 |
self.Bind(wx.EVT_MENU, self.OnPops31, id=self.popsID31)
|
| |
3233 |
self.Bind(wx.EVT_MENU, self.OnPops32, id=self.popsID32)
|
| |
3234 |
self.Bind(wx.EVT_MENU, self.OnPops33, id=self.popsID33)
|
| |
3235 |
self.Bind(wx.EVT_MENU, self.OnPops33, id=self.popsID41)
|
| |
3236 |
self.Bind(wx.EVT_MENU, self.OnPops33, id=self.popsID42)
|
| |
3237 |
self.Bind(wx.EVT_MENU, self.OnPops33, id=self.popsID43)
|
| |
3238 |
self.Bind(wx.EVT_MENU, self.OnPops33, id=self.popsID44)
|
| |
3479 |
def OnPops21(self, event):
|
| |
3480 |
if not self.rolelist: return # ignore command of not roles have been selected
|
| |
3481 |
l = self.pdc.FindObjects(self.popupx, self.popupy, hitradius)
|
| |
3482 |
if l:
|
| |
3483 |
shape = self.dcid_to_shape_xref.get(l[0])
|
| |
3484 |
target = shape.Get('Target')
|
| |
3485 |
# create new constraint list
|
| |
3486 |
priorlists = target.GetList('ORMConstraintList')
|
| |
3487 |
clist = shape.db.GetObject('ORMConstraintList') # new constraint object
|
| |
3488 |
clist.ORMConstraintID = target.ID
|
| |
3489 |
clist.Seq = len(priorlists)+1 # next number
|
| |
3490 |
fact_type_ids = {}
|
| |
3491 |
for i, role in enumerate(self.rolelist):
|
| |
3492 |
crole = shape.db.GetObject('ORMConstraintRole')
|
| |
3493 |
crole.ORMConstraintListID = clist.ID
|
| |
3494 |
crole.ORMRoleID = role.ID
|
| |
3495 |
crole.Seq = i + 1
|
| |
3496 |
fact_type_ids[role.ORMFactTypeID] = None
|
| |
3497 |
|
| |
3498 |
print 'fact type ids', fact_type_ids
|
| |
3499 |
self.rolelist = []
|
| |
3500 |
facts = [ x for x in self.Report.GetList('GraphicObject') if x.Subtype == 'ORMFactTypeShape' ]
|
| |
3501 |
for factshape in facts:
|
| |
3502 |
print factshape.Target.ID, factshape.Target.ID in fact_type_ids
|
| |
3503 |
if factshape.Target.ID in fact_type_ids:
|
| |
3504 |
new_shape = self.AddConnector('ORMConstraintConnectorShape', shape, factshape)
|
| |
3505 |
new_shape.TableName = clist.Table # so 'Target' will work
|
| |
3506 |
new_shape.TableID = clist.ID
|
| |
3507 |
new_shape.ORMConstraintListID = clist.ID
|
| |
3508 |
self.RedrawID(factshape.dcid)
|
| |
3509 |
|
| |
3510 |
## self.ClearSelection()
|
| |
3511 |
## self.SelectObject(new_shape.dcid)
|
| |
3512 |
Data.SetUndo("Add Constraint List")
|
| |
3513 |
## self.RedisplayID(new_shape.dcid)
|
| |
3514 |
## self.RedrawID(shape.dcid)
|
| |
3515 |
## for x in shape.GetFollowers():
|
| |
3516 |
## self.RedrawID(x.dcid)
|
| |
3517 |
|
| |
3518 |
def OnPops22(self, event):
|
| |
3519 |
pass
|
| |
3520 |
def OnPops23(self, event):
|
| |
3521 |
pass
|
| |
3522 |
def OnPops24(self, event):
|
| |
3523 |
pass
|
| |
3524 |
def OnPops25(self, event):
|
| |
3525 |
pass
|
| |
3526 |
def OnPops26(self, event):
|
| |
3527 |
pass
|
| |
3528 |
def OnPops27(self, event):
|
| |
3529 |
pass
|
| |
3530 |
def OnPops28(self, event):
|
| |
3531 |
pass
|
| |
3532 |
def OnPops29(self, event):
|
| |
3533 |
pass
|
| |
3534 |
|
| |
3535 |
def OnPops41(self, event):
|
| |
3536 |
pass
|
| |
3537 |
def OnPops42(self, event):
|
| |
3538 |
pass
|
| |
3539 |
def OnPops43(self, event):
|
| |
3540 |
pass
|
| |
3541 |
def OnPops44(self, event):
|
| |
3542 |
pass
|
| |
3543 |
|
| |
3544 |
def SubtypeConstraintOperator(self, event, new_value, undo_msg):
|
| |
3545 |
l = self.pdc.FindObjects(self.popupx, self.popupy, hitradius)
|
| |
3546 |
if l:
|
| |
3547 |
shape = self.dcid_to_shape_xref.get(l[0])
|
| |
3548 |
target = shape.Get('Target')
|
| |
3549 |
target.Operator = new_value
|
| |
3550 |
Data.SetUndo(undo_msg)
|
| |
3551 |
self.RedrawID(shape.dcid)
|
| |
3552 |
|
| |
3553 |
def OnPops31(self, event):
|
| |
3554 |
self.SubtypeConstraintOperator(event, 'Exclusive', 'Set Exclusive')
|
| |
3555 |
|
| |
3556 |
def OnPops32(self, event):
|
| |
3557 |
self.SubtypeConstraintOperator(event, 'Total', 'Set Total')
|
| |
3558 |
|
| |
3559 |
def OnPops33(self, event):
|
| |
3560 |
self.SubtypeConstraintOperator(event, 'Partition', 'Set Partition')
|
| |
3561 |
|