graphics/GraphicCommons.py
changeset 27 dae55dd9ee14
parent 5 f8652b073e84
child 28 fc23e1f415d8
equal deleted inserted replaced
26:36d378bd852e 27:dae55dd9ee14
    53 LD_COMMENT_DEFAULTSIZE = (600, 40)  # Size (width, height) of a comment box
    53 LD_COMMENT_DEFAULTSIZE = (600, 40)  # Size (width, height) of a comment box
    54 
    54 
    55 # SFC constants
    55 # SFC constants
    56 SFC_STEP_DEFAULT_SIZE = (40, 30)      # Default size of a SFC step
    56 SFC_STEP_DEFAULT_SIZE = (40, 30)      # Default size of a SFC step
    57 SFC_TRANSITION_SIZE = (20, 2)         # Size of a SFC transition
    57 SFC_TRANSITION_SIZE = (20, 2)         # Size of a SFC transition
    58 SFC_DEFAULT_SEQUENCE_INTERVAL = 80    # Default size of the interval between two divergence branches
    58 SFC_DEFAULT_SEQUENCE_INTERVAL = 40    # Default size of the interval between two divergence branches
    59 SFC_SIMULTANEOUS_SEQUENCE_EXTRA = 20  # Size of extra lines for simultaneous divergence and convergence
    59 SFC_SIMULTANEOUS_SEQUENCE_EXTRA = 20  # Size of extra lines for simultaneous divergence and convergence
    60 SFC_JUMP_SIZE = (12, 13)              # Size of a SFC jump to step
    60 SFC_JUMP_SIZE = (12, 13)              # Size of a SFC jump to step
    61 SFC_WIRE_MIN_SIZE = 25                # Size of a wire between two elements
    61 SFC_WIRE_MIN_SIZE = 25                # Size of a wire between two elements
    62 SFC_ACTION_MIN_SIZE = (100, 30)       # Minimum size of an action block line
    62 SFC_ACTION_MIN_SIZE = (100, 30)       # Minimum size of an action block line
    63 
    63 
    78 # Contants for defining the direction of a connector
    78 # Contants for defining the direction of a connector
    79 [EAST, NORTH, WEST, SOUTH] = [(1,0), (0,-1), (-1,0), (0,1)]
    79 [EAST, NORTH, WEST, SOUTH] = [(1,0), (0,-1), (-1,0), (0,1)]
    80 
    80 
    81 # Contants for defining which mode is selected for each view 
    81 # Contants for defining which mode is selected for each view 
    82 [MODE_SELECTION, MODE_BLOCK, MODE_VARIABLE, MODE_CONNECTION, MODE_COMMENT, MODE_WIRE,
    82 [MODE_SELECTION, MODE_BLOCK, MODE_VARIABLE, MODE_CONNECTION, MODE_COMMENT, MODE_WIRE,
    83  MODE_INITIAL_STEP] = range(7)
    83  MODE_COIL, MODE_CONTACT, MODE_POWERRAIL, MODE_INITIALSTEP, MODE_STEP, MODE_TRANSITION,
       
    84  MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION] = range(15)
       
    85 
       
    86 # Contants for defining which drawing mode is selected for app
       
    87 [FREEDRAWING_MODE, DRIVENDRAWING_MODE] = [1, 2]
       
    88 
    84 
    89 
    85 """
    90 """
    86 Basic vector operations for calculate wire points
    91 Basic vector operations for calculate wire points
    87 """
    92 """
    88 
    93 
   113 
   118 
   114 """
   119 """
   115 Function that calculates the nearest point of the grid defined by scaling for the given point
   120 Function that calculates the nearest point of the grid defined by scaling for the given point
   116 """
   121 """
   117 
   122 
   118 def GetScaledEventPosition(event, scaling):
   123 def GetScaledEventPosition(event, dc, scaling):
   119     pos = event.GetPosition()
   124     pos = event.GetLogicalPosition(dc)
   120     if scaling:
   125     if scaling:
   121         pos.x = round(float(pos.x) / float(scaling[0])) * scaling[0]
   126         pos.x = round(float(pos.x) / float(scaling[0])) * scaling[0]
   122         pos.y = round(float(pos.y) / float(scaling[1])) * scaling[1]
   127         pos.y = round(float(pos.y) / float(scaling[1])) * scaling[1]
   123     return pos
   128     return pos
   124 
   129 
   164     # Method that returns the currently edited box
   169     # Method that returns the currently edited box
   165     def GetCurrentExtent(self):
   170     def GetCurrentExtent(self):
   166         return self.currentBox
   171         return self.currentBox
   167     
   172     
   168     # Method called when a new box starts to be edited
   173     # Method called when a new box starts to be edited
   169     def OnLeftDown(self, event, scaling):
   174     def OnLeftDown(self, event, dc, scaling):
   170         pos = GetScaledEventPosition(event, scaling)
   175         pos = GetScaledEventPosition(event, dc, scaling)
   171         # Save the point for calculate the box position and size
   176         # Save the point for calculate the box position and size
   172         self.startPoint = pos
   177         self.startPoint = pos
   173         self.currentBox = wxRect(pos.x, pos.y, 0, 0)
   178         self.currentBox = wxRect(pos.x, pos.y, 0, 0)
   174         self.drawingSurface.SetCursor(wxStockCursor(wxCURSOR_CROSS))
   179         self.drawingSurface.SetCursor(wxStockCursor(wxCURSOR_CROSS))
   175         self.Redraw()
   180         self.Redraw()
   176     
   181     
   177     # Method called when dragging with a box edited
   182     # Method called when dragging with a box edited
   178     def OnMotion(self, event, scaling):
   183     def OnMotion(self, event, dc, scaling):
   179         pos = GetScaledEventPosition(event, scaling)
   184         pos = GetScaledEventPosition(event, dc, scaling)
   180         # Save the last position and size of the box for erasing it
   185         # Save the last position and size of the box for erasing it
   181         self.lastBox = wxRect(self.currentBox.x, self.currentBox.y, self.currentBox.width,
   186         self.lastBox = wxRect(self.currentBox.x, self.currentBox.y, self.currentBox.width,
   182             self.currentBox.height)
   187             self.currentBox.height)
   183         # Calculate new position and size of the box 
   188         # Calculate new position and size of the box 
   184         if pos.x >= self.startPoint.x:
   189         if pos.x >= self.startPoint.x:
   194             self.currentBox.y = pos.y
   199             self.currentBox.y = pos.y
   195             self.currentBox.height = self.startPoint.y - pos.y + 1
   200             self.currentBox.height = self.startPoint.y - pos.y + 1
   196         self.Redraw()
   201         self.Redraw()
   197     
   202     
   198     # Method called when dragging is stopped
   203     # Method called when dragging is stopped
   199     def OnLeftUp(self, event, scaling):
   204     def OnLeftUp(self, event, dc, scaling):
   200         self.drawingSurface.SetCursor(wxNullCursor)
   205         self.drawingSurface.SetCursor(wxNullCursor)
   201         self.lastBox = self.currentBox
   206         self.lastBox = self.currentBox
   202         self.currentBox = None
   207         self.currentBox = None
   203         self.Redraw()
   208         self.Redraw()
   204 
   209 
   205     # Method that erase the last box and draw the new box
   210     # Method that erase the last box and draw the new box
   206     def Redraw(self):
   211     def Redraw(self):
   207         dc = wxClientDC(self.drawingSurface)
   212         dc = self.drawingSurface.GetLogicalDC()
   208         dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
   213         dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
   209         dc.SetBrush(wxTRANSPARENT_BRUSH)
   214         dc.SetBrush(wxTRANSPARENT_BRUSH)
   210         dc.SetLogicalFunction(wxXOR)
   215         dc.SetLogicalFunction(wxXOR)
   211         if self.lastBox:
   216         if self.lastBox:
   212             # Erase last box
   217             # Erase last box
   213             dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
   218             dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
   214                 self.lastBox.height)
   219                 self.lastBox.height)
       
   220         if self.currentBox:
       
   221             # Draw current box
       
   222             dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
       
   223                 self.currentBox.height)
       
   224 
       
   225     # Erase last box
       
   226     def Erase(self):
       
   227         dc = self.drawingSurface.GetLogicalDC()
       
   228         dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
       
   229         dc.SetBrush(wxTRANSPARENT_BRUSH)
       
   230         dc.SetLogicalFunction(wxXOR)
       
   231         if self.lastBox:
       
   232             dc.DrawRectangle(self.lastBox.x, self.lastBox.y, self.lastBox.width,
       
   233                 self.lastBox.height)
       
   234         
       
   235     # Draw current box
       
   236     def Draw(self):
       
   237         dc = self.drawingSurface.GetLogicalDC()
       
   238         dc.SetPen(wxPen(wxWHITE, 1, wxDOT))
       
   239         dc.SetBrush(wxTRANSPARENT_BRUSH)
       
   240         dc.SetLogicalFunction(wxXOR)
   215         if self.currentBox:
   241         if self.currentBox:
   216             # Draw current box
   242             # Draw current box
   217             dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
   243             dc.DrawRectangle(self.currentBox.x, self.currentBox.y, self.currentBox.width,
   218                 self.currentBox.height)
   244                 self.currentBox.height)
   219 
   245 
   333             if (handle_x, handle_y) in VALID_HANDLES:
   359             if (handle_x, handle_y) in VALID_HANDLES:
   334                 return handle_x, handle_y
   360                 return handle_x, handle_y
   335         return 0, 0
   361         return 0, 0
   336     
   362     
   337     # Method called when a LeftDown event have been generated
   363     # Method called when a LeftDown event have been generated
   338     def OnLeftDown(self, event, scaling):
   364     def OnLeftDown(self, event, dc, scaling):
   339         pos = event.GetPosition()
   365         pos = event.GetLogicalPosition(dc)
   340         # Test if an handle have been clicked
   366         # Test if an handle have been clicked
   341         result = self.TestHandle(pos)
   367         result = self.TestHandle(pos)
   342         # Find which type of handle have been clicked,
   368         # Find which type of handle have been clicked,
   343         # Save a resize event and change the cursor
   369         # Save a resize event and change the cursor
   344         if result == (1, 1) or result == (3, 3):
   370         if result == (1, 1) or result == (3, 3):
   357         else:
   383         else:
   358             self.Handle = (HANDLE_MOVE, None)
   384             self.Handle = (HANDLE_MOVE, None)
   359             self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
   385             self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
   360             self.SetSelected(False)
   386             self.SetSelected(False)
   361         # Initializes the last position
   387         # Initializes the last position
   362         self.oldPos = GetScaledEventPosition(event, scaling)
   388         self.oldPos = GetScaledEventPosition(event, dc, scaling)
   363     
   389     
   364     # Method called when a LeftUp event have been generated
   390     # Method called when a LeftUp event have been generated
   365     def OnLeftUp(self, event, scaling):
   391     def OnLeftUp(self, event, dc, scaling):
   366         # If a dragging have been initiated
   392         # If a dragging have been initiated
   367         if self.Dragging and self.oldPos:
   393         if self.Dragging and self.oldPos:
   368             # Calculate the movement of cursor and refreshes the element state
   394             # Calculate the movement of cursor and refreshes the element state
   369             pos = GetScaledEventPosition(event, scaling)
   395             pos = GetScaledEventPosition(event, dc, scaling)
   370             movex = pos.x - self.oldPos.x
   396             movex = pos.x - self.oldPos.x
   371             movey = pos.y - self.oldPos.y
   397             movey = pos.y - self.oldPos.y
   372             self.ProcessDragging(movex, movey)
   398             self.ProcessDragging(movex, movey)
   373             self.RefreshModel()
   399             self.RefreshModel()
   374         self.SetSelected(True)
   400         self.SetSelected(True)
   375         self.oldPos = None
   401         self.oldPos = None
   376 
   402 
   377     # Method called when a RightUp event have been generated
   403     # Method called when a RightUp event have been generated
   378     def OnRightUp(self, event, scaling):
   404     def OnRightUp(self, event, dc, scaling):
   379         self.SetSelected(True)
   405         self.SetSelected(True)
   380         self.oldPos = None
   406         self.oldPos = None
   381 
   407 
   382     # Method called when a LeftDClick event have been generated
   408     # Method called when a LeftDClick event have been generated
   383     def OnLeftDClick(self, event, scaling):
   409     def OnLeftDClick(self, event, dc, scaling):
   384         pass
   410         pass
   385     
   411     
   386     # Method called when a Motion event have been generated
   412     # Method called when a Motion event have been generated
   387     def OnMotion(self, event, scaling):
   413     def OnMotion(self, event, dc, scaling):
   388         # If the cursor is dragging and the element have been clicked
   414         # If the cursor is dragging and the element have been clicked
   389         if event.Dragging() and self.oldPos:
   415         if event.Dragging() and self.oldPos:
   390             # Calculate the movement of cursor
   416             # Calculate the movement of cursor
   391             pos = GetScaledEventPosition(event, scaling)
   417             pos = GetScaledEventPosition(event, dc, scaling)
   392             movex = pos.x - self.oldPos.x
   418             movex = pos.x - self.oldPos.x
   393             movey = pos.y - self.oldPos.y
   419             movey = pos.y - self.oldPos.y
   394             # If movement is greater than MIN_MOVE then a dragging is initiated
   420             # If movement is greater than MIN_MOVE then a dragging is initiated
   395             if not self.Dragging and (abs(movex) > MIN_MOVE or abs(movey) > MIN_MOVE):
   421             if not self.Dragging and (abs(movex) > MIN_MOVE or abs(movey) > MIN_MOVE):
   396                 self.Dragging = True
   422                 self.Dragging = True
   398             if self.Dragging:
   424             if self.Dragging:
   399                 self.oldPos = pos
   425                 self.oldPos = pos
   400                 self.ProcessDragging(movex, movey)
   426                 self.ProcessDragging(movex, movey)
   401         # If cursor just pass over the element, changes the cursor if it is on a handle
   427         # If cursor just pass over the element, changes the cursor if it is on a handle
   402         else:
   428         else:
   403             pos = event.GetPosition()
   429             pos = event.GetLogicalPosition(dc)
   404             handle = self.TestHandle(pos)
   430             handle = self.TestHandle(pos)
   405             if handle == (1, 1) or handle == (3, 3):
   431             if handle == (1, 1) or handle == (3, 3):
   406                 wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENWSE))
   432                 wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENWSE))
   407             elif handle == (1, 3) or handle == (3, 1):
   433             elif handle == (1, 3) or handle == (3, 1):
   408                 wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENESW))
   434                 wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENESW))
   612 """
   638 """
   613 
   639 
   614 class Connector:
   640 class Connector:
   615     
   641     
   616     # Create a new connector
   642     # Create a new connector
   617     def __init__(self, parent, name, type, position, direction, negated = False, edge = "none"):
   643     def __init__(self, parent, name, type, position, direction, negated = False, edge = "none", onlyone = False):
   618         self.ParentBlock = parent
   644         self.ParentBlock = parent
   619         self.Name = name
   645         self.Name = name
   620         self.Type = type
   646         self.Type = type
   621         self.Pos = position
   647         self.Pos = position
   622         self.Direction = direction
   648         self.Direction = direction
   623         self.Wires = []
   649         self.Wires = []
   624         self.Negated = negated
   650         self.Negated = negated
   625         self.Edge = edge
   651         self.Edge = edge
       
   652         self.OneConnected = onlyone
   626         self.Pen = wxBLACK_PEN
   653         self.Pen = wxBLACK_PEN
   627     
   654     
   628     # Change the connector pen
   655     # Change the connector pen
   629     def SetPen(self, pen):
   656     def SetPen(self, pen):
   630         self.Pen = pen
   657         self.Pen = pen
   756     
   783     
   757     # Refreshes the parent block model
   784     # Refreshes the parent block model
   758     def RefreshParentBlock(self):
   785     def RefreshParentBlock(self):
   759         self.ParentBlock.RefreshModel(False)
   786         self.ParentBlock.RefreshModel(False)
   760     
   787     
       
   788     # Returns all the blocks connected to this connector
       
   789     def GetConnectedBlocks(self):
       
   790         blocks = []
       
   791         for wire, handle in self.Wires:
       
   792             # Get other connector connected to each wire
       
   793             if handle == 0:
       
   794                 connector = blocks.GetEndConnected()
       
   795             else:
       
   796                 connector = blocks.GetStartConnected()
       
   797             # Get parent block for this connector
       
   798             if connector:
       
   799                 block = connector.GetParentBlock()
       
   800                 if block not in blocks:
       
   801                     blocks.append(block)
       
   802         return blocks
       
   803     
   761     # Returns the connector negated property
   804     # Returns the connector negated property
   762     def IsNegated(self):
   805     def IsNegated(self):
   763         return self.Negated
   806         return self.Negated
   764     
   807     
   765     # Changes the connector negated property
   808     # Changes the connector negated property
   777         self.Negated = False
   820         self.Negated = False
   778     
   821     
   779     # Tests if the point given is near from the end point of this connector
   822     # Tests if the point given is near from the end point of this connector
   780     def TestPoint(self, pt, exclude = True):
   823     def TestPoint(self, pt, exclude = True):
   781         parent_pos = self.ParentBlock.GetPosition()
   824         parent_pos = self.ParentBlock.GetPosition()
   782         if not (len(self.Wires) > 0 and self.Direction == WEST and exclude):
   825         if not (len(self.Wires) > 0 and self.OneConnected and exclude):
   783             # Calculate a square around the end point of this connector
   826             # Calculate a square around the end point of this connector
   784             x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE
   827             x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE
   785             y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE
   828             y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE
   786             width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE
   829             width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE
   787             height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE
   830             height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE
   870     
   913     
   871     # Forbids to change the wire size
   914     # Forbids to change the wire size
   872     def SetSize(width, height):
   915     def SetSize(width, height):
   873         pass
   916         pass
   874     
   917     
       
   918     # Returns connector to which start point is connected
       
   919     def GetStartConnected(self):
       
   920         return self.StartConnected
       
   921     
       
   922     # Returns connector to which end point is connected
       
   923     def GetEndConnected(self):
       
   924         return self.EndConnected
       
   925     
   875     # Unconnect the start and end points
   926     # Unconnect the start and end points
   876     def Clean(self):
   927     def Clean(self):
   877         if self.StartConnected:
   928         if self.StartConnected:
   878             self.UnConnectStartPoint()
   929             self.UnConnectStartPoint()
   879         if self.EndConnected:
   930         if self.EndConnected:
  1082         if self.EndConnected and self.EndPoint[1] == WEST:
  1133         if self.EndConnected and self.EndPoint[1] == WEST:
  1083             connected.append(self.EndConnected)
  1134             connected.append(self.EndConnected)
  1084         return connected
  1135         return connected
  1085     
  1136     
  1086     # Returns the id of the block connected to the first or the last wire point
  1137     # Returns the id of the block connected to the first or the last wire point
  1087     def GetConnectedId(self, index):
  1138     def GetConnectedInfos(self, index):
  1088         if index == 0 and self.StartConnected:
  1139         if index == 0 and self.StartConnected:
  1089             return self.StartConnected.GetBlockId()
  1140             return self.StartConnected.GetBlockId(), self.StartConnected.GetName()
  1090         elif index == -1 and self.EndConnected:
  1141         elif index == -1 and self.EndConnected:
  1091             return self.EndConnected.GetBlockId()
  1142             return self.EndConnected.GetBlockId(), self.StartConnected.GetName()
  1092         return None
  1143         return None
  1093     
  1144     
  1094     # Update the wire points position by keeping at most possible the current positions
  1145     # Update the wire points position by keeping at most possible the current positions
  1095     def GeneratePoints(self, realpoints = True):
  1146     def GeneratePoints(self, realpoints = True):
  1096         i = 0
  1147         i = 0
  1421                 self.Segments.pop(segment)
  1472                 self.Segments.pop(segment)
  1422             self.GeneratePoints()
  1473             self.GeneratePoints()
  1423             self.RefreshModel()
  1474             self.RefreshModel()
  1424             
  1475             
  1425     # Method called when a LeftDown event have been generated
  1476     # Method called when a LeftDown event have been generated
  1426     def OnLeftDown(self, event, scaling):
  1477     def OnLeftDown(self, event, dc, scaling):
  1427         pos = GetScaledEventPosition(event, scaling)
  1478         pos = GetScaledEventPosition(event, dc, scaling)
  1428         # Test if a point have been handled
  1479         # Test if a point have been handled
  1429         #result = self.TestPoint(pos)
  1480         #result = self.TestPoint(pos)
  1430         #if result != None:
  1481         #if result != None:
  1431         #    self.Handle = (HANDLE_POINT, result)
  1482         #    self.Handle = (HANDLE_POINT, result)
  1432         #    self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
  1483         #    self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
  1439             elif result[1] in (EAST, WEST):
  1490             elif result[1] in (EAST, WEST):
  1440                 self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZENS))
  1491                 self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZENS))
  1441             self.Handle = (HANDLE_SEGMENT, result)
  1492             self.Handle = (HANDLE_SEGMENT, result)
  1442         # Execute the default method for a graphic element
  1493         # Execute the default method for a graphic element
  1443         else:
  1494         else:
  1444             Graphic_Element.OnLeftDown(self, event, scaling)
  1495             Graphic_Element.OnLeftDown(self, event, dc, scaling)
  1445         self.oldPos = pos
  1496         self.oldPos = pos
  1446     
  1497     
  1447     # Method called when a RightUp event have been generated
  1498     # Method called when a RightUp event have been generated
  1448     def OnRightUp(self, event, scaling):
  1499     def OnRightUp(self, event, dc, scaling):
  1449         pos = GetScaledEventPosition(event, scaling)
  1500         pos = GetScaledEventPosition(event, dc, scaling)
  1450         # Test if a segment has been handled
  1501         # Test if a segment has been handled
  1451         result = self.TestSegment(pos)
  1502         result = self.TestSegment(pos)
  1452         if result != None:
  1503         if result != None:
  1453             self.Handle = (HANDLE_SEGMENT, result)
  1504             self.Handle = (HANDLE_SEGMENT, result)
  1454             # Popup the menu with special items for a wire
  1505             # Popup the menu with special items for a wire
  1455             self.Parent.PopupWireMenu()
  1506             self.Parent.PopupWireMenu()
  1456         else:
  1507         else:
  1457             # Execute the default method for a graphic element
  1508             # Execute the default method for a graphic element
  1458             Graphic_Element.OnRightUp(self, event, scaling)
  1509             Graphic_Element.OnRightUp(self, event, dc, scaling)
  1459     
  1510     
  1460     # Method called when a LeftDClick event have been generated
  1511     # Method called when a LeftDClick event have been generated
  1461     def OnLeftDClick(self, event, scaling):
  1512     def OnLeftDClick(self, event, dc, scaling):
  1462         self.ResetPoints()
  1513         self.ResetPoints()
  1463         self.GeneratePoints()
  1514         self.GeneratePoints()
  1464         
  1515         
  1465     # Method called when a Motion event have been generated
  1516     # Method called when a Motion event have been generated
  1466     def OnMotion(self, event, scaling):
  1517     def OnMotion(self, event, dc, scaling):
  1467         pos = GetScaledEventPosition(event, scaling)
  1518         pos = GetScaledEventPosition(event, dc, scaling)
  1468         if not event.Dragging():
  1519         if not event.Dragging():
  1469             # Test if a segment has been handled
  1520             # Test if a segment has been handled
  1470             result = self.TestSegment(pos)
  1521             result = self.TestSegment(pos)
  1471             if result:
  1522             if result:
  1472                 if result[1] in (NORTH, SOUTH):
  1523                 if result[1] in (NORTH, SOUTH):
  1483                 #        self.OverEnd = True
  1534                 #        self.OverEnd = True
  1484                 #else:
  1535                 #else:
  1485                 #    self.OverStart = False
  1536                 #    self.OverStart = False
  1486                 #    self.OverEnd = False
  1537                 #    self.OverEnd = False
  1487                 # Execute the default method for a graphic element
  1538                 # Execute the default method for a graphic element
  1488                 Graphic_Element.OnMotion(self, event, scaling)
  1539                 Graphic_Element.OnMotion(self, event, dc, scaling)
  1489         else:
  1540         else:
  1490             # Execute the default method for a graphic element
  1541             # Execute the default method for a graphic element
  1491             Graphic_Element.OnMotion(self, event, scaling)
  1542             Graphic_Element.OnMotion(self, event, dc, scaling)
  1492     
  1543     
  1493     # Refreshes the wire state according to move defined and handle selected
  1544     # Refreshes the wire state according to move defined and handle selected
  1494     def ProcessDragging(self, movex, movey):
  1545     def ProcessDragging(self, movex, movey):
  1495         handle_type, handle = self.Handle
  1546         handle_type, handle = self.Handle
  1496         # A point has been handled
  1547         # A point has been handled
  1646     def Resize(self, x, y, width, height):
  1697     def Resize(self, x, y, width, height):
  1647         self.Move(x, y)
  1698         self.Move(x, y)
  1648         self.SetSize(width, height)
  1699         self.SetSize(width, height)
  1649     
  1700     
  1650     # Method called when a RightUp event have been generated
  1701     # Method called when a RightUp event have been generated
  1651     def OnRightUp(self, event, scaling):
  1702     def OnRightUp(self, event, dc, scaling):
  1652         # Popup the default menu
  1703         # Popup the default menu
  1653         self.Parent.PopupDefaultMenu()
  1704         self.Parent.PopupDefaultMenu()
  1654     
  1705     
  1655     # Refreshes the comment model
  1706     # Refreshes the comment model
  1656     def RefreshModel(self, move=True):
  1707     def RefreshModel(self, move=True):
  1657         self.Parent.RefreshCommentModel(self)
  1708         self.Parent.RefreshCommentModel(self)
  1658     
  1709     
  1659     # Method called when a LeftDClick event have been generated
  1710     # Method called when a LeftDClick event have been generated
  1660     def OnLeftDClick(self, event, scaling):
  1711     def OnLeftDClick(self, event, dc, scaling):
  1661         # Edit the comment content
  1712         # Edit the comment content
  1662         self.Parent.EditCommentContent(self)
  1713         self.Parent.EditCommentContent(self)
  1663     
  1714     
  1664     # Draws the comment and its content
  1715     # Draws the comment and its content
  1665     def Draw(self, dc):
  1716     def Draw(self, dc):