Merge pull request #3951 from dubstar-04/PathTurnBase

[Path] - Add Turning / Lathe Base Support
This commit is contained in:
sliptonic
2020-10-11 11:19:21 -05:00
committed by GitHub
5 changed files with 208 additions and 1 deletions

View File

@@ -99,6 +99,7 @@
<file>panels/PageBaseHoleGeometryEdit.ui</file>
<file>panels/PageBaseLocationEdit.ui</file>
<file>panels/PageDepthsEdit.ui</file>
<file>panels/PageDiametersEdit.ui</file>
<file>panels/PageHeightsEdit.ui</file>
<file>panels/PageOpCustomEdit.ui</file>
<file>panels/PageOpDeburrEdit.ui</file>

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>235</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="minDiameter">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Start Depth of the operation. The highest point in Z-axis the operation needs to process.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="maxDiameter">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The depth of the operation which corresponds to the lowest value in Z-axis the operation needs to process.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="finalDepthSet">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Transfer the Z value of the selected feature as the Final Depth for the operation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../../Gui/Icons/resource.qrc">
<normaloff>:/icons/button_left.svg</normaloff>:/icons/button_left.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="startDepthSet">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Transfer the Z value of the selected feature as the Start Depth for the operation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../../Gui/Icons/resource.qrc">
<normaloff>:/icons/button_left.svg</normaloff>:/icons/button_left.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="startDepthLabel">
<property name="text">
<string>Min Diameter</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="finalDepthLabel">
<property name="text">
<string>Max Diameter</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>minDiameter</tabstop>
<tabstop>maxDiameter</tabstop>
<tabstop>startDepthSet</tabstop>
<tabstop>finalDepthSet</tabstop>
</tabstops>
<resources>
<include location="../../../../../Gui/Icons/resource.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -64,6 +64,7 @@ FeatureBaseFaces = 0x0400 # Base
FeatureBasePanels = 0x0800 # Base
FeatureLocations = 0x1000 # Locations
FeatureCoolant = 0x2000 # Coolant
FeatureDiameters = 0x4000 # Turning Diameters
FeatureBaseGeometry = FeatureBaseVertexes | FeatureBaseFaces | FeatureBaseEdges | FeatureBasePanels
@@ -91,6 +92,7 @@ class ObjectOp(object):
FeatureBasePanels ... Base geometry support for Arch.Panels
FeatureLocations ... Base location support
FeatureCoolant ... Support for operation coolant
FeatureDiameters ... Support for turning operation diameters
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(),
@@ -169,6 +171,10 @@ class ObjectOp(object):
obj.addProperty("App::PropertyVectorDistance", "StartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("PathOp", "The start point of this path"))
obj.addProperty("App::PropertyBool", "UseStartPoint", "Start Point", QtCore.QT_TRANSLATE_NOOP("PathOp", "Make True, if specifying a Start Point"))
if FeatureDiameters & features:
obj.addProperty("App::PropertyDistance", "MinDiameter", "Diameter", QtCore.QT_TRANSLATE_NOOP("PathOp", "Lower limit of the turning diameter"))
obj.addProperty("App::PropertyDistance", "MaxDiameter", "Diameter", QtCore.QT_TRANSLATE_NOOP("PathOp", "Upper limit of the turning diameter."))
# members being set later
self.commandlist = None
self.horizFeed = None
@@ -352,6 +358,10 @@ class ObjectOp(object):
if not self.applyExpression(obj, 'ClearanceHeight', job.SetupSheet.ClearanceHeightExpression):
obj.ClearanceHeight = '5 mm'
if FeatureDiameters & features:
obj.MinDiameter = '0 mm'
obj.MaxDiameter = '0 mm'
if FeatureStartPoint & features:
obj.UseStartPoint = False

View File

@@ -928,6 +928,43 @@ class TaskPanelDepthsPage(TaskPanelPage):
self.form.startDepthSet.setEnabled(False)
self.form.finalDepthSet.setEnabled(False)
class TaskPanelDiametersPage(TaskPanelPage):
'''Page controller for diameters.'''
def __init__(self, obj, features):
super(TaskPanelDiametersPage, self).__init__(obj, features)
# members initialized later
self.clearanceHeight = None
self.safeHeight = None
def getForm(self):
return FreeCADGui.PySideUic.loadUi(":/panels/PageDiametersEdit.ui")
def initPage(self, obj):
self.minDiameter = PathGui.QuantitySpinBox(self.form.minDiameter, obj, 'MinDiameter')
self.maxDiameter = PathGui.QuantitySpinBox(self.form.maxDiameter, obj, 'MaxDiameter')
def getTitle(self, obj):
return translate("Path", "Diameters")
def getFields(self, obj):
self.minDiameter.updateProperty()
self.maxDiameter.updateProperty()
def setFields(self, obj):
self.minDiameter.updateSpinBox()
self.maxDiameter.updateSpinBox()
def getSignalsForUpdate(self, obj):
signals = []
signals.append(self.form.minDiameter.editingFinished)
signals.append(self.form.maxDiameter.editingFinished)
return signals
def pageUpdateData(self, obj, prop):
if prop in ['MinDiameter', 'MaxDiameter']:
self.setFields(obj)
class TaskPanel(object):
'''
@@ -953,6 +990,8 @@ class TaskPanel(object):
self.finalDepth = None
self.stepDown = None
self.buttonBox = None
self.minDiameter = None
self.maxDiameter = None
features = obj.Proxy.opFeatures(obj)
opPage.features = features
@@ -980,7 +1019,13 @@ class TaskPanel(object):
self.featurePages.append(opPage.taskPanelHeightsPage(obj, features))
else:
self.featurePages.append(TaskPanelHeightsPage(obj, features))
if PathOp.FeatureDiameters & features:
if hasattr(opPage, 'taskPanelDiametersPage'):
self.featurePages.append(opPage.taskPanelDiametersPage(obj, features))
else:
self.featurePages.append(TaskPanelDiametersPage(obj, features))
self.featurePages.append(opPage)
for page in self.featurePages:

View File

@@ -260,6 +260,15 @@ class PROBEGate:
def allow(self, doc, obj, sub):
pass
class TURNGate(PathBaseGate):
def allow(self, doc, obj, sub): # pylint: disable=unused-argument
PathLog.debug('obj: {} sub: {}'.format(obj, sub))
if hasattr(obj, "Shape") and sub:
shape = obj.Shape
subobj = shape.getElement(sub)
return PathUtils.isDrillable(shape, subobj, includePartials=True)
else:
return False
class ALLGate(PathBaseGate):
def allow(self, doc, obj, sub): # pylint: disable=unused-argument
@@ -340,6 +349,10 @@ def probeselect():
def customselect():
FreeCAD.Console.PrintWarning("Custom Select Mode\n")
def turnselect():
FreeCADGui.Selection.addSelectionGate(TURNGate())
FreeCAD.Console.PrintWarning("Turning Select Mode\n")
def select(op):
@@ -363,6 +376,8 @@ def select(op):
opsel['Vcarve'] = vcarveselect
opsel['Probe'] = probeselect
opsel['Custom'] = customselect
opsel['TurnFace'] = turnselect
opsel['TurnProfile'] = turnselect
return opsel[op]