Added ToolTable to job and convert old ToolController property on the fly.
This commit is contained in:
@@ -58,6 +58,7 @@ class JobTemplate:
|
||||
PostProcessorOutputFile = 'Output'
|
||||
SetupSheet = 'SetupSheet'
|
||||
Stock = 'Stock'
|
||||
# TCs are grouped under ToolTable in a job, the template refers to them directly though
|
||||
ToolController = 'ToolController'
|
||||
Version = 'Version'
|
||||
|
||||
@@ -120,7 +121,7 @@ class ObjectJob:
|
||||
|
||||
obj.addProperty("App::PropertyLink", "Stock", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Solid object to be used as stock."))
|
||||
obj.addProperty("App::PropertyLink", "Operations", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Compound path of all operations in the order they are processed."))
|
||||
obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job."))
|
||||
#obj.addProperty("App::PropertyLinkList", "ToolController", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of tool controllers available for this job."))
|
||||
|
||||
obj.addProperty("App::PropertyBool", "SplitOutput", "Output", QtCore.QT_TRANSLATE_NOOP("PathJob", "Split output into multiple gcode files"))
|
||||
obj.addProperty("App::PropertyEnumeration", "OrderOutputBy", "WCS", QtCore.QT_TRANSLATE_NOOP("PathJob", "If multiple WCS, order the output this way"))
|
||||
@@ -150,6 +151,7 @@ class ObjectJob:
|
||||
|
||||
self.setupSetupSheet(obj)
|
||||
self.setupBaseModel(obj, models)
|
||||
self.setupToolTable(obj)
|
||||
|
||||
self.tooltip = None
|
||||
self.tooltipArgs = None
|
||||
@@ -191,6 +193,18 @@ class ObjectJob:
|
||||
obj.Base = None
|
||||
obj.removeProperty('Base')
|
||||
|
||||
def setupToolTable(self, obj):
|
||||
if not hasattr(obj, 'ToolTable'):
|
||||
obj.addProperty("App::PropertyLink", "ToolTable", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of all tool controllers for the job"))
|
||||
toolTable = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "ToolTable")
|
||||
toolTable.Label = 'ToolTable'
|
||||
if toolTable.ViewObject:
|
||||
toolTable.ViewObject.Visibility = False
|
||||
if hasattr(obj, 'ToolController'):
|
||||
toolTable.addObjects(obj.ToolController)
|
||||
obj.removeProperty('ToolController')
|
||||
obj.ToolTable = toolTable
|
||||
|
||||
def removeBase(self, obj, base, removeFromModel):
|
||||
if isResourceClone(obj, base, None):
|
||||
PathUtil.clearExpressionEngine(base)
|
||||
@@ -234,14 +248,16 @@ class ObjectJob:
|
||||
|
||||
# Tool controllers might refer to either legacy tool or toolbit
|
||||
PathLog.debug('taking down tool controller')
|
||||
for tc in obj.ToolController:
|
||||
for tc in obj.ToolTable.Group:
|
||||
if hasattr(tc.Tool, "Proxy"):
|
||||
PathUtil.clearExpressionEngine(tc.Tool)
|
||||
doc.removeObject(tc.Tool.Name)
|
||||
PathUtil.clearExpressionEngine(tc)
|
||||
tc.Proxy.onDelete(tc)
|
||||
doc.removeObject(tc.Name)
|
||||
obj.ToolController = []
|
||||
obj.ToolTable = []
|
||||
doc.removeObject(obj.ToolTable.Name)
|
||||
obj.ToolTable = None
|
||||
|
||||
# SetupSheet
|
||||
PathUtil.clearExpressionEngine(obj.SetupSheet)
|
||||
@@ -268,6 +284,7 @@ class ObjectJob:
|
||||
self.setupBaseModel(obj)
|
||||
self.fixupOperations(obj)
|
||||
self.setupSetupSheet(obj)
|
||||
self.setupToolTable(obj)
|
||||
|
||||
obj.setEditorMode('Operations', 2) # hide
|
||||
obj.setEditorMode('Placement', 2)
|
||||
@@ -334,7 +351,7 @@ class ObjectJob:
|
||||
obj.Stock = PathStock.CreateFromTemplate(obj, attrs.get(JobTemplate.Stock))
|
||||
|
||||
PathLog.debug("setting tool controllers (%d)" % len(tcs))
|
||||
obj.ToolController = tcs
|
||||
obj.ToolTable.Group = tcs
|
||||
else:
|
||||
PathLog.error(translate('PathJob', "Unsupported PathJob template version %s") % attrs.get(JobTemplate.Version))
|
||||
if not tcs:
|
||||
@@ -414,13 +431,12 @@ class ObjectJob:
|
||||
op.Path.Center = self.obj.Operations.Path.Center
|
||||
|
||||
def addToolController(self, tc):
|
||||
group = self.obj.ToolController
|
||||
group = self.obj.ToolTable.Group
|
||||
PathLog.debug("addToolController(%s): %s" % (tc.Label, [t.Label for t in group]))
|
||||
if tc.Name not in [str(t.Name) for t in group]:
|
||||
tc.setExpression('VertRapid', "%s.%s" % (self.setupSheet.expressionReference(), PathSetupSheet.Template.VertRapid))
|
||||
tc.setExpression('HorizRapid', "%s.%s" % (self.setupSheet.expressionReference(), PathSetupSheet.Template.HorizRapid))
|
||||
group.append(tc)
|
||||
self.obj.ToolController = group
|
||||
self.obj.ToolTable.addObject(tc)
|
||||
Notification.updateTC.emit(self.obj, tc)
|
||||
|
||||
def allOperations(self):
|
||||
|
||||
@@ -210,7 +210,7 @@ class ViewProvider:
|
||||
return ":/icons/Path_Job.svg"
|
||||
|
||||
def claimChildren(self):
|
||||
children = self.obj.ToolController
|
||||
children = []
|
||||
children.append(self.obj.Operations)
|
||||
if hasattr(self.obj, 'Model'):
|
||||
# unfortunately this function is called before the object has been fully loaded
|
||||
@@ -222,6 +222,8 @@ class ViewProvider:
|
||||
if hasattr(self.obj, 'SetupSheet'):
|
||||
# when loading a job that didn't have a setup sheet they might not've been created yet
|
||||
children.append(self.obj.SetupSheet)
|
||||
if hasattr(self.obj, 'ToolTable'):
|
||||
children.append(self.obj.ToolTable)
|
||||
return children
|
||||
|
||||
def onDelete(self, vobj, arg2=None):
|
||||
@@ -707,7 +709,7 @@ class TaskPanel:
|
||||
|
||||
vUnit = FreeCAD.Units.Quantity(1, FreeCAD.Units.Velocity).getUserPreferred()[2]
|
||||
|
||||
for row, tc in enumerate(sorted(self.obj.ToolController, key=lambda tc: tc.Label)):
|
||||
for row, tc in enumerate(sorted(self.obj.ToolTable.Group, key=lambda tc: tc.Label)):
|
||||
self.form.activeToolController.addItem(tc.Label, tc)
|
||||
if tc == select:
|
||||
index = row
|
||||
@@ -847,7 +849,7 @@ class TaskPanel:
|
||||
# can only delete what is selected
|
||||
delete = edit
|
||||
# ... but we want to make sure there's at least one TC left
|
||||
if len(self.obj.ToolController) == len(self.form.toolControllerList.selectedItems()):
|
||||
if len(self.obj.ToolTable.Group) == len(self.form.toolControllerList.selectedItems()):
|
||||
delete = False
|
||||
# ... also don't want to delete any TCs that are already used
|
||||
if delete:
|
||||
|
||||
Reference in New Issue
Block a user