--- a/LDViewer.py Fri Oct 19 17:08:46 2007 +0200
+++ b/LDViewer.py Wed Oct 24 15:59:46 2007 +0200
@@ -169,6 +169,7 @@
Viewer.__init__(self, parent, window, controler)
self.Rungs = []
self.RungComments = []
+ self.CurrentLanguage = "LD"
#-------------------------------------------------------------------------------
# Refresh functions
@@ -441,7 +442,8 @@
self.Scroll(xpos, ymax)
elif event.ControlDown():
self.Scroll(xpos, min(ypos + 1, ymax))
- event.Skip()
+ else:
+ event.Skip()
#-------------------------------------------------------------------------------
# Adding element functions
--- a/SFCViewer.py Fri Oct 19 17:08:46 2007 +0200
+++ b/SFCViewer.py Wed Oct 24 15:59:46 2007 +0200
@@ -31,6 +31,7 @@
def __init__(self, parent, window, controler):
Viewer.__init__(self, parent, window, controler)
+ self.CurrentLanguage = "SFC"
def ConnectConnectors(self, start, end):
startpoint = [start.GetPosition(False), start.GetDirection()]
@@ -323,7 +324,7 @@
if event.ControlDown() and event.ShiftDown():
self.Scroll(0, ypos)
elif event.ControlDown():
- self.Scroll(max(0, xpos - 1), ypos)
+ event.Skip()
elif self.SelectedElement:
self.SelectedElement.Move(-scaling[0], 0)
self.SelectedElement.RefreshModel()
@@ -334,7 +335,7 @@
if event.ControlDown() and event.ShiftDown():
self.Scroll(xmax, ypos)
elif event.ControlDown():
- self.Scroll(min(xpos + 1, xmax), ypos)
+ event.Skip()
elif self.SelectedElement:
self.SelectedElement.Move(scaling[0], 0)
self.SelectedElement.RefreshModel()
@@ -345,7 +346,7 @@
if event.ControlDown() and event.ShiftDown():
self.Scroll(xpos, 0)
elif event.ControlDown():
- self.Scroll(xpos, max(0, ypos - 1))
+ event.Skip()
elif self.SelectedElement:
self.SelectedElement.Move(0, -scaling[1])
self.SelectedElement.RefreshModel()
@@ -356,13 +357,15 @@
if event.ControlDown() and event.ShiftDown():
self.Scroll(xpos, ymax)
elif event.ControlDown():
- self.Scroll(xpos, min(ypos + 1, ymax))
+ event.Skip()
elif self.SelectedElement:
self.SelectedElement.Move(0, scaling[1])
self.SelectedElement.RefreshModel()
self.RefreshBuffer()
self.RefreshScrollBars()
self.Refresh()
+ else:
+ event.Skip()
#-------------------------------------------------------------------------------
# Adding element functions
--- a/graphics/FBD_Objects.py Fri Oct 19 17:08:46 2007 +0200
+++ b/graphics/FBD_Objects.py Wed Oct 24 15:59:46 2007 +0200
@@ -52,6 +52,16 @@
self.Pen = wx.BLACK_PEN
self.SetType(type, extension, inputs, connectors)
+ # Make a clone of this FBD_Block
+ def Clone(self, id = None, name = "", pos = None):
+ block = FBD_Block(self.Parent, self.Type, name, id, self.Extension)
+ block.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ block.SetPosition(pos.x, pos.y)
+ block.Inputs = [input.Clone(block) for input in self.Inputs]
+ block.Outputs = [output.Clone(block) for output in self.Outputs]
+ return block
+
# Destructor
def __del__(self):
self.Inputs = []
@@ -137,7 +147,7 @@
return None
def GetInputTypes(self):
- return tuple([input.GetType() for input in self.Inputs])
+ return tuple([input.GetType(True) for input in self.Inputs])
def SetOutputValues(self, values):
for output in self.Outputs:
@@ -351,6 +361,16 @@
self.RefreshNameSize()
self.SetType(type, value_type)
+ # Make a clone of this FBD_Variable
+ def Clone(self, id = None, pos = None):
+ variable = FBD_Variable(self.Parent, self.Type, self.Name, self.ValueType, id)
+ variable.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ variable.SetPosition(pos.x, pos.y)
+ variable.Input = self.Input.Clone(variable)
+ variable.Output = self.Output.Clone(variable)
+ return variable
+
# Destructor
def __del__(self):
self.Input = None
@@ -541,6 +561,15 @@
def __del__(self):
self.Connector = None
+ # Make a clone of this FBD_Connector
+ def Clone(self, id = None, pos = None):
+ connection = FBD_Connector(self.Parent, self.Type, self.Name, id)
+ connection.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ connection.SetPosition(pos.x, pos.y)
+ connection.Connector = self.Connector.Clone(connection)
+ return connection
+
# Unconnect connector
def Clean(self):
if self.Connector:
--- a/graphics/GraphicCommons.py Fri Oct 19 17:08:46 2007 +0200
+++ b/graphics/GraphicCommons.py Wed Oct 24 15:59:46 2007 +0200
@@ -714,8 +714,10 @@
self.Pen = pen
# Make a clone of the connector
- def Clone(self):
- return Connector(self.ParentBlock, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]),
+ def Clone(self, parent = None):
+ if parent is None:
+ parent = self.ParentBlock
+ return Connector(parent, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]),
self.Direction, self.Negated)
# Returns the connector parent block
@@ -723,8 +725,8 @@
return self.ParentBlock
# Returns the connector type
- def GetType(self):
- if IsEndType(self.Type):
+ def GetType(self, raw = False):
+ if IsEndType(self.Type) or raw:
return self.Type
elif (self.Negated or self.Edge != "none") and IsOfType("BOOL", self.Type):
return "BOOL"
@@ -1562,12 +1564,20 @@
def MoveSegment(self, idx, movex, movey):
if 0 < idx < len(self.Segments) - 1:
if self.Segments[idx] in (NORTH, SOUTH):
+ start_x = self.Points[idx].x
self.Points[idx].x += movex
self.Points[idx + 1].x += movex
+ self.GeneratePoints()
+ if start_x != self.Points[idx].x:
+ return True, False
elif self.Segments[idx] in (EAST, WEST):
+ start_y = self.Points[idx].y
self.Points[idx].y += movey
self.Points[idx + 1].y += movey
- self.GeneratePoints()
+ self.GeneratePoints()
+ if start_y != self.Points[idx].y:
+ return False, True
+ return False, False
# Adds two points in the middle of the handled segment
def AddSegment(self):
@@ -1709,8 +1719,7 @@
return True, True
# A segment has been handled, move a segment
elif handle_type == HANDLE_SEGMENT:
- self.MoveSegment(handle[0], movex, movey)
- return True, True
+ return self.MoveSegment(handle[0], movex, movey)
# Execute the default method for a graphic element
else:
return Graphic_Element.ProcessDragging(self, movex, movey)
@@ -1762,6 +1771,12 @@
self.Pos = wx.Point(0, 0)
self.Size = wx.Size(0, 0)
+ # Make a clone of this comment
+ def Clone(self, id = None):
+ comment = Comment(self.Parent, self.Content, id)
+ comment.SetSize(self.Size[0], self.Size[1])
+ return comment
+
# Method for keeping compatibility with others
def Clean(self):
pass
--- a/graphics/LD_Objects.py Fri Oct 19 17:08:46 2007 +0200
+++ b/graphics/LD_Objects.py Wed Oct 24 15:59:46 2007 +0200
@@ -53,6 +53,20 @@
def __del__(self):
self.Connectors = []
+ # Make a clone of this LD_PowerRail
+ def Clone(self, id = None, pos = None):
+ powerrail = LD_PowerRail(self.Parent, self.Type, id)
+ powerrail.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ powerrail.SetPosition(pos.x, pos.y)
+ powerrail.Connectors = []
+ for connector in self.Connectors:
+ if connector is not None:
+ powerrail.Connectors.append(connector.Clone(powerrail))
+ else:
+ powerrail.Connectors.append(None)
+ return powerrail
+
# Forbids to change the power rail size
def SetSize(self, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
@@ -345,6 +359,16 @@
self.Input = None
self.Output = None
+ # Make a clone of this LD_Contact
+ def Clone(self, id = None, pos = None):
+ contact = LD_Contact(self.Parent, self.Type, self.Name, id)
+ contact.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ contact.SetPosition(pos.x, pos.y)
+ contact.Input = self.Input.Clone(contact)
+ contact.Output = self.Output.Clone(contact)
+ return contact
+
# Forbids to change the contact size
def SetSize(self, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
@@ -534,6 +558,16 @@
self.Input = None
self.Output = None
+ # Make a clone of this LD_Coil
+ def Clone(self, id = None, pos = None):
+ coil = LD_Coil(self.Parent, self.Type, self.Name, id)
+ coil.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ coil.SetPosition(pos.x, pos.y)
+ coil.Input = self.Input.Clone(coil)
+ coil.Output = self.Output.Clone(coil)
+ return coil
+
# Forbids to change the contact size
def SetSize(self, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
--- a/graphics/SFC_Objects.py Fri Oct 19 17:08:46 2007 +0200
+++ b/graphics/SFC_Objects.py Wed Oct 24 15:59:46 2007 +0200
@@ -64,6 +64,17 @@
self.Output = None
self.Action = None
+ # Make a clone of this SFC_Step
+ def Clone(self, id = None, pos = None):
+ step = SFC_Step(self.Parent, self.Type, self.Name, id)
+ step.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ step.SetPosition(pos.x, pos.y)
+ step.Input = self.Input.Clone(step)
+ step.Output = self.Output.Clone(step)
+ step.Action = self.Action.Clone(step)
+ return step
+
# Delete this step by calling the appropriate method
def Delete(self):
self.Parent.DeleteStep(self)
@@ -462,6 +473,16 @@
if self.Type == "connection":
self.Condition = None
+ # Make a clone of this SFC_Transition
+ def Clone(self, id = None, pos = None):
+ transition = SFC_Transition(self.Parent, self.Type, self.Condition, self.Priority, id)
+ transition.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ transition.SetPosition(pos.x, pos.y)
+ transition.Input = self.Input.Clone(transition)
+ transition.Output = self.Output.Clone(transition)
+ return transition
+
# Forbids to change the transition size
def SetSize(self, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
@@ -799,6 +820,16 @@
self.Inputs = []
self.Outputs = []
+ # Make a clone of this SFC_Divergence
+ def Clone(self, id = None, pos = None):
+ divergence = SFC_Divergence(self.Parent, self.Type, max(len(self.Inputs), len(self.Outputs)), id)
+ divergence.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ divergence.SetPosition(pos.x, pos.y)
+ divergence.Inputs = [input.Clone(divergence) for input in self.Inputs]
+ divergence.Outputs = [output.Clone(divergence) for output in self.Outputs]
+ return divergence
+
# Forbids to resize the divergence
def Resize(self, x, y, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
@@ -1173,6 +1204,15 @@
def __del__(self):
self.Input = None
+ # Make a clone of this SFC_Jump
+ def Clone(self, id = None, pos = None):
+ jump = SFC_Jump(self.Parent, self.Target, id)
+ jump.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ jump.SetPosition(pos.x, pos.y)
+ jump.Input = self.Input.Clone(jump)
+ return jump
+
# Forbids to change the jump size
def SetSize(self, width, height):
if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
@@ -1346,6 +1386,16 @@
def __del__(self):
self.Input = None
+ # Make a clone of this SFC_ActionBlock
+ def Clone(self, id = None, pos = None):
+ actions = [action.copy() for action in self.Actions]
+ action_block = SFC_ActionBlock(self.Parent, actions, id)
+ action_block.SetSize(self.Size[0], self.Size[1])
+ if pos is not None:
+ action_block.SetPosition(pos.x, pos.y)
+ action_block.Input = self.Input.Clone(action_block)
+ return jump
+
# Returns the number of action lines
def GetLineNumber(self):
return len(self.Actions)