From 8d79228dcedd68572bd4b24e91517595af30c758 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 8 Oct 2017 10:33:45 -0700 Subject: [PATCH] Removed depths lock - obsolete through usage of expressions. --- .../Gui/Resources/panels/PageDepthsEdit.ui | 44 ++++--------------- src/Mod/Path/PathScripts/PathGui.py | 5 +++ src/Mod/Path/PathScripts/PathOp.py | 40 ++++------------- src/Mod/Path/PathScripts/PathOpGui.py | 31 ++++--------- 4 files changed, 29 insertions(+), 91 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui index a2143bac66..e4f34974f1 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui @@ -14,7 +14,7 @@ Form - + <html><head/><body><p>Start Depth of the operation. The highest point in Z-axis the operation needs to process.</p></body></html> @@ -30,7 +30,7 @@ - + <html><head/><body><p>The depth of the operation which corresponds to the lowest value in Z-axis the operation needs to process.</p></body></html> @@ -53,7 +53,7 @@ - + <html><head/><body><p>Depth of the final cut of the operation. Can be used to produce a cleaner finish.</p></body></html> @@ -69,7 +69,7 @@ - + ... @@ -80,7 +80,7 @@ - + ... @@ -98,7 +98,7 @@ - + Qt::Vertical @@ -111,7 +111,7 @@ - + <html><head/><body><p>The depth in Z-axis the operation moves downwards between layers.</p><p><br/></p><p>This value depends on the tool being used, the material to be cut, available cooling and many other factors. Please consult the tool manufacturers data sheets for the proper value.</p></body></html> @@ -141,33 +141,7 @@ - - - - <html><head/><body><p>Lock Start Depth to specified value, prevent automatic recalculation.</p></body></html> - - - - - - false - - - - - - - <html><head/><body><p>Lock Start Depth to specified value, prevent automatic recalculation.</p></body></html> - - - - - - false - - - - + Qt::Horizontal @@ -196,8 +170,6 @@ stepDown startDepthSet finalDepthSet - startDepthLock - finalDepthLock diff --git a/src/Mod/Path/PathScripts/PathGui.py b/src/Mod/Path/PathScripts/PathGui.py index a3cc8ec27c..9d8f262a45 100644 --- a/src/Mod/Path/PathScripts/PathGui.py +++ b/src/Mod/Path/PathScripts/PathGui.py @@ -72,6 +72,11 @@ class QuantitySpinBox: else: self.valid = False + def expression(self): + if self.valid: + return self.widget.property('expression') + return False + def updateSpinBox(self, quantity=None): if self.valid: if quantity is None: diff --git a/src/Mod/Path/PathScripts/PathOp.py b/src/Mod/Path/PathScripts/PathOp.py index 01c6418791..273c89fa8c 100644 --- a/src/Mod/Path/PathScripts/PathOp.py +++ b/src/Mod/Path/PathScripts/PathOp.py @@ -128,12 +128,9 @@ class ObjectOp(object): 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")) - obj.addProperty("App::PropertyBool", "StartDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Start Depth will not be automatically updated when geometry changes")) - obj.addProperty("App::PropertyBool", "FinalDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Final Depth will not be automatically updated when geometry changes")) values = ['start'] if FeatureNoFinalDepth & features: obj.setEditorMode('FinalDepth', 2) # hide - obj.setEditorMode('FinalDepthLock', 2) # hide else: values.append('final') self.addOpValues(obj, values) @@ -168,24 +165,18 @@ class ObjectOp(object): obj.touch() obj.Document.recompute() if FeatureDepths & self.opFeatures(obj): - if not hasattr(obj, 'StartDepthLock'): - obj.addProperty("App::PropertyBool", "StartDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Start Depth will not be automatically updated when geometry changes")) - obj.StartDepthLock = False - if not hasattr(obj, 'FinalDepthLock'): - obj.addProperty("App::PropertyBool", "FinalDepthLock", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "If enabled Final Depth will not be automatically updated when geometry changes")) - obj.FinalDepthLock = False if not hasattr(obj, 'OpStartDepth'): self.addOpValues(obj, ['start', 'final']) - if not obj.StartDepthLock: + if not hasattr(obj, 'StartDepthLock') or not obj.StartDepthLock: obj.setExpression('StartDepth', 'OpStartDepth') - if FeatureNoFinalDepth & features: + if FeatureNoFinalDepth & self.opFeatures(obj): obj.setEditorMode('OpFinalDepth', 2) - elif not obj.FinalDepthLock: + elif not hasattr(obj, 'FinalDepthLock') or not obj.FinalDepthLock: obj.setExpression('FinalDepth', 'OpFinalDepth') - if PatGeom.isRoughly(obj.StepDown.Value, 1): + if PathGeom.isRoughly(obj.StepDown.Value, 1): obj.setExpression('StepDown', 'OpToolDiameter') if FeatureStepDown & self.opFeatures(obj) and not hasattr(obj, 'OpToolDiameter'): - self.addOpValues(['tooldia']) + self.addOpValues(obj, ['tooldia']) def __getstate__(self): '''__getstat__(self) ... called when receiver is saved. @@ -237,7 +228,7 @@ class ObjectOp(object): '''onChanged(obj, prop) ... base implementation of the FC notification framework. Do not overwrite, overwrite opOnChanged() instead.''' - if not 'Restore' in obj.State and prop in ['Base', 'StartDepth', 'StartDepthLock', 'FinalDepth', 'FinalDepthLock']: + if not 'Restore' in obj.State and prop in ['Base', 'StartDepth', 'FinalDepth']: self.updateDepths(obj, True) self.opOnChanged(obj, prop) @@ -258,9 +249,7 @@ class ObjectOp(object): obj.setExpression('StartDepth', 'OpStartDepth') obj.setExpression('FinalDepth', 'OpFinalDepth') obj.OpStartDepth = 1.0 - obj.StartDepthLock = False obj.OpFinalDepth = 0.0 - obj.FinalDepthLock = False if FeatureStepDown & features: obj.OpToolDiameter = 1.0 @@ -331,15 +320,10 @@ class ObjectOp(object): # clearing with stock boundaries pass - safeDepths = True if FeatureDepths & self.opFeatures(obj): # first set update final depth, it's value is not negotiable if not PathGeom.isRoughly(obj.OpFinalDepth.Value, zmin): - if not hasattr(obj, 'FinalDepthLock') or not obj.FinalDepthLock: - obj.OpFinalDepth = zmin - else: - if obj.OpFinalDepth.Value < zmin: - safeDepths = False + obj.OpFinalDepth = zmin zmin = obj.OpFinalDepth.Value def minZmax(z): @@ -354,15 +338,7 @@ class ObjectOp(object): # update start depth if requested and required if not PathGeom.isRoughly(obj.OpStartDepth.Value, zmax): - if not hasattr(obj, 'StartDepthLock') or not obj.StartDepthLock: - obj.OpStartDepth = zmax - elif (obj.OpStartDepth.Value - 0.0001) <= obj.OpFinalDepth.Value: - obj.OpStartDepth = minZmax(obj.OpFinalDepth.Value) - else: - if obj.OpStartDepth.Value < zmax: - safeDepths = False - - return safeDepths + obj.OpStartDepth = zmax @waiting_effects def execute(self, obj): diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index 19e807d86a..ff7c3bbe71 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -569,7 +569,6 @@ class TaskPanelDepthsPage(TaskPanelPage): if PathOp.FeatureNoFinalDepth & self.features: self.form.finalDepth.hide() self.form.finalDepthLabel.hide() - self.form.finalDepthLock.hide() self.form.finalDepthSet.hide() if not PathOp.FeatureStepDown & self.features: @@ -580,27 +579,15 @@ class TaskPanelDepthsPage(TaskPanelPage): self.form.finishDepth.hide() self.form.finishDepthLabel.hide() - self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth', self.lockStartDepth) - self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth', self.lockFinalDepth) + 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") - def lockStartDepth(self, obj): - if not obj.StartDepthLock: - obj.StartDepthLock = True - def lockFinalDepth(self, obj): - if not obj.FinalDepthLock: - obj.FinalDepthLock = True - def getFields(self, obj): - if obj.StartDepthLock != self.form.startDepthLock.isChecked(): - obj.StartDepthLock = self.form.startDepthLock.isChecked() - if obj.FinalDepthLock != self.form.finalDepthLock.isChecked(): - obj.FinalDepthLock = self.form.finalDepthLock.isChecked() - self.startDepth.updateProperty() if not PathOp.FeatureNoFinalDepth & self.features: self.finalDepth.updateProperty() @@ -611,10 +598,8 @@ class TaskPanelDepthsPage(TaskPanelPage): def setFields(self, obj): self.startDepth.updateSpinBox() - self.form.startDepthLock.setChecked(obj.StartDepthLock) if not PathOp.FeatureNoFinalDepth & self.features: self.finalDepth.updateSpinBox() - self.form.finalDepthLock.setChecked(obj.FinalDepthLock) if PathOp.FeatureStepDown & self.features: self.stepDown.updateSpinBox() if PathOp.FeatureFinishDepth & self.features: @@ -624,10 +609,8 @@ class TaskPanelDepthsPage(TaskPanelPage): def getSignalsForUpdate(self, obj): signals = [] signals.append(self.form.startDepth.editingFinished) - signals.append(self.form.startDepthLock.clicked) if not PathOp.FeatureNoFinalDepth & self.features: signals.append(self.form.finalDepth.editingFinished) - signals.append(self.form.finalDepthLock.clicked) if PathOp.FeatureStepDown & self.features: signals.append(self.form.stepDown.editingFinished) if PathOp.FeatureFinishDepth & self.features: @@ -635,18 +618,20 @@ class TaskPanelDepthsPage(TaskPanelPage): return signals def registerSignalHandlers(self, obj): - self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth)) + 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)) + self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth, 'FinaleDepth')) def pageUpdateData(self, obj, prop): - if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth', 'FinalDepthLock', 'StartDepthLock']: + if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth']: self.setFields(obj) - def depthSet(self, obj, spinbox): + def depthSet(self, obj, spinbox, prop): z = self.selectionZLevel(FreeCADGui.Selection.getSelectionEx()) if z is not None: PathLog.debug("depthSet(%.2f)" % z) + if spinbox.expression(): + obj.setExpression(prop, None) spinbox.updateSpinBox(FreeCAD.Units.Quantity(z, FreeCAD.Units.Length)) spinbox.updateProperty() else: