graphics/SFC_Objects.py
changeset 563 3f92a5e18804
parent 553 1e1b632c7a41
child 566 6014ef82a98a
--- a/graphics/SFC_Objects.py	Thu Sep 22 10:56:52 2011 +0200
+++ b/graphics/SFC_Objects.py	Thu Sep 22 15:33:31 2011 +0200
@@ -522,13 +522,13 @@
         Graphic_Element.Draw(self, dc)
         if self.Value:
             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))
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLUE))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -938,16 +938,16 @@
         Graphic_Element.Draw(self, dc)
         if self.Value:
             if self.Forced:
-                dc.SetPen(wx.CYAN_PEN)
+                dc.SetPen(MiterPen(wx.CYAN))
                 dc.SetBrush(wx.CYAN_BRUSH)
             else:
-                dc.SetPen(wx.GREEN_PEN)
+                dc.SetPen(MiterPen(wx.GREEN))
                 dc.SetBrush(wx.GREEN_BRUSH)
         elif self.Forced:
-            dc.SetPen(wx.Pen(wx.BLUE))
+            dc.SetPen(MiterPen(wx.BLUE))
             dc.SetBrush(wx.BLUE_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -1416,26 +1416,32 @@
     
     # 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
-        posx = self.Pos.x - 2
-        width = self.Size[0] + 5
+        posx = self.Pos.x
+        width = self.Size[0]
         if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
             width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
-        dc.DrawRectangle(posx, self.Pos.y - 2, width, self.Size[1] + 5)
+        dc.DrawRectangle(int(round((posx - 1) * scalex)) - 2, 
+                         int(round((self.Pos.y - 1) * scaley)) - 2, 
+                         int(round((width + 3) * scalex)) + 5, 
+                         int(round((self.Size.height + 3) * scaley)) + 5)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
         
     # Draws divergence
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
             dc.SetBrush(wx.GREEN_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         # Draw plain rectangle for representing the divergence
         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
@@ -1659,23 +1665,29 @@
     
     # 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)
-        points = [wx.Point(self.Pos.x - 3, self.Pos.y - 2),
-                  wx.Point(self.Pos.x + self.Size[0] + 4, self.Pos.y - 2),
-                  wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] + 4)]
+        points = [wx.Point(int(round((self.Pos.x - 2) * scalex)) - 3, 
+                           int(round((self.Pos.y - 2) * scaley)) - 2),
+                  wx.Point(int(round((self.Pos.x + self.Size[0] + 2) * scalex)) + 4, 
+                           int(round((self.Pos.y - 2) * scaley)) - 2),
+                  wx.Point(int(round((self.Pos.x + self.Size[0] / 2) * scalex)), 
+                           int(round((self.Pos.y + self.Size[1] + 3) * scaley)) + 4)]
         dc.DrawPolygon(points)
         dc.SetLogicalFunction(wx.COPY)
+        dc.SetUserScale(scalex, scaley)
     
     # Draws divergence
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
             dc.SetBrush(wx.GREEN_BRUSH)
         else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
         
         if getattr(dc, "printing", False):
@@ -1914,9 +1926,9 @@
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
         if self.Value:
-            dc.SetPen(wx.GREEN_PEN)
-        else:
-            dc.SetPen(wx.BLACK_PEN)
+            dc.SetPen(MiterPen(wx.GREEN))
+        else:
+            dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
         colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
         # Draw plain rectangle for representing the action block