graphics/GraphicCommons.py
changeset 537 a31bf722aa82
parent 532 63e141705d19
child 550 cfa295862d55
equal deleted inserted replaced
536:288324dddfb8 537:a31bf722aa82
   568         pass
   568         pass
   569     
   569     
   570     def GetConnectorTranslation(self, element):
   570     def GetConnectorTranslation(self, element):
   571         return {}
   571         return {}
   572     
   572     
       
   573     def FindNearestConnector(self, position, connectors):
       
   574         distances = []
       
   575         for connector in connectors:
       
   576             connector_pos = connector.GetRelPosition()
       
   577             distances.append((sqrt((self.Pos.x + connector_pos.x - position.x) ** 2 +
       
   578                                    (self.Pos.y + connector_pos.y - position.y) ** 2),
       
   579                               connector))
       
   580         distances.sort()
       
   581         if len(distances) > 0:
       
   582             return distances[0][1]
       
   583         return None
       
   584         
   573     def IsOfType(self, type, reference):
   585     def IsOfType(self, type, reference):
   574         return self.Parent.IsOfType(type, reference)
   586         return self.Parent.IsOfType(type, reference)
   575     
   587     
   576     def IsEndType(self, type):
   588     def IsEndType(self, type):
   577         return self.Parent.IsEndType(type)
   589         return self.Parent.IsEndType(type)