graphics/SFC_Objects.py
changeset 1784 64beb9e9c749
parent 1782 5b6ad7a7fd9d
child 1846 14b40afccd69
--- a/graphics/SFC_Objects.py	Mon Aug 21 20:17:19 2017 +0000
+++ b/graphics/SFC_Objects.py	Mon Aug 21 23:22:58 2017 +0300
@@ -28,24 +28,25 @@
 from graphics.DebugDataConsumer import DebugDataConsumer
 from plcopen.structures import *
 
+
 def GetWireSize(block):
     if isinstance(block, SFC_Step):
         return SFC_WIRE_MIN_SIZE + block.GetActionExtraLineNumber() * SFC_ACTION_MIN_SIZE[1]
     else:
         return SFC_WIRE_MIN_SIZE
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                         Sequencial Function Chart Step
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements the graphic representation of a step
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFC_Step(Graphic_Element, DebugDataConsumer):
-    
+    """
+    Class that implements the graphic representation of a step
+    """
+
     # Create a new step
-    def __init__(self, parent, name, initial = False, id = None):
+    def __init__(self, parent, name, initial=False, id=None):
         Graphic_Element.__init__(self, parent)
         DebugDataConsumer.__init__(self)
         self.SetName(name)
@@ -62,7 +63,7 @@
         self.Action = None
         self.PreviousValue = None
         self.PreviousSpreading = False
-    
+
     def Flush(self):
         if self.Input is not None:
             self.Input.Flush()
@@ -73,13 +74,13 @@
         if self.Action is not None:
             self.Action.Flush()
             self.Action = None
-    
+
     def SetForced(self, forced):
         if self.Forced != forced:
             self.Forced = forced
             if self.Visible:
                 self.Parent.ElementNeedRefresh(self)
-    
+
     def SetValue(self, value):
         self.PreviousValue = self.Value
         self.Value = value
@@ -87,7 +88,7 @@
             if self.Visible:
                 self.Parent.ElementNeedRefresh(self)
             self.SpreadCurrent()
-    
+
     def SpreadCurrent(self):
         if self.Parent.Debug:
             spreading = self.Value
@@ -102,9 +103,9 @@
                 if self.Action is not None:
                     self.Action.SpreadCurrent(False)
             self.PreviousSpreading = spreading
-    
+
     # Make a clone of this SFC_Step
-    def Clone(self, parent, id = None, name = "Step", pos = None):
+    def Clone(self, parent, id=None, name="Step", pos=None):
         step = SFC_Step(parent, name, self.Initial, id)
         step.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
@@ -118,7 +119,7 @@
         if self.Action:
             step.Action = self.Action.Clone(step)
         return step
-    
+
     def GetConnectorTranslation(self, element):
         connectors = {}
         if self.Input is not None:
@@ -128,9 +129,9 @@
         if self.Action is not None:
             connectors[self.Action] = element.Action
         return connectors
-    
+
     # Returns the RedrawRect
-    def GetRedrawRect(self, movex = 0, movey = 0):
+    def GetRedrawRect(self, movex=0, movey=0):
         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
         if self.Input:
             rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -146,63 +147,63 @@
             if self.Action and self.Action.IsConnected():
                 rect = rect.Union(self.Action.GetConnectedRedrawRect(movex, movey))
         return rect
-    
+
     # Delete this step by calling the appropriate method
     def Delete(self):
         self.Parent.DeleteStep(self)
-    
+
     # Unconnect input and output
     def Clean(self):
         if self.Input:
-            self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
         if self.Output:
-            self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
         if self.Action:
-            self.Action.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-    
+            self.Action.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+
     # Refresh the size of text for name
     def RefreshNameSize(self):
         self.NameSize = self.Parent.GetTextExtent(self.Name)
-    
+
     # Add output connector to step
     def AddInput(self):
         if not self.Input:
             self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH)
             self.RefreshBoundingBox()
-    
+
     # Remove output connector from step
     def RemoveInput(self):
         if self.Input:
-            self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
             self.Input = None
             self.RefreshBoundingBox()
-    
+
     # Add output connector to step
     def AddOutput(self):
         if not self.Output:
-            self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)
+            self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True)
             self.RefreshBoundingBox()
-    
+
     # Remove output connector from step
     def RemoveOutput(self):
         if self.Output:
-            self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
             self.Output = None
             self.RefreshBoundingBox()
-    
+
     # Add action connector to step
     def AddAction(self):
         if not self.Action:
-            self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] / 2), EAST, onlyone = True)
+            self.Action = Connector(self, "", None, wx.Point(self.Size[0], self.Size[1] / 2), EAST, onlyone=True)
             self.RefreshBoundingBox()
-    
+
     # Remove action connector from step
     def RemoveAction(self):
         if self.Action:
-            self.Action.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            self.Action.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
             self.Action = None
             self.RefreshBoundingBox()
-    
+
     # Refresh the step bounding box
     def RefreshBoundingBox(self):
         # Calculate the bounding box size
@@ -220,9 +221,9 @@
             bbx_height = self.Size[1] + CONNECTOR_SIZE
             if self.Output:
                 bbx_height += CONNECTOR_SIZE
-        #self.BoundingBox = wx.Rect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
+        # self.BoundingBox = wx.Rect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
         self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
-        
+
     # Refresh the positions of the step connectors
     def RefreshConnectors(self):
         scaling = self.Parent.GetScaling()
@@ -241,22 +242,22 @@
         if self.Action:
             self.Action.SetPosition(wx.Point(self.Size[0], vertical_pos))
         self.RefreshConnected()
-    
+
     # Refresh the position of wires connected to step
-    def RefreshConnected(self, exclude = []):
+    def RefreshConnected(self, exclude=[]):
         if self.Input:
             self.Input.MoveConnected(exclude)
         if self.Output:
             self.Output.MoveConnected(exclude)
         if self.Action:
             self.Action.MoveConnected(exclude)
-    
-    # Returns the step connector that starts with the point given if it exists 
-    def GetConnector(self, position, name = None):
+
+    # Returns the step connector that starts with the point given if it exists
+    def GetConnector(self, position, name=None):
         # if a name is given
         if name is not None:
             # Test input, output and action connector if they exists
-            #if self.Input and name == self.Input.GetName():
+            # if self.Input and name == self.Input.GetName():
             #    return self.Input
             if self.Output and name == self.Output.GetName():
                 return self.Output
@@ -273,12 +274,12 @@
         if self.Action:
             connectors.append(self.Action)
         return self.FindNearestConnector(position, connectors)
-    
-    # Returns action step connector 
+
+    # Returns action step connector
     def GetActionConnector(self):
         return self.Action
-        
-    # Returns input and output step connectors 
+
+    # Returns input and output step connectors
     def GetConnectors(self):
         connectors = {"inputs": [], "outputs": []}
         if self.Input:
@@ -286,9 +287,9 @@
         if self.Output:
             connectors["outputs"].append(self.Output)
         return connectors
-    
+
     # Test if point given is on step input or output connector
-    def TestConnector(self, pt, direction = None, exclude=True):
+    def TestConnector(self, pt, direction=None, exclude=True):
         # Test input connector if it exists
         if self.Input and self.Input.TestPoint(pt, direction, exclude):
             return self.Input
@@ -312,7 +313,7 @@
     # Returns the step initial property
     def GetInitial(self):
         return self.Initial
-    
+
     # Returns the connector connected to input
     def GetPreviousConnector(self):
         if self.Input:
@@ -320,7 +321,7 @@
             if len(wires) == 1:
                 return wires[0][0].GetOtherConnected(self.Input)
         return None
-    
+
     # Returns the connector connected to output
     def GetNextConnector(self):
         if self.Output:
@@ -328,7 +329,7 @@
             if len(wires) == 1:
                 return wires[0][0].GetOtherConnected(self.Output)
         return None
-    
+
     # Returns the connector connected to action
     def GetActionConnected(self):
         if self.Action:
@@ -336,7 +337,7 @@
             if len(wires) == 1:
                 return wires[0][0].GetOtherConnected(self.Action)
         return None
-    
+
     # Returns the number of action line
     def GetActionExtraLineNumber(self):
         if self.Action:
@@ -346,7 +347,7 @@
             action_block = wires[0][0].GetOtherConnected(self.Action).GetParentBlock()
             return max(0, action_block.GetLineNumber() - 1)
         return 0
-    
+
     # Returns the step minimum size
     def GetMinSize(self):
         text_width, text_height = self.Parent.GetTextExtent(self.Name)
@@ -354,7 +355,7 @@
             return text_width + 14, text_height + 14
         else:
             return text_width + 10, text_height + 10
-    
+
     # Updates the step size
     def UpdateSize(self, width, height):
         diffx = self.Size.GetWidth() / 2 - width / 2
@@ -365,7 +366,7 @@
             self.RefreshConnected()
         else:
             self.RefreshOutputPosition((0, diffy))
-    
+
     # Align input element with this step
     def RefreshInputPosition(self):
         if self.Input:
@@ -382,9 +383,9 @@
                         input_block.MoveActionBlock((diffx, 0))
                     input_block.Move(diffx, 0)
                     input_block.RefreshInputPosition()
-    
+
     # Align output element with this step
-    def RefreshOutputPosition(self, move = None):
+    def RefreshOutputPosition(self, move=None):
         if self.Output:
             wires = self.Output.GetWires()
             if len(wires) != 1:
@@ -400,7 +401,7 @@
                 if isinstance(output_block, SFC_Step):
                     output_block.MoveActionBlock((diffx, diffy))
                 wires[0][0].SetPoints([wx.Point(current_pos.x, current_pos.y + wire_size),
-                    wx.Point(current_pos.x, current_pos.y)])
+                                       wx.Point(current_pos.x, current_pos.y)])
                 if not isinstance(output_block, SFC_Divergence) or output_block.GetConnectors()["inputs"].index(output) == 0:
                     output_block.Move(diffx, diffy, self.Parent.Wires)
                     output_block.RefreshOutputPosition((diffx, diffy))
@@ -422,7 +423,7 @@
                     output_block.MoveActionBlock((diffx, 0))
                 output_block.Move(diffx, 0)
                 output_block.RefreshOutputPosition()
-    
+
     # Refresh action element with this step
     def MoveActionBlock(self, move):
         if self.Action:
@@ -432,24 +433,24 @@
             action_block = wires[0][0].GetOtherConnected(self.Action).GetParentBlock()
             action_block.Move(move[0], move[1], self.Parent.Wires)
             wires[0][0].Move(move[0], move[1], True)
-    
+
     # Resize the divergence from position and size given
     def Resize(self, x, y, width, height):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
             self.UpdateSize(width, height)
         else:
             Graphic_Element.Resize(self, x, y, width, height)
-    
+
     # Method called when a LeftDClick event have been generated
     def OnLeftDClick(self, event, dc, scaling):
         # Edit the step properties
         self.Parent.EditStepContent(self)
-    
+
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
         # Popup the menu with special items for a step
         self.Parent.PopupDefaultMenu()
-    
+
     # Refreshes the step state according to move defined and handle selected
     def ProcessDragging(self, movex, movey, event, scaling):
         handle_type, handle = self.Handle
@@ -477,17 +478,17 @@
                 return movex, 0
         else:
             return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling)
-    
+
     # Refresh input element model
     def RefreshInputModel(self):
         if self.Input:
             input = self.GetPreviousConnector()
-            if input:                
+            if input:
                 input_block = input.GetParentBlock()
                 input_block.RefreshModel(False)
                 if not isinstance(input_block, SFC_Divergence):
                     input_block.RefreshInputModel()
-    
+
     # Refresh output element model
     def RefreshOutputModel(self, move=False):
         if self.Output:
@@ -497,7 +498,7 @@
                 output_block.RefreshModel(False)
                 if not isinstance(output_block, SFC_Divergence) or move:
                     output_block.RefreshOutputModel(move)
-    
+
     # Refreshes the step model
     def RefreshModel(self, move=True):
         self.Parent.RefreshStepModel(self)
@@ -513,21 +514,21 @@
                 self.RefreshOutputModel(self.Initial)
             elif self.Output:
                 self.Output.RefreshWires()
-    
+
     # Adds an highlight to the connection
     def AddHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "name" and start[0] == 0 and end[0] == 0:
             AddHighlight(self.Highlights, (start, end, highlight_type))
-    
+
     # Removes an highlight from the connection
     def RemoveHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "name":
             RemoveHighlight(self.Highlights, (start, end, highlight_type))
-    
+
     # Removes all the highlights of one particular type from the connection
     def ClearHighlight(self, highlight_type=None):
         ClearHighlights(self.Highlights, highlight_type)
-    
+
     # Draws step
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
@@ -541,12 +542,12 @@
         else:
             dc.SetPen(MiterPen(wx.BLACK))
         dc.SetBrush(wx.WHITE_BRUSH)
-        
+
         if getattr(dc, "printing", False):
             name_size = dc.GetTextExtent(self.Name)
         else:
             name_size = self.NameSize
-        
+
         # Draw two rectangles for representing the step
         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
         if self.Initial:
@@ -562,23 +563,23 @@
             self.Output.Draw(dc)
         if self.Action:
             self.Action.Draw(dc)
-        
+
         if not getattr(dc, "printing", False):
             DrawHighlightedText(dc, self.Name, self.Highlights, name_pos[0], name_pos[1])
-        
-
-#-------------------------------------------------------------------------------
+
+
+# -------------------------------------------------------------------------------
 #                       Sequencial Function Chart Transition
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements the graphic representation of a transition
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFC_Transition(Graphic_Element, DebugDataConsumer):
-    
+    """
+    Class that implements the graphic representation of a transition
+    """
+
     # Create a new transition
-    def __init__(self, parent, type = "reference", condition = None, priority = 0, id = None):
+    def __init__(self, parent, type="reference", condition=None, priority=0, id=None):
         Graphic_Element.__init__(self, parent)
         DebugDataConsumer.__init__(self)
         self.Type = None
@@ -586,14 +587,14 @@
         self.Priority = 0
         self.Size = wx.Size(SFC_TRANSITION_SIZE[0], SFC_TRANSITION_SIZE[1])
         # Create an input and output connector
-        self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)
-        self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)
+        self.Input = Connector(self,  "", None, wx.Point(self.Size[0] / 2, 0),            NORTH, onlyone=True)
+        self.Output = Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True)
         self.SetType(type, condition)
         self.SetPriority(priority)
         self.Highlights = {}
         self.PreviousValue = None
         self.PreviousSpreading = False
-    
+
     def Flush(self):
         if self.Input is not None:
             self.Input.Flush()
@@ -604,13 +605,13 @@
         if self.Type == "connection" and self.Condition is not None:
             self.Condition.Flush()
             self.Condition = None
-    
+
     def SetForced(self, forced):
         if self.Forced != forced:
             self.Forced = forced
             if self.Visible:
                 self.Parent.ElementNeedRefresh(self)
-        
+
     def SetValue(self, value):
         self.PreviousValue = self.Value
         self.Value = value
@@ -618,7 +619,7 @@
             if self.Visible:
                 self.Parent.ElementNeedRefresh(self)
             self.SpreadCurrent()
-    
+
     def SpreadCurrent(self):
         if self.Parent.Debug:
             if self.Value is None:
@@ -629,9 +630,9 @@
             elif not spreading and self.PreviousSpreading:
                 self.Output.SpreadCurrent(False)
             self.PreviousSpreading = spreading
-    
+
     # Make a clone of this SFC_Transition
-    def Clone(self, parent, id = None, pos = None):
+    def Clone(self, parent, id=None, pos=None):
         transition = SFC_Transition(parent, self.Type, self.Condition, self.Priority, id)
         transition.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
@@ -643,15 +644,15 @@
         if self.Type == "connection":
             transition.Condition = self.Condition.Clone(transition)
         return transition
-    
+
     def GetConnectorTranslation(self, element):
-        connectors = {self.Input : element.Input, self.Output : element.Output}
+        connectors = {self.Input: element.Input, self.Output: element.Output}
         if self.Type == "connection" and self.Condition is not None:
             connectors[self.Condition] = element.Condition
         return connectors
-    
+
     # Returns the RedrawRect
-    def GetRedrawRect(self, movex = 0, movey = 0):
+    def GetRedrawRect(self, movex=0, movey=0):
         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
         if self.Input:
             rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -665,17 +666,17 @@
             if self.Type == "connection" and self.Condition.IsConnected():
                 rect = rect.Union(self.Condition.GetConnectedRedrawRect(movex, movey))
         return rect
-    
+
     # Forbids to change the transition size
     def SetSize(self, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.SetSize(self, width, height)
-    
+
     # Forbids to resize the transition
     def Resize(self, x, y, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.Resize(self, x, y, width, height)
-    
+
     # Refresh the size of text for name
     def RefreshConditionSize(self):
         if self.Type != "connection":
@@ -683,7 +684,7 @@
                 self.ConditionSize = self.Parent.GetTextExtent(self.Condition)
             else:
                 self.ConditionSize = self.Parent.GetTextExtent("Transition")
-    
+
     # Refresh the size of text for name
     def RefreshPrioritySize(self):
         if self.Priority != "":
@@ -694,14 +695,14 @@
     # Delete this transition by calling the appropriate method
     def Delete(self):
         self.Parent.DeleteTransition(self)
-    
+
     # Unconnect input and output
     def Clean(self):
-        self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-        self.Output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+        self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+        self.Output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
         if self.Type == "connection":
-            self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-    
+            self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+
     # Returns if the point given is in the bounding box
     def HitTest(self, pt, connectors=True):
         if self.Type != "connection":
@@ -715,7 +716,7 @@
         else:
             test_text = False
         return test_text or Graphic_Element.HitTest(self, pt, connectors)
-    
+
     # Refresh the transition bounding box
     def RefreshBoundingBox(self):
         bbx_x, bbx_y, bbx_width, bbx_height = self.Pos.x, self.Pos.y, self.Size[0], self.Size[1]
@@ -733,21 +734,21 @@
             bbx_y = min(bbx_y, self.Pos.y - max(0, (text_height - self.Size[1]) / 2))
             bbx_height = max(bbx_height, self.Pos.y - bbx_y + (self.Size[1] + text_height) / 2)
         self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)
-        
+
     # Returns the connector connected to input
     def GetPreviousConnector(self):
         wires = self.Input.GetWires()
         if len(wires) == 1:
             return wires[0][0].GetOtherConnected(self.Input)
         return None
-    
+
     # Returns the connector connected to output
     def GetNextConnector(self):
         wires = self.Output.GetWires()
         if len(wires) == 1:
             return wires[0][0].GetOtherConnected(self.Output)
         return None
-    
+
     # Refresh the positions of the transition connectors
     def RefreshConnectors(self):
         scaling = self.Parent.GetScaling()
@@ -763,20 +764,20 @@
         if self.Type == "connection":
             self.Condition.SetPosition(wx.Point(0, vertical_pos))
         self.RefreshConnected()
-    
+
     # Refresh the position of the wires connected to transition
-    def RefreshConnected(self, exclude = []):
+    def RefreshConnected(self, exclude=[]):
         self.Input.MoveConnected(exclude)
         self.Output.MoveConnected(exclude)
         if self.Type == "connection":
             self.Condition.MoveConnected(exclude)
-    
-    # Returns the transition connector that starts with the point given if it exists 
-    def GetConnector(self, position, name = None):
+
+    # Returns the transition connector that starts with the point given if it exists
+    def GetConnector(self, position, name=None):
         # if a name is given
         if name is not None:
             # Test input and output connector
-            #if name == self.Input.GetName():
+            # if name == self.Input.GetName():
             #    return self.Input
             if name == self.Output.GetName():
                 return self.Output
@@ -786,19 +787,19 @@
         if self.Type == "connection":
             connectors.append(self.Condition)
         return self.FindNearestConnector(position, connectors)
-    
+
     # Returns the transition condition connector
     def GetConditionConnector(self):
         if self.Type == "connection":
             return self.Condition
         return None
-        
+
     # Returns input and output transition connectors
     def GetConnectors(self):
         return {"inputs": [self.Input], "outputs": [self.Output]}
-        
+
     # Test if point given is on transition input or output connector
-    def TestConnector(self, pt, direction = None, exclude=True):
+    def TestConnector(self, pt, direction=None, exclude=True):
         # Test input connector
         if self.Input.TestPoint(pt, direction, exclude):
             return self.Input
@@ -811,25 +812,25 @@
         return None
 
     # Changes the transition type
-    def SetType(self, type, condition = None):
+    def SetType(self, type, condition=None):
         if self.Type != type:
             if self.Type == "connection":
-               self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE) 
+                self.Condition.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
             self.Type = type
             if type == "connection":
                 self.Condition = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2), WEST)
             else:
-                if condition == None:
+                if condition is None:
                     condition = ""
                 self.Condition = condition
                 self.RefreshConditionSize()
         elif self.Type != "connection":
-            if condition == None:
+            if condition is None:
                 condition = ""
             self.Condition = condition
             self.RefreshConditionSize()
         self.RefreshBoundingBox()
-        
+
     # Returns the transition type
     def GetType(self):
         return self.Type
@@ -839,7 +840,7 @@
         self.Priority = priority
         self.RefreshPrioritySize()
         self.RefreshBoundingBox()
-        
+
     # Returns the transition type
     def GetPriority(self):
         return self.Priority
@@ -849,11 +850,11 @@
         if self.Type != "connection":
             return self.Condition
         return None
-        
+
     # Returns the transition minimum size
     def GetMinSize(self):
         return SFC_TRANSITION_SIZE
-    
+
     # Align input element with this step
     def RefreshInputPosition(self):
         wires = self.Input.GetWires()
@@ -870,9 +871,9 @@
                     input_block.MoveActionBlock((diffx, 0))
                 input_block.Move(diffx, 0)
                 input_block.RefreshInputPosition()
-    
+
     # Align output element with this step
-    def RefreshOutputPosition(self, move = None):
+    def RefreshOutputPosition(self, move=None):
         wires = self.Output.GetWires()
         if len(wires) != 1:
             return
@@ -902,12 +903,12 @@
     def OnLeftDClick(self, event, dc, scaling):
         # Edit the transition properties
         self.Parent.EditTransitionContent(self)
-    
+
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
         # Popup the menu with special items for a step
         self.Parent.PopupDefaultMenu()
-    
+
     # Refreshes the transition state according to move defined and handle selected
     def ProcessDragging(self, movex, movey, event, scaling):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -919,8 +920,8 @@
             self.RefreshOutputPosition()
             return movex, 0
         else:
-            return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac = 2, height_fac = 2)
-    
+            return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac=2, height_fac=2)
+
     # Refresh input element model
     def RefreshInputModel(self):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -930,7 +931,7 @@
                 input_block.RefreshModel(False)
                 if not isinstance(input_block, SFC_Divergence):
                     input_block.RefreshInputModel()
-    
+
     # Refresh output element model
     def RefreshOutputModel(self, move=False):
         output = self.GetNextConnector()
@@ -939,7 +940,7 @@
             output_block.RefreshModel(False)
             if not isinstance(output_block, SFC_Divergence) or move:
                 output_block.RefreshOutputModel(move)
-    
+
     # Refreshes the transition model
     def RefreshModel(self, move=True):
         self.Parent.RefreshTransitionModel(self)
@@ -950,20 +951,20 @@
                 self.RefreshOutputModel()
             else:
                 self.Output.RefreshWires()
-    
+
     # Adds an highlight to the block
-    def AddHighlight(self, infos, start, end ,highlight_type):
+    def AddHighlight(self, infos, start, end, highlight_type):
         if infos[0] in ["reference", "inline", "priority"] and start[0] == 0 and end[0] == 0:
             highlights = self.Highlights.setdefault(infos[0], [])
             AddHighlight(highlights, (start, end, highlight_type))
-    
+
     # Removes an highlight from the block
     def RemoveHighlight(self, infos, start, end, highlight_type):
         if infos[0] in ["reference", "inline", "priority"]:
             highlights = self.Highlights.get(infos[0], [])
             if RemoveHighlight(highlights, (start, end, highlight_type)) and len(highlights) == 0:
                 self.Highlights.pop(infos[0])
-            
+
     # Removes all the highlights of one particular type from the block
     def ClearHighlight(self, highlight_type=None):
         if highlight_type is None:
@@ -974,7 +975,7 @@
                 highlights = ClearHighlights(highlight, highlight_type)
                 if len(highlights) == 0:
                     self.Highlights.pop(name)
-    
+
     # Draws transition
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
@@ -991,7 +992,7 @@
         else:
             dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
-        
+
         if getattr(dc, "printing", False):
             if self.Type != "connection":
                 condition_size = dc.GetTextExtent(self.Condition)
@@ -1002,14 +1003,14 @@
                 condition_size = self.ConditionSize
             if self.Priority != 0:
                 priority_size = self.PrioritySize
-        
+
         # Draw plain rectangle for representing the transition
-        dc.DrawRectangle(self.Pos.x, 
-                         self.Pos.y + (self.Size[1] - SFC_TRANSITION_SIZE[1])/2, 
+        dc.DrawRectangle(self.Pos.x,
+                         self.Pos.y + (self.Size[1] - SFC_TRANSITION_SIZE[1])/2,
                          self.Size[0] + 1,
                          SFC_TRANSITION_SIZE[1] + 1)
         vertical_line_x = self.Input.GetPosition()[0]
-        dc.DrawLine(vertical_line_x, self.Pos.y, vertical_line_x, self.Pos.y + self.Size[1] + 1) 
+        dc.DrawLine(vertical_line_x, self.Pos.y, vertical_line_x, self.Pos.y + self.Size[1] + 1)
         # Draw transition condition
         if self.Type != "connection":
             if self.Condition != "":
@@ -1028,7 +1029,7 @@
         self.Output.Draw(dc)
         if self.Type == "connection":
             self.Condition.Draw(dc)
-        
+
         if not getattr(dc, "printing", False):
             for name, highlights in self.Highlights.iteritems():
                 if name == "priority":
@@ -1036,19 +1037,20 @@
                 else:
                     DrawHighlightedText(dc, condition, highlights, condition_pos[0], condition_pos[1])
 
-#-------------------------------------------------------------------------------
+
+# -------------------------------------------------------------------------------
 #                Sequencial Function Chart Divergence and Convergence
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements the graphic representation of a divergence or convergence,
-selection or simultaneous
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFC_Divergence(Graphic_Element):
-    
+    """
+    Class that implements the graphic representation of a divergence or convergence,
+    selection or simultaneous
+    """
+
     # Create a new divergence
-    def __init__(self, parent, type, number = 2, id = None):
+    def __init__(self, parent, type, number=2, id=None):
         Graphic_Element.__init__(self, parent)
         self.Type = type
         self.Id = id
@@ -1057,18 +1059,18 @@
         self.Size = wx.Size((number - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL, self.GetMinSize()[1])
         # Create an input and output connector
         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
-            self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)]
+            self.Inputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True)]
             self.Outputs = []
             for i in xrange(number):
-                self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone = True))
+                self.Outputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True))
         elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             self.Inputs = []
             for i in xrange(number):
-                self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True))
-            self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone = True)]
+                self.Inputs.append(Connector(self, "", None, wx.Point(i * SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True))
+            self.Outputs = [Connector(self, "", None, wx.Point(self.Size[0] / 2, self.Size[1]), SOUTH, onlyone=True)]
         self.Value = None
         self.PreviousValue = None
-    
+
     def Flush(self):
         for input in self.Inputs:
             input.Flush()
@@ -1076,7 +1078,7 @@
         for output in self.Outputs:
             output.Flush()
         self.Outputs = []
-    
+
     def SpreadCurrent(self):
         if self.Parent.Debug:
             self.PreviousValue = self.Value
@@ -1102,9 +1104,9 @@
                     self.Parent.ElementNeedRefresh(self)
                 for output in self.Outputs:
                     output.SpreadCurrent(False)
-    
+
     # Make a clone of this SFC_Divergence
-    def Clone(self, parent, id = None, pos = None):
+    def Clone(self, parent, id=None, pos=None):
         divergence = SFC_Divergence(parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id)
         divergence.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
@@ -1114,12 +1116,12 @@
         divergence.Inputs = [input.Clone(divergence) for input in self.Inputs]
         divergence.Outputs = [output.Clone(divergence) for output in self.Outputs]
         return divergence
-    
+
     def GetConnectorTranslation(self, element):
         return dict(zip(self.Inputs + self.Outputs, element.Inputs + element.Outputs))
-    
+
     # Returns the RedrawRect
-    def GetRedrawRect(self, movex = 0, movey = 0):
+    def GetRedrawRect(self, movex=0, movey=0):
         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
         if movex != 0 or movey != 0:
             for input in self.Inputs:
@@ -1129,27 +1131,27 @@
                 if output.IsConnected():
                     rect = rect.Union(output.GetConnectedRedrawRect(movex, movey))
         return rect
-    
+
     # Forbids to resize the divergence
     def Resize(self, x, y, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.Resize(self, x, 0, width, self.GetMinSize()[1])
-    
+
     # Delete this divergence by calling the appropriate method
     def Delete(self):
         self.Parent.DeleteDivergence(self)
-    
+
     # Returns the divergence type
     def GetType(self):
         return self.Type
-    
+
     # Unconnect input and output
     def Clean(self):
         for input in self.Inputs:
-            input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+            input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
         for output in self.Outputs:
-            output.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-    
+            output.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+
     # Add a branch to the divergence
     def AddBranch(self):
         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
@@ -1157,7 +1159,7 @@
             for output in self.Outputs:
                 pos = output.GetRelPosition()
                 maxx = max(maxx, pos.x)
-            connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone = True)
+            connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, self.Size[1]), SOUTH, onlyone=True)
             self.Outputs.append(connector)
             self.MoveConnector(connector, 0)
         elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
@@ -1165,10 +1167,10 @@
             for input in self.Inputs:
                 pos = input.GetRelPosition()
                 maxx = max(maxx, pos.x)
-            connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone = True)
+            connector = Connector(self, "", None, wx.Point(maxx + SFC_DEFAULT_SEQUENCE_INTERVAL, 0), NORTH, onlyone=True)
             self.Inputs.append(connector)
             self.MoveConnector(connector, SFC_DEFAULT_SEQUENCE_INTERVAL)
-    
+
     # Remove a branch from the divergence
     def RemoveBranch(self, connector):
         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
@@ -1179,41 +1181,42 @@
             if connector in self.Inputs and len(self.Inputs) > 2:
                 self.Inputs.remove(connector)
                 self.MoveConnector(self.Inputs[0], 0)
-    
+
     # Remove the handled branch from the divergence
     def RemoveHandledBranch(self):
         handle_type, handle = self.Handle
         if handle_type == HANDLE_CONNECTOR:
             handle.UnConnect(delete=True)
             self.RemoveBranch(handle)
-            
+
     # Return the number of branches for the divergence
     def GetBranchNumber(self):
         if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
             return len(self.Outputs)
         elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             return len(self.Inputs)
-    
+
     # Returns if the point given is in the bounding box
     def HitTest(self, pt, connectors=True):
-        return self.BoundingBox.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) != None
-    
+        return self.BoundingBox.InsideXY(pt.x, pt.y) or self.TestConnector(pt, exclude=False) is not None
+
     # Refresh the divergence bounding box
     def RefreshBoundingBox(self):
         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
-            self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, 
-                self.Size[0] + 1, self.Size[1] + 1)
+            self.BoundingBox = wx.Rect(self.Pos.x,       self.Pos.y,
+                                       self.Size[0] + 1, self.Size[1] + 1)
         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
-            self.BoundingBox = wx.Rect(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y, 
+            self.BoundingBox = wx.Rect(
+                self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA,           self.Pos.y,
                 self.Size[0] + 2 * SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Size[1] + 1)
-    
+
     # Refresh the position of wires connected to divergence
-    def RefreshConnected(self, exclude = []):
+    def RefreshConnected(self, exclude=[]):
         for input in self.Inputs:
             input.MoveConnected(exclude)
         for output in self.Outputs:
             output.MoveConnected(exclude)
-    
+
     # Moves the divergence connector given
     def MoveConnector(self, connector, movex):
         position = connector.GetRelPosition()
@@ -1241,26 +1244,26 @@
         self.Size[0] = maxx - minx
         connector.MoveConnected()
         self.RefreshBoundingBox()
-    
-    # Returns the divergence connector that starts with the point given if it exists 
-    def GetConnector(self, position, name = None):
+
+    # Returns the divergence connector that starts with the point given if it exists
+    def GetConnector(self, position, name=None):
         # if a name is given
         if name is not None:
             # Test each input and output connector
-            #for input in self.Inputs:
+            # for input in self.Inputs:
             #    if name == input.GetName():
             #        return input
             for output in self.Outputs:
                 if name == output.GetName():
                     return output
         return self.FindNearestConnector(position, self.Inputs + self.Outputs)
-    
-    # Returns input and output divergence connectors 
+
+    # Returns input and output divergence connectors
     def GetConnectors(self):
         return {"inputs": self.Inputs, "outputs": self.Outputs}
-    
+
     # Test if point given is on divergence input or output connector
-    def TestConnector(self, pt, direction = None, exclude=True):
+    def TestConnector(self, pt, direction=None, exclude=True):
         # Test input connector
         for input in self.Inputs:
             if input.TestPoint(pt, direction, exclude):
@@ -1270,7 +1273,7 @@
             if output.TestPoint(pt, direction, exclude):
                 return output
         return None
-    
+
     # Changes the divergence size
     def SetSize(self, width, height):
         height = self.GetMinSize()[1]
@@ -1290,7 +1293,7 @@
             output.MoveConnected()
         self.Size = wx.Size(width, height)
         self.RefreshBoundingBox()
-    
+
     # Returns the divergence minimum size
     def GetMinSize(self, default=False):
         width = 0
@@ -1304,7 +1307,7 @@
         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             return width, 3
         return 0, 0
-    
+
     # Refresh the position of the block connected to connector
     def RefreshConnectedPosition(self, connector):
         wires = connector.GetWires()
@@ -1340,9 +1343,9 @@
             self.RefreshOutputPosition((0, diffy))
         for input in self.Inputs:
             input.MoveConnected()
-    
+
     # Align output element with this divergence
-    def RefreshOutputPosition(self, move = None):
+    def RefreshOutputPosition(self, move=None):
         if move:
             for output_connector in self.Outputs:
                 wires = output_connector.GetWires()
@@ -1359,10 +1362,10 @@
                 if not isinstance(output_block, SFC_Divergence) or output_block.GetConnectors()["inputs"].index(output) == 0:
                     output_block.Move(move[0], move[1], self.Parent.Wires)
                     output_block.RefreshOutputPosition(move)
-    
+
     # Method called when a LeftDown event have been generated
     def OnLeftDown(self, event, dc, scaling):
-        self.RealConnectors = {"Inputs":[],"Outputs":[]}
+        self.RealConnectors = {"Inputs": [], "Outputs": []}
         for input in self.Inputs:
             position = input.GetRelPosition()
             self.RealConnectors["Inputs"].append(float(position.x)/float(self.Size[0]))
@@ -1370,12 +1373,12 @@
             position = output.GetRelPosition()
             self.RealConnectors["Outputs"].append(float(position.x)/float(self.Size[0]))
         Graphic_Element.OnLeftDown(self, event, dc, scaling)
-    
+
     # Method called when a LeftUp event have been generated
     def OnLeftUp(self, event, dc, scaling):
         Graphic_Element.OnLeftUp(self, event, dc, scaling)
         self.RealConnectors = None
-    
+
     # Method called when a RightDown event have been generated
     def OnRightDown(self, event, dc, scaling):
         pos = GetScaledEventPosition(event, dc, scaling)
@@ -1389,7 +1392,7 @@
             self.oldPos = GetScaledEventPosition(event, dc, scaling)
         else:
             Graphic_Element.OnRightDown(self, event, dc, scaling)
-    
+
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
         pos = GetScaledEventPosition(event, dc, scaling)
@@ -1414,7 +1417,7 @@
             else:
                 # Popup the divergence menu without delete branch
                 self.Parent.PopupDivergenceMenu(False)
-        
+
     # Refreshes the divergence state according to move defined and handle selected
     def ProcessDragging(self, movex, movey, event, scaling):
         handle_type, handle = self.Handle
@@ -1430,7 +1433,7 @@
         elif self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling)
         return 0, 0
-    
+
     # Refresh output element model
     def RefreshOutputModel(self, move=False):
         if move and self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -1442,7 +1445,7 @@
                 output_block.RefreshModel(False)
                 if not isinstance(output_block, SFC_Divergence) or move:
                     output_block.RefreshOutputModel(move)
-    
+
     # Refreshes the divergence model
     def RefreshModel(self, move=True):
         self.Parent.RefreshDivergenceModel(self)
@@ -1453,7 +1456,7 @@
             else:
                 for output in self.Outputs:
                     output.RefreshWires()
-    
+
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
         scalex, scaley = dc.GetUserScale()
@@ -1467,13 +1470,13 @@
         if self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
             posx -= SFC_SIMULTANEOUS_SEQUENCE_EXTRA
             width += SFC_SIMULTANEOUS_SEQUENCE_EXTRA * 2
-        dc.DrawRectangle(int(round((posx - 1) * scalex)) - 2, 
-                         int(round((self.Pos.y - 1) * scaley)) - 2, 
-                         int(round((width + 3) * scalex)) + 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)
@@ -1487,53 +1490,53 @@
         if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
             dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
         elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
-            dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y, 
+            dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y,
                         self.Pos.x + self.Size[0] + SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Pos.y)
-            dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y + self.Size[1], 
+            dc.DrawLine(self.Pos.x - SFC_SIMULTANEOUS_SEQUENCE_EXTRA, self.Pos.y + self.Size[1],
                         self.Pos.x + self.Size[0] + SFC_SIMULTANEOUS_SEQUENCE_EXTRA + 1, self.Pos.y + self.Size[1])
         # Draw inputs and outputs connectors
         for input in self.Inputs:
             input.Draw(dc)
         for output in self.Outputs:
             output.Draw(dc)
-        
-
-#-------------------------------------------------------------------------------
+
+
+# -------------------------------------------------------------------------------
 #                   Sequencial Function Chart Jump to Step
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements the graphic representation of a jump to step
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFC_Jump(Graphic_Element):
-    
+    """
+    Class that implements the graphic representation of a jump to step
+    """
+
     # Create a new jump
-    def __init__(self, parent, target, id = None):
+    def __init__(self, parent, target, id=None):
         Graphic_Element.__init__(self, parent)
         self.SetTarget(target)
         self.Id = id
         self.Size = wx.Size(SFC_JUMP_SIZE[0], SFC_JUMP_SIZE[1])
         self.Highlights = []
         # Create an input and output connector
-        self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone = True)
+        self.Input = Connector(self, "", None, wx.Point(self.Size[0] / 2, 0), NORTH, onlyone=True)
         self.Value = None
         self.PreviousValue = None
-        
+
     def Flush(self):
         if self.Input is not None:
             self.Input.Flush()
             self.Input = None
-    
+
     def SpreadCurrent(self):
         if self.Parent.Debug:
             self.PreviousValue = self.Value
             self.Value = self.Input.ReceivingCurrent()
             if self.Value != self.PreviousValue and self.Visible:
                 self.Parent.ElementNeedRefresh(self)
-    
+
     # Make a clone of this SFC_Jump
-    def Clone(self, parent, id = None, pos = None):
+    def Clone(self, parent, id=None, pos=None):
         jump = SFC_Jump(parent, self.Target, id)
         jump.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
@@ -1542,12 +1545,12 @@
             jump.SetPosition(self.Pos.x, self.Pos.y)
         jump.Input = self.Input.Clone(jump)
         return jump
-    
+
     def GetConnectorTranslation(self, element):
-        return {self.Input : element.Input}
-    
+        return {self.Input: element.Input}
+
     # Returns the RedrawRect
-    def GetRedrawRect(self, movex = 0, movey = 0):
+    def GetRedrawRect(self, movex=0, movey=0):
         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
         if self.Input:
             rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -1555,29 +1558,29 @@
             if self.Input.IsConnected():
                 rect = rect.Union(self.Input.GetConnectedRedrawRect(movex, movey))
         return rect
-    
+
     # Forbids to change the jump size
     def SetSize(self, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.SetSize(self, width, height)
-    
+
     # Forbids to resize jump
     def Resize(self, x, y, width, height):
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             Graphic_Element.Resize(self, x, y, width, height)
-    
+
     # Delete this jump by calling the appropriate method
     def Delete(self):
         self.Parent.DeleteJump(self)
-    
+
     # Unconnect input
     def Clean(self):
-        self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-    
+        self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+
     # Refresh the size of text for target
     def RefreshTargetSize(self):
         self.TargetSize = self.Parent.GetTextExtent(self.Target)
-    
+
     # Returns if the point given is in the bounding box
     def HitTest(self, pt, connectors=True):
         # Calculate the bounding box of the condition outside the transition
@@ -1587,22 +1590,22 @@
                            text_width,
                            text_height)
         return text_bbx.InsideXY(pt.x, pt.y) or Graphic_Element.HitTest(self, pt, connectors)
-    
+
     # Refresh the jump bounding box
     def RefreshBoundingBox(self):
         text_width, text_height = self.Parent.GetTextExtent(self.Target)
         # Calculate the bounding box size
         bbx_width = self.Size[0] + 2 + text_width
-        self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y - CONNECTOR_SIZE, 
-                bbx_width + 1, self.Size[1] + CONNECTOR_SIZE + 1)
-    
+        self.BoundingBox = wx.Rect(self.Pos.x,    self.Pos.y - CONNECTOR_SIZE,
+                                   bbx_width + 1, self.Size[1] + CONNECTOR_SIZE + 1)
+
     # Returns the connector connected to input
     def GetPreviousConnector(self):
         wires = self.Input.GetWires()
         if len(wires) == 1:
             return wires[0][0].GetOtherConnected(self.Input)
         return None
-    
+
     # Refresh the element connectors position
     def RefreshConnectors(self):
         scaling = self.Parent.GetScaling()
@@ -1611,41 +1614,41 @@
             horizontal_pos = round(float(self.Pos.x + horizontal_pos) / float(scaling[0])) * scaling[0] - self.Pos.x
         self.Input.SetPosition(wx.Point(horizontal_pos, 0))
         self.RefreshConnected()
-    
+
     # Refresh the position of wires connected to jump
-    def RefreshConnected(self, exclude = []):
+    def RefreshConnected(self, exclude=[]):
         if self.Input:
             self.Input.MoveConnected(exclude)
-    
-    # Returns input jump connector 
-    def GetConnector(self, position = None, name = None):
+
+    # Returns input jump connector
+    def GetConnector(self, position=None, name=None):
         return self.Input
-    
-    # Returns all the jump connectors 
+
+    # Returns all the jump connectors
     def GetConnectors(self):
         return {"inputs": [self.Input], "outputs": []}
-    
+
     # Test if point given is on jump input connector
-    def TestConnector(self, pt, direction = None, exclude = True):
+    def TestConnector(self, pt, direction=None, exclude=True):
         # Test input connector
         if self.Input and self.Input.TestPoint(pt, direction, exclude):
             return self.Input
         return None
-    
+
     # Changes the jump target
     def SetTarget(self, target):
         self.Target = target
         self.RefreshTargetSize()
         self.RefreshBoundingBox()
-    
+
     # Returns the jump target
     def GetTarget(self):
         return self.Target
-    
+
     # Returns the jump minimum size
     def GetMinSize(self):
         return SFC_JUMP_SIZE
-    
+
     # Align input element with this jump
     def RefreshInputPosition(self):
         if self.Input:
@@ -1662,21 +1665,21 @@
                         input_block.MoveActionBlock((diffx, 0))
                     input_block.Move(diffx, 0)
                     input_block.RefreshInputPosition()
-    
+
     # Can't align output element, because there is no output
-    def RefreshOutputPosition(self, move = None):
+    def RefreshOutputPosition(self, move=None):
         pass
-    
+
     # Method called when a LeftDClick event have been generated
     def OnLeftDClick(self, event, dc, scaling):
         # Edit the jump properties
         self.Parent.EditJumpContent(self)
-    
+
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
         # Popup the default menu
         self.Parent.PopupDefaultMenu()
-    
+
     # Refreshes the jump state according to move defined and handle selected
     def ProcessDragging(self, movex, movey, event, scaling):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -1687,8 +1690,8 @@
             self.RefreshInputPosition()
             return movex, 0
         else:
-            return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac = 2)
-    
+            return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling, width_fac=2)
+
     # Refresh input element model
     def RefreshInputModel(self):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -1698,32 +1701,32 @@
                 input_block.RefreshModel(False)
                 if not isinstance(input_block, SFC_Divergence):
                     input_block.RefreshInputModel()
-    
+
     # Refresh output element model
     def RefreshOutputModel(self, move=False):
         pass
-    
+
     # Refreshes the jump model
     def RefreshModel(self, move=True):
         self.Parent.RefreshJumpModel(self)
         if move:
             if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
                 self.RefreshInputModel()
-    
+
     # Adds an highlight to the variable
     def AddHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "target" and start[0] == 0 and end[0] == 0:
             AddHighlight(self.Highlights, (start, end, highlight_type))
-    
+
     # Removes an highlight from the variable
     def RemoveHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "target":
             RemoveHighlight(self.Highlights, (start, end, highlight_type))
-    
+
     # Removes all the highlights of one particular type from the variable
     def ClearHighlight(self, highlight_type=None):
         ClearHighlights(self.Highlights, highlight_type)
-    
+
     # Draws the highlightment of this element if it is highlighted
     def DrawHighlightment(self, dc):
         scalex, scaley = dc.GetUserScale()
@@ -1731,16 +1734,16 @@
         dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
         dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
         dc.SetLogicalFunction(wx.AND)
-        points = [wx.Point(int(round((self.Pos.x - 2) * scalex)) - 3, 
+        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, 
+                  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)), 
+                  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)
@@ -1750,12 +1753,12 @@
         else:
             dc.SetPen(MiterPen(wx.BLACK))
             dc.SetBrush(wx.BLACK_BRUSH)
-        
+
         if getattr(dc, "printing", False):
             target_size = dc.GetTextExtent(self.Target)
         else:
             target_size = self.TargetSize
-        
+
         # Draw plain rectangle for representing the divergence
         dc.DrawLine(self.Pos.x + self.Size[0] / 2, self.Pos.y, self.Pos.x + self.Size[0] / 2, self.Pos.y + self.Size[1])
         points = [wx.Point(self.Pos.x, self.Pos.y),
@@ -1769,48 +1772,48 @@
         # Draw input connector
         if self.Input:
             self.Input.Draw(dc)
-            
+
         if not getattr(dc, "printing", False):
             DrawHighlightedText(dc, self.Target, self.Highlights, target_pos[0], target_pos[1])
-        
-
-#-------------------------------------------------------------------------------
+
+
+# -------------------------------------------------------------------------------
 #                   Sequencial Function Chart Action Block
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements the graphic representation of an action block
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFC_ActionBlock(Graphic_Element):
-    
+    """
+    Class that implements the graphic representation of an action block
+    """
+
     # Create a new action block
-    def __init__(self, parent, actions = [], id = None):
+    def __init__(self, parent, actions=[], id=None):
         Graphic_Element.__init__(self, parent)
         self.Id = id
         self.Size = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
         self.MinSize = wx.Size(SFC_ACTION_MIN_SIZE[0], SFC_ACTION_MIN_SIZE[1])
         self.Highlights = {}
         # Create an input and output connector
-        self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone = True)
+        self.Input = Connector(self, "", None, wx.Point(0, SFC_ACTION_MIN_SIZE[1] / 2), WEST, onlyone=True)
         self.SetActions(actions)
         self.Value = None
         self.PreviousValue = None
-    
+
     def Flush(self):
         if self.Input is not None:
             self.Input.Flush()
             self.Input = None
-    
+
     def SpreadCurrent(self):
         if self.Parent.Debug:
             self.PreviousValue = self.Value
             self.Value = self.Input.ReceivingCurrent()
             if self.Value != self.PreviousValue and self.Visible:
                 self.Parent.ElementNeedRefresh(self)
-    
+
     # Make a clone of this SFC_ActionBlock
-    def Clone(self, parent, id = None, pos = None):
+    def Clone(self, parent, id=None, pos=None):
         actions = [action.copy() for action in self.Actions]
         action_block = SFC_ActionBlock(parent, actions, id)
         action_block.SetSize(self.Size[0], self.Size[1])
@@ -1820,12 +1823,12 @@
             action_block.SetPosition(self.Pos.x, self.Pos.y)
         action_block.Input = self.Input.Clone(action_block)
         return action_block
-    
+
     def GetConnectorTranslation(self, element):
-        return {self.Input : element.Input}
-    
+        return {self.Input: element.Input}
+
     # Returns the RedrawRect
-    def GetRedrawRect(self, movex = 0, movey = 0):
+    def GetRedrawRect(self, movex=0, movey=0):
         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
         if self.Input:
             rect = rect.Union(self.Input.GetRedrawRect(movex, movey))
@@ -1833,17 +1836,17 @@
             if self.Input.IsConnected():
                 rect = rect.Union(self.Input.GetConnectedRedrawRect(movex, movey))
         return rect
-    
+
     # Returns the number of action lines
     def GetLineNumber(self):
         return len(self.Actions)
-    
+
     def GetLineSize(self):
         if len(self.Actions) > 0:
             return self.Size[1] / len(self.Actions)
         else:
             return SFC_ACTION_MIN_SIZE[1]
-    
+
     # Forbids to resize the action block
     def Resize(self, x, y, width, height):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -1851,38 +1854,38 @@
                 self.SetSize(width, self.Size[1])
         else:
             Graphic_Element.Resize(self, x, y, width, height)
-    
+
     # Delete this action block by calling the appropriate method
     def Delete(self):
         self.Parent.DeleteActionBlock(self)
-    
+
     # Unconnect input and output
     def Clean(self):
-        self.Input.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
-        
+        self.Input.UnConnect(delete=self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
+
     # Refresh the action block bounding box
     def RefreshBoundingBox(self):
         self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
-    
+
     # Refresh the position of wires connected to action block
-    def RefreshConnected(self, exclude = []):
+    def RefreshConnected(self, exclude=[]):
         self.Input.MoveConnected(exclude)
-    
-    # Returns input action block connector 
-    def GetConnector(self, position = None, name = None):
+
+    # Returns input action block connector
+    def GetConnector(self, position=None, name=None):
         return self.Input
-    
-    # Returns all the action block connectors 
+
+    # Returns all the action block connectors
     def GetConnectors(self):
         return {"inputs": [self.Input], "outputs": []}
-    
+
     # Test if point given is on action block input connector
-    def TestConnector(self, pt, direction = None, exclude = True):
+    def TestConnector(self, pt, direction=None, exclude=True):
         # Test input connector
         if self.Input.TestPoint(pt, direction, exclude):
             return self.Input
         return None
-    
+
     # Refresh the element connectors position
     def RefreshConnectors(self):
         scaling = self.Parent.GetScaling()
@@ -1891,7 +1894,7 @@
             vertical_pos = round(float(self.Pos.y + vertical_pos) / float(scaling[1])) * scaling[1] - self.Pos.y
         self.Input.SetPosition(wx.Point(0, vertical_pos))
         self.RefreshConnected()
-    
+
     # Changes the action block actions
     def SetActions(self, actions):
         self.Actions = actions
@@ -1917,13 +1920,14 @@
         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
             self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], max(min_height, SFC_ACTION_MIN_SIZE[1], self.Size[1]))
             self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
-                SFC_ACTION_MIN_SIZE[0]), max(SFC_ACTION_MIN_SIZE[1], min_height)
+                               SFC_ACTION_MIN_SIZE[0]), max(SFC_ACTION_MIN_SIZE[1], min_height)
             self.RefreshBoundingBox()
         else:
             self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
-                SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1])
+                                    SFC_ACTION_MIN_SIZE[0]),
+                                len(self.Actions) * SFC_ACTION_MIN_SIZE[1])
             self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2],
-                SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]
+                               SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]
             self.RefreshBoundingBox()
             if self.Input is not None:
                 wires = self.Input.GetWires()
@@ -1931,25 +1935,25 @@
                     input_block = wires[0][0].GetOtherConnected(self.Input).GetParentBlock()
                     input_block.RefreshOutputPosition()
                     input_block.RefreshOutputModel(True)
-    
+
     # Returns the action block actions
     def GetActions(self):
         return self.Actions
-    
+
     # Returns the action block minimum size
     def GetMinSize(self):
         return self.MinSize
-    
+
     # Method called when a LeftDClick event have been generated
     def OnLeftDClick(self, event, dc, scaling):
         # Edit the action block properties
         self.Parent.EditActionBlockContent(self)
-    
+
     # Method called when a RightUp event have been generated
     def OnRightUp(self, event, dc, scaling):
         # Popup the default menu
         self.Parent.PopupDefaultMenu()
-    
+
     # Refreshes the action block state according to move defined and handle selected
     def ProcessDragging(self, movex, movey, event, scaling):
         if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
@@ -1970,18 +1974,17 @@
         else:
             return Graphic_Element.ProcessDragging(self, movex, movey, event, scaling)
 
-    
     # Refreshes the action block model
     def RefreshModel(self, move=True):
         self.Parent.RefreshActionBlockModel(self)
-    
+
     # Adds an highlight to the variable
     def AddHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "action" and infos[1] < len(self.Actions):
             action_highlights = self.Highlights.setdefault(infos[1], {})
             attribute_highlights = action_highlights.setdefault(infos[2], [])
             AddHighlight(attribute_highlights, (start, end, highlight_type))
-    
+
     # Removes an highlight from the block
     def RemoveHighlight(self, infos, start, end, highlight_type):
         if infos[0] == "action" and infos[1] < len(self.Actions):
@@ -1991,7 +1994,7 @@
                 action_highlights.pop(infos[2])
                 if len(action_highlights) == 0:
                     self.Highlights.pop(infos[1])
-    
+
     # Removes all the highlights of one particular type from the block
     def ClearHighlight(self, highlight_type=None):
         if highlight_type is None:
@@ -2006,7 +2009,7 @@
                         action_highlights.pop(name)
                 if len(action_highlights) == 0:
                     self.Highlights.pop(number)
-    
+
     # Draws divergence
     def Draw(self, dc):
         Graphic_Element.Draw(self, dc)
@@ -2018,15 +2021,15 @@
         colsize = [self.ColSize[0], self.Size[0] - self.ColSize[0] - self.ColSize[2], self.ColSize[2]]
         # Draw plain rectangle for representing the action block
         dc.DrawRectangle(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)
-        dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y, 
-                self.Pos.x + colsize[0], self.Pos.y + self.Size[1])
-        dc.DrawLine(self.Pos.x + colsize[0] + colsize[1], self.Pos.y, 
-                self.Pos.x + colsize[0] + colsize[1], self.Pos.y + self.Size[1])
+        dc.DrawLine(self.Pos.x + colsize[0], self.Pos.y,
+                    self.Pos.x + colsize[0], self.Pos.y + self.Size[1])
+        dc.DrawLine(self.Pos.x + colsize[0] + colsize[1], self.Pos.y,
+                    self.Pos.x + colsize[0] + colsize[1], self.Pos.y + self.Size[1])
         line_size = self.GetLineSize()
         for i, action in enumerate(self.Actions):
             if i != 0:
-                dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, 
-                    self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
+                dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size,
+                            self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
             qualifier_size = dc.GetTextExtent(action.qualifier)
             if action.duration != "":
                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
@@ -2048,7 +2051,7 @@
                 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
                                  self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
                 dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1])
-            
+
             if not getattr(dc, "printing", False):
                 action_highlights = self.Highlights.get(i, {})
                 for name, attribute_highlights in action_highlights.iteritems():
@@ -2060,7 +2063,6 @@
                         DrawHighlightedText(dc, action.value, attribute_highlights, content_pos[0], content_pos[1])
                     elif name == "indicator":
                         DrawHighlightedText(dc, action.indicator, attribute_highlights, indicator_pos[0], indicator_pos[1])
-        
+
         # Draw input connector
         self.Input.Draw(dc)
-