Add UseOutline property to PocketShape in order to mill full pockets and not have to add all sub-shapes.

This commit is contained in:
Markus Lampert
2018-08-17 20:57:52 -07:00
committed by wmayer
parent 321b159f27
commit 04807fddd7
6 changed files with 57 additions and 28 deletions

View File

@@ -214,6 +214,23 @@
<item>
<widget class="QWidget" name="pocketWidget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QCheckBox" name="minTravel">
<property name="text">
<string>Min Travel</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="useOutline">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If selected the operation uses the outline of the selected base geometry and ignores all holes and islands.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Use Outline</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="useStartPoint">
<property name="toolTip">
@@ -224,20 +241,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="keepToolDown">
<property name="text">
<string>Keep tool down</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="minTravel">
<property name="text">
<string>Min Travel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -177,6 +177,8 @@ class ObjectOp(object):
if FeatureNoFinalDepth & features:
obj.setEditorMode('OpFinalDepth', 2)
self.opOnDocumentRestored(obj)
def __getstate__(self):
'''__getstat__(self) ... called when receiver is saved.
Can safely be overwritten by subclasses.'''
@@ -198,6 +200,11 @@ class ObjectOp(object):
Should be overwritten by subclasses.'''
pass
def opOnDocumentRestored(self, obj):
'''opOnDocumentRestored(obj) ... implement if an op needs special handling like migrating the data model.
Should be overwritten by subclasses.'''
pass
def opOnChanged(self, obj, prop):
'''opOnChanged(obj, prop) ... overwrite to process property changes.
This is a callback function that is invoked each time a property of the

View File

@@ -79,7 +79,7 @@ class ObjectPocket(PathAreaOp.ObjectOp):
obj.addProperty("App::PropertyEnumeration", "OffsetPattern", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Clearing pattern to use"))
obj.OffsetPattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle']
obj.addProperty("App::PropertyBool", "MinTravel", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Use 3D Sorting of Path"))
obj.addProperty("App::PropertyBool", "KeepToolDown", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Attempts to avoid unnecessary retractions."))
obj.addProperty("App::PropertyBool", "KeepToolDown", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Attempts to avoid unnecessary retractions."))
self.initPocketOp(obj)

View File

@@ -40,20 +40,22 @@ __doc__ = "Base page controller and command implementation for path pocket opera
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
FeaturePocket = 0x01
FeatureFacing = 0x02
FeaturePocket = 0x01
FeatureFacing = 0x02
FeatureOutline = 0x04
class TaskPanelOpPage(PathOpGui.TaskPanelPage):
'''Page controller class for pocket operations, supports two different features:
'''Page controller class for pocket operations, supports:
FeaturePocket ... used for pocketing operation
FeatureFacing ... used for face milling operation
FeatureOutline ... used for pocket-shape operation
'''
def pocketFeatures(self):
'''pocketFeatures() ... return which features of the UI are supported by the operation.
Typically one of the following is enabled:
FeaturePocket ... used for pocketing operation
FeatureFacing ... used for face milling operation
FeatureOutline ... used for pocket-shape operation
Must be overwritten by subclasses'''
pass
@@ -68,9 +70,11 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
form.extraOffsetLabel.setText(translate("PathPocket", "Pass Extension"))
form.extraOffset.setToolTip(translate("PathPocket", "The distance the facing operation will extend beyond the boundary shape."))
if not (FeatureOutline & self.pocketFeatures()):
form.useOutline.hide()
if True:
# currently doesn't have an effect or is experimental
form.keepToolDown.hide()
form.minTravel.hide()
return form
@@ -109,8 +113,10 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
if obj.UseStartPoint != self.form.useStartPoint.isChecked():
obj.UseStartPoint = self.form.useStartPoint.isChecked()
if obj.KeepToolDown != self.form.keepToolDown.isChecked():
obj.KeepToolDown = self.form.keepToolDown.isChecked()
if FeatureOutline & self.pocketFeatures():
if obj.UseOutline != self.form.useOutline.isChecked():
obj.UseOutline = self.form.useOutline.isChecked()
self.updateMinTravel(obj)
@@ -123,7 +129,8 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
self.form.stepOverPercent.setValue(obj.StepOver)
self.form.extraOffset.setText(FreeCAD.Units.Quantity(obj.ExtraOffset.Value, FreeCAD.Units.Length).UserString)
self.form.useStartPoint.setChecked(obj.UseStartPoint)
self.form.keepToolDown.setChecked(obj.KeepToolDown)
if FeatureOutline & self.pocketFeatures():
self.form.useOutline.setChecked(obj.UseOutline)
self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(obj.ZigZagAngle, FreeCAD.Units.Angle).UserString)
self.updateZigZagAngle(obj, False)
@@ -149,7 +156,7 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
signals.append(self.form.toolController.currentIndexChanged)
signals.append(self.form.extraOffset.editingFinished)
signals.append(self.form.useStartPoint.clicked)
signals.append(self.form.keepToolDown.clicked)
signals.append(self.form.useOutline.clicked)
signals.append(self.form.minTravel.clicked)
if FeatureFacing & self.pocketFeatures():

View File

@@ -55,7 +55,13 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
def initPocketOp(self, obj):
'''initPocketOp(obj) ... setup receiver'''
pass
obj.addProperty("App::PropertyBool", "UseOutline", "Pocket", QtCore.QT_TRANSLATE_NOOP("App::Property", "Uses the outline of the base geometry."))
obj.UseOutline = False
def opOnDocumentRestored(self, obj):
'''opOnDocumentRestored(obj) ... adds the UseOutline property if it doesn't exist.'''
if not hasattr(obj, 'UseOutline'):
self.initPocketOp(obj)
def pocketInvertExtraOffset(self):
return False
@@ -110,10 +116,16 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
f.translate(FreeCAD.Vector(0, 0, obj.FinalDepth.Value - f.BoundBox.ZMin))
# check all faces and see if they are touching/overlapping and combine those into a compound
self.horizontal = PathGeom.combineConnectedShapes(self.horiz)
for shape in self.horizontal:
self.horizontal = []
for shape in PathGeom.combineConnectedShapes(self.horiz):
shape.sewShape()
shape.tessellate(0.1)
if obj.UseOutline:
wire = TechDraw.findShapeOutline(shape, 1, FreeCAD.Vector(0, 0, 1))
wire.translate(FreeCAD.Vector(0, 0, obj.FinalDepth.Value - wire.BoundBox.ZMin))
self.horizontal.append(Part.Face(wire))
else:
self.horizontal.append(shape)
# extrude all faces up to StartDepth and those are the removal shapes
extent = FreeCAD.Vector(0, 0, obj.StartDepth.Value - obj.FinalDepth.Value)

View File

@@ -39,7 +39,7 @@ class TaskPanelOpPage(PathPocketBaseGui.TaskPanelOpPage):
def pocketFeatures(self):
'''pocketFeatures() ... return FeaturePocket (see PathPocketBaseGui)'''
return PathPocketBaseGui.FeaturePocket
return PathPocketBaseGui.FeaturePocket | PathPocketBaseGui.FeatureOutline
Command = PathOpGui.SetupOperation('Pocket Shape',
PathPocketShape.Create,