Fix some bugs in driven drawing for LD viewer
authorlaurent
Fri, 09 Sep 2011 17:19:35 +0200
changeset 554 08c26c62f5a7
parent 553 1e1b632c7a41
child 555 b6f9d08fd69f
Fix some bugs in driven drawing for LD viewer
LDViewer.py
graphics/GraphicCommons.py
graphics/LD_Objects.py
--- a/LDViewer.py	Fri Sep 09 11:58:53 2011 +0200
+++ b/LDViewer.py	Fri Sep 09 17:19:35 2011 +0200
@@ -184,6 +184,7 @@
 
     def RefreshView(self, selection=None):
         Viewer.RefreshView(self, selection)
+        wx.CallAfter(self.Refresh)
         for i, rung in enumerate(self.Rungs):
             bbox = rung.GetBoundingBox()
             if i < len(self.RungComments):
@@ -1151,11 +1152,9 @@
                 else:
                     if startpoint.y + offset != endpoint.y:
                         if isinstance(element, LD_PowerRail):
-                            element.MoveConnector(i, startpoint.y - endpoint.y)
+                            element.MoveConnector(connector, startpoint.y - endpoint.y)
                         elif isinstance(block, LD_PowerRail):
-                            index = block.GetConnectorIndex(wire.EndConnected)
-                            if index:
-                                block.MoveConnector(index, startpoint.y - endpoint.y)
+                            block.MoveConnector(wire.EndConnected, startpoint.y - endpoint.y)
                         else:
                             block.Move(0, startpoint.y + offset - endpoint.y)
                             self.RefreshPosition(block, False)
--- a/graphics/GraphicCommons.py	Fri Sep 09 11:58:53 2011 +0200
+++ b/graphics/GraphicCommons.py	Fri Sep 09 17:19:35 2011 +0200
@@ -2883,6 +2883,12 @@
         # Popup the default menu
         self.Parent.PopupDefaultMenu()
     
+    # Refreshes the wire state according to move defined and handle selected
+    def ProcessDragging(self, movex, movey, event, scaling):
+        if self.Parent.GetDrawingMode() != FREEDRAWING_MODE and self.Parent.CurrentLanguage == "LD":
+            movex = movey = 0
+        return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling)
+        
     # Refreshes the comment model
     def RefreshModel(self, move=True):
         self.Parent.RefreshCommentModel(self)
--- a/graphics/LD_Objects.py	Fri Sep 09 11:58:53 2011 +0200
+++ b/graphics/LD_Objects.py	Fri Sep 09 17:19:35 2011 +0200
@@ -308,8 +308,9 @@
                 movey = round(float(self.Pos.y + position.y + movey) / float(scaling[1])) * scaling[1] - self.Pos.y - position.y
             self.MoveConnector(handle, movey)
             return 0, movey
-        else:
+        elif self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling)
+        return 0, 0
     
     # Refreshes the power rail model
     def RefreshModel(self, move=True):
@@ -439,6 +440,8 @@
         return rect
 
     def ProcessDragging(self, movex, movey, event, scaling):
+        if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
+            movex = movey = 0
         return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac = 2)
     
     # Forbids to change the contact size
@@ -718,6 +721,8 @@
         return rect
     
     def ProcessDragging(self, movex, movey, event, scaling):
+        if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
+            movex = movey = 0
         return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, height_fac = 2)    
     
     # Forbids to change the Coil size