graphics/SFC_Objects.py
changeset 1852 70c1cc354a8f
parent 1849 6811021e3d94
child 1872 866fb3ab8778
equal deleted inserted replaced
1851:1b8b5324506c 1852:70c1cc354a8f
   244         if self.Action:
   244         if self.Action:
   245             self.Action.SetPosition(wx.Point(self.Size[0], vertical_pos))
   245             self.Action.SetPosition(wx.Point(self.Size[0], vertical_pos))
   246         self.RefreshConnected()
   246         self.RefreshConnected()
   247 
   247 
   248     # Refresh the position of wires connected to step
   248     # Refresh the position of wires connected to step
   249     def RefreshConnected(self, exclude=[]):
   249     def RefreshConnected(self, exclude=None):
   250         if self.Input:
   250         if self.Input:
   251             self.Input.MoveConnected(exclude)
   251             self.Input.MoveConnected(exclude)
   252         if self.Output:
   252         if self.Output:
   253             self.Output.MoveConnected(exclude)
   253             self.Output.MoveConnected(exclude)
   254         if self.Action:
   254         if self.Action:
   765         if self.Type == "connection":
   765         if self.Type == "connection":
   766             self.Condition.SetPosition(wx.Point(0, vertical_pos))
   766             self.Condition.SetPosition(wx.Point(0, vertical_pos))
   767         self.RefreshConnected()
   767         self.RefreshConnected()
   768 
   768 
   769     # Refresh the position of the wires connected to transition
   769     # Refresh the position of the wires connected to transition
   770     def RefreshConnected(self, exclude=[]):
   770     def RefreshConnected(self, exclude=None):
   771         self.Input.MoveConnected(exclude)
   771         self.Input.MoveConnected(exclude)
   772         self.Output.MoveConnected(exclude)
   772         self.Output.MoveConnected(exclude)
   773         if self.Type == "connection":
   773         if self.Type == "connection":
   774             self.Condition.MoveConnected(exclude)
   774             self.Condition.MoveConnected(exclude)
   775 
   775 
  1209             self.BoundingBox = wx.Rect(
  1209             self.BoundingBox = wx.Rect(
  1210                 self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA,           self.Pos.y,
  1210                 self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA,           self.Pos.y,
  1211                 self.Size[0] + 2 * SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Size[1] + 1)
  1211                 self.Size[0] + 2 * SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Size[1] + 1)
  1212 
  1212 
  1213     # Refresh the position of wires connected to divergence
  1213     # Refresh the position of wires connected to divergence
  1214     def RefreshConnected(self, exclude=[]):
  1214     def RefreshConnected(self, exclude=None):
  1215         for input in self.Inputs:
  1215         for input in self.Inputs:
  1216             input.MoveConnected(exclude)
  1216             input.MoveConnected(exclude)
  1217         for output in self.Outputs:
  1217         for output in self.Outputs:
  1218             output.MoveConnected(exclude)
  1218             output.MoveConnected(exclude)
  1219 
  1219 
  1611             horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x
  1611             horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x
  1612         self.Input.SetPosition(wx.Point(horizontal_pos, 0))
  1612         self.Input.SetPosition(wx.Point(horizontal_pos, 0))
  1613         self.RefreshConnected()
  1613         self.RefreshConnected()
  1614 
  1614 
  1615     # Refresh the position of wires connected to jump
  1615     # Refresh the position of wires connected to jump
  1616     def RefreshConnected(self, exclude=[]):
  1616     def RefreshConnected(self, exclude=None):
  1617         if self.Input:
  1617         if self.Input:
  1618             self.Input.MoveConnected(exclude)
  1618             self.Input.MoveConnected(exclude)
  1619 
  1619 
  1620     # Returns input jump connector
  1620     # Returns input jump connector
  1621     def GetConnector(self, position=None, name=None):
  1621     def GetConnector(self, position=None, name=None):
  1783     """
  1783     """
  1784     Class that implements the graphic representation of an action block
  1784     Class that implements the graphic representation of an action block
  1785     """
  1785     """
  1786 
  1786 
  1787     # Create a new action block
  1787     # Create a new action block
  1788     def __init__(self, parent, actions=[], id=None):
  1788     def __init__(self, parent, actions=None, id=None):
  1789         Graphic_Element.__init__(self, parent)
  1789         Graphic_Element.__init__(self, parent)
  1790         self.Id = id
  1790         self.Id = id
  1791         self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
  1791         self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
  1792         self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
  1792         self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
  1793         self.Highlights = {}
  1793         self.Highlights = {}
  1863     # Refresh the action block bounding box
  1863     # Refresh the action block bounding box
  1864     def RefreshBoundingBox(self):
  1864     def RefreshBoundingBox(self):
  1865         self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1865         self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
  1866 
  1866 
  1867     # Refresh the position of wires connected to action block
  1867     # Refresh the position of wires connected to action block
  1868     def RefreshConnected(self, exclude=[]):
  1868     def RefreshConnected(self, exclude=None):
  1869         self.Input.MoveConnected(exclude)
  1869         self.Input.MoveConnected(exclude)
  1870 
  1870 
  1871     # Returns input action block connector
  1871     # Returns input action block connector
  1872     def GetConnector(self, position=None, name=None):
  1872     def GetConnector(self, position=None, name=None):
  1873         return self.Input
  1873         return self.Input
  1891             vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y
  1891             vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y
  1892         self.Input.SetPosition(wx.Point(0, vertical_pos))
  1892         self.Input.SetPosition(wx.Point(0, vertical_pos))
  1893         self.RefreshConnected()
  1893         self.RefreshConnected()
  1894 
  1894 
  1895     # Changes the action block actions
  1895     # Changes the action block actions
  1896     def SetActions(self, actions):
  1896     def SetActions(self, actions=None):
       
  1897         actions = [] if actions is None else actions
  1897         self.Actions = actions
  1898         self.Actions = actions
  1898         self.ColSize = [0, 0, 0]
  1899         self.ColSize = [0, 0, 0]
  1899         min_height = 0
  1900         min_height = 0
  1900         for action in self.Actions:
  1901         for action in self.Actions:
  1901             width, height = self.Parent.GetTextExtent(
  1902             width, height = self.Parent.GetTextExtent(