--- a/graphics/LD_Objects.py Mon Aug 13 18:06:50 2007 +0200
+++ b/graphics/LD_Objects.py Tue Aug 14 14:53:06 2007 +0200
@@ -42,6 +42,7 @@
Graphic_Element.__init__(self, parent)
self.Type = None
self.Connectors = []
+ self.RealConnectors = None
self.Id = id
self.Extensions = [LD_LINE_SIZE / 2, LD_LINE_SIZE / 2]
if len(connectors) < 1:
@@ -151,14 +152,24 @@
# Refresh the positions of the power rail connectors
def RefreshConnectors(self):
- position = self.Extensions[0]
- for connector in self.Connectors:
- if connector:
- if self.Type == LEFTRAIL:
- connector.SetPosition(wx.Point(self.Size[0], position))
- elif self.Type == RIGHTRAIL:
- connector.SetPosition(wx.Point(0, position))
- position += LD_LINE_SIZE
+ if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
+ height = self.Size[1] - self.Extensions[0] - self.Extensions[1]
+ for i, connector in enumerate(self.Connectors):
+ position = connector.GetRelPosition()
+ if self.RealConnectors:
+ if self.Type == LEFTRAIL:
+ connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(self.RealConnectors[i] * height))))
+ elif self.Type == RIGHTRAIL:
+ connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(self.RealConnectors[i] * height))))
+ else:
+ position = self.Extensions[0]
+ for connector in self.Connectors:
+ if connector:
+ if self.Type == LEFTRAIL:
+ connector.SetPosition(wx.Point(self.Size[0], position))
+ elif self.Type == RIGHTRAIL:
+ connector.SetPosition(wx.Point(0, position))
+ position += LD_LINE_SIZE
self.RefreshConnected()
# Refresh the position of wires connected to power rail
@@ -221,13 +232,12 @@
# Initializes the last position
self.oldPos = GetScaledEventPosition(event, dc, scaling)
else:
-## self.RealConnectors = {"Inputs":[],"Outputs":[]}
-## for input in self.Inputs:
-## position = input.GetRelPosition()
-## self.RealConnectors["Inputs"].append(float(position.x)/float(self.Size[0]))
-## for output in self.Outputs:
-## position = output.GetRelPosition()
-## self.RealConnectors["Outputs"].append(float(position.x)/float(self.Size[0]))
+ self.RealConnectors = []
+ height = self.Size[1] - self.Extensions[0] - self.Extensions[1]
+ for connector in self.Connectors:
+ position = connector.GetRelPosition()
+ self.RealConnectors.append(float(position.y - self.Extensions[0])/float(max(1, height)))
+ print self.RealConnectors
Graphic_Element.OnLeftDown(self, event, dc, scaling)
# Method called when a LeftUp event have been generated