--- a/graphics/LD_Objects.py Fri Jan 04 17:49:17 2008 +0100
+++ b/graphics/LD_Objects.py Fri Jan 11 17:51:56 2008 +0100
@@ -186,29 +186,33 @@
# Refresh the positions of the power rail connectors
def RefreshConnectors(self):
+ scaling = self.Parent.GetScaling()
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
height = self.Size[1] - self.Extensions[0] - self.Extensions[1]
interval = float(height) / float(max(len(self.Connectors) - 1, 1))
for i, connector in enumerate(self.Connectors):
- position = connector.GetRelPosition()
+ if self.RealConnectors:
+ position = self.Extensions[0] + int(round(self.RealConnectors[i] * height))
+ else:
+ position = self.Extensions[0] + int(round(i * interval))
+ if scaling is not None:
+ position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y
if self.Type == LEFTRAIL:
- 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 * interval))))
+ connector.SetPosition(wx.Point(self.Size[0], position))
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 * interval))))
+ connector.SetPosition(wx.Point(0, position))
else:
position = self.Extensions[0]
for connector in self.Connectors:
if connector:
+ if scaling is not None:
+ ypos = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y
+ else:
+ ypos = position
if self.Type == LEFTRAIL:
- connector.SetPosition(wx.Point(self.Size[0], position))
+ connector.SetPosition(wx.Point(self.Size[0], ypos))
elif self.Type == RIGHTRAIL:
- connector.SetPosition(wx.Point(0, position))
+ connector.SetPosition(wx.Point(0, ypos))
position += LD_LINE_SIZE
self.RefreshConnected()
@@ -262,6 +266,20 @@
# Method called when a LeftDown event have been generated
def OnLeftDown(self, event, dc, scaling):
+ 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)))
+ Graphic_Element.OnLeftDown(self, event, dc, scaling)
+
+ # Method called when a LeftUp event have been generated
+ def OnLeftUp(self, event, dc, scaling):
+ Graphic_Element.OnLeftUp(self, event, dc, scaling)
+ self.RealConnectors = None
+
+ # Method called when a LeftDown event have been generated
+ def OnRightDown(self, event, dc, scaling):
pos = GetScaledEventPosition(event, dc, scaling)
# Test if a connector have been handled
connector = self.TestConnector(pos, False)
@@ -272,15 +290,15 @@
# Initializes the last position
self.oldPos = GetScaledEventPosition(event, dc, scaling)
else:
- 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)))
- Graphic_Element.OnLeftDown(self, event, dc, scaling)
-
- # Method called when a LeftUp event have been generated
- def OnLeftUp(self, event, dc, scaling):
+ Graphic_Element.OnRightDown(self, event, dc, scaling)
+
+ # Method called when a LeftDClick event have been generated
+ def OnLeftDClick(self, event, dc, scaling):
+ # Edit the powerrail properties
+ self.Parent.EditPowerRailContent(self)
+
+ # Method called when a RightUp event have been generated
+ def OnRightUp(self, event, dc, scaling):
handle_type, handle = self.Handle
if handle_type == HANDLE_CONNECTOR:
wires = handle.GetWires()
@@ -290,28 +308,23 @@
else:
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):
- # Edit the powerrail properties
- self.Parent.EditPowerRailContent(self)
-
- # Method called when a RightUp event have been generated
- def OnRightUp(self, event, dc, scaling):
- self.Parent.PopupDefaultMenu()
+ Graphic_Element.OnRightUp(self, event, dc, scaling)
+ else:
+ self.Parent.PopupDefaultMenu()
# Refreshes the powerrail state according to move defined and handle selected
- def ProcessDragging(self, movex, movey):
+ def ProcessDragging(self, movex, movey, scaling):
handle_type, handle = self.Handle
# A connector has been handled
if handle_type == HANDLE_CONNECTOR:
movey = max(-self.BoundingBox.y, movey)
+ if scaling is not None:
+ position = handle.GetRelPosition()
+ 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:
- return Graphic_Element.ProcessDragging(self, movex, movey)
+ return Graphic_Element.ProcessDragging(self, movex, movey, scaling)
# Refreshes the power rail model
def RefreshModel(self, move=True):
@@ -486,8 +499,12 @@
# Refresh the positions of the block connectors
def RefreshConnectors(self):
- self.Input.SetPosition(wx.Point(0, self.Size[1] / 2 + 1))
- self.Output.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2 + 1))
+ scaling = self.Parent.GetScaling()
+ position = self.Size[1] / 2 + 1
+ if scaling is not None:
+ position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y
+ self.Input.SetPosition(wx.Point(0, position))
+ self.Output.SetPosition(wx.Point(self.Size[0], position))
self.RefreshConnected()
# Changes the contact name
@@ -712,8 +729,12 @@
# Refresh the positions of the block connectors
def RefreshConnectors(self):
- self.Input.SetPosition(wx.Point(0, self.Size[1] / 2 + 1))
- self.Output.SetPosition(wx.Point(self.Size[0], self.Size[1] / 2 + 1))
+ scaling = self.Parent.GetScaling()
+ position = self.Size[1] / 2 + 1
+ if scaling is not None:
+ position = round(float(self.Pos.y + position) / float(scaling[1])) * scaling[1] - self.Pos.y
+ self.Input.SetPosition(wx.Point(0, position))
+ self.Output.SetPosition(wx.Point(self.Size[0], position))
self.RefreshConnected()
# Changes the coil name