Operation settings support for Drilling.

This commit is contained in:
Markus Lampert
2018-08-25 19:35:17 -07:00
parent f4124b91bc
commit ea84b18aee
4 changed files with 35 additions and 10 deletions

View File

@@ -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)

View File

@@ -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")

View File

@@ -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)

View File

@@ -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,
}