| 2295 |
|
dc.SetId(self.dcid)
|
| 2296 |
|
|
| 2297 |
|
text = (orm_object.Name or '')
|
| 2298 |
|
if text: text = '[' + text + ']'
|
| 2299 |
|
if debug: print orm_object, 'has name:', text or '--'
|
| 2300 |
|
lines = text.splitlines()
|
| 2301 |
|
sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ] # pull out only w and h
|
| 2302 |
|
w = 5
|
| 2303 |
|
h = 0
|
| 2304 |
|
for line_w,line_h in sizes:
|
| 2305 |
|
w = max(w, line_w)
|
| 2306 |
|
h += line_h
|
| 2307 |
|
box_w = w + 6
|
| 2308 |
|
box_h = h + 6
|
| 2309 |
|
box_x = x - box_w/2
|
| 2310 |
|
box_y = y - box_h/2
|
| 2311 |
|
|
| 2312 |
|
### don't draw anything
|
| 2313 |
|
if text == '':
|
| 2314 |
|
pen = self.canvas.CachedPen(1, 1, wx.DOT)
|
| 2315 |
|
# pen = self.canvas.CachedPen(1, 1, wx.SOLID)
|
| 2316 |
|
else:
|
| 2317 |
|
pen = self.canvas.CachedPen(2, 1, wx.SOLID)
|
| 2318 |
|
dc.SetPen(pen)
|
| 2319 |
|
### dc.SetBrush(self.RandomBrush())
|
| 2320 |
|
if self.GetSelected():
|
| 2321 |
|
dc.SetBrush(self.canvas.CachedBrush((210,210,210)))
|
| 2322 |
|
else:
|
| 2323 |
|
dc.SetBrush(self.canvas.CachedBrush((254,254,254)))
|
| 2324 |
|
# dc.SetBrush(self.canvas.CachedBrush('White'))
|
| 2325 |
|
dc.DrawRectangle(box_x,box_y,box_w,box_h)
|
| 2326 |
|
|
| 2327 |
|
dc.SetFont(self.canvas.GetFont())
|
| 2328 |
|
# dc.SetTextForeground(self.RandomColor())
|
| 2329 |
|
dc.SetTextForeground('Black')
|
| 2330 |
|
dc.SetTextBackground('White')
|
| 2331 |
|
w = 3; h = 2
|
| 2332 |
|
for i in range(len(lines)):
|
| 2333 |
|
line = lines[i]
|
| 2334 |
|
line_w, line_h = sizes[i]
|
| 2335 |
|
dc.DrawText(line, box_x+w, box_y+h)
|
| 2336 |
|
h += line_h
|
| 2337 |
|
|
| 2338 |
|
r = wx.Rect(box_x,box_y,box_w,box_h)
|
| 2339 |
|
r.Inflate(pen.GetWidth(),pen.GetWidth())
|
| 2340 |
|
dc.SetIdBounds(self.dcid,r)
|
| |
2295 |
## dc.SetId(self.dcid)
|
| |
2296 |
##
|
| |
2297 |
## text = (orm_object.Name or '')
|
| |
2298 |
## if text: text = '[' + text + ']'
|
| |
2299 |
## if debug: print orm_object, 'has name:', text or '--'
|
| |
2300 |
## lines = text.splitlines()
|
| |
2301 |
## sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ] # pull out only w and h
|
| |
2302 |
## w = 5
|
| |
2303 |
## h = 0
|
| |
2304 |
## for line_w,line_h in sizes:
|
| |
2305 |
## w = max(w, line_w)
|
| |
2306 |
## h += line_h
|
| |
2307 |
## box_w = w + 6
|
| |
2308 |
## box_h = h + 6
|
| |
2309 |
## box_x = x - box_w/2
|
| |
2310 |
## box_y = y - box_h/2
|
| |
2311 |
##
|
| |
2312 |
##### don't draw anything
|
| |
2313 |
## if text == '':
|
| |
2314 |
## pen = self.canvas.CachedPen(1, 1, wx.DOT)
|
| |
2315 |
### pen = self.canvas.CachedPen(1, 1, wx.SOLID)
|
| |
2316 |
## else:
|
| |
2317 |
## pen = self.canvas.CachedPen(2, 1, wx.SOLID)
|
| |
2318 |
## dc.SetPen(pen)
|
| |
2319 |
##### dc.SetBrush(self.RandomBrush())
|
| |
2320 |
## if self.GetSelected():
|
| |
2321 |
## dc.SetBrush(self.canvas.CachedBrush((210,210,210)))
|
| |
2322 |
## else:
|
| |
2323 |
## dc.SetBrush(self.canvas.CachedBrush((254,254,254)))
|
| |
2324 |
### dc.SetBrush(self.canvas.CachedBrush('White'))
|
| |
2325 |
## dc.DrawRectangle(box_x,box_y,box_w,box_h)
|
| |
2326 |
##
|
| |
2327 |
## dc.SetFont(self.canvas.GetFont())
|
| |
2328 |
### dc.SetTextForeground(self.RandomColor())
|
| |
2329 |
## dc.SetTextForeground('Black')
|
| |
2330 |
## dc.SetTextBackground('White')
|
| |
2331 |
## w = 3; h = 2
|
| |
2332 |
## for i in range(len(lines)):
|
| |
2333 |
## line = lines[i]
|
| |
2334 |
## line_w, line_h = sizes[i]
|
| |
2335 |
## dc.DrawText(line, box_x+w, box_y+h)
|
| |
2336 |
## h += line_h
|
| |
2337 |
##
|
| |
2338 |
## r = wx.Rect(box_x,box_y,box_w,box_h)
|
| |
2339 |
## r.Inflate(pen.GetWidth(),pen.GetWidth())
|
| |
2340 |
## dc.SetIdBounds(self.dcid,r)
|
| 3045 |
|
self.log.WriteText("Popup seven\n")
|
| |
3047 |
'''Reverse role order'''
|
| |
3048 |
l = self.pdc.FindObjects(self.popupx, self.popupy, hitradius)
|
| |
3049 |
if l:
|
| |
3050 |
shape = self.dcid_to_shape_xref.get(l[0]) # fact type shape
|
| |
3051 |
# reverse readings
|
| |
3052 |
target = shape.Get('Target')
|
| |
3053 |
if target.Nary != 2: return
|
| |
3054 |
reading = target.Get('ORMFactReading')
|
| |
3055 |
if not reading.Reading:
|
| |
3056 |
pass
|
| |
3057 |
elif '/' in reading.Reading:
|
| |
3058 |
a, x, b = reading.Reading.partition('/')
|
| |
3059 |
if '/' in b:
|
| |
3060 |
return
|
| |
3061 |
elif a:
|
| |
3062 |
reading.Reading = b + '/' + a
|
| |
3063 |
else:
|
| |
3064 |
reading.Reading = b
|
| |
3065 |
else:
|
| |
3066 |
reading.Reading = '/' + reading.Reading
|
| |
3067 |
|
| |
3068 |
# reverse the order of role connectors
|
| |
3069 |
roles = target.GetList('ORMRole')
|
| |
3070 |
sorted_roles = sorted(roles, cmp=lambda x,y: cmp(x.Seq, y.Seq), reverse=True)
|
| |
3071 |
for i, x in enumerate(sorted_roles):
|
| |
3072 |
x.Seq = i+1
|
| |
3073 |
self.RedrawID(shape.dcid)
|
| |
3074 |
for x in shape.GetFollowers():
|
| |
3075 |
self.RedrawID(x.dcid)
|
| |
3076 |
Data.SetUndo('Reverse role order')
|