91 self.Size = wx.Size(2, LD_LINE_SIZE * len(self.Connectors)) |
91 self.Size = wx.Size(2, LD_LINE_SIZE * len(self.Connectors)) |
92 self.RefreshBoundingBox() |
92 self.RefreshBoundingBox() |
93 |
93 |
94 # Returns the block minimum size |
94 # Returns the block minimum size |
95 def GetMinSize(self): |
95 def GetMinSize(self): |
96 return 2, LD_LINE_SIZE * len(self.Connectors) |
96 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
|
97 return 2, self.Extensions[0] + self.Extensions[1] |
|
98 else: |
|
99 return 2, LD_LINE_SIZE * len(self.Connectors) |
97 |
100 |
98 # Add a connector or a blank to this power rail at the last place |
101 # Add a connector or a blank to this power rail at the last place |
99 def AddConnector(self, connector = True): |
102 def AddConnector(self, connector = True): |
100 self.InsertConnector(len(self.Connectors), connector) |
103 self.InsertConnector(len(self.Connectors), connector) |
101 |
104 |
163 position = connector.GetRelPosition() |
166 position = connector.GetRelPosition() |
164 if self.Type == LEFTRAIL: |
167 if self.Type == LEFTRAIL: |
165 if self.RealConnectors: |
168 if self.RealConnectors: |
166 connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(self.RealConnectors[i] * height)))) |
169 connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(self.RealConnectors[i] * height)))) |
167 else: |
170 else: |
168 connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(i * height)))) |
171 connector.SetPosition(wx.Point(self.Size[0], self.Extensions[0] + int(round(i * interval)))) |
169 elif self.Type == RIGHTRAIL: |
172 elif self.Type == RIGHTRAIL: |
170 if self.RealConnectors: |
173 if self.RealConnectors: |
171 connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(self.RealConnectors[i] * height)))) |
174 connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(self.RealConnectors[i] * height)))) |
172 else: |
175 else: |
173 connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(i * height)))) |
176 connector.SetPosition(wx.Point(0, self.Extensions[0] + int(round(i * interval)))) |
174 else: |
177 else: |
175 position = self.Extensions[0] |
178 position = self.Extensions[0] |
176 for connector in self.Connectors: |
179 for connector in self.Connectors: |
177 if connector: |
180 if connector: |
178 if self.Type == LEFTRAIL: |
181 if self.Type == LEFTRAIL: |
249 self.RealConnectors.append(float(position.y - self.Extensions[0])/float(max(1, height))) |
252 self.RealConnectors.append(float(position.y - self.Extensions[0])/float(max(1, height))) |
250 Graphic_Element.OnLeftDown(self, event, dc, scaling) |
253 Graphic_Element.OnLeftDown(self, event, dc, scaling) |
251 |
254 |
252 # Method called when a LeftUp event have been generated |
255 # Method called when a LeftUp event have been generated |
253 def OnLeftUp(self, event, dc, scaling): |
256 def OnLeftUp(self, event, dc, scaling): |
254 self.RealConnectors = None |
|
255 handle_type, handle = self.Handle |
257 handle_type, handle = self.Handle |
256 if handle_type == HANDLE_CONNECTOR: |
258 if handle_type == HANDLE_CONNECTOR: |
257 wires = handle.GetWires() |
259 wires = handle.GetWires() |
258 if len(wires) == 1: |
260 if len(wires) == 1: |
259 if handle == wires[0][0].StartConnected: |
261 if handle == wires[0][0].StartConnected: |
260 block = wires[0][0].EndConnected.GetParentBlock() |
262 block = wires[0][0].EndConnected.GetParentBlock() |
261 else: |
263 else: |
262 block = wires[0][0].StartConnected.GetParentBlock() |
264 block = wires[0][0].StartConnected.GetParentBlock() |
263 block.RefreshModel(False) |
265 block.RefreshModel(False) |
264 Graphic_Element.OnLeftUp(self, event, dc, scaling) |
266 Graphic_Element.OnLeftUp(self, event, dc, scaling) |
|
267 self.RealConnectors = None |
265 |
268 |
266 # Method called when a LeftDClick event have been generated |
269 # Method called when a LeftDClick event have been generated |
267 def OnLeftDClick(self, event, dc, scaling): |
270 def OnLeftDClick(self, event, dc, scaling): |
268 # Edit the powerrail properties |
271 # Edit the powerrail properties |
269 self.Parent.EditPowerRailContent(self) |
272 self.Parent.EditPowerRailContent(self) |