SFCViewer.py
changeset 409 34c9f624c2fe
parent 391 07447ee3538e
child 563 3f92a5e18804
equal deleted inserted replaced
408:0e389fa5b160 409:34c9f624c2fe
   357 #-------------------------------------------------------------------------------
   357 #-------------------------------------------------------------------------------
   358 #                          Adding element functions
   358 #                          Adding element functions
   359 #-------------------------------------------------------------------------------
   359 #-------------------------------------------------------------------------------
   360 
   360 
   361     def AddInitialStep(self, pos):
   361     def AddInitialStep(self, pos):
   362         dialog = StepNameDialog(self.ParentWindow, _("Please enter step name"), _("Add a new initial step"), "", wx.OK|wx.CANCEL)
   362         dialog = SFCStepNameDialog(self.ParentWindow, _("Please enter step name"), _("Add a new initial step"), "", wx.OK|wx.CANCEL)
   363         dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   363         dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   364         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   364         dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   365         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   365         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   366         if dialog.ShowModal() == wx.ID_OK:
   366         if dialog.ShowModal() == wx.ID_OK:
   367             id = self.GetNewId()
   367             id = self.GetNewId()
   379             self.Refresh(False)
   379             self.Refresh(False)
   380         dialog.Destroy()
   380         dialog.Destroy()
   381 
   381 
   382     def AddStep(self):
   382     def AddStep(self):
   383         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   383         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step):
   384             dialog = StepNameDialog(self.ParentWindow, _("Add a new step"), _("Please enter step name"), "", wx.OK|wx.CANCEL)
   384             dialog = SFCStepNameDialog(self.ParentWindow, _("Add a new step"), _("Please enter step name"), "", wx.OK|wx.CANCEL)
   385             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   385             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   386             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   386             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   387             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   387             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
   388             if dialog.ShowModal() == wx.ID_OK:
   388             if dialog.ShowModal() == wx.ID_OK:
   389                 name = dialog.GetValue()
   389                 name = dialog.GetValue()
   462                     self.Refresh(False)
   462                     self.Refresh(False)
   463                 dialog.Destroy()
   463                 dialog.Destroy()
   464     
   464     
   465     def AddDivergence(self):
   465     def AddDivergence(self):
   466         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step):        
   466         if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step):        
   467             dialog = DivergenceCreateDialog(self.ParentWindow)
   467             dialog = SFCDivergenceDialog(self.ParentWindow)
   468             dialog.SetPreviewFont(self.GetFont())
   468             dialog.SetPreviewFont(self.GetFont())
   469             if dialog.ShowModal() == wx.ID_OK:
   469             if dialog.ShowModal() == wx.ID_OK:
   470                 value = dialog.GetValues()
   470                 value = dialog.GetValues()
   471                 if value["type"] == SELECTION_DIVERGENCE:
   471                 if value["type"] == SELECTION_DIVERGENCE:
   472                     if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Step):
   472                     if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Step):
   721 
   721 
   722     def EditStepContent(self, step):
   722     def EditStepContent(self, step):
   723         if self.GetDrawingMode() == FREEDRAWING_MODE:
   723         if self.GetDrawingMode() == FREEDRAWING_MODE:
   724             Viewer.EditStepContent(self, step)
   724             Viewer.EditStepContent(self, step)
   725         else:
   725         else:
   726             dialog = StepNameDialog(self.ParentWindow, _("Edit step name"), _("Please enter step name"), step.GetName(), wx.OK|wx.CANCEL)
   726             dialog = SFCStepNameDialog(self.ParentWindow, _("Edit step name"), _("Please enter step name"), step.GetName(), wx.OK|wx.CANCEL)
   727             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   727             dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
   728             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   728             dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug))
   729             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   729             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   730             if dialog.ShowModal() == wx.ID_OK:
   730             if dialog.ShowModal() == wx.ID_OK:
   731                 value = dialog.GetValue()
   731                 value = dialog.GetValue()