From 1d8c2eef2492a95539bd0f4ce919e449dc0c4686 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 27 Aug 2017 23:08:50 -0700 Subject: [PATCH] Create clone for stock and go to some lengths to enforce that. --- src/Mod/Path/Gui/Resources/panels/PathEdit.ui | 125 +++++++++--------- src/Mod/Path/PathScripts/PathJob.py | 35 +++++ src/Mod/Path/PathScripts/PathJobGui.py | 4 + 3 files changed, 105 insertions(+), 59 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/PathEdit.ui b/src/Mod/Path/Gui/Resources/panels/PathEdit.ui index 803ae15cb6..df6fc1c813 100644 --- a/src/Mod/Path/Gui/Resources/panels/PathEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PathEdit.ui @@ -86,8 +86,8 @@ 0 0 - 294 - 309 + 378 + 477 @@ -218,15 +218,15 @@ true - 1 + 0 0 0 - 368 - 399 + 378 + 403 @@ -234,7 +234,7 @@ - + Stock @@ -404,10 +404,18 @@ - + + + <html><head/><body><p>Enter a path and optionally file name (see below) to be used as the default for the post processor export.</p><p>The following substitutions are performed before the name is resolved at the time of the post processing:</p><p>%D ... directory of the active document<br/>%d ... name of the active document (with extension)<br/>%M ... user macro directory<br/>%j ... name of the active Job object</p><p>The following example store all files with the same name as the document the directory /home/freecad (please remove quotes):</p><p>&quot;/home/cnc/%d.g-code&quot;</p><p>See the file save policy below on how to deal with name conflicts.</p></body></html> + + - + + + <html><head/><body><p>Optional arguments passed to the Post Processor. The arguments are specific for each Post Processor, please see it's documentation for details.</p></body></html> + + @@ -535,7 +543,9 @@ Feed - + + + @@ -543,7 +553,9 @@ Feed - + + + @@ -600,7 +612,7 @@ - 0 + 1 @@ -685,49 +697,6 @@ Default Values - - - - Operation - - - true - - - false - - - - - - Milling - - - - - - - - conventional - - - - - climb - - - - - - - - Tool Compensated - - - - - - @@ -821,11 +790,49 @@ - label_15 - label_3 - lineEdit - lineEdit_2 - label_4 + + + + + + Operation + + + true + + + false + + + + + + Milling + + + + + + + + conventional + + + + + climb + + + + + + + + Tool Compensated + + + + diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index eeb9ef7a2a..1c8e4f2612 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -23,6 +23,7 @@ # *************************************************************************** import ArchPanel +import Draft import FreeCAD import PathScripts.PathLog as PathLog import PathScripts.PathToolController as PathToolController @@ -104,12 +105,46 @@ class ObjectJob: FreeCAD.ActiveDocument.removeObject(obj.Operations.Name) obj.Operations = None + def isResourceClone(self, obj, propName, resourceName): + if hasattr(obj, propName): + prop = getattr(obj, propName) + if hasattr(prop, 'PathResource') and resourceName == getattr(prop, 'PathResource'): + return True + return False + + def fixupResourceClone(self, obj, name): + if not self.isResourceClone(obj, name, name): + orig = getattr(obj, name) + if orig: + clone = Draft.clone(orig) + clone.Label = name + clone.addProperty('App::PropertyString', 'PathResource') + clone.PathResource = name + setattr(obj, name, clone) + + def onBeforeChange(self, obj, prop): + PathLog.track(obj.Label, prop) + if prop == 'Base' and obj.Base and hasattr(obj.Base, 'PathResource'): + PathLog.info('removing old base clone') + obj.Base.removeProperty('PathResource') + obj.Document.removeObject(obj.Base.Name) + def onChanged(self, obj, prop): + PathLog.track(obj.Label, prop) if prop == "PostProcessor" and obj.PostProcessor: processor = PostProcessor.load(obj.PostProcessor) self.tooltip = processor.tooltip self.tooltipArgs = processor.tooltipArgs + if prop == 'Base': + self.fixupResourceClone(obj, 'Base') + if prop == 'Stock': + self.fixupResourceClone(obj, 'Stock') + + def onDocumentRestored(self, obj): + self.fixupResourceClone(obj, 'Base') + self.fixupResourceClone(obj, 'Stock') + def assignTemplate(self, obj, template): '''assignTemplate(obj, template) ... extract the properties from the given template file and assign to receiver. This will also create any TCs stored in the template.''' diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index 0d915eb235..c86f1a7076 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -83,6 +83,10 @@ class ViewProvider: def claimChildren(self): children = self.obj.ToolController children.append(self.obj.Operations) + if self.obj.Base: + children.append(self.obj.Base) + if self.obj.Stock: + children.append(self.obj.Stock) return children class TaskPanel: