Bug on LDPowerRail resize fixed
authorlbessard
Wed, 19 Sep 2007 13:28:04 +0200
changeset 96 d178cfa9e77f
parent 95 ee66a9a1748b
child 97 28337cd092fd
Bug on LDPowerRail resize fixed
Dialogs.py
graphics/LD_Objects.py
--- a/Dialogs.py	Tue Sep 18 18:05:52 2007 +0200
+++ b/Dialogs.py	Wed Sep 19 13:28:04 2007 +0200
@@ -1130,7 +1130,7 @@
         dc = wx.ClientDC(self.Preview)
         dc.Clear()
         self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
-        min_width, min_height = self.PowerRail.GetMinSize()
+        min_width, min_height = 2, LD_LINE_SIZE * self.PinNumber.GetValue()
         width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
         self.PowerRail.SetSize(width, height)
         clientsize = self.Preview.GetClientSize()
--- a/graphics/LD_Objects.py	Tue Sep 18 18:05:52 2007 +0200
+++ b/graphics/LD_Objects.py	Wed Sep 19 13:28:04 2007 +0200
@@ -93,7 +93,10 @@
     
     # Returns the block minimum size
     def GetMinSize(self):
-        return 2, LD_LINE_SIZE * len(self.Connectors)
+        if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
+            return 2, self.Extensions[0] + self.Extensions[1]
+        else:
+            return 2, LD_LINE_SIZE * len(self.Connectors)
     
     # Add a connector or a blank to this power rail at the last place
     def AddConnector(self, connector = True):
@@ -165,12 +168,12 @@
                     if self.RealConnectors:
                         connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(self.RealConnectors[i] * height))))
                     else:
-                        connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(i * height))))
+                        connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(i * interval))))
                 elif self.Type == RIGHTRAIL:
                     if self.RealConnectors:
                         connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(self.RealConnectors[i] * height))))
                     else:
-                        connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(i * height))))
+                        connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(i * interval))))
         else:
             position = self.Extensions[0]
             for connector in self.Connectors:
@@ -251,7 +254,6 @@
     
     # Method called when a LeftUp event have been generated
     def OnLeftUp(self, event, dc, scaling):
-        self.RealConnectors = None
         handle_type, handle = self.Handle
         if handle_type == HANDLE_CONNECTOR:
             wires = handle.GetWires()
@@ -262,6 +264,7 @@
                     block = wires[0][0].StartConnected.GetParentBlock()
                 block.RefreshModel(False)
         Graphic_Element.OnLeftUp(self, event, dc, scaling)
+        self.RealConnectors = None
     
     # Method called when a LeftDClick event have been generated
     def OnLeftDClick(self, event, dc, scaling):