SFCViewer.py
changeset 71 0578bc212c20
parent 67 3a1b0afdaf84
child 80 c798a68c5560
equal deleted inserted replaced
70:0e48629c1e6d 71:0578bc212c20
   283         event.Skip()
   283         event.Skip()
   284     
   284     
   285     def OnViewerMotion(self, event):
   285     def OnViewerMotion(self, event):
   286         if self.GetDrawingMode() == FREEDRAWING_MODE:
   286         if self.GetDrawingMode() == FREEDRAWING_MODE:
   287             Viewer.OnViewerMotion(self, event)
   287             Viewer.OnViewerMotion(self, event)
   288         elif self.rubberBand.IsShown():
   288         else:
   289             self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling)
   289             if self.rubberBand.IsShown():
   290         elif self.Mode == MODE_SELECTION and self.SelectedElement:
   290                 self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling)
   291             if not self.IsWire(self.SelectedElement):
   291             elif self.Mode == MODE_SELECTION and self.SelectedElement:
       
   292                 if not self.IsWire(self.SelectedElement) and not isinstance(self.SelectedElement, Graphic_Group):
       
   293                     self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
       
   294                 self.Refresh()
       
   295             elif self.Mode == MODE_WIRE and self.SelectedElement:
       
   296                 self.SelectedElement.ResetPoints()
   292                 self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
   297                 self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
   293             self.Refresh()
   298                 self.SelectedElement.GeneratePoints()
   294         elif self.Mode == MODE_WIRE and self.SelectedElement:
   299                 self.Refresh()
   295             self.SelectedElement.ResetPoints()
   300             self.UpdateScrollPos(event)
   296             self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
       
   297             self.SelectedElement.GeneratePoints()
       
   298             self.Refresh()
       
   299         Viewer.OnViewerMotion(self, event)
       
   300         event.Skip()
   301         event.Skip()
   301 
   302 
   302 #-------------------------------------------------------------------------------
   303 #-------------------------------------------------------------------------------
   303 #                          Keyboard event functions
   304 #                          Keyboard event functions
   304 #-------------------------------------------------------------------------------
   305 #-------------------------------------------------------------------------------
   715                 self.RefreshScrollBars()
   716                 self.RefreshScrollBars()
   716                 self.Refresh()
   717                 self.Refresh()
   717             dialog.Destroy()
   718             dialog.Destroy()
   718 
   719 
   719     def EditStepContent(self, step):
   720     def EditStepContent(self, step):
   720         dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
   721         if self.GetDrawingMode() == FREEDRAWING_MODE:
   721         dialog.SetPouNames(self.Controler.GetProjectPouNames())
   722             Viewer.EditStepContent(self, step)
   722         dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   723         else:
   723         dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   724             dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wx.OK|wx.CANCEL)
   724         if dialog.ShowModal() == wx.ID_OK:
   725             dialog.SetPouNames(self.Controler.GetProjectPouNames())
   725             value = dialog.GetValue()
   726             dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
   726             step.SetName(value)
   727             dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
   727             min_size = step.GetMinSize()
   728             if dialog.ShowModal() == wx.ID_OK:
   728             size = step.GetSize()
   729                 value = dialog.GetValue()
   729             step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1]))
   730                 step.SetName(value)
   730             step.RefreshModel()
   731                 min_size = step.GetMinSize()
   731             self.RefreshBuffer()
   732                 size = step.GetSize()
   732             self.RefreshScrollBars()
   733                 step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1]))
   733             self.Refresh()
   734                 step.RefreshModel()
   734         dialog.Destroy()
   735                 self.RefreshBuffer()
       
   736                 self.RefreshScrollBars()
       
   737                 self.Refresh()
       
   738             dialog.Destroy()
   735 
   739 
   736 #-------------------------------------------------------------------------------
   740 #-------------------------------------------------------------------------------
   737 #                          Delete element functions
   741 #                          Delete element functions
   738 #-------------------------------------------------------------------------------
   742 #-------------------------------------------------------------------------------
   739 
   743