graphics/SFC_Objects.py
changeset 140 06d28f03f6f4
parent 138 9c74d00ce93e
child 144 b67a5de5a24a
equal deleted inserted replaced
139:c2d093402005 140:06d28f03f6f4
   444         if self.Output:
   444         if self.Output:
   445             self.Output.Draw(dc)
   445             self.Output.Draw(dc)
   446         if self.Action:
   446         if self.Action:
   447             self.Action.Draw(dc)
   447             self.Action.Draw(dc)
   448         Graphic_Element.Draw(self, dc)
   448         Graphic_Element.Draw(self, dc)
       
   449         
   449 
   450 
   450 #-------------------------------------------------------------------------------
   451 #-------------------------------------------------------------------------------
   451 #                       Sequencial Function Chart Transition
   452 #                       Sequencial Function Chart Transition
   452 #-------------------------------------------------------------------------------
   453 #-------------------------------------------------------------------------------
   453 
   454 
   783         self.Input.Draw(dc)
   784         self.Input.Draw(dc)
   784         self.Output.Draw(dc)
   785         self.Output.Draw(dc)
   785         if self.Type == "connection":
   786         if self.Type == "connection":
   786             self.Condition.Draw(dc)
   787             self.Condition.Draw(dc)
   787         Graphic_Element.Draw(self, dc)
   788         Graphic_Element.Draw(self, dc)
       
   789         
   788 
   790 
   789 #-------------------------------------------------------------------------------
   791 #-------------------------------------------------------------------------------
   790 #                Sequencial Function Chart Divergence and Convergence
   792 #                Sequencial Function Chart Divergence and Convergence
   791 #-------------------------------------------------------------------------------
   793 #-------------------------------------------------------------------------------
   792 
   794 
  1166                 self.RefreshOutputModel()
  1168                 self.RefreshOutputModel()
  1167             else:
  1169             else:
  1168                 for output in self.Outputs:
  1170                 for output in self.Outputs:
  1169                     output.RefreshWires()
  1171                     output.RefreshWires()
  1170     
  1172     
       
  1173     # Draws the highlightment of this element if it is highlighted
       
  1174     def DrawHighlightment(self, dc):
       
  1175         if self.Highlighted:
       
  1176             dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
       
  1177             dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
       
  1178             # Draw two rectangles for representing the contact
       
  1179             posx = self.Pos.x - 2
       
  1180             width = self.Size[0] + 5
       
  1181             if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
       
  1182                 posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
       
  1183                 width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
       
  1184             dc.DrawRectangle(posx, self.Pos.y - 2, width, self.Size[1] + 5)
       
  1185         
  1171     # Draws divergence
  1186     # Draws divergence
  1172     def Draw(self, dc):
  1187     def Draw(self, dc):
  1173         dc.SetPen(wx.BLACK_PEN)
  1188         dc.SetPen(wx.BLACK_PEN)
  1174         dc.SetBrush(wx.BLACK_BRUSH)
  1189         dc.SetBrush(wx.BLACK_BRUSH)
  1175         # Draw plain rectangle for representing the divergence
  1190         # Draw plain rectangle for representing the divergence
  1184         for input in self.Inputs:
  1199         for input in self.Inputs:
  1185             input.Draw(dc)
  1200             input.Draw(dc)
  1186         for output in self.Outputs:
  1201         for output in self.Outputs:
  1187             output.Draw(dc)
  1202             output.Draw(dc)
  1188         Graphic_Element.Draw(self, dc)
  1203         Graphic_Element.Draw(self, dc)
       
  1204         
  1189 
  1205 
  1190 #-------------------------------------------------------------------------------
  1206 #-------------------------------------------------------------------------------
  1191 #                   Sequencial Function Chart Jump to Step
  1207 #                   Sequencial Function Chart Jump to Step
  1192 #-------------------------------------------------------------------------------
  1208 #-------------------------------------------------------------------------------
  1193 
  1209 
  1346     def RefreshModel(self, move=True):
  1362     def RefreshModel(self, move=True):
  1347         self.Parent.RefreshJumpModel(self)
  1363         self.Parent.RefreshJumpModel(self)
  1348         if move:
  1364         if move:
  1349             if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
  1365             if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
  1350                 self.RefreshInputModel()
  1366                 self.RefreshInputModel()
       
  1367     
       
  1368     # Draws the highlightment of this element if it is highlighted
       
  1369     def DrawHighlightment(self, dc):
       
  1370         if self.Highlighted:
       
  1371             dc.SetPen(wx.Pen(HIGHLIGHTCOLOR))
       
  1372             dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
       
  1373             points = [wx.Point(self.Pos.x - 3, self.Pos.y - 2),
       
  1374                       wx.Point(self.Pos.x + self.Size[0] + 4, self.Pos.y - 2),
       
  1375                       wx.Point(self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1] + 4)]
       
  1376             dc.DrawPolygon(points)
  1351     
  1377     
  1352     # Draws divergence
  1378     # Draws divergence
  1353     def Draw(self, dc):
  1379     def Draw(self, dc):
  1354         dc.SetPen(wx.BLACK_PEN)
  1380         dc.SetPen(wx.BLACK_PEN)
  1355         dc.SetBrush(wx.BLACK_BRUSH)
  1381         dc.SetBrush(wx.BLACK_BRUSH)
  1365                     self.Pos.y + (self.Size[1] - text_height) / 2)
  1391                     self.Pos.y + (self.Size[1] - text_height) / 2)
  1366         # Draw input connector
  1392         # Draw input connector
  1367         if self.Input:
  1393         if self.Input:
  1368             self.Input.Draw(dc)
  1394             self.Input.Draw(dc)
  1369         Graphic_Element.Draw(self, dc)
  1395         Graphic_Element.Draw(self, dc)
  1370 
  1396         
  1371 
  1397 
  1372 #-------------------------------------------------------------------------------
  1398 #-------------------------------------------------------------------------------
  1373 #                   Sequencial Function Chart Action Block
  1399 #                   Sequencial Function Chart Action Block
  1374 #-------------------------------------------------------------------------------
  1400 #-------------------------------------------------------------------------------
  1375 
  1401 
  1563                 dc.DrawText(action["indicator"], self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - text_width) / 2,
  1589                 dc.DrawText(action["indicator"], self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - text_width) / 2,
  1564                         self.Pos.y + i * line_size + (line_size - text_height) / 2)
  1590                         self.Pos.y + i * line_size + (line_size - text_height) / 2)
  1565         # Draw input connector
  1591         # Draw input connector
  1566         self.Input.Draw(dc)
  1592         self.Input.Draw(dc)
  1567         Graphic_Element.Draw(self, dc)
  1593         Graphic_Element.Draw(self, dc)
  1568 
  1594