editors/SFCViewer.py
changeset 1745 f9d32913bad4
parent 1744 69dfdb26f600
child 1764 d5df428640ff
equal deleted inserted replaced
1744:69dfdb26f600 1745:f9d32913bad4
   428 #-------------------------------------------------------------------------------
   428 #-------------------------------------------------------------------------------
   429 #                          Adding element functions
   429 #                          Adding element functions
   430 #-------------------------------------------------------------------------------
   430 #-------------------------------------------------------------------------------
   431 
   431 
   432     def AddInitialStep(self, pos):
   432     def AddInitialStep(self, pos):
   433         dialog = SFCStepNameDialog(self.ParentWindow, _("Please enter step name"), _("Add a new initial step"), "", wx.OK|wx.CANCEL)
   433         dialog = SFCStepNameDialog(self.ParentWindow, _("Please enter step name"), _("Add a new initial step"), "", wx.OK | wx.CANCEL)
   434         dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   434         dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   435         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   435         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   436         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   436         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   437         if dialog.ShowModal() == wx.ID_OK:
   437         if dialog.ShowModal() == wx.ID_OK:
   438             id = self.GetNewId()
   438             id = self.GetNewId()
   450             self.Refresh(False)
   450             self.Refresh(False)
   451         dialog.Destroy()
   451         dialog.Destroy()
   452 
   452 
   453     def AddStep(self):
   453     def AddStep(self):
   454         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   454         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   455             dialog = SFCStepNameDialog(self.ParentWindow, _("Add a new step"), _("Please enter step name"), "", wx.OK|wx.CANCEL)
   455             dialog = SFCStepNameDialog(self.ParentWindow, _("Add a new step"), _("Please enter step name"), "", wx.OK | wx.CANCEL)
   456             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   456             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   457             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   457             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   458             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   458             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   459             if dialog.ShowModal() == wx.ID_OK:
   459             if dialog.ShowModal() == wx.ID_OK:
   460                 name = dialog.GetValue()
   460                 name = dialog.GetValue()
   766             for block in self.Blocks:
   766             for block in self.Blocks:
   767                 if isinstance(block, SFC_Step):
   767                 if isinstance(block, SFC_Step):
   768                     choices.append(block.GetName())
   768                     choices.append(block.GetName())
   769             dialog = wx.SingleChoiceDialog(self.ParentWindow,
   769             dialog = wx.SingleChoiceDialog(self.ParentWindow,
   770                   _("Add a new jump"), _("Please choose a target"),
   770                   _("Add a new jump"), _("Please choose a target"),
   771                   choices, wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
   771                   choices, wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
   772             if dialog.ShowModal() == wx.ID_OK:
   772             if dialog.ShowModal() == wx.ID_OK:
   773                 value = dialog.GetStringSelection()
   773                 value = dialog.GetStringSelection()
   774                 self.SelectedElement.AddOutput()
   774                 self.SelectedElement.AddOutput()
   775                 self.RefreshStepModel(self.SelectedElement)
   775                 self.RefreshStepModel(self.SelectedElement)
   776                 step_connectors = self.SelectedElement.GetConnectors()
   776                 step_connectors = self.SelectedElement.GetConnectors()
   794 
   794 
   795     def EditStepContent(self, step):
   795     def EditStepContent(self, step):
   796         if self.GetDrawingMode() == FREEDRAWING_MODE:
   796         if self.GetDrawingMode() == FREEDRAWING_MODE:
   797             Viewer.EditStepContent(self, step)
   797             Viewer.EditStepContent(self, step)
   798         else:
   798         else:
   799             dialog = SFCStepNameDialog(self.ParentWindow, _("Edit step name"), _("Please enter step name"), step.GetName(), wx.OK|wx.CANCEL)
   799             dialog = SFCStepNameDialog(self.ParentWindow, _("Edit step name"), _("Please enter step name"), step.GetName(), wx.OK | wx.CANCEL)
   800             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   800             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   801             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   801             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
   802             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   802             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   803             if dialog.ShowModal() == wx.ID_OK:
   803             if dialog.ShowModal() == wx.ID_OK:
   804                 value = dialog.GetValue()
   804                 value = dialog.GetValue()