Add a coolant feature to the base PathOP

This commit is contained in:
Daniel Wood
2019-08-28 19:32:09 +01:00
parent f68e58e389
commit 2085cf338a
2 changed files with 35 additions and 2 deletions

View File

@@ -63,8 +63,9 @@ FeatureBaseEdges = 0x0200 # Base
FeatureBaseFaces = 0x0400 # Base
FeatureBasePanels = 0x0800 # Base
FeatureLocations = 0x1000 # Locations
FeatureCoolant = 0x2000 # Coolant
FeatureBaseGeometry = FeatureBaseVertexes | FeatureBaseFaces | FeatureBaseEdges | FeatureBasePanels
FeatureBaseGeometry = FeatureBaseVertexes | FeatureBaseFaces | FeatureBaseEdges | FeatureBasePanels | FeatureCoolant
class ObjectOp(object):
@@ -89,6 +90,7 @@ class ObjectOp(object):
FeatureBaseFaces ... Base geometry support for faces
FeatureBasePanels ... Base geometry support for Arch.Panels
FeatureLocations ... Base location support
FeatureCoolant ... Support for operation coolant
The base class handles all base API and forwards calls to subclasses with
an op prefix. For instance, an op is not expected to overwrite onChanged(),
@@ -135,6 +137,9 @@ class ObjectOp(object):
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 FeatureCoolant & features:
obj.addProperty("App::PropertyString", "CoolantMode", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Coolant mode for this operation"))
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"))
@@ -208,6 +213,9 @@ class ObjectOp(object):
if FeatureTool & features and not hasattr(obj, 'OpToolDiameter'):
self.addOpValues(obj, ['tooldia'])
if FeatureCoolant & features and not hasattr(obj, 'CoolantMode'):
obj.addProperty("App::PropertyString", "CoolantMode", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Coolant option for this operation"))
if FeatureDepths & features and not hasattr(obj, 'OpStartDepth'):
self.addOpValues(obj, ['start', 'final'])
if FeatureNoFinalDepth & features:
@@ -238,7 +246,7 @@ class ObjectOp(object):
The default implementation returns "FeatureTool | FeatureDeptsh | FeatureHeights | FeatureStartPoint"
Should be overwritten by subclasses.'''
# pylint: disable=unused-argument
return FeatureTool | FeatureDepths | FeatureHeights | FeatureStartPoint | FeatureBaseGeometry | FeatureFinishDepth
return FeatureTool | FeatureDepths | FeatureHeights | FeatureStartPoint | FeatureBaseGeometry | FeatureFinishDepth | FeatureCoolant
def initOperation(self, obj):
'''initOperation(obj) ... implement to create additional properties.
@@ -316,6 +324,9 @@ class ObjectOp(object):
return None
obj.OpToolDiameter = obj.ToolController.Tool.Diameter
if FeatureCoolant & features:
obj.CoolantMode = job.SetupSheet.CoolantMode
if FeatureDepths & features:
if self.applyExpression(obj, 'StartDepth', job.SetupSheet.StartDepthExpression):
obj.OpStartDepth = 1.0
@@ -472,6 +483,10 @@ class ObjectOp(object):
if not self._setBaseAndStock(obj):
return
if FeatureCoolant & self.opFeatures(obj):
if not hasattr(obj, 'CoolantMode'):
FreeCAD.Console.PrintError("No coolant property found. Please recreate operation.")
if FeatureTool & self.opFeatures(obj):
tc = obj.ToolController
if tc is None or tc.ToolNumber == 0:

View File

@@ -369,6 +369,24 @@ class TaskPanelPage(object):
if obj.ToolController != tc:
obj.ToolController = tc
def setupCoolant(self, obj, combo):
'''setupCoolant(obj, combo) ... helper function to setup obj's Coolant option.'''
job = PathUtils.findParentJob(obj)
options = job.SetupSheet.CoolantModes
combo.blockSignals(True)
combo.clear()
combo.addItems(options)
combo.blockSignals(False)
if hasattr(obj, 'CoolantMode'):
self.selectInComboBox(obj.CoolantMode, combo)
def updateCoolant(self, obj, combo):
'''updateCoolant(obj, combo) ... helper function to update obj's Coolant property if a different one has been selected in the combo box.'''
option = combo.currentText()
if hasattr(obj, 'CoolantMode'):
if obj.CoolantMode != option:
obj.CoolantMode = option
class TaskPanelBaseGeometryPage(TaskPanelPage):
'''Page controller for the base geometry.'''