graphics/GraphicCommons.py
changeset 180 3b0d3ea35ee5
parent 175 cc78572dfbbc
child 208 c70aefcadf66
equal deleted inserted replaced
179:32f269883027 180:3b0d3ea35ee5
   287     # Create a new graphic element
   287     # Create a new graphic element
   288     def __init__(self, parent, id = None):
   288     def __init__(self, parent, id = None):
   289         self.Parent = parent
   289         self.Parent = parent
   290         self.Id = id
   290         self.Id = id
   291         self.oldPos = None
   291         self.oldPos = None
   292         self.Handle = False
   292         self.Handle = (None,None)
   293         self.Dragging = False
   293         self.Dragging = False
   294         self.Selected = False
   294         self.Selected = False
   295         self.Highlighted = False
   295         self.Highlighted = False
   296         self.Pos = wx.Point(0, 0)
   296         self.Pos = wx.Point(0, 0)
   297         self.Size = wx.Size(0, 0)
   297         self.Size = wx.Size(0, 0)
   527             x = y = start_x = start_y = 0
   527             x = y = start_x = start_y = 0
   528             width, height = start_width, start_height = self.GetSize()
   528             width, height = start_width, start_height = self.GetSize()
   529             if handle[0] == 1:
   529             if handle[0] == 1:
   530                 movex = max(-self.BoundingBox.x, movex)
   530                 movex = max(-self.BoundingBox.x, movex)
   531                 if scaling is not None:
   531                 if scaling is not None:
   532                     movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x
   532                     movex = -(round(float(width - movex) / float(scaling[0])) * scaling[0] - width)
   533                 x = movex
   533                 x = movex
   534                 if centered:
   534                 if centered:
   535                     width -= 2 * movex
   535                     width -= 2 * movex
   536                 else:
   536                 else:
   537                     width -= movex
   537                     width -= movex
   538             elif handle[0] == 3:
   538             elif handle[0] == 3:
   539                 if scaling is not None:
   539                 if scaling is not None:
   540                     movex = round(float(self.Pos.x + width + movex) / float(scaling[0])) * scaling[0] - self.Pos.x - width
   540                     movex = round(float(width + movex) / float(scaling[0])) * scaling[0] - width
   541                 if centered:
   541                 if centered:
   542                     x = -movex
   542                     x = -movex
   543                     width += 2 * movex
   543                     width += 2 * movex
   544                 else:
   544                 else:
   545                     width += movex
   545                     width += movex
   546             if handle[1] == 1:
   546             if handle[1] == 1:
   547                 movey = max(-self.BoundingBox.y, movey)
   547                 movey = max(-self.BoundingBox.y, movey)
   548                 if scaling is not None:
   548                 if scaling is not None:
   549                     movey = round(float(self.Pos.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y
   549                     movey = -(round(float(height - movey) / float(scaling[1])) * scaling[1] - height)
   550                 y = movey
   550                 y = movey
   551                 if centered:
   551                 if centered:
   552                     height -= 2 * movey
   552                     height -= 2 * movey
   553                 else:
   553                 else:
   554                     height -= movey
   554                     height -= movey
   555             elif handle[1] == 3:
   555             elif handle[1] == 3:
   556                 if scaling is not None:
   556                 if scaling is not None:
   557                     movey = round(float(self.Pos.y + height + movey) / float(scaling[1])) * scaling[1] - self.Pos.y - height
   557                     movey = round(float(height + movey) / float(scaling[1])) * scaling[1] - height
   558                 if centered:
   558                 if centered:
   559                     y = -movey
   559                     y = -movey
   560                     height += 2 * movey
   560                     height += 2 * movey
   561                 else:
   561                 else:
   562                     height += movey
   562                     height += movey