From 8e6f964e0d1fa341b633b8ab2a6fabb694ab7782 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Thu, 31 Dec 2020 18:40:23 -0800 Subject: [PATCH] Renamed ToolTable group to Tools in order to (not) set expectations. --- src/Mod/Path/PathScripts/PathJob.py | 26 +++++++++---------- src/Mod/Path/PathScripts/PathJobCmd.py | 2 +- src/Mod/Path/PathScripts/PathJobDlg.py | 2 +- src/Mod/Path/PathScripts/PathJobGui.py | 8 +++--- src/Mod/Path/PathScripts/PathSanity.py | 2 +- .../Path/PathScripts/PathToolControllerGui.py | 4 +-- src/Mod/Path/PathScripts/PathUtils.py | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index eadf2884cc8b..a6c027b722c7 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -58,7 +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 + # TCs are grouped under Tools in a job, the template refers to them directly though ToolController = 'ToolController' Version = 'Version' @@ -194,16 +194,16 @@ def setupBaseModel(self, obj, models=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 not hasattr(obj, 'Tools'): + obj.addProperty("App::PropertyLink", "Tools", "Base", QtCore.QT_TRANSLATE_NOOP("PathJob", "Collection of all tool controllers for the job")) + toolTable = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup", "Tools") + toolTable.Label = 'Tools' if toolTable.ViewObject: toolTable.ViewObject.Visibility = False if hasattr(obj, 'ToolController'): toolTable.addObjects(obj.ToolController) obj.removeProperty('ToolController') - obj.ToolTable = toolTable + obj.Tools = toolTable def removeBase(self, obj, base, removeFromModel): if isResourceClone(obj, base, None): @@ -248,16 +248,16 @@ def onDelete(self, obj, arg2=None): # Tool controllers might refer to either legacy tool or toolbit PathLog.debug('taking down tool controller') - for tc in obj.ToolTable.Group: + for tc in obj.Tools.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.ToolTable.Group = [] - doc.removeObject(obj.ToolTable.Name) - obj.ToolTable = None + obj.Tools.Group = [] + doc.removeObject(obj.Tools.Name) + obj.Tools = None # SetupSheet PathUtil.clearExpressionEngine(obj.SetupSheet) @@ -351,7 +351,7 @@ def setFromTemplateFile(self, obj, template): obj.Stock = PathStock.CreateFromTemplate(obj, attrs.get(JobTemplate.Stock)) PathLog.debug("setting tool controllers (%d)" % len(tcs)) - obj.ToolTable.Group = tcs + obj.Tools.Group = tcs else: PathLog.error(translate('PathJob', "Unsupported PathJob template version %s") % attrs.get(JobTemplate.Version)) if not tcs: @@ -431,12 +431,12 @@ def addOperation(self, op, before=None, removeBefore=False): op.Path.Center = self.obj.Operations.Path.Center def addToolController(self, tc): - group = self.obj.ToolTable.Group + group = self.obj.Tools.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)) - self.obj.ToolTable.addObject(tc) + self.obj.Tools.addObject(tc) Notification.updateTC.emit(self.obj, tc) def allOperations(self): diff --git a/src/Mod/Path/PathScripts/PathJobCmd.py b/src/Mod/Path/PathScripts/PathJobCmd.py index b452304d791e..a3b26ac12874 100644 --- a/src/Mod/Path/PathScripts/PathJobCmd.py +++ b/src/Mod/Path/PathScripts/PathJobCmd.py @@ -146,7 +146,7 @@ def Execute(cls, job, path, dialog=None): attrs.pop(PathJob.JobTemplate.PostProcessorOutputFile, None) # tool controller settings - toolControllers = dialog.includeToolControllers() if dialog else job.ToolTable.Group + toolControllers = dialog.includeToolControllers() if dialog else job.Tools.Group if toolControllers: tcAttrs = [tc.Proxy.templateAttrs(tc) for tc in toolControllers] attrs[PathJob.JobTemplate.ToolController] = tcAttrs diff --git a/src/Mod/Path/PathScripts/PathJobDlg.py b/src/Mod/Path/PathScripts/PathJobDlg.py index e54a990e8f28..c7e98edda5a8 100644 --- a/src/Mod/Path/PathScripts/PathJobDlg.py +++ b/src/Mod/Path/PathScripts/PathJobDlg.py @@ -338,7 +338,7 @@ def updateUI(self): self.dialog.settingsOpsList.addItem(item) self.dialog.toolsList.clear() - for tc in sorted(job.ToolTable.Group, key=lambda o: o.Label): + for tc in sorted(job.Tools.Group, key=lambda o: o.Label): item = QtGui.QListWidgetItem(tc.Label) item.setData(self.DataObject, tc) item.setCheckState(QtCore.Qt.CheckState.Checked) diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index cbdb125ea7d0..f5d2fa9db279 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -222,8 +222,8 @@ def claimChildren(self): 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) + if hasattr(self.obj, 'Tools'): + children.append(self.obj.Tools) return children def onDelete(self, vobj, arg2=None): @@ -709,7 +709,7 @@ def updateToolController(self): vUnit = FreeCAD.Units.Quantity(1, FreeCAD.Units.Velocity).getUserPreferred()[2] - for row, tc in enumerate(sorted(self.obj.ToolTable.Group, key=lambda tc: tc.Label)): + for row, tc in enumerate(sorted(self.obj.Tools.Group, key=lambda tc: tc.Label)): self.form.activeToolController.addItem(tc.Label, tc) if tc == select: index = row @@ -849,7 +849,7 @@ def canDeleteTC(tc): # 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.ToolTable.Group) == len(self.form.toolControllerList.selectedItems()): + if len(self.obj.Tools.Group) == len(self.form.toolControllerList.selectedItems()): delete = False # ... also don't want to delete any TCs that are already used if delete: diff --git a/src/Mod/Path/PathScripts/PathSanity.py b/src/Mod/Path/PathScripts/PathSanity.py index 120789116823..0d1517e4f79d 100644 --- a/src/Mod/Path/PathScripts/PathSanity.py +++ b/src/Mod/Path/PathScripts/PathSanity.py @@ -517,7 +517,7 @@ def __toolData(self, obj): data = {} try: - for TC in obj.ToolTable.Group: + for TC in obj.Tools.Group: if not hasattr(TC.Tool, 'BitBody'): self.squawk("PathSanity", "Tool number {} is a legacy tool. Legacy tools not \ diff --git a/src/Mod/Path/PathScripts/PathToolControllerGui.py b/src/Mod/Path/PathScripts/PathToolControllerGui.py index 8f72838df959..33e735a08d9c 100644 --- a/src/Mod/Path/PathScripts/PathToolControllerGui.py +++ b/src/Mod/Path/PathScripts/PathToolControllerGui.py @@ -165,12 +165,12 @@ def Activated(self): tool = PathToolBitGui.ToolBitSelector().getTool() if tool: toolNr = None - for tc in job.ToolTable.Group: + for tc in job.Tools.Group: if tc.Tool == tool: toolNr = tc.ToolNumber break if not toolNr: - toolNr = max([tc.ToolNumber for tc in job.ToolTable.Group]) + 1 + toolNr = max([tc.ToolNumber for tc in job.Tools.Group]) + 1 tc = Create("TC: {}".format(tool.Label), tool, toolNr) job.Proxy.addToolController(tc) FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py index 1b8aba0950b7..b27251ce0cc1 100644 --- a/src/Mod/Path/PathScripts/PathUtils.py +++ b/src/Mod/Path/PathScripts/PathUtils.py @@ -403,7 +403,7 @@ def getToolControllers(obj, proxy=None): PathLog.debug("op={} ({})".format(obj.Label, type(obj))) if job: - return [tc for tc in job.ToolTable.Group if proxy.isToolSupported(obj, tc.Tool)] + return [tc for tc in job.Tools.Group if proxy.isToolSupported(obj, tc.Tool)] return []