Support for step down in deburr op.

This commit is contained in:
Markus Lampert
2018-11-05 21:14:26 -08:00
committed by Yorik van Havre
parent 64addcabd9
commit 2d3f94590e
2 changed files with 60 additions and 25 deletions

View File

@@ -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 = []

View File

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