graphics/LD_Objects.py
changeset 140 06d28f03f6f4
parent 138 9c74d00ce93e
child 144 b67a5de5a24a
equal deleted inserted replaced
139:c2d093402005 140:06d28f03f6f4
   320         # Draw connectors
   320         # Draw connectors
   321         for connector in self.Connectors:
   321         for connector in self.Connectors:
   322             if connector:
   322             if connector:
   323                 connector.Draw(dc)
   323                 connector.Draw(dc)
   324         Graphic_Element.Draw(self, dc)
   324         Graphic_Element.Draw(self, dc)
   325 
   325         
   326 
   326 
   327 #-------------------------------------------------------------------------------
   327 #-------------------------------------------------------------------------------
   328 #                         Ladder Diagram Contact
   328 #                         Ladder Diagram Contact
   329 #-------------------------------------------------------------------------------
   329 #-------------------------------------------------------------------------------
   330 
   330 
   498     def RefreshModel(self, move=True):
   498     def RefreshModel(self, move=True):
   499         self.Parent.RefreshContactModel(self)
   499         self.Parent.RefreshContactModel(self)
   500         # If contact has moved, refresh the model of wires connected to output
   500         # If contact has moved, refresh the model of wires connected to output
   501         if move:
   501         if move:
   502             self.Output.RefreshWires()
   502             self.Output.RefreshWires()
       
   503     
       
   504     # Draws the highlightment of this element if it is highlighted
       
   505     def DrawHighlightment(self, dc):
       
   506         if self.Highlighted:
       
   507             dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
       
   508             dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
       
   509             # Draw two rectangles for representing the contact
       
   510             dc.DrawRectangle(self.Pos.x - 2, self.Pos.y - 2, 6, self.Size[1] + 5)
       
   511             dc.DrawRectangle(self.Pos.x + self.Size[0] - 3, self.Pos.y - 2, 6, self.Size[1] + 5)
   503     
   512     
   504     # Draws contact
   513     # Draws contact
   505     def Draw(self, dc):
   514     def Draw(self, dc):
   506         dc.SetPen(wx.BLACK_PEN)
   515         dc.SetPen(wx.BLACK_PEN)
   507         dc.SetBrush(wx.BLACK_BRUSH)
   516         dc.SetBrush(wx.BLACK_BRUSH)
   524                     self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2)
   533                     self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2)
   525         # Draw input and output connectors
   534         # Draw input and output connectors
   526         self.Input.Draw(dc)
   535         self.Input.Draw(dc)
   527         self.Output.Draw(dc)
   536         self.Output.Draw(dc)
   528         Graphic_Element.Draw(self, dc)
   537         Graphic_Element.Draw(self, dc)
   529 
   538         
   530 
   539 
   531 #-------------------------------------------------------------------------------
   540 #-------------------------------------------------------------------------------
   532 #                         Ladder Diagram Coil
   541 #                         Ladder Diagram Coil
   533 #-------------------------------------------------------------------------------
   542 #-------------------------------------------------------------------------------
   534 
   543 
   702     def RefreshModel(self, move=True):
   711     def RefreshModel(self, move=True):
   703         self.Parent.RefreshCoilModel(self)
   712         self.Parent.RefreshCoilModel(self)
   704         # If coil has moved, refresh the model of wires connected to output
   713         # If coil has moved, refresh the model of wires connected to output
   705         if move:
   714         if move:
   706             self.Output.RefreshWires()
   715             self.Output.RefreshWires()
       
   716     
       
   717     # Draws the highlightment of this element if it is highlighted
       
   718     def DrawHighlightment(self, dc):
       
   719         if self.Highlighted:
       
   720             dc.SetPen(wx.Pen(HIGHLIGHTCOLOR, 6, wx.SOLID))
       
   721             dc.SetBrush(wx.TRANSPARENT_BRUSH)
       
   722             # Draw a two circle arcs for representing the coil
       
   723             dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, 135, 225)
       
   724             dc.DrawEllipticArc(self.Pos.x, self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1, self.Size[0], int(self.Size[1] * sqrt(2)) - 1, -45, 45)
   707     
   725     
   708     # Draws coil
   726     # Draws coil
   709     def Draw(self, dc):
   727     def Draw(self, dc):
   710         dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID))
   728         dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID))
   711         dc.SetBrush(wx.TRANSPARENT_BRUSH)
   729         dc.SetBrush(wx.TRANSPARENT_BRUSH)
   730                     self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2)
   748                     self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2)
   731         # Draw input and output connectors
   749         # Draw input and output connectors
   732         self.Input.Draw(dc)
   750         self.Input.Draw(dc)
   733         self.Output.Draw(dc)
   751         self.Output.Draw(dc)
   734         Graphic_Element.Draw(self, dc)
   752         Graphic_Element.Draw(self, dc)
       
   753