86 self.RefreshConnectors() |
86 self.RefreshConnectors() |
87 |
87 |
88 # Forbids to select a power rail |
88 # Forbids to select a power rail |
89 def HitTest(self, pt): |
89 def HitTest(self, pt): |
90 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
90 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
91 return Graphic_Element.HitTest(self, pt) or self.TestConnector(pt, False) != None |
91 return Graphic_Element.HitTest(self, pt) or self.TestConnector(pt, exclude=False) != None |
92 return False |
92 return False |
93 |
93 |
94 # Forbids to select a power rail |
94 # Forbids to select a power rail |
95 def IsInSelection(self, rect): |
95 def IsInSelection(self, rect): |
96 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
96 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
239 # Returns all the power rail connectors |
239 # Returns all the power rail connectors |
240 def GetConnectors(self): |
240 def GetConnectors(self): |
241 return [connector for connector in self.Connectors if connector] |
241 return [connector for connector in self.Connectors if connector] |
242 |
242 |
243 # Test if point given is on one of the power rail connectors |
243 # Test if point given is on one of the power rail connectors |
244 def TestConnector(self, pt, exclude=True): |
244 def TestConnector(self, pt, direction = None, exclude = True): |
245 for connector in self.Connectors: |
245 for connector in self.Connectors: |
246 if connector and connector.TestPoint(pt, exclude): |
246 if connector and connector.TestPoint(pt, direction, exclude): |
247 return connector |
247 return connector |
248 return None |
248 return None |
249 |
249 |
250 # Returns the power rail type |
250 # Returns the power rail type |
251 def SetType(self, type, connectors): |
251 def SetType(self, type, connectors): |
279 |
279 |
280 # Method called when a LeftDown event have been generated |
280 # Method called when a LeftDown event have been generated |
281 def OnRightDown(self, event, dc, scaling): |
281 def OnRightDown(self, event, dc, scaling): |
282 pos = GetScaledEventPosition(event, dc, scaling) |
282 pos = GetScaledEventPosition(event, dc, scaling) |
283 # Test if a connector have been handled |
283 # Test if a connector have been handled |
284 connector = self.TestConnector(pos, False) |
284 connector = self.TestConnector(pos, exclude=False) |
285 if connector: |
285 if connector: |
286 self.Handle = (HANDLE_CONNECTOR, connector) |
286 self.Handle = (HANDLE_CONNECTOR, connector) |
287 self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) |
287 self.Parent.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) |
288 self.Selected = False |
288 self.Selected = False |
289 # Initializes the last position |
289 # Initializes the last position |
493 # Returns input and output contact connectors |
493 # Returns input and output contact connectors |
494 def GetConnectors(self): |
494 def GetConnectors(self): |
495 return {"input":self.Input,"output":self.Output} |
495 return {"input":self.Input,"output":self.Output} |
496 |
496 |
497 # Test if point given is on contact input or output connector |
497 # Test if point given is on contact input or output connector |
498 def TestConnector(self, pt, exclude=True): |
498 def TestConnector(self, pt, direction = None, exclude=True): |
499 # Test input connector |
499 # Test input connector |
500 if self.Input.TestPoint(pt, exclude): |
500 if self.Input.TestPoint(pt, direction, exclude): |
501 return self.Input |
501 return self.Input |
502 # Test output connector |
502 # Test output connector |
503 if self.Output.TestPoint(pt, exclude): |
503 if self.Output.TestPoint(pt, direction, exclude): |
504 return self.Output |
504 return self.Output |
505 return None |
505 return None |
506 |
506 |
507 # Refresh the positions of the block connectors |
507 # Refresh the positions of the block connectors |
508 def RefreshConnectors(self): |
508 def RefreshConnectors(self): |
745 # Returns input and output coil connectors |
745 # Returns input and output coil connectors |
746 def GetConnectors(self): |
746 def GetConnectors(self): |
747 return {"input":self.Input,"output":self.Output} |
747 return {"input":self.Input,"output":self.Output} |
748 |
748 |
749 # Test if point given is on coil input or output connector |
749 # Test if point given is on coil input or output connector |
750 def TestConnector(self, pt, exclude=True): |
750 def TestConnector(self, pt, direction = None, exclude=True): |
751 # Test input connector |
751 # Test input connector |
752 if self.Input.TestPoint(pt, exclude): |
752 if self.Input.TestPoint(pt, direction, exclude): |
753 return self.Input |
753 return self.Input |
754 # Test output connector |
754 # Test output connector |
755 if self.Output.TestPoint(pt, exclude): |
755 if self.Output.TestPoint(pt, direction, exclude): |
756 return self.Output |
756 return self.Output |
757 return None |
757 return None |
758 |
758 |
759 # Refresh the positions of the block connectors |
759 # Refresh the positions of the block connectors |
760 def RefreshConnectors(self): |
760 def RefreshConnectors(self): |