Various bug fixes

This commit is contained in:
Markus Lampert
2017-10-08 22:39:02 -07:00
parent 47b1360856
commit cccf014f06
3 changed files with 20 additions and 17 deletions

View File

@@ -53,7 +53,7 @@ def _getProperty(obj, prop):
attr = getattr(o, name)
if o == attr:
PathLog.warning(translate('PathGui', "%s has no property %s (%s))") % (obj.Label, prop))
PathLog.warning(translate('PathGui', "%s has no property %s (%s))") % (obj.Label, prop, name))
return (None, None, None)
#PathLog.debug("found property %s of %s (%s: %s)" % (prop, obj.Label, name, attr))

View File

@@ -124,20 +124,17 @@ class ObjectOp(object):
if FeatureTool & features:
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "The tool controller that will be used to calculate the path"))
self.addOpValues(obj, ['tooldia'])
if FeatureDepths & features:
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Starting Depth of Tool- first cut depth in Z"))
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Final Depth of Tool- lowest value in Z"))
values = ['start']
if FeatureNoFinalDepth & features:
obj.setEditorMode('FinalDepth', 2) # hide
else:
values.append('final')
self.addOpValues(obj, values)
self.addOpValues(obj, ['start', 'final'])
if FeatureStepDown & features:
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Incremental Step Down of Tool"))
self.addOpValues(obj, ['tooldia'])
if FeatureFinishDepth & features:
obj.addProperty("App::PropertyDistance", "FinishDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Maximum material removed on final pass."))
@@ -164,6 +161,10 @@ class ObjectOp(object):
obj.Base = base
obj.touch()
obj.Document.recompute()
if FeatureTool & self.opFeatures(obj) and not hasattr(obj, 'OpToolDiameter'):
self.addOpValues(obj, ['tooldia'])
if FeatureDepths & self.opFeatures(obj):
if not hasattr(obj, 'OpStartDepth'):
self.addOpValues(obj, ['start', 'final'])
@@ -175,8 +176,6 @@ class ObjectOp(object):
obj.setExpression('FinalDepth', 'OpFinalDepth')
if PathGeom.isRoughly(obj.StepDown.Value, 1):
obj.setExpression('StepDown', 'OpToolDiameter')
if FeatureStepDown & self.opFeatures(obj) and not hasattr(obj, 'OpToolDiameter'):
self.addOpValues(obj, ['tooldia'])
def __getstate__(self):
'''__getstat__(self) ... called when receiver is saved.
@@ -244,6 +243,7 @@ class ObjectOp(object):
if FeatureTool & features:
obj.ToolController = PathUtils.findToolController(obj)
obj.OpToolDiameter = 1.0
if FeatureDepths & features:
obj.setExpression('StartDepth', 'OpStartDepth')
@@ -252,7 +252,6 @@ class ObjectOp(object):
obj.OpFinalDepth = 0.0
if FeatureStepDown & features:
obj.OpToolDiameter = 1.0
obj.setExpression('StepDown', 'OpToolDiameter')
if FeatureHeights & features:

View File

@@ -566,23 +566,27 @@ class TaskPanelDepthsPage(TaskPanelPage):
return FreeCADGui.PySideUic.loadUi(":/panels/PageDepthsEdit.ui")
def initPage(self, obj):
self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth')
if PathOp.FeatureNoFinalDepth & self.features:
self.form.finalDepth.hide()
self.form.finalDepthLabel.hide()
self.form.finalDepthSet.hide()
else:
self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth')
if not PathOp.FeatureStepDown & self.features:
if PathOp.FeatureStepDown & self.features:
self.stepDown = PathGui.QuantitySpinBox(self.form.stepDown, obj, 'StepDown')
else:
self.form.stepDown.hide()
self.form.stepDownLabel.hide()
if not PathOp.FeatureFinishDepth & self.features:
if PathOp.FeatureFinishDepth & self.features:
self.finishDepth = PathGui.QuantitySpinBox(self.form.finishDepth, obj, 'FinishDepth')
else:
self.form.finishDepth.hide()
self.form.finishDepthLabel.hide()
self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth')
self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth')
self.finishDepth = PathGui.QuantitySpinBox(self.form.finishDepth, obj, 'FinishDepth')
self.stepDown = PathGui.QuantitySpinBox(self.form.stepDown, obj, 'StepDown')
def getTitle(self, obj):
return translate("PathOp", "Depths")
@@ -620,7 +624,7 @@ class TaskPanelDepthsPage(TaskPanelPage):
def registerSignalHandlers(self, obj):
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth, 'StartDepth'))
if not PathOp.FeatureNoFinalDepth & self.features:
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth, 'FinaleDepth'))
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth, 'FinalDepth'))
def pageUpdateData(self, obj, prop):
if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth']:
@@ -629,7 +633,7 @@ class TaskPanelDepthsPage(TaskPanelPage):
def depthSet(self, obj, spinbox, prop):
z = self.selectionZLevel(FreeCADGui.Selection.getSelectionEx())
if z is not None:
PathLog.debug("depthSet(%.2f)" % z)
PathLog.debug("depthSet(%s, %s, %.2f)" % (obj.Label, prop, z))
if spinbox.expression():
obj.setExpression(prop, None)
spinbox.updateSpinBox(FreeCAD.Units.Quantity(z, FreeCAD.Units.Length))