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.
This commit is contained in:
Russell Johnson
2022-03-12 20:36:41 -06:00
parent aa4ba37a6c
commit e4286139db
2 changed files with 24 additions and 10 deletions

View File

@@ -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):

View File

@@ -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()