Fixed pocket final depth calculation and hide it from user modifications.
This commit is contained in:
@@ -51,6 +51,7 @@ FeatureHeights = 0x0004 # ClearanceHeight, SafeHeight
|
||||
FeatureStartPoint = 0x0008 # StartPoint
|
||||
FeatureFinishDepth = 0x0010 # FinishDepth
|
||||
FeatureStepDown = 0x0020 # StepDown
|
||||
FeatureNoFinalDepth = 0x0040 # edit or not edit FinalDepth
|
||||
FeatureBaseVertexes = 0x0100 # Base
|
||||
FeatureBaseEdges = 0x0200 # Base
|
||||
FeatureBaseFaces = 0x0400 # Base
|
||||
@@ -75,6 +76,7 @@ class ObjectOp(object):
|
||||
FeatureStartPoint ... Supports setting a start point
|
||||
FeatureFinishDepth ... Operation supports a finish depth
|
||||
FeatureStepDown ... Support for step down
|
||||
FeatureNoFinalDepth ... Disable support for final depth modifications
|
||||
FeatureBaseVertexes ... Base geometry support for vertexes
|
||||
FeatureBaseEdges ... Base geometry support for edges
|
||||
FeatureBaseFaces ... Base geometry support for faces
|
||||
@@ -113,6 +115,8 @@ class ObjectOp(object):
|
||||
if FeatureDepths & features:
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
if FeatureNoFinalDepth & features:
|
||||
obj.setEditorMode('FinalDepth', 2) # hide
|
||||
|
||||
if FeatureStepDown & features:
|
||||
obj.addProperty("App::PropertyDistance", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
|
||||
@@ -544,6 +544,11 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
def getForm(self):
|
||||
return FreeCADGui.PySideUic.loadUi(":/panels/PageDepthsEdit.ui")
|
||||
def initPage(self, obj):
|
||||
if PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.form.finalDepth.hide()
|
||||
self.form.finalDepthLabel.hide()
|
||||
self.form.finalDepthSet.hide()
|
||||
|
||||
if not PathOp.FeatureStepDown & self.features:
|
||||
self.form.stepDown.hide()
|
||||
self.form.stepDownLabel.hide()
|
||||
@@ -555,14 +560,16 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
return translate("PathOp", "Depths")
|
||||
def getFields(self, obj):
|
||||
self.updateInputField(obj, 'StartDepth', self.form.startDepth)
|
||||
self.updateInputField(obj, 'FinalDepth', self.form.finalDepth)
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.updateInputField(obj, 'FinalDepth', self.form.finalDepth)
|
||||
if PathOp.FeatureStepDown & self.features:
|
||||
self.updateInputField(obj, 'StepDown', self.form.stepDown)
|
||||
if PathOp.FeatureFinishDepth & self.features:
|
||||
self.updateInputField(obj, 'FinishDepth', self.form.finishDepth)
|
||||
def setFields(self, obj):
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
if PathOp.FeatureStepDown & self.features:
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
if PathOp.FeatureFinishDepth & self.features:
|
||||
@@ -571,7 +578,8 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
def getSignalsForUpdate(self, obj):
|
||||
signals = []
|
||||
signals.append(self.form.startDepth.editingFinished)
|
||||
signals.append(self.form.finalDepth.editingFinished)
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
signals.append(self.form.finalDepth.editingFinished)
|
||||
if PathOp.FeatureStepDown & self.features:
|
||||
signals.append(self.form.stepDown.editingFinished)
|
||||
if PathOp.FeatureFinishDepth & self.features:
|
||||
@@ -579,7 +587,8 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
return signals
|
||||
def registerSignalHandlers(self, obj):
|
||||
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.form.startDepth))
|
||||
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.form.finalDepth))
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.form.finalDepth))
|
||||
def pageUpdateData(self, obj, prop):
|
||||
if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth']:
|
||||
self.setFields(obj)
|
||||
@@ -592,6 +601,7 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
self.getFields(obj)
|
||||
else:
|
||||
PathLog.info("depthSet(-)")
|
||||
|
||||
def selectionZLevel(self, sel):
|
||||
if len(sel) == 1 and len(sel[0].SubObjects) == 1:
|
||||
sub = sel[0].SubObjects[0]
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
import FreeCAD
|
||||
import Part
|
||||
import PathScripts.PathLog as PathLog
|
||||
import PathScripts.PathOp as PathOp
|
||||
import PathScripts.PathPocketBase as PathPocketBase
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import sys
|
||||
|
||||
from PathScripts.PathGeom import PathGeom
|
||||
from PySide import QtCore
|
||||
|
||||
__doc__ = "Class and implementation of the Pocket operation."
|
||||
@@ -46,6 +49,9 @@ def translate(context, text, disambig=None):
|
||||
class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
'''Proxy object for Pocket operation.'''
|
||||
|
||||
def pocketOpFeatures(self, obj):
|
||||
return PathOp.FeatureNoFinalDepth
|
||||
|
||||
def initPocketOp(self, obj):
|
||||
'''initPocketOp(obj) ... setup receiver'''
|
||||
pass
|
||||
@@ -71,12 +77,14 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=shape, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
obj.removalshape.tessellate(0.1)
|
||||
removalshapes.append((obj.removalshape, False))
|
||||
else: # process the job base object as a whole
|
||||
PathLog.debug("processing the whole job base object")
|
||||
|
||||
env = PathUtils.getEnvelope(self.baseobject.Shape, subshape=None, depthparams=self.depthparams)
|
||||
obj.removalshape = env.cut(self.baseobject.Shape)
|
||||
obj.removalshape.tessellate(0.1)
|
||||
removalshapes = [(obj.removalshape, False)]
|
||||
return removalshapes
|
||||
|
||||
@@ -85,6 +93,46 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
obj.StepOver = 100
|
||||
obj.ZigZagAngle = 45
|
||||
|
||||
def areaOpOnChanged(self, obj, prop):
|
||||
if 'Base' == prop and obj.Base and not 'Restore' in obj.State:
|
||||
PathLog.track(obj.Label, prop)
|
||||
zmin = sys.maxint
|
||||
zmax = -zmin
|
||||
for base, sublist in obj.Base:
|
||||
bb = base.Shape.BoundBox # parent boundbox
|
||||
for sub in sublist:
|
||||
subobj = base.Shape.getElement(sub)
|
||||
fbb = subobj.BoundBox # feature boundbox
|
||||
|
||||
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
|
||||
finalDepth = bb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
|
||||
finalDepth = fbb.ZMin
|
||||
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
|
||||
finalDepth = fbb.ZMin
|
||||
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
|
||||
finalDepth = fbb.ZMin
|
||||
else: # catch all
|
||||
finalDepth = bb.ZMin
|
||||
|
||||
if finalDepth < zmin:
|
||||
zmin = finalDepth
|
||||
if bb.ZMax > zmax:
|
||||
zmax = bb.ZMax
|
||||
PathLog.debug("%s: final=%.2f, max=%.2f" % (sub, zmin, zmax))
|
||||
|
||||
PathLog.debug("zmin=%.2f, zmax=%.2f" % (zmin, zmax))
|
||||
if not PathGeom.isRoughly(zmin, obj.FinalDepth.Value):
|
||||
obj.FinalDepth = zmin
|
||||
if not PathGeom.isRoughly(zmax, obj.StartDepth.Value):
|
||||
obj.StartDepth = zmax
|
||||
clearance = zmax + 5.0
|
||||
safe = zmax + 3
|
||||
if not PathGeom.isRoughly(clearance, obj.ClearanceHeight.Value):
|
||||
obj.CearanceHeight = clearance
|
||||
if not PathGeom.isRoughly(safe, obj.SafeHeight.Value):
|
||||
obj.SafeHeight = safe
|
||||
|
||||
|
||||
def Create(name):
|
||||
'''Create(name) ... Creates and returns a Pocket operation.'''
|
||||
|
||||
@@ -48,7 +48,10 @@ class ObjectPocket(PathAreaOp.ObjectOp):
|
||||
|
||||
def areaOpFeatures(self, obj):
|
||||
'''areaOpFeatures(obj) ... Pockets have a FinishDepth and work on Faces'''
|
||||
return PathOp.FeatureBaseFaces | PathOp.FeatureFinishDepth
|
||||
return PathOp.FeatureBaseFaces | PathOp.FeatureFinishDepth | self.pocketOpFeatures(obj)
|
||||
|
||||
def pocketOpFeatures(self, obj):
|
||||
return 0
|
||||
|
||||
def initAreaOp(self, obj):
|
||||
'''initAreaOp(obj) ... create pocket specific properties.
|
||||
|
||||
@@ -60,11 +60,12 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
|
||||
'''getForm() ... returns UI, adapted to the resutls from pocketFeatures()'''
|
||||
form = FreeCADGui.PySideUic.loadUi(":/panels/PageOpPocketFullEdit.ui")
|
||||
|
||||
if FeatureFacing & self.pocketFeatures():
|
||||
if not FeatureFacing & self.pocketFeatures():
|
||||
form.facingWidget.hide()
|
||||
|
||||
if FeaturePocket & self.pocketFeatures():
|
||||
form.extraOffsetLabel.setText(translate("PathPocket", "Pass Extension"))
|
||||
form.extraOffset.setToolTip(translate("PathPocket", "The distance the facing operation will extend beyond the boundary shape."))
|
||||
else:
|
||||
form.facingWidget.hide()
|
||||
|
||||
if True:
|
||||
# currently doesn't have an effect
|
||||
|
||||
Reference in New Issue
Block a user