561 # Draws contact |
561 # Draws contact |
562 def Draw(self, dc): |
562 def Draw(self, dc): |
563 Graphic_Element.Draw(self, dc) |
563 Graphic_Element.Draw(self, dc) |
564 dc.SetPen(wx.BLACK_PEN) |
564 dc.SetPen(wx.BLACK_PEN) |
565 dc.SetBrush(wx.BLACK_BRUSH) |
565 dc.SetBrush(wx.BLACK_BRUSH) |
566 # Draw two rectangles for representing the contact |
566 |
567 dc.DrawRectangle(self.Pos.x, self.Pos.y, 2, self.Size[1] + 1) |
567 # Compiling contact type modifier symbol |
568 dc.DrawRectangle(self.Pos.x + self.Size[0] - 1, self.Pos.y, 2, self.Size[1] + 1) |
|
569 # Draw contact name |
|
570 dc.DrawText(self.Name, self.Pos.x + (self.Size[0] - self.NameSize[0]) / 2, |
|
571 self.Pos.y - (self.NameSize[1] + 2)) |
|
572 # Draw the modifier symbol in the middle of contact |
|
573 typetext = "" |
568 typetext = "" |
574 if self.Type == CONTACT_REVERSE: |
569 if self.Type == CONTACT_REVERSE: |
575 typetext = "/" |
570 typetext = "/" |
576 elif self.Type == CONTACT_RISING: |
571 elif self.Type == CONTACT_RISING: |
577 typetext = "P" |
572 typetext = "P" |
578 elif self.Type == CONTACT_FALLING: |
573 elif self.Type == CONTACT_FALLING: |
579 typetext = "N" |
574 typetext = "N" |
|
575 |
|
576 if getattr(dc, "printing", False): |
|
577 name_size = dc.GetTextExtent(self.Name) |
|
578 if typetext != "": |
|
579 type_size = dc.GetTextExtent(typetext) |
|
580 else: |
|
581 name_size = self.NameSize |
|
582 if typetext != "": |
|
583 type_size = self.TypeSize |
|
584 |
|
585 # Draw two rectangles for representing the contact |
|
586 dc.DrawRectangle(self.Pos.x, self.Pos.y, 2, self.Size[1] + 1) |
|
587 dc.DrawRectangle(self.Pos.x + self.Size[0] - 1, self.Pos.y, 2, self.Size[1] + 1) |
|
588 # Draw contact name |
|
589 dc.DrawText(self.Name, self.Pos.x + (self.Size[0] - name_size[0]) / 2, |
|
590 self.Pos.y - (name_size[1] + 2)) |
|
591 # Draw the modifier symbol in the middle of contact |
580 if typetext != "": |
592 if typetext != "": |
581 dc.DrawText(typetext, self.Pos.x + (self.Size[0] - self.TypeSize[0]) / 2 + 1, |
593 dc.DrawText(typetext, self.Pos.x + (self.Size[0] - type_size[0]) / 2 + 1, |
582 self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2) |
594 self.Pos.y + (self.Size[1] - type_size[1]) / 2) |
583 # Draw input and output connectors |
595 # Draw input and output connectors |
584 self.Input.Draw(dc) |
596 self.Input.Draw(dc) |
585 self.Output.Draw(dc) |
597 self.Output.Draw(dc) |
586 |
598 |
587 |
599 |
791 # Draws coil |
803 # Draws coil |
792 def Draw(self, dc): |
804 def Draw(self, dc): |
793 Graphic_Element.Draw(self, dc) |
805 Graphic_Element.Draw(self, dc) |
794 dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID)) |
806 dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID)) |
795 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
807 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
796 # Draw a two circle arcs for representing the coil |
808 |
797 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) |
809 # Compiling coil type modifier symbol |
798 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) |
|
799 dc.SetPen(wx.BLACK_PEN) |
|
800 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1) |
|
801 # Draw coil name |
|
802 dc.DrawText(self.Name, self.Pos.x + (self.Size[0] - self.NameSize[0]) / 2, |
|
803 self.Pos.y - (self.NameSize[1] + 2)) |
|
804 # Draw the modifier symbol in the middle of coil |
|
805 typetext = "" |
810 typetext = "" |
806 if self.Type == COIL_REVERSE: |
811 if self.Type == COIL_REVERSE: |
807 typetext = "/" |
812 typetext = "/" |
808 elif self.Type == COIL_SET: |
813 elif self.Type == COIL_SET: |
809 typetext = "S" |
814 typetext = "S" |
810 elif self.Type == COIL_RESET: |
815 elif self.Type == COIL_RESET: |
811 typetext = "R" |
816 typetext = "R" |
|
817 |
|
818 if getattr(dc, "printing", False) and not isinstance(dc, wx.PostScriptDC): |
|
819 # Draw an clipped ellipse for representing the coil |
|
820 clipping_box = dc.GetClippingBox() |
|
821 dc.SetClippingRegion(self.Pos.x - 1, self.Pos.y, self.Size[0] + 2, self.Size[1] + 1) |
|
822 dc.DrawEllipse(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) |
|
823 dc.DestroyClippingRegion() |
|
824 if clipping_box != (0, 0, 0, 0): |
|
825 dc.SetClippingRegion(*clipping_box) |
|
826 name_size = dc.GetTextExtent(self.Name) |
|
827 if typetext != "": |
|
828 type_size = dc.GetTextExtent(typetext) |
|
829 else: |
|
830 # Draw a two ellipse arcs for representing the coil |
|
831 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) |
|
832 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) |
|
833 # Draw a point to avoid hole in left arc |
|
834 if not getattr(dc, "printing", False): |
|
835 dc.SetPen(wx.BLACK_PEN) |
|
836 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1) |
|
837 name_size = self.NameSize |
|
838 if typetext != "": |
|
839 type_size = self.TypeSize |
|
840 |
|
841 # Draw coil name |
|
842 dc.DrawText(self.Name, self.Pos.x + (self.Size[0] - name_size[0]) / 2, |
|
843 self.Pos.y - (name_size[1] + 2)) |
|
844 # Draw the modifier symbol in the middle of coil |
812 if typetext != "": |
845 if typetext != "": |
813 dc.DrawText(typetext, self.Pos.x + (self.Size[0] - self.TypeSize[0]) / 2 + 1, |
846 dc.DrawText(typetext, self.Pos.x + (self.Size[0] - type_size[0]) / 2 + 1, |
814 self.Pos.y + (self.Size[1] - self.TypeSize[1]) / 2) |
847 self.Pos.y + (self.Size[1] - type_size[1]) / 2) |
815 # Draw input and output connectors |
848 # Draw input and output connectors |
816 self.Input.Draw(dc) |
849 self.Input.Draw(dc) |
817 self.Output.Draw(dc) |
850 self.Output.Draw(dc) |
818 |
851 |