graphics/LD_Objects.py
changeset 283 c4199b88cf60
parent 269 34eff05909b0
child 327 7fd5233ce5ce
equal deleted inserted replaced
282:a18ddbbc5c58 283:c4199b88cf60
    59     def Clone(self, parent, id = None, pos = None):
    59     def Clone(self, parent, id = None, pos = None):
    60         powerrail = LD_PowerRail(parent, self.Type, id)
    60         powerrail = LD_PowerRail(parent, self.Type, id)
    61         powerrail.SetSize(self.Size[0], self.Size[1])
    61         powerrail.SetSize(self.Size[0], self.Size[1])
    62         if pos is not None:
    62         if pos is not None:
    63             powerrail.SetPosition(pos.x, pos.y)
    63             powerrail.SetPosition(pos.x, pos.y)
       
    64         else:
       
    65             powerrail.SetPosition(self.Pos.x, self.Pos.y)
    64         powerrail.Connectors = []
    66         powerrail.Connectors = []
    65         for connector in self.Connectors:
    67         for connector in self.Connectors:
    66             if connector is not None:
    68             if connector is not None:
    67                 powerrail.Connectors.append(connector.Clone(powerrail))
    69                 powerrail.Connectors.append(connector.Clone(powerrail))
    68             else:
    70             else:
    69                 powerrail.Connectors.append(None)
    71                 powerrail.Connectors.append(None)
    70         return powerrail
    72         return powerrail
       
    73     
       
    74     def GetConnectorTranslation(self, element):
       
    75         return dict(zip([connector for connector in self.Connectors if connector is not None],
       
    76                         [connector for connector in element.Connectors if connector is not None]))
    71     
    77     
    72     # Returns the RedrawRect
    78     # Returns the RedrawRect
    73     def GetRedrawRect(self, movex = 0, movey = 0):
    79     def GetRedrawRect(self, movex = 0, movey = 0):
    74         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
    80         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
    75         for connector in self.Connectors:
    81         for connector in self.Connectors:
   432     def Clone(self, parent, id = None, pos = None):
   438     def Clone(self, parent, id = None, pos = None):
   433         contact = LD_Contact(parent, self.Type, self.Name, id)
   439         contact = LD_Contact(parent, self.Type, self.Name, id)
   434         contact.SetSize(self.Size[0], self.Size[1])
   440         contact.SetSize(self.Size[0], self.Size[1])
   435         if pos is not None:
   441         if pos is not None:
   436             contact.SetPosition(pos.x, pos.y)
   442             contact.SetPosition(pos.x, pos.y)
       
   443         else:
       
   444             contact.SetPosition(self.Pos.x, self.Pos.y)
   437         contact.Input = self.Input.Clone(contact)
   445         contact.Input = self.Input.Clone(contact)
   438         contact.Output = self.Output.Clone(contact)
   446         contact.Output = self.Output.Clone(contact)
   439         return contact
   447         return contact
       
   448     
       
   449     def GetConnectorTranslation(self, element):
       
   450         return {self.Input : element.Input, self.Output : element.Output}
   440     
   451     
   441     # Returns the RedrawRect
   452     # Returns the RedrawRect
   442     def GetRedrawRect(self, movex = 0, movey = 0):
   453     def GetRedrawRect(self, movex = 0, movey = 0):
   443         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
   454         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
   444         rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
   455         rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
   712     def Clone(self, parent, id = None, pos = None):
   723     def Clone(self, parent, id = None, pos = None):
   713         coil = LD_Coil(parent, self.Type, self.Name, id)
   724         coil = LD_Coil(parent, self.Type, self.Name, id)
   714         coil.SetSize(self.Size[0], self.Size[1])
   725         coil.SetSize(self.Size[0], self.Size[1])
   715         if pos is not None:
   726         if pos is not None:
   716             coil.SetPosition(pos.x, pos.y)
   727             coil.SetPosition(pos.x, pos.y)
       
   728         else:
       
   729             coil.SetPosition(self.Pos.x, self.Pos.y)
   717         coil.Input = self.Input.Clone(coil)
   730         coil.Input = self.Input.Clone(coil)
   718         coil.Output = self.Output.Clone(coil)
   731         coil.Output = self.Output.Clone(coil)
   719         return coil
   732         return coil
       
   733     
       
   734     def GetConnectorTranslation(self, element):
       
   735         return {self.Input : element.Input, self.Output : element.Output}
   720     
   736     
   721     # Returns the RedrawRect
   737     # Returns the RedrawRect
   722     def GetRedrawRect(self, movex = 0, movey = 0):
   738     def GetRedrawRect(self, movex = 0, movey = 0):
   723         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
   739         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
   724         rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
   740         rect = rect.Union(self.Input.GetRedrawRect(movex, movey))