graphics/FBD_Objects.py
changeset 243 c5da8b706cde
parent 231 fc2d6cbb8b39
child 249 d8425712acef
equal deleted inserted replaced
242:5b3e1c4569e6 243:c5da8b706cde
   196     # Returns all the block connectors
   196     # Returns all the block connectors
   197     def GetConnectors(self):
   197     def GetConnectors(self):
   198         return {"inputs" : self.Inputs, "outputs" : self.Outputs}
   198         return {"inputs" : self.Inputs, "outputs" : self.Outputs}
   199     
   199     
   200     # Test if point given is on one of the block connectors
   200     # Test if point given is on one of the block connectors
   201     def TestConnector(self, pt, exclude = True):
   201     def TestConnector(self, pt, direction = None, exclude = True):
   202         # Test each input connector
   202         # Test each input connector
   203         for input in self.Inputs:
   203         for input in self.Inputs:
   204             if input.TestPoint(pt, exclude):
   204             if input.TestPoint(pt, direction, exclude):
   205                 return input
   205                 return input
   206         # Test each output connector
   206         # Test each output connector
   207         for output in self.Outputs:
   207         for output in self.Outputs:
   208             if output.TestPoint(pt, exclude):
   208             if output.TestPoint(pt, direction, exclude):
   209                 return output
   209                 return output
   210         return None
   210         return None
   211     
   211     
   212     # Changes the block type
   212     # Changes the block type
   213     def SetType(self, type, extension, inputs = None, connectors = {}):
   213     def SetType(self, type, extension, inputs = None, connectors = {}):
   333     
   333     
   334     # Method called when a RightUp event have been generated
   334     # Method called when a RightUp event have been generated
   335     def OnRightUp(self, event, dc, scaling):
   335     def OnRightUp(self, event, dc, scaling):
   336         pos = GetScaledEventPosition(event, dc, scaling)
   336         pos = GetScaledEventPosition(event, dc, scaling)
   337         # Popup the menu with special items for a block and a connector if one is handled
   337         # Popup the menu with special items for a block and a connector if one is handled
   338         connector = self.TestConnector(pos, False)
   338         connector = self.TestConnector(pos, exclude=False)
   339         if connector:
   339         if connector:
   340             self.Handle = (HANDLE_CONNECTOR, connector)
   340             self.Handle = (HANDLE_CONNECTOR, connector)
   341             self.Parent.PopupBlockMenu(connector)
   341             self.Parent.PopupBlockMenu(connector)
   342         else:
   342         else:
   343             self.Parent.PopupBlockMenu()
   343             self.Parent.PopupBlockMenu()
   504             self.Input.MoveConnected(exclude)
   504             self.Input.MoveConnected(exclude)
   505         if self.Output:
   505         if self.Output:
   506             self.Output.MoveConnected(exclude)
   506             self.Output.MoveConnected(exclude)
   507         
   507         
   508     # Test if point given is on the variable connector
   508     # Test if point given is on the variable connector
   509     def TestConnector(self, pt, exclude=True):
   509     def TestConnector(self, pt, direction = None, exclude=True):
   510         if self.Input and self.Input.TestPoint(pt, exclude):
   510         if self.Input and self.Input.TestPoint(pt, direction, exclude):
   511             return self.Input
   511             return self.Input
   512         if self.Output and self.Output.TestPoint(pt, exclude):
   512         if self.Output and self.Output.TestPoint(pt, direction, exclude):
   513             return self.Output
   513             return self.Output
   514         return None
   514         return None
   515     
   515     
   516     # Returns the block connector that starts with the point given if it exists 
   516     # Returns the block connector that starts with the point given if it exists 
   517     def GetConnector(self, position, name = None):
   517     def GetConnector(self, position, name = None):
   732     def RefreshConnected(self, exclude = []):
   732     def RefreshConnected(self, exclude = []):
   733         if self.Connector:
   733         if self.Connector:
   734             self.Connector.MoveConnected(exclude)
   734             self.Connector.MoveConnected(exclude)
   735     
   735     
   736     # Test if point given is on the connection connector
   736     # Test if point given is on the connection connector
   737     def TestConnector(self, pt, exclude=True):
   737     def TestConnector(self, pt, direction = None, exclude=True):
   738         if self.Connector and self.Connector.TestPoint(pt, exclude):
   738         if self.Connector and self.Connector.TestPoint(pt, direction, exclude):
   739             return self.Connector
   739             return self.Connector
   740         return None
   740         return None
   741     
   741     
   742     # Returns the connection connector
   742     # Returns the connection connector
   743     def GetConnector(self, position = None, name = None):
   743     def GetConnector(self, position = None, name = None):