SFCViewer.py
changeset 90 2245e8776086
parent 80 c798a68c5560
child 112 317148fc1225
equal deleted inserted replaced
89:a6ff2b3fcc25 90:2245e8776086
   367 #-------------------------------------------------------------------------------
   367 #-------------------------------------------------------------------------------
   368 #                          Adding element functions
   368 #                          Adding element functions
   369 #-------------------------------------------------------------------------------
   369 #-------------------------------------------------------------------------------
   370 
   370 
   371     def AddInitialStep(self, pos):
   371     def AddInitialStep(self, pos):
   372         dialog = StepNameDialog(self.Parent, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
   372         dialog = StepNameDialog(self.ParentWindow, "Add a new initial step", "Please enter step name", "", wx.OK|wx.CANCEL)
   373         dialog.SetPouNames(self.Controler.GetProjectPouNames())
   373         dialog.SetPouNames(self.Controler.GetProjectPouNames())
   374         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   374         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   375         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   375         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   376         if dialog.ShowModal() == wx.ID_OK:
   376         if dialog.ShowModal() == wx.ID_OK:
   377             id = self.GetNewId()
   377             id = self.GetNewId()
   389             self.Refresh()
   389             self.Refresh()
   390         dialog.Destroy()
   390         dialog.Destroy()
   391 
   391 
   392     def AddStep(self):
   392     def AddStep(self):
   393         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   393         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   394             dialog = StepNameDialog(self.Parent, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
   394             dialog = StepNameDialog(self.ParentWindow, "Add a new step", "Please enter step name", "", wx.OK|wx.CANCEL)
   395             dialog.SetPouNames(self.Controler.GetProjectPouNames())
   395             dialog.SetPouNames(self.Controler.GetProjectPouNames())
   396             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   396             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   397             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   397             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   398             if dialog.ShowModal() == wx.ID_OK:
   398             if dialog.ShowModal() == wx.ID_OK:
   399                 name = dialog.GetValue()
   399                 name = dialog.GetValue()
   445     
   445     
   446     def AddStepAction(self):
   446     def AddStepAction(self):
   447         if isinstance(self.SelectedElement, SFC_Step):
   447         if isinstance(self.SelectedElement, SFC_Step):
   448             connectors = self.SelectedElement.GetConnectors()
   448             connectors = self.SelectedElement.GetConnectors()
   449             if not connectors["action"]:
   449             if not connectors["action"]:
   450                 dialog = ActionBlockDialog(self.Parent)
   450                 dialog = ActionBlockDialog(self.ParentWindow)
   451                 dialog.SetQualifierList(self.Controler.GetQualifierTypes())
   451                 dialog.SetQualifierList(self.Controler.GetQualifierTypes())
   452                 dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
   452                 dialog.SetActionList(self.Controler.GetCurrentElementEditingActions())
   453                 dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
   453                 dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars())
   454                 if dialog.ShowModal() == wx.ID_OK:
   454                 if dialog.ShowModal() == wx.ID_OK:
   455                     actions = dialog.GetValues()
   455                     actions = dialog.GetValues()
   472                     self.Refresh()
   472                     self.Refresh()
   473                 dialog.Destroy()
   473                 dialog.Destroy()
   474     
   474     
   475     def AddDivergence(self):
   475     def AddDivergence(self):
   476         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step):        
   476         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step):        
   477             dialog = DivergenceCreateDialog(self.Parent)
   477             dialog = DivergenceCreateDialog(self.ParentWindow)
   478             if dialog.ShowModal() == wx.ID_OK:
   478             if dialog.ShowModal() == wx.ID_OK:
   479                 value = dialog.GetValues()
   479                 value = dialog.GetValues()
   480                 if value["type"] == SELECTION_DIVERGENCE:
   480                 if value["type"] == SELECTION_DIVERGENCE:
   481                     if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Step):
   481                     if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Step):
   482                         self.SelectedElement.SetSelectedSegment(None)
   482                         self.SelectedElement.SetSelectedSegment(None)
   700         if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output:
   700         if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output:
   701             choices = []
   701             choices = []
   702             for block in self.Blocks:
   702             for block in self.Blocks:
   703                 if isinstance(block, SFC_Step):
   703                 if isinstance(block, SFC_Step):
   704                     choices.append(block.GetName())
   704                     choices.append(block.GetName())
   705             dialog = wx.SingleChoiceDialog(self.Parent, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL)
   705             dialog = wx.SingleChoiceDialog(self.ParentWindow, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL)
   706             if dialog.ShowModal() == wx.ID_OK:
   706             if dialog.ShowModal() == wx.ID_OK:
   707                 value = dialog.GetStringSelection()
   707                 value = dialog.GetStringSelection()
   708                 self.SelectedElement.AddOutput()
   708                 self.SelectedElement.AddOutput()
   709                 self.RefreshStepModel(self.SelectedElement)
   709                 self.RefreshStepModel(self.SelectedElement)
   710                 step_connectors = self.SelectedElement.GetConnectors()
   710                 step_connectors = self.SelectedElement.GetConnectors()
   728 
   728 
   729     def EditStepContent(self, step):
   729     def EditStepContent(self, step):
   730         if self.GetDrawingMode() == FREEDRAWING_MODE:
   730         if self.GetDrawingMode() == FREEDRAWING_MODE:
   731             Viewer.EditStepContent(self, step)
   731             Viewer.EditStepContent(self, step)
   732         else:
   732         else:
   733             dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
   733             dialog = StepNameDialog(self.ParentWindow, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
   734             dialog.SetPouNames(self.Controler.GetProjectPouNames())
   734             dialog.SetPouNames(self.Controler.GetProjectPouNames())
   735             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   735             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   736             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   736             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   737             if dialog.ShowModal() == wx.ID_OK:
   737             if dialog.ShowModal() == wx.ID_OK:
   738                 value = dialog.GetValue()
   738                 value = dialog.GetValue()