From 53404b32078595f2247bb8434286804c69a348aa Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sat, 25 Aug 2018 19:35:17 -0700 Subject: [PATCH] Operation settings support for Drilling. --- src/Mod/Path/PathScripts/PathDrilling.py | 16 ++++++++++++-- src/Mod/Path/PathScripts/PathDrillingGui.py | 3 ++- .../PathScripts/PathSetupSheetOpPrototype.py | 21 ++++++++++++++----- .../PathSetupSheetOpPrototypeGui.py | 5 +++-- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 45e82a1ba6..8502ae8b9b 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -120,9 +120,21 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): '''opSetDefaultValues(obj, job) ... set default value for RetractHeight''' obj.RetractHeight = 10 -def Create(name): +def SetupProperties(): + setup = [] + setup.append("PeckDepth") + setup.append("PeckEnabled") + setup.append("DwellTime") + setup.append("DwellEnabled") + setup.append("AddTipLength") + setup.append("ReturnLevel") + setup.append("RetractHeight") + return setup + +def Create(name, obj = None): '''Create(name) ... Creates and returns a Drilling operation.''' - obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name) + if obj is None: + obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name) proxy = ObjectDrilling(obj, name) if obj.Proxy: proxy.findAllHoles(obj) diff --git a/src/Mod/Path/PathScripts/PathDrillingGui.py b/src/Mod/Path/PathScripts/PathDrillingGui.py index 19bfdf4aff..74446595f3 100644 --- a/src/Mod/Path/PathScripts/PathDrillingGui.py +++ b/src/Mod/Path/PathScripts/PathDrillingGui.py @@ -111,6 +111,7 @@ Command = PathOpGui.SetupOperation('Drilling', TaskPanelOpPage, 'Path-Drilling', QtCore.QT_TRANSLATE_NOOP("PathDrilling", "Drilling"), - QtCore.QT_TRANSLATE_NOOP("PathDrilling", "Creates a Path Drilling object from a features of a base object")) + QtCore.QT_TRANSLATE_NOOP("PathDrilling", "Creates a Path Drilling object from a features of a base object"), + PathDrilling.SetupProperties) FreeCAD.Console.PrintLog("Loading PathDrillingGui... done\n") diff --git a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py index b121edd520..77255718ec 100644 --- a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py +++ b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototype.py @@ -100,15 +100,20 @@ class PropertyEnumeration(Property): def initProperty(self, obj, name): setattr(obj, name, self.enums) -class PropertyDistance(Property): - def typeString(self): - return "Distance" - +class PropertyQuantity(Property): def displayString(self): if self.value is None: return Property.displayString(self) return self.value.getUserPreferred()[0] +class PropertyDistance(PropertyQuantity): + def typeString(self): + return "Distance" + +class PropertyLength(PropertyQuantity): + def typeString(self): + return "Length" + class PropertyPercent(Property): def typeString(self): return "Percent" @@ -132,11 +137,14 @@ class OpPrototype(object): 'App::PropertyDistance': PropertyDistance, 'App::PropertyEnumeration': PropertyEnumeration, 'App::PropertyFloat': PropertyFloat, + 'App::PropertyLength': PropertyLength, 'App::PropertyLink': Property, 'App::PropertyLinkSubListGlobal': Property, 'App::PropertyPercent': PropertyPercent, 'App::PropertyString': PropertyString, + 'App::PropertyStringList': Property, 'App::PropertyVectorDistance': Property, + 'App::PropertyVectorList': Property, 'Part::PropertyPartShape': Property, } @@ -144,9 +152,12 @@ class OpPrototype(object): self.name = name self.properties = {} self.DoNotSetDefaultValues = True + self.Proxy = None def __setattr__(self, name, val): - if name in ['name', 'properties', 'DoNotSetDefaultValues']: + if name in ['name', 'DoNotSetDefaultValues', 'properties', 'Proxy']: + if name == 'Proxy': + val = None # make sure the proxy is never set return super(self.__class__, self).__setattr__(name, val) self.properties[name].setValue(val) diff --git a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py index 10004ad376..28ffb26ff4 100644 --- a/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py +++ b/src/Mod/Path/PathScripts/PathSetupSheetOpPrototypeGui.py @@ -96,7 +96,7 @@ class _PropertyStringEditor(_PropertyEditor): def setModelData(self, widget): self.prop.setValue(widget.text()) -class _PropertyDistanceEditor(_PropertyEditor): +class _PropertyLengthEditor(_PropertyEditor): def widget(self, parent): return QtGui.QLineEdit(parent) @@ -140,9 +140,10 @@ class _PropertyFloatEditor(_PropertyEditor): _EditorFactory = { PathSetupSheetOpPrototype.Property: None, PathSetupSheetOpPrototype.PropertyBool: _PropertyBoolEditor, - PathSetupSheetOpPrototype.PropertyDistance: _PropertyDistanceEditor, + PathSetupSheetOpPrototype.PropertyDistance: _PropertyLengthEditor, PathSetupSheetOpPrototype.PropertyEnumeration: _PropertyEnumEditor, PathSetupSheetOpPrototype.PropertyFloat: _PropertyFloatEditor, + PathSetupSheetOpPrototype.PropertyLength: _PropertyLengthEditor, PathSetupSheetOpPrototype.PropertyPercent: _PropertyPercentEditor, PathSetupSheetOpPrototype.PropertyString: _PropertyStringEditor, }