SFCViewer.py
changeset 121 40b91ba978db
parent 112 317148fc1225
child 122 e6faee0c271b
--- a/SFCViewer.py	Tue Nov 13 17:21:30 2007 +0100
+++ b/SFCViewer.py	Fri Nov 16 17:43:32 2007 +0100
@@ -27,10 +27,28 @@
 
 from Viewer import *
 
+if wx.VERSION >= (2, 8, 0):
+    import wx.aui
+
+    class SFC_MDIViewer(wx.aui.AuiMDIChildFrame):
+        def __init__(self, parent, tagname, window, controler):
+            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
+            
+            sizer = wx.BoxSizer(wx.HORIZONTAL)
+            
+            self.Viewer = SFC_Viewer(self, tagname, window, controler)
+            
+            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
+            
+            self.SetSizer(sizer)
+        
+        def GetViewer(self):
+            return self.Viewer
+
 class SFC_Viewer(Viewer):
     
-    def __init__(self, parent, window, controler):
-        Viewer.__init__(self, parent, window, controler)
+    def __init__(self, parent, tagname, window, controler):
+        Viewer.__init__(self, parent, tagname, window, controler)
         self.CurrentLanguage = "SFC"
     
     def ConnectConnectors(self, start, end):
@@ -58,7 +76,7 @@
             previous.RefreshOutputPosition()
         wire.SetPoints([wx.Point(pos.x, pos.y + GetWireSize(previous)), wx.Point(pos.x, pos.y)])
         self.AddBlock(transition)
-        self.Controler.AddCurrentElementEditingTransition(id)
+        self.Controler.AddEditedElementTransition(self.TagName, id)
         self.RefreshTransitionModel(transition)
         if next:
             wire = self.ConnectConnectors(next, transition_connectors["output"])
@@ -90,7 +108,7 @@
         self.RemoveWire(output_wire)
         transition.Clean()
         self.RemoveBlock(transition)
-        self.Controler.RemoveCurrentElementEditingInstance(transition.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
         wire = self.ConnectConnectors(next, previous)
         return wire
     
@@ -112,7 +130,7 @@
             previous.RefreshOutputPosition()
         wire.SetPoints([wx.Point(pos.x, pos.y + GetWireSize(previous)), wx.Point(pos.x, pos.y)])
         self.AddBlock(step)
-        self.Controler.AddCurrentElementEditingStep(id)
+        self.Controler.AddEditedElementStep(self.TagName, id)
         self.RefreshStepModel(step)
         if next:
             wire = self.ConnectConnectors(next, step_connectors["output"])
@@ -153,7 +171,7 @@
             self.DeleteActionBlock(action.GetParentBlock())
         step.Clean()
         self.RemoveBlock(step)
-        self.Controler.RemoveCurrentElementEditingInstance(step.GetId())
+        self.Controler.RemoveEditedElementInstance(self.TagName, step.GetId())
         if next and previous:
             wire = self.ConnectConnectors(next, previous)
             return wire
@@ -374,7 +392,7 @@
     def AddInitialStep(self, pos):
         dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
         dialog.SetPouNames(self.Controler.GetProjectPouNames())
-        dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+        dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
@@ -385,7 +403,7 @@
             width, height = step.GetSize()
             step.SetSize(max(min_width, width), max(min_height, height))
             self.AddBlock(step)
-            self.Controler.AddCurrentElementEditingStep(id)
+            self.Controler.AddEditedElementStep(self.TagName, id)
             self.RefreshStepModel(step)
             self.RefreshBuffer()
             self.RefreshScrollBars()
@@ -396,7 +414,7 @@
         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
             dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
-            dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+            dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
             if dialog.ShowModal() == wx.ID_OK:
                 name = dialog.GetValue()
@@ -452,8 +470,8 @@
             if not connectors["action"]:
                 dialog = ActionBlockDialog(self.ParentWindow)
                 dialog.SetQualifierList(self.Controler.GetQualifierTypes())
-                dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
-                dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
+                dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName))
+                dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName))
                 if dialog.ShowModal() == wx.ID_OK:
                     actions = dialog.GetValues()
                     self.SelectedElement.AddAction()
@@ -468,7 +486,7 @@
                     wire.SetPoints([wx.Point(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wx.Point(pos.x, pos.y)])
                     actionblock.SetActions(actions)
                     self.AddBlock(actionblock)
-                    self.Controler.AddCurrentElementEditingActionBlock(id)
+                    self.Controler.AddEditedElementActionBlock(self.TagName, id)
                     self.RefreshActionBlockModel(actionblock)
                     self.RefreshBuffer()
                     self.RefreshScrollBars()
@@ -518,7 +536,7 @@
                     previous_block.RefreshOutputPosition()
                     wire.SetPoints([wx.Point(pos.x, pos.y + wire_size), wx.Point(pos.x, pos.y)])
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     for index, connector in enumerate(divergence_connectors["outputs"]):
                         if next:
@@ -576,7 +594,7 @@
                     previous_block.RefreshOutputPosition()
                     wire.SetPoints([wx.Point(pos.x, pos.y + wire_size), wx.Point(pos.x, pos.y)])
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     for index, connector in enumerate(divergence_connectors["outputs"]):
                         if next:
@@ -647,7 +665,7 @@
                     pos = divergence_connectors["outputs"][0].GetRelPosition()
                     divergence.MoveConnector(divergence_connectors["outputs"][0], - pos.x)
                     self.AddBlock(divergence)
-                    self.Controler.AddCurrentElementEditingDivergence(id, value["type"])
+                    self.Controler.AddEditedElementDivergence(self.TagName, id, value["type"])
                     self.RefreshDivergenceModel(divergence)
                     if next:
                         wire = self.ConnectConnectors(next, divergence_connectors["outputs"][0])
@@ -718,7 +736,7 @@
                 pos = transition_connectors["output"].GetPosition(False)
                 jump.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
                 self.AddBlock(jump)
-                self.Controler.AddCurrentElementEditingJump(id)
+                self.Controler.AddEditedElementJump(self.TagName, id)
                 jump_connector = jump.GetConnector()
                 wire = self.ConnectConnectors(jump_connector, transition_connectors["output"])
                 transition.RefreshOutputPosition()
@@ -735,7 +753,7 @@
         else:
             dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
             dialog.SetPouNames(self.Controler.GetProjectPouNames())
-            dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+            dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName))
             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetValue()
@@ -845,7 +863,7 @@
                 self.RemoveWire(wire)
                 transition.Clean()
                 self.RemoveBlock(transition)
-                self.Controler.RemoveCurrentElementEditingInstance(transition.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId())
                 previous_block.RemoveBranch(previous)
                 if previous_block.GetBranchNumber() < 2:
                     self.DeleteDivergence(previous_block)
@@ -908,7 +926,7 @@
                                 self.DeleteDivergence(previous_block)
                 divergence.Clean()
                 self.RemoveBlock(divergence)
-                self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId())
                 if next:
                     wire = self.ConnectConnectors(next, previous)
                     previous_block = previous.GetParentBlock()
@@ -940,7 +958,7 @@
                 self.RemoveWire(wire)
                 divergence.Clean()
                 self.RemoveBlock(divergence)
-                self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId())
+                self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId())
                 wire = self.ConnectConnectors(next, previous)
                 previous_pos = previous.GetPosition(False)
                 next_pos = next.GetPosition(False)
@@ -973,7 +991,7 @@
             self.RemoveWire(wire)
             jump.Clean()
             self.RemoveBlock(jump)
-            self.Controler.RemoveCurrentElementEditingInstance(jump.GetId())
+            self.Controler.RemoveEditedElementInstance(self.TagName, jump.GetId())
             if isinstance(previous_block, SFC_Step):
                 previous_block.RemoveOutput()
                 self.RefreshStepModel(previous_block)
@@ -1001,7 +1019,7 @@
             self.RemoveWire(wire)
             actionblock.Clean()
             self.RemoveBlock(actionblock)
-            self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId())
+            self.Controler.RemoveEditedElementInstance(self.TagName, actionblock.GetId())
             step.RemoveAction()
             self.RefreshStepModel(step)
             step.RefreshOutputPosition()