Fixed bad handle initialisation, causing exception on rightup event in some cases.
authoretisserant
Thu, 28 Feb 2008 18:09:09 +0100
changeset 180 3b0d3ea35ee5
parent 179 32f269883027
child 181 2981c3d3b088
Fixed bad handle initialisation, causing exception on rightup event in some cases.
graphics/GraphicCommons.py
graphics/LD_Objects.py
--- a/graphics/GraphicCommons.py	Thu Feb 28 18:07:52 2008 +0100
+++ b/graphics/GraphicCommons.py	Thu Feb 28 18:09:09 2008 +0100
@@ -289,7 +289,7 @@
         self.Parent = parent
         self.Id = id
         self.oldPos = None
-        self.Handle = False
+        self.Handle = (None,None)
         self.Dragging = False
         self.Selected = False
         self.Highlighted = False
@@ -529,7 +529,7 @@
             if handle[0] == 1:
                 movex = max(-self.BoundingBox.x, movex)
                 if scaling is not None:
-                    movex = round(float(self.Pos.x + movex) / float(scaling[0])) * scaling[0] - self.Pos.x
+                    movex = -(round(float(width - movex) / float(scaling[0])) * scaling[0] - width)
                 x = movex
                 if centered:
                     width -= 2 * movex
@@ -537,7 +537,7 @@
                     width -= movex
             elif handle[0] == 3:
                 if scaling is not None:
-                    movex = round(float(self.Pos.x + width + movex) / float(scaling[0])) * scaling[0] - self.Pos.x - width
+                    movex = round(float(width + movex) / float(scaling[0])) * scaling[0] - width
                 if centered:
                     x = -movex
                     width += 2 * movex
@@ -546,7 +546,7 @@
             if handle[1] == 1:
                 movey = max(-self.BoundingBox.y, movey)
                 if scaling is not None:
-                    movey = round(float(self.Pos.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y
+                    movey = -(round(float(height - movey) / float(scaling[1])) * scaling[1] - height)
                 y = movey
                 if centered:
                     height -= 2 * movey
@@ -554,7 +554,7 @@
                     height -= movey
             elif handle[1] == 3:
                 if scaling is not None:
-                    movey = round(float(self.Pos.y + height + movey) / float(scaling[1])) * scaling[1] - self.Pos.y - height
+                    movey = round(float(height + movey) / float(scaling[1])) * scaling[1] - height
                 if centered:
                     y = -movey
                     height += 2 * movey
--- a/graphics/LD_Objects.py	Thu Feb 28 18:07:52 2008 +0100
+++ b/graphics/LD_Objects.py	Thu Feb 28 18:09:09 2008 +0100
@@ -404,6 +404,9 @@
             if self.Output.IsConnected():
                 rect = rect.Union(self.Output.GetConnectedRedrawRect(movex, movey))
         return rect
+
+    def ProcessDragging(self, movex, movey, centered, scaling):
+        return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling, height_fac = 2)
     
     # Forbids to change the contact size
     def SetSize(self, width, height):
@@ -632,7 +635,10 @@
                 rect = rect.Union(self.Output.GetConnectedRedrawRect(movex, movey))
         return rect
     
-    # Forbids to change the contact size
+    def ProcessDragging(self, movex, movey, centered, scaling):
+        return Graphic_Element.ProcessDragging(self, movex, movey, centered, scaling, height_fac = 2)    
+    
+    # Forbids to change the Coil size
     def SetSize(self, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.SetSize(self, width, height)