graphics/LD_Objects.py
changeset 563 3f92a5e18804
parent 554 08c26c62f5a7
child 566 6014ef82a98a
--- a/graphics/LD_Objects.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/LD_Objects.py	Thu Sep 22 15:33:31 2011 +0200
@@ -324,7 +324,7 @@
     # Draws power rail
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
-        dc.SetPen(wx.BLACK_PEN)
+        dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.BLACK_BRUSH)
         # Draw a rectangle with the power rail size
         if self.Type == LEFTRAIL:
@@ -578,13 +578,22 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
         # Draw two rectangles for representing the contact
-        dc.DrawRectangle(self.Pos.x - 2, self.Pos.y - 2, 6, self.Size[1] + 5)
-        dc.DrawRectangle(self.Pos.x + self.Size[0] - 3, self.Pos.y - 2, 6, self.Size[1] + 5)
+        left_left = (self.Pos.x - 1) * scalex - 2
+        right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
+        top = (self.Pos.y - 1) * scaley - 2
+        width = 4 * scalex + 5
+        height = (self.Size[1] + 3) * scaley + 5
+        
+        dc.DrawRectangle(left_left, top, width, height)
+        dc.DrawRectangle(right_left, top, width, height)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     def AddError(self, infos, start, end):
         self.Errors[infos[0]] = (start[1], end[1])
@@ -598,15 +607,15 @@
                self.Type == CONTACT_RISING and self.Value and not self.PreviousValue or \
                self.Type == CONTACT_RISING and not self.Value and self.PreviousValue:
                 if self.Forced:
-                    dc.SetPen(wx.CYAN_PEN)
+                    dc.SetPen(MiterPen(wx.CYAN))
                 else:
-                    dc.SetPen(wx.GREEN_PEN)
+                    dc.SetPen(MiterPen(wx.GREEN))
             elif self.Forced:
-                dc.SetPen(wx.Pen(wx.BLUE))
+                dc.SetPen(MiterPen(wx.BLUE))
             else:
-                dc.SetPen(wx.BLACK_PEN)
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+                dc.SetPen(MiterPen(wx.BLACK))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.BLACK_BRUSH)
         
         # Compiling contact type modifier symbol
@@ -863,13 +872,24 @@
     
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
-        dc.SetPen(wx.Pen(HIGHLIGHTCOLOR, 6, wx.SOLID))
+        scalex, scaley = dc.GetUserScale()
+        dc.SetUserScale(1, 1)
+        dc.SetPen(MiterPen(HIGHLIGHTCOLOR, (3 * scalex + 5), wx.SOLID))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         dc.SetLogicalFunction(wx.AND)
         # Draw a two circle arcs for representing the coil
-        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)
-        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)
+        dc.DrawEllipticArc(round(self.Pos.x * scalex), 
+                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), 
+                           round(self.Size[0] * scalex), 
+                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
+                           135, 225)
+        dc.DrawEllipticArc(round(self.Pos.x * scalex), 
+                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley), 
+                           round(self.Size[0] * scalex), 
+                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
+                           -45, 45)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     def AddError(self, infos, start, end):
         self.Errors[infos[0]] = (start[1], end[1])
@@ -878,9 +898,9 @@
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value is not None and self.Value:
-            dc.SetPen(wx.Pen(wx.GREEN, 2, wx.SOLID))
-        else:
-            dc.SetPen(wx.Pen(wx.BLACK, 2, wx.SOLID))
+            dc.SetPen(MiterPen(wx.GREEN, 2, wx.SOLID))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK, 2, wx.SOLID))
         dc.SetBrush(wx.TRANSPARENT_BRUSH)
         
         # Compiling coil type modifier symbol 
@@ -914,9 +934,9 @@
             # Draw a point to avoid hole in left arc
             if not getattr(dc, "printing", False):
                 if self.Value is not None and self.Value:
-                    dc.SetPen(wx.GREEN_PEN)
+                    dc.SetPen(MiterPen(wx.GREEN))
                 else:
-                    dc.SetPen(wx.BLACK_PEN)
+                    dc.SetPen(MiterPen(wx.BLACK))
                 dc.DrawPoint(self.Pos.x + 1, self.Pos.y + self.Size[1] / 2 + 1)
             name_size = self.NameSize
             if typetext != "":