From 2d3f94590e997bd574da503eefb069bed023c061 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Mon, 5 Nov 2018 21:14:26 -0800 Subject: [PATCH] Support for step down in deburr op. --- src/Mod/Path/PathScripts/PathDeburr.py | 16 +++++- src/Mod/Path/PathScripts/PathOpGui.py | 69 +++++++++++++++++--------- 2 files changed, 60 insertions(+), 25 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDeburr.py b/src/Mod/Path/PathScripts/PathDeburr.py index 6b5382d8c9..aa34cbde4a 100644 --- a/src/Mod/Path/PathScripts/PathDeburr.py +++ b/src/Mod/Path/PathScripts/PathDeburr.py @@ -29,6 +29,7 @@ import PathScripts.PathEngraveBase as PathEngraveBase import PathScripts.PathLog as PathLog import PathScripts.PathOp as PathOp import PathScripts.PathOpTools as PathOpTools +import PathScripts.PathUtil as PathUtil import math from PySide import QtCore @@ -62,7 +63,7 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): '''Proxy class for Deburr operation.''' def opFeatures(self, obj): - return PathOp.FeatureTool | PathOp.FeatureHeights | PathOp.FeatureBaseEdges | PathOp.FeatureBaseFaces + return PathOp.FeatureTool | PathOp.FeatureHeights | PathOp.FeatureStepDown | PathOp.FeatureBaseEdges | PathOp.FeatureBaseFaces def initOperation(self, obj): PathLog.track(obj.Label) @@ -106,8 +107,17 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): if wire: wires.append(wire) + zValues = [] + z = 0 + if obj.StepDown.Value != 0: + while z + obj.StepDown.Value < depth: + z = z + obj.StepDown.Value + zValues.append(z) + zValues.append(depth) + PathLog.track(obj.Label, depth, zValues) + self.wires = wires - self.buildpathocc(obj, wires, [depth], True) + self.buildpathocc(obj, wires, zValues, True) def opRejectAddBase(self, obj, base, sub): '''The chamfer op can only deal with features of the base model, all others are rejected.''' @@ -118,6 +128,8 @@ class ObjectDeburr(PathEngraveBase.ObjectOp): obj.Width = '1 mm' obj.ExtraDepth = '0.1 mm' obj.Join = 'Round' + obj.setExpression('StepDown', '0 mm') + obj.StepDown = '0 mm' def SetupProperties(): setup = [] diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index c5ab50ccd2..c01b1c1820 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -615,23 +615,42 @@ class TaskPanelDepthsPage(TaskPanelPage): def getForm(self): return FreeCADGui.PySideUic.loadUi(":/panels/PageDepthsEdit.ui") + def haveStartDepth(self): + return PathOp.FeatureDepths & self.features + def haveFinalDepth(self): + return PathOp.FeatureDepths & self.features and not PathOp.FeatureNoFinalDepth & self.features + def haveFinishDepth(self): + return PathOp.FeatureDepths & self.features and PathOp.FeatureFinishDepth & self.features + def haveStepDown(self): + return PathOp.FeatureStepDown & self. features + def initPage(self, obj): - self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth') - if PathOp.FeatureNoFinalDepth & self.features: - self.form.finalDepth.setEnabled(False) - self.form.finalDepth.setToolTip(translate('PathOp', 'FinalDepth cannot be modified for this operation.\nIf it is necessary to set the FinalDepth manually please select a different operation.')) - self.form.finalDepthSet.hide() + if self.haveStartDepth(): + self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth') else: - self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth') + self.form.startDepth.hide() + self.form.startDepthLabel.hide() + self.form.startDepthSet.hide() - if PathOp.FeatureStepDown & self.features: + if self.haveFinalDepth(): + self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth') + else: + if self.haveStartDepth(): + self.form.finalDepth.setEnabled(False) + self.form.finalDepth.setToolTip(translate('PathOp', 'FinalDepth cannot be modified for this operation.\nIf it is necessary to set the FinalDepth manually please select a different operation.')) + else: + self.form.finalDepth.hide() + self.form.finalDepthLabel.hide() + self.form.finalDepthSet.hide() + + if self.haveStepDown(): self.stepDown = PathGui.QuantitySpinBox(self.form.stepDown, obj, 'StepDown') else: self.form.stepDown.hide() self.form.stepDownLabel.hide() - if PathOp.FeatureFinishDepth & self.features: + if self.haveFinishDepth(): self.finishDepth = PathGui.QuantitySpinBox(self.form.finishDepth, obj, 'FinishDepth') else: self.form.finishDepth.hide() @@ -641,38 +660,42 @@ class TaskPanelDepthsPage(TaskPanelPage): return translate("PathOp", "Depths") def getFields(self, obj): - self.startDepth.updateProperty() - if not PathOp.FeatureNoFinalDepth & self.features: + if self.haveStartDepth(): + self.startDepth.updateProperty() + if self.haveFinalDepth(): self.finalDepth.updateProperty() - if PathOp.FeatureStepDown & self.features: + if self.haveStepDown(): self.stepDown.updateProperty() - if PathOp.FeatureFinishDepth & self.features: + if self.haveFinishDepth(): self.finishDepth.updateProperty() def setFields(self, obj): - self.startDepth.updateSpinBox() - if not PathOp.FeatureNoFinalDepth & self.features: + if self.haveStartDepth(): + self.startDepth.updateSpinBox() + if self.haveFinalDepth(): self.finalDepth.updateSpinBox() - if PathOp.FeatureStepDown & self.features: + if self.haveStepDown(): self.stepDown.updateSpinBox() - if PathOp.FeatureFinishDepth & self.features: + if self.haveFinishDepth(): self.finishDepth.updateSpinBox() self.updateSelection(obj, FreeCADGui.Selection.getSelectionEx()) def getSignalsForUpdate(self, obj): signals = [] - signals.append(self.form.startDepth.editingFinished) - if not PathOp.FeatureNoFinalDepth & self.features: + if self.haveStartDepth(): + signals.append(self.form.startDepth.editingFinished) + if self.haveFinalDepth(): signals.append(self.form.finalDepth.editingFinished) - if PathOp.FeatureStepDown & self.features: + if self.haveStepDown(): signals.append(self.form.stepDown.editingFinished) - if PathOp.FeatureFinishDepth & self.features: + if self.haveFinishDepth(): signals.append(self.form.finishDepth.editingFinished) return signals def registerSignalHandlers(self, obj): - self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth, 'StartDepth')) - if not PathOp.FeatureNoFinalDepth & self.features: + if self.haveStartDepth(): + self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth, 'StartDepth')) + if self.haveFinalDepth(): self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth, 'FinalDepth')) def pageUpdateData(self, obj, prop): @@ -744,7 +767,7 @@ class TaskPanel(object): else: self.featurePages.append(TaskPanelBaseLocationPage(obj, features)) - if PathOp.FeatureDepths & features: + if PathOp.FeatureDepths & features or PathOp.FeatureStepDown: if hasattr(opPage, 'taskPanelDepthsPage'): self.featurePages.append(opPage.taskPanelDepthsPage(obj, features)) else: