322 connector.RefreshWires() |
322 connector.RefreshWires() |
323 |
323 |
324 # Draws power rail |
324 # Draws power rail |
325 def Draw(self, dc): |
325 def Draw(self, dc): |
326 Graphic_Element.Draw(self, dc) |
326 Graphic_Element.Draw(self, dc) |
327 dc.SetPen(wx.BLACK_PEN) |
327 dc.SetPen(MiterPen(wx.BLACK)) |
328 dc.SetBrush(wx.BLACK_BRUSH) |
328 dc.SetBrush(wx.BLACK_BRUSH) |
329 # Draw a rectangle with the power rail size |
329 # Draw a rectangle with the power rail size |
330 if self.Type == LEFTRAIL: |
330 if self.Type == LEFTRAIL: |
331 dc.DrawRectangle(self.Pos.x + self.Size[0] - LD_POWERRAIL_WIDTH, self.Pos.y, LD_POWERRAIL_WIDTH + 1, self.Size[1] + 1) |
331 dc.DrawRectangle(self.Pos.x + self.Size[0] - LD_POWERRAIL_WIDTH, self.Pos.y, LD_POWERRAIL_WIDTH + 1, self.Size[1] + 1) |
332 else: |
332 else: |
576 if move: |
576 if move: |
577 self.Output.RefreshWires() |
577 self.Output.RefreshWires() |
578 |
578 |
579 # Draws the highlightment of this element if it is highlighted |
579 # Draws the highlightment of this element if it is highlighted |
580 def DrawHighlightment(self, dc): |
580 def DrawHighlightment(self, dc): |
581 dc.SetPen(wx.Pen(HIGHLIGHTCOLOR)) |
581 scalex, scaley = dc.GetUserScale() |
|
582 dc.SetUserScale(1, 1) |
|
583 dc.SetPen(MiterPen(HIGHLIGHTCOLOR)) |
582 dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR)) |
584 dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR)) |
583 dc.SetLogicalFunction(wx.AND) |
585 dc.SetLogicalFunction(wx.AND) |
584 # Draw two rectangles for representing the contact |
586 # Draw two rectangles for representing the contact |
585 dc.DrawRectangle(self.Pos.x - 2, self.Pos.y - 2, 6, self.Size[1] + 5) |
587 left_left = (self.Pos.x - 1) * scalex - 2 |
586 dc.DrawRectangle(self.Pos.x + self.Size[0] - 3, self.Pos.y - 2, 6, self.Size[1] + 5) |
588 right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2 |
|
589 top = (self.Pos.y - 1) * scaley - 2 |
|
590 width = 4 * scalex + 5 |
|
591 height = (self.Size[1] + 3) * scaley + 5 |
|
592 |
|
593 dc.DrawRectangle(left_left, top, width, height) |
|
594 dc.DrawRectangle(right_left, top, width, height) |
587 dc.SetLogicalFunction(wx.COPY) |
595 dc.SetLogicalFunction(wx.COPY) |
|
596 dc.SetUserScale(scalex, scaley) |
588 |
597 |
589 def AddError(self, infos, start, end): |
598 def AddError(self, infos, start, end): |
590 self.Errors[infos[0]] = (start[1], end[1]) |
599 self.Errors[infos[0]] = (start[1], end[1]) |
591 |
600 |
592 # Draws contact |
601 # Draws contact |
596 if self.Type == CONTACT_NORMAL and self.Value or \ |
605 if self.Type == CONTACT_NORMAL and self.Value or \ |
597 self.Type == CONTACT_REVERSE and not self.Value or \ |
606 self.Type == CONTACT_REVERSE and not self.Value or \ |
598 self.Type == CONTACT_RISING and self.Value and not self.PreviousValue or \ |
607 self.Type == CONTACT_RISING and self.Value and not self.PreviousValue or \ |
599 self.Type == CONTACT_RISING and not self.Value and self.PreviousValue: |
608 self.Type == CONTACT_RISING and not self.Value and self.PreviousValue: |
600 if self.Forced: |
609 if self.Forced: |
601 dc.SetPen(wx.CYAN_PEN) |
610 dc.SetPen(MiterPen(wx.CYAN)) |
602 else: |
611 else: |
603 dc.SetPen(wx.GREEN_PEN) |
612 dc.SetPen(MiterPen(wx.GREEN)) |
604 elif self.Forced: |
613 elif self.Forced: |
605 dc.SetPen(wx.Pen(wx.BLUE)) |
614 dc.SetPen(MiterPen(wx.BLUE)) |
606 else: |
615 else: |
607 dc.SetPen(wx.BLACK_PEN) |
616 dc.SetPen(MiterPen(wx.BLACK)) |
608 else: |
617 else: |
609 dc.SetPen(wx.BLACK_PEN) |
618 dc.SetPen(MiterPen(wx.BLACK)) |
610 dc.SetBrush(wx.BLACK_BRUSH) |
619 dc.SetBrush(wx.BLACK_BRUSH) |
611 |
620 |
612 # Compiling contact type modifier symbol |
621 # Compiling contact type modifier symbol |
613 typetext = "" |
622 typetext = "" |
614 if self.Type == CONTACT_REVERSE: |
623 if self.Type == CONTACT_REVERSE: |
861 if move: |
870 if move: |
862 self.Output.RefreshWires() |
871 self.Output.RefreshWires() |
863 |
872 |
864 # Draws the highlightment of this element if it is highlighted |
873 # Draws the highlightment of this element if it is highlighted |
865 def DrawHighlightment(self, dc): |
874 def DrawHighlightment(self, dc): |
866 dc.SetPen(wx.Pen(HIGHLIGHTCOLOR, 6, wx.SOLID)) |
875 scalex, scaley = dc.GetUserScale() |
|
876 dc.SetUserScale(1, 1) |
|
877 dc.SetPen(MiterPen(HIGHLIGHTCOLOR, (3 * scalex + 5), wx.SOLID)) |
867 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
878 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
868 dc.SetLogicalFunction(wx.AND) |
879 dc.SetLogicalFunction(wx.AND) |
869 # Draw a two circle arcs for representing the coil |
880 # Draw a two circle arcs for representing the coil |
870 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) |
881 dc.DrawEllipticArc(round(self.Pos.x * scalex), |
871 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) |
882 round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), |
|
883 round(self.Size[0] * scalex), |
|
884 round((int(self.Size[1] * sqrt(2)) - 1) * scaley), |
|
885 135, 225) |
|
886 dc.DrawEllipticArc(round(self.Pos.x * scalex), |
|
887 round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), |
|
888 round(self.Size[0] * scalex), |
|
889 round((int(self.Size[1] * sqrt(2)) - 1) * scaley), |
|
890 -45, 45) |
872 dc.SetLogicalFunction(wx.COPY) |
891 dc.SetLogicalFunction(wx.COPY) |
|
892 dc.SetUserScale(scalex, scaley) |
873 |
893 |
874 def AddError(self, infos, start, end): |
894 def AddError(self, infos, start, end): |
875 self.Errors[infos[0]] = (start[1], end[1]) |
895 self.Errors[infos[0]] = (start[1], end[1]) |
876 |
896 |
877 # Draws coil |
897 # Draws coil |
878 def Draw(self, dc): |
898 def Draw(self, dc): |
879 Graphic_Element.Draw(self, dc) |
899 Graphic_Element.Draw(self, dc) |
880 if self.Value is not None and self.Value: |
900 if self.Value is not None and self.Value: |
881 dc.SetPen(wx.Pen(wx.GREEN, 2, wx.SOLID)) |
901 dc.SetPen(MiterPen(wx.GREEN, 2, wx.SOLID)) |
882 else: |
902 else: |
883 dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID)) |
903 dc.SetPen(MiterPen(wx.BLACK, 2, wx.SOLID)) |
884 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
904 dc.SetBrush(wx.TRANSPARENT_BRUSH) |
885 |
905 |
886 # Compiling coil type modifier symbol |
906 # Compiling coil type modifier symbol |
887 typetext = "" |
907 typetext = "" |
888 if self.Type == COIL_REVERSE: |
908 if self.Type == COIL_REVERSE: |
912 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) |
932 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) |
913 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) |
933 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) |
914 # Draw a point to avoid hole in left arc |
934 # Draw a point to avoid hole in left arc |
915 if not getattr(dc, "printing", False): |
935 if not getattr(dc, "printing", False): |
916 if self.Value is not None and self.Value: |
936 if self.Value is not None and self.Value: |
917 dc.SetPen(wx.GREEN_PEN) |
937 dc.SetPen(MiterPen(wx.GREEN)) |
918 else: |
938 else: |
919 dc.SetPen(wx.BLACK_PEN) |
939 dc.SetPen(MiterPen(wx.BLACK)) |
920 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1) |
940 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1) |
921 name_size = self.NameSize |
941 name_size = self.NameSize |
922 if typetext != "": |
942 if typetext != "": |
923 type_size = self.TypeSize |
943 type_size = self.TypeSize |
924 |
944 |