Bug on Element Paste fixed
authorlbessard
Tue, 29 Jan 2008 18:30:47 +0100
changeset 162 e746ff4aa8be
parent 161 6af49f77fa2b
child 163 e4949f54c5d6
Bug on Element Paste fixed
PLCControler.py
Viewer.py
graphics/FBD_Objects.py
graphics/GraphicCommons.py
graphics/LD_Objects.py
graphics/SFC_Objects.py
--- a/PLCControler.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/PLCControler.py	Tue Jan 29 18:30:47 2008 +0100
@@ -1709,7 +1709,7 @@
                 elif param == "type":
                     block.settypeName(value)
                 elif param == "executionOrder" and block.getexecutionOrderId() != value:
-                    self.GetEditedElement(tagname).setelementExecutionOrder(block, value)
+                    element.setelementExecutionOrder(block, value)
                 elif param == "height":
                     block.setheight(value)
                 elif param == "width":
@@ -1768,7 +1768,7 @@
                 if param == "name":
                     variable.setexpression(value)    
                 elif param == "executionOrder" and variable.getexecutionOrderId() != value:
-                    self.GetEditedElement(tagname).setelementExecutionOrder(variable, value)
+                    element.setelementExecutionOrder(variable, value)
                 elif param == "height":
                     variable.setheight(value)
                 elif param == "width":
--- a/Viewer.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/Viewer.py	Tue Jan 29 18:30:47 2008 +0100
@@ -2184,7 +2184,7 @@
     
     def Cut(self):
         if self.IsBlock(self.SelectedElement):
-            self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone())
+            self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self))
             rect = self.SelectedElement.GetRedrawRect(1, 1)
             self.SelectedElement.Delete()
             self.SelectedElement = None
@@ -2194,7 +2194,7 @@
         
     def Copy(self):
         if self.IsBlock(self.SelectedElement):
-            self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone())
+            self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self))
             
     def Paste(self):
         element = self.ParentWindow.GetCopyBuffer()
@@ -2230,10 +2230,10 @@
             while (format%i).upper() in names:
                 i += 1
             name = format%i
-            block = element.Clone(id, name, pos)
+            block = element.Clone(self, id, name, pos)
         else:
             name = None
-            block = element.Clone(id, pos=pos)
+            block = element.Clone(self, id, pos=pos)
         self.AddBlock(block)
         if isinstance(block, Comment):
             self.Controler.AddEditedElementComment(self.TagName, id)
--- a/graphics/FBD_Objects.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/graphics/FBD_Objects.py	Tue Jan 29 18:30:47 2008 +0100
@@ -53,10 +53,10 @@
         self.SetType(type, extension, inputs, connectors)
     
     # Make a clone of this FBD_Block
-    def Clone(self, id = None, name = "", pos = None):
+    def Clone(self, parent, id = None, name = "", pos = None):
         if self.Name != "" and name == "":
             name = self.Name
-        block = FBD_Block(self.Parent, self.Type, name, id, self.Extension)
+        block = FBD_Block(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)
@@ -401,8 +401,8 @@
         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)
+    def Clone(self, parent, id = None, pos = None):
+        variable = FBD_Variable(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)
@@ -649,8 +649,8 @@
         return rect
     
     # Make a clone of this FBD_Connector
-    def Clone(self, id = None, pos = None):
-        connection = FBD_Connector(self.Parent, self.Type, self.Name, id)
+    def Clone(self, parent, id = None, pos = None):
+        connection = FBD_Connector(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)
--- a/graphics/GraphicCommons.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/graphics/GraphicCommons.py	Tue Jan 29 18:30:47 2008 +0100
@@ -303,8 +303,8 @@
         return self.Dragging
     
     # Make a clone of this element
-    def Clone(self):
-        return Graphic_Element(self.Parent, self.Id)
+    def Clone(self, parent):
+        return Graphic_Element(parent, self.Id)
     
     # Changes the block position
     def SetPosition(self, x, y):
@@ -636,12 +636,12 @@
                     self.WireExcluded.append(element)
     
     # Make a clone of this group
-    def Clone(self):
-        clone = Graphic_Group(self.Parent)
+    def Clone(self, parent):
+        clone = Graphic_Group(parent)
         elements = []
         # Makes a clone of all the elements in this group
         for element in self.Elements:
-            elements.append(element.Clone())
+            elements.append(element.Clone(parent))
         clone.SetElements(elements)
         return clone
     
@@ -2038,8 +2038,8 @@
         self.Size = wx.Size(0, 0)
     
     # Make a clone of this comment
-    def Clone(self, id = None, pos = None):
-        comment = Comment(self.Parent, self.Content, id)
+    def Clone(self, parent, id = None, pos = None):
+        comment = Comment(parent, self.Content, id)
         if pos is not None:
             comment.SetPosition(pos.x, pos.y)
         comment.SetSize(self.Size[0], self.Size[1])
--- a/graphics/LD_Objects.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/graphics/LD_Objects.py	Tue Jan 29 18:30:47 2008 +0100
@@ -54,8 +54,8 @@
         self.Connectors = []
     
     # Make a clone of this LD_PowerRail
-    def Clone(self, id = None, pos = None):
-        powerrail = LD_PowerRail(self.Parent, self.Type, id)
+    def Clone(self, parent, id = None, pos = None):
+        powerrail = LD_PowerRail(parent, self.Type, id)
         powerrail.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
             powerrail.SetPosition(pos.x, pos.y)
@@ -378,8 +378,8 @@
         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)
+    def Clone(self, parent, id = None, pos = None):
+        contact = LD_Contact(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)
@@ -608,8 +608,8 @@
         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)
+    def Clone(self, parent, id = None, pos = None):
+        coil = LD_Coil(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)
--- a/graphics/SFC_Objects.py	Tue Jan 29 11:09:49 2008 +0100
+++ b/graphics/SFC_Objects.py	Tue Jan 29 18:30:47 2008 +0100
@@ -65,8 +65,8 @@
         self.Action = None
     
     # Make a clone of this SFC_Step
-    def Clone(self, id = None, name = "Step", pos = None):
-        step = SFC_Step(self.Parent, name, self.Initial, id)
+    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:
             step.SetPosition(pos.x, pos.y)
@@ -509,8 +509,8 @@
             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)
+    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:
             transition.SetPosition(pos.x, pos.y)
@@ -878,8 +878,8 @@
         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)
+    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:
             divergence.SetPosition(pos.x, pos.y)
@@ -1292,8 +1292,8 @@
         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)
+    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:
             jump.SetPosition(pos.x, pos.y)
@@ -1501,9 +1501,9 @@
         self.Input = None
     
     # Make a clone of this SFC_ActionBlock
-    def Clone(self, id = None, pos = None):
+    def Clone(self, parent, id = None, pos = None):
         actions = [action.copy() for action in self.Actions]
-        action_block = SFC_ActionBlock(self.Parent, actions, id)
+        action_block = SFC_ActionBlock(parent, actions, id)
         action_block.SetSize(self.Size[0], self.Size[1])
         if pos is not None:
             action_block.SetPosition(pos.x, pos.y)