Merge pull request #6575 from Russ4262/fix/rebuild_empty_job_with_gui

Path: Extend Job integrity check to GUI side, issue #6207 [Bug]
This commit is contained in:
sliptonic
2022-03-19 15:44:28 -05:00
committed by GitHub
2 changed files with 44 additions and 8 deletions

View File

@@ -296,14 +296,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

View File

@@ -694,6 +694,7 @@ class TaskPanel:
def accept(self, resetEdit=True):
PathLog.track()
self._jobIntegrityCheck() # Check existence of Model and Tools
self.preCleanup()
self.getFields()
self.setupGlobal.accept()
@@ -1569,6 +1570,40 @@ class TaskPanel:
def open(self):
FreeCADGui.Selection.addObserver(self)
def _jobIntegrityCheck(self):
"""_jobIntegrityCheck() ... Check Job object for existence of Model and Tools
If either Model or Tools is empty, change GUI tab, issue appropriate warning,
and offer chance to add appropriate item."""
def _displayWarningWindow(msg):
"""Display window with warning message and Add action button.
Return action state."""
txtHeader = translate("Path_Job", "Warning")
txtPleaseAddOne = translate("Path_Job", "Please add one.")
txtOk = translate("Path_Job", "Ok")
txtAdd = translate("Path_Job", "Add")
msgbox = QtGui.QMessageBox(
QtGui.QMessageBox.Warning, txtHeader, msg + " " + txtPleaseAddOne
)
msgbox.addButton(txtOk, QtGui.QMessageBox.AcceptRole) # Add 'Ok' button
msgbox.addButton(txtAdd, QtGui.QMessageBox.ActionRole) # Add 'Add' button
return msgbox.exec_()
# Check if at least on base model is present
if len(self.obj.Model.Group) == 0:
self.form.setCurrentIndex(0) # Change tab to General tab
no_model_txt = translate("Path_Job", "This job has no base model.")
if _displayWarningWindow(no_model_txt) == 1:
self.jobModelEdit()
# Check if at least one tool is present
if len(self.obj.Tools.Group) == 0:
self.form.setCurrentIndex(3) # Change tab to Tools tab
no_tool_txt = translate("Path_Job", "This job has no tool.")
if _displayWarningWindow(no_tool_txt) == 1:
self.toolControllerAdd()
# SelectionObserver interface
def addSelection(self, doc, obj, sub, pnt):
self.updateSelection()