From e4286139dbb6439d3cebe5a0f7ea3a7afb2bc71a Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 12 Mar 2022 20:36:41 -0600 Subject: [PATCH] Path: Extend Job integrity check to GUI side, issue #6207 [Bug] This commit adds a simple `_jobIntegrityCheck()` method to verify that a model and tool exists within the Job object, when interacting with the Task Panel. If either is missing, the appropriate tab is activated in the task window, and the appropriate edit window is opened for the user, with messages printed in the report view window. Add check for existence of `SetupSheet` property of empty Job object. These changes improve upon fixes in PR #5008 and related bug fixes. --- src/Mod/Path/PathScripts/PathJob.py | 21 +++++++++++---------- src/Mod/Path/PathScripts/PathJobGui.py | 13 +++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index 77bdfa3e22..8af6f934df 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -284,7 +284,7 @@ class ObjectJob: # ops = FreeCAD.ActiveDocument.addObject( # "Path::FeatureCompoundPython", "Operations" # ) - ops = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","Operations") + ops = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "Operations") if ops.ViewObject: # ops.ViewObject.Proxy = 0 ops.ViewObject.Visibility = True @@ -295,14 +295,15 @@ class ObjectJob: def setupSetupSheet(self, obj): if not getattr(obj, "SetupSheet", None): - obj.addProperty( - "App::PropertyLink", - "SetupSheet", - "Base", - QT_TRANSLATE_NOOP( - "App::Property", "SetupSheet holding the settings for this job" - ), - ) + if not hasattr(obj, "SetupSheet"): + obj.addProperty( + "App::PropertyLink", + "SetupSheet", + "Base", + QT_TRANSLATE_NOOP( + "App::Property", "SetupSheet holding the settings for this job" + ), + ) obj.SetupSheet = PathSetupSheet.Create() if obj.SetupSheet.ViewObject: import PathScripts.PathIconViewProvider @@ -659,7 +660,7 @@ class ObjectJob: def execute(self, obj): if getattr(obj, "Operations", None): - #obj.Path = obj.Operations.Path + # obj.Path = obj.Operations.Path self.getCycleTime() def getCycleTime(self): diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index 78359a947e..46de1cf3ed 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -694,6 +694,7 @@ class TaskPanel: def accept(self, resetEdit=True): PathLog.track() + self._jobIntegrityCheck() # Check existance of Model and Tools self.preCleanup() self.getFields() self.setupGlobal.accept() @@ -1569,6 +1570,18 @@ class TaskPanel: def open(self): FreeCADGui.Selection.addObserver(self) + def _jobIntegrityCheck(self): + """_jobIntegrityCheck() ... Check Job object for existance of Model and Tools + If either Model or Tools is empty, change GUI tab and open appropriate selection window.""" + if len(self.obj.Model.Group) == 0: + PathLog.info(translate("Path_Job", "Please select a model for this job.")) + self.form.setCurrentIndex(0) # Change tab to General tab + self.jobModelEdit() + if len(self.obj.Tools.Group) == 0: + PathLog.info(translate("Path_Job", "Please add a tool to this job.")) + self.form.setCurrentIndex(3) # Change tab to Tools tab + self.toolControllerAdd() + # SelectionObserver interface def addSelection(self, doc, obj, sub, pnt): self.updateSelection()