graphics/GraphicCommons.py
changeset 3 86ccc89d7b0b
parent 2 93bc4c2cf376
child 5 f8652b073e84
--- a/graphics/GraphicCommons.py	Wed Feb 07 18:43:32 2007 +0100
+++ b/graphics/GraphicCommons.py	Thu Feb 08 17:41:41 2007 +0100
@@ -396,8 +396,8 @@
                 self.Dragging = True
             # If a dragging have been initiated, refreshes the element state
             if self.Dragging:
+                self.oldPos = pos
                 self.ProcessDragging(movex, movey)
-                self.oldPos = pos
         # If cursor just pass over the element, changes the cursor if it is on a handle
         else:
             pos = event.GetPosition()
@@ -639,6 +639,14 @@
         return self.ParentBlock
     
     # Returns the connector name
+    def GetType(self):
+        return self.Type
+    
+    # Changes the connector name
+    def SetType(self, type):
+        self.Type = type
+    
+    # Returns the connector name
     def GetName(self):
         return self.Name
     
@@ -1418,22 +1426,22 @@
     def OnLeftDown(self, event, scaling):
         pos = GetScaledEventPosition(event, scaling)
         # Test if a point have been handled
-        result = self.TestPoint(pos)
+        #result = self.TestPoint(pos)
+        #if result != None:
+        #    self.Handle = (HANDLE_POINT, result)
+        #    self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
+        #else:
+        # Test if a segment have been handled
+        result = self.TestSegment(pos)
         if result != None:
-            self.Handle = (HANDLE_POINT, result)
-            self.Parent.SetCursor(wxStockCursor(wxCURSOR_HAND))
+            if result[1] in (NORTH, SOUTH):
+                self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZEWE))
+            elif result[1] in (EAST, WEST):
+                self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZENS))
+            self.Handle = (HANDLE_SEGMENT, result)
+        # Execute the default method for a graphic element
         else:
-            # Test if a segment have been handled
-            result = self.TestSegment(pos)
-            if result != None:
-                if result[1] in (NORTH, SOUTH):
-                    self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZEWE))
-                elif result[1] in (EAST, WEST):
-                    self.Parent.SetCursor(wxStockCursor(wxCURSOR_SIZENS))
-                self.Handle = (HANDLE_SEGMENT, result)
-            # Execute the default method for a graphic element
-            else:
-                Graphic_Element.OnLeftDown(self, event, scaling)
+            Graphic_Element.OnLeftDown(self, event, scaling)
         self.oldPos = pos
     
     # Method called when a RightUp event have been generated
@@ -1467,17 +1475,17 @@
                     wxCallAfter(self.Parent.SetCursor, wxStockCursor(wxCURSOR_SIZENS))
             else:
                 # Test if a point has been handled
-                result = self.TestPoint(pos)
-                if result != None:
-                    if result == 0 and self.StartConnected:
-                        self.OverStart = True
-                    elif result != 0 and self.EndConnected:
-                        self.OverEnd = True
-                else:
-                    self.OverStart = False
-                    self.OverEnd = False
-                    # Execute the default method for a graphic element
-                    Graphic_Element.OnMotion(self, event, scaling)
+                #result = self.TestPoint(pos)
+                #if result != None:
+                #    if result == 0 and self.StartConnected:
+                #        self.OverStart = True
+                #    elif result != 0 and self.EndConnected:
+                #        self.OverEnd = True
+                #else:
+                #    self.OverStart = False
+                #    self.OverEnd = False
+                # Execute the default method for a graphic element
+                Graphic_Element.OnMotion(self, event, scaling)
         else:
             # Execute the default method for a graphic element
             Graphic_Element.OnMotion(self, event, scaling)
@@ -1495,11 +1503,13 @@
                     connector.Connect((self, handle))
                     self.SetStartPointDirection(connector.GetDirection())
                     self.ConnectStartPoint(connector.GetPosition(), connector)
+                    self.oldPos = connector.GetPosition()
                     self.Dragging = False
                 elif handle != 0 and self.StartConnected != connector:
                     connector.Connect((self, handle))
                     self.SetEndPointDirection(connector.GetDirection())
                     self.ConnectEndPoint(connector.GetPosition(), connector)
+                    self.oldPos = connector.GetPosition()
                     self.Dragging = False
                 elif handle == 0:
                     self.MoveStartPoint(new_pos)