graphics/SFC_Objects.py
changeset 563 3f92a5e18804
parent 553 1e1b632c7a41
child 566 6014ef82a98a
equal deleted inserted replaced
562:0ce12552cf36 563:3f92a5e18804
   520     # Draws step
   520     # Draws step
   521     def Draw(self, dc):
   521     def Draw(self, dc):
   522         Graphic_Element.Draw(self, dc)
   522         Graphic_Element.Draw(self, dc)
   523         if self.Value:
   523         if self.Value:
   524             if self.Forced:
   524             if self.Forced:
   525                 dc.SetPen(wx.CYAN_PEN)
   525                 dc.SetPen(MiterPen(wx.CYAN))
   526             else:
   526             else:
   527                 dc.SetPen(wx.GREEN_PEN)
   527                 dc.SetPen(MiterPen(wx.GREEN))
   528         elif self.Forced:
   528         elif self.Forced:
   529             dc.SetPen(wx.Pen(wx.BLUE))
   529             dc.SetPen(MiterPen(wx.BLUE))
   530         else:
   530         else:
   531             dc.SetPen(wx.BLACK_PEN)
   531             dc.SetPen(MiterPen(wx.BLACK))
   532         dc.SetBrush(wx.WHITE_BRUSH)
   532         dc.SetBrush(wx.WHITE_BRUSH)
   533         
   533         
   534         if getattr(dc, "printing", False):
   534         if getattr(dc, "printing", False):
   535             name_size = dc.GetTextExtent(self.Name)
   535             name_size = dc.GetTextExtent(self.Name)
   536         else:
   536         else:
   936     # Draws transition
   936     # Draws transition
   937     def Draw(self, dc):
   937     def Draw(self, dc):
   938         Graphic_Element.Draw(self, dc)
   938         Graphic_Element.Draw(self, dc)
   939         if self.Value:
   939         if self.Value:
   940             if self.Forced:
   940             if self.Forced:
   941                 dc.SetPen(wx.CYAN_PEN)
   941                 dc.SetPen(MiterPen(wx.CYAN))
   942                 dc.SetBrush(wx.CYAN_BRUSH)
   942                 dc.SetBrush(wx.CYAN_BRUSH)
   943             else:
   943             else:
   944                 dc.SetPen(wx.GREEN_PEN)
   944                 dc.SetPen(MiterPen(wx.GREEN))
   945                 dc.SetBrush(wx.GREEN_BRUSH)
   945                 dc.SetBrush(wx.GREEN_BRUSH)
   946         elif self.Forced:
   946         elif self.Forced:
   947             dc.SetPen(wx.Pen(wx.BLUE))
   947             dc.SetPen(MiterPen(wx.BLUE))
   948             dc.SetBrush(wx.BLUE_BRUSH)
   948             dc.SetBrush(wx.BLUE_BRUSH)
   949         else:
   949         else:
   950             dc.SetPen(wx.BLACK_PEN)
   950             dc.SetPen(MiterPen(wx.BLACK))
   951             dc.SetBrush(wx.BLACK_BRUSH)
   951             dc.SetBrush(wx.BLACK_BRUSH)
   952         
   952         
   953         if getattr(dc, "printing", False):
   953         if getattr(dc, "printing", False):
   954             if self.Type != "connection":
   954             if self.Type != "connection":
   955                 condition_size = dc.GetTextExtent(self.Condition)
   955                 condition_size = dc.GetTextExtent(self.Condition)
  1414                 for output in self.Outputs:
  1414                 for output in self.Outputs:
  1415                     output.RefreshWires()
  1415                     output.RefreshWires()
  1416     
  1416     
  1417     # Draws the highlightment of this element if it is highlighted
  1417     # Draws the highlightment of this element if it is highlighted
  1418     def DrawHighlightment(self, dc):
  1418     def DrawHighlightment(self, dc):
  1419         dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
  1419         scalex, scaley = dc.GetUserScale()
       
  1420         dc.SetUserScale(1, 1)
       
  1421         dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
  1420         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
  1422         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
  1421         dc.SetLogicalFunction(wx.AND)
  1423         dc.SetLogicalFunction(wx.AND)
  1422         # Draw two rectangles for representing the contact
  1424         # Draw two rectangles for representing the contact
  1423         posx = self.Pos.x - 2
  1425         posx = self.Pos.x
  1424         width = self.Size[0] + 5
  1426         width = self.Size[0]
  1425         if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1427         if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1426             posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
  1428             posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
  1427             width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
  1429             width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
  1428         dc.DrawRectangle(posx, self.Pos.y - 2, width, self.Size[1] + 5)
  1430         dc.DrawRectangle(int(round((posx - 1) * scalex)) - 2, 
       
  1431                          int(round((self.Pos.y - 1) * scaley)) - 2, 
       
  1432                          int(round((width + 3) * scalex)) + 5, 
       
  1433                          int(round((self.Size.height + 3) * scaley)) + 5)
  1429         dc.SetLogicalFunction(wx.COPY)
  1434         dc.SetLogicalFunction(wx.COPY)
       
  1435         dc.SetUserScale(scalex, scaley)
  1430         
  1436         
  1431     # Draws divergence
  1437     # Draws divergence
  1432     def Draw(self, dc):
  1438     def Draw(self, dc):
  1433         Graphic_Element.Draw(self, dc)
  1439         Graphic_Element.Draw(self, dc)
  1434         if self.Value:
  1440         if self.Value:
  1435             dc.SetPen(wx.GREEN_PEN)
  1441             dc.SetPen(MiterPen(wx.GREEN))
  1436             dc.SetBrush(wx.GREEN_BRUSH)
  1442             dc.SetBrush(wx.GREEN_BRUSH)
  1437         else:
  1443         else:
  1438             dc.SetPen(wx.BLACK_PEN)
  1444             dc.SetPen(MiterPen(wx.BLACK))
  1439             dc.SetBrush(wx.BLACK_BRUSH)
  1445             dc.SetBrush(wx.BLACK_BRUSH)
  1440         # Draw plain rectangle for representing the divergence
  1446         # Draw plain rectangle for representing the divergence
  1441         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
  1447         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
  1442             dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1448             dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1443         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1449         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
  1657         if infos[0] == "target" and start[0] == 0 and end[0] == 0:
  1663         if infos[0] == "target" and start[0] == 0 and end[0] == 0:
  1658             self.Errors[infos[0]] = (start[1], end[1])
  1664             self.Errors[infos[0]] = (start[1], end[1])
  1659     
  1665     
  1660     # Draws the highlightment of this element if it is highlighted
  1666     # Draws the highlightment of this element if it is highlighted
  1661     def DrawHighlightment(self, dc):
  1667     def DrawHighlightment(self, dc):
  1662         dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
  1668         scalex, scaley = dc.GetUserScale()
       
  1669         dc.SetUserScale(1, 1)
       
  1670         dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
  1663         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
  1671         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
  1664         dc.SetLogicalFunction(wx.AND)
  1672         dc.SetLogicalFunction(wx.AND)
  1665         points = [wx.Point(self.Pos.x - 3, self.Pos.y - 2),
  1673         points = [wx.Point(int(round((self.Pos.x - 2) * scalex)) - 3, 
  1666                   wx.Point(self.Pos.x + self.Size[0] + 4, self.Pos.y - 2),
  1674                            int(round((self.Pos.y - 2) * scaley)) - 2),
  1667                   wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] + 4)]
  1675                   wx.Point(int(round((self.Pos.x + self.Size[0] + 2) * scalex)) + 4, 
       
  1676                            int(round((self.Pos.y - 2) * scaley)) - 2),
       
  1677                   wx.Point(int(round((self.Pos.x + self.Size[0] / 2) * scalex)), 
       
  1678                            int(round((self.Pos.y + self.Size[1] + 3) * scaley)) + 4)]
  1668         dc.DrawPolygon(points)
  1679         dc.DrawPolygon(points)
  1669         dc.SetLogicalFunction(wx.COPY)
  1680         dc.SetLogicalFunction(wx.COPY)
       
  1681         dc.SetUserScale(scalex, scaley)
  1670     
  1682     
  1671     # Draws divergence
  1683     # Draws divergence
  1672     def Draw(self, dc):
  1684     def Draw(self, dc):
  1673         Graphic_Element.Draw(self, dc)
  1685         Graphic_Element.Draw(self, dc)
  1674         if self.Value:
  1686         if self.Value:
  1675             dc.SetPen(wx.GREEN_PEN)
  1687             dc.SetPen(MiterPen(wx.GREEN))
  1676             dc.SetBrush(wx.GREEN_BRUSH)
  1688             dc.SetBrush(wx.GREEN_BRUSH)
  1677         else:
  1689         else:
  1678             dc.SetPen(wx.BLACK_PEN)
  1690             dc.SetPen(MiterPen(wx.BLACK))
  1679             dc.SetBrush(wx.BLACK_BRUSH)
  1691             dc.SetBrush(wx.BLACK_BRUSH)
  1680         
  1692         
  1681         if getattr(dc, "printing", False):
  1693         if getattr(dc, "printing", False):
  1682             target_size = dc.GetTextExtent(self.Target)
  1694             target_size = dc.GetTextExtent(self.Target)
  1683         else:
  1695         else:
  1912     
  1924     
  1913     # Draws divergence
  1925     # Draws divergence
  1914     def Draw(self, dc):
  1926     def Draw(self, dc):
  1915         Graphic_Element.Draw(self, dc)
  1927         Graphic_Element.Draw(self, dc)
  1916         if self.Value:
  1928         if self.Value:
  1917             dc.SetPen(wx.GREEN_PEN)
  1929             dc.SetPen(MiterPen(wx.GREEN))
  1918         else:
  1930         else:
  1919             dc.SetPen(wx.BLACK_PEN)
  1931             dc.SetPen(MiterPen(wx.BLACK))
  1920         dc.SetBrush(wx.WHITE_BRUSH)
  1932         dc.SetBrush(wx.WHITE_BRUSH)
  1921         colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
  1933         colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
  1922         # Draw plain rectangle for representing the action block
  1934         # Draw plain rectangle for representing the action block
  1923         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1935         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1924         dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y, 
  1936         dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y,