diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpSurfaceEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpSurfaceEdit.ui
index c2c9a27309..91996fa8e1 100644
--- a/src/Mod/Path/Gui/Resources/panels/PageOpSurfaceEdit.ui
+++ b/src/Mod/Path/Gui/Resources/panels/PageOpSurfaceEdit.ui
@@ -22,21 +22,15 @@
QFrame::Raised
-
-
- 0
-
-
- 0
-
- -
+
+
-
ToolController
- -
+
-
<html><head/><body><p>The tool and its settings to be used for this operation.</p></body></html>
@@ -48,15 +42,15 @@
-
-
-
-
+
+
-
Algorithm
- -
+
-
-
@@ -70,9 +64,145 @@
-
-
-
+ -
+
+
+ BoundBox
+
+
+
+ -
+
+
-
+
+ Stock
+
+
+ -
+
+ BaseBoundBox
+
+
+
+
+
+ -
+
+
+ BoundBox extra offset X, Y
+
+
+
+ -
+
+
+ mm
+
+
+
+ -
+
+
+ mm
+
+
+
+
+ -
+
+
+ Drop Cutter Direction
+
+
+
+ -
+
+
-
+
+ X
+
+
+ -
+
+ Y
+
+
+
+
+
+ -
+
+
+ Depth offset
+
+
+
+ -
+
+
+ mm
+
+
+
+
+ -
+
+
+ Sample interval
+
+
+
+ -
+
+
+ mm
+
+
+
+ -
+
+
+ Step over
+
+
+
+ -
+
+
+ <html><head/><body><p>The amount by which the tool is laterally displaced on each cycle of the pattern, specified in percent of the tool diameter.</p><p>A step over of 100% results in no overlap between two different cycles.</p></body></html>
+
+
+ 1
+
+
+ 100
+
+
+ 10
+
+
+ 100
+
+
+
+ -
+
+
+ Optimize output
+
+
+
+ -
+
+
+ Enabled
+
+
+
+
+
+
+
-
diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py
index 8d6e31dfe1..a7839ffb0b 100644
--- a/src/Mod/Path/PathScripts/PathSurface.py
+++ b/src/Mod/Path/PathScripts/PathSurface.py
@@ -76,6 +76,7 @@ class ObjectSurface(PathOp.ObjectOp):
obj.addProperty("App::PropertyPercent", "StepOver", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property", "Step over percentage of the drop cutter path"))
obj.addProperty("App::PropertyDistance", "DepthOffset", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property", "Z-axis offset from the surface of the object"))
obj.addProperty("App::PropertyFloatConstraint", "SampleInterval", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property", "The Sample Interval. Small values cause long wait times"))
+ obj.addProperty("App::PropertyBool", "Optimize", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property", "Enable optimization which removes unecessary points from G-Code output"))
obj.BoundBox = ['Stock', 'BaseBoundBox']
obj.DropCutterDir = ['X', 'Y']
obj.Algorithm = ['OCL Dropcutter', 'OCL Waterline']
@@ -179,9 +180,22 @@ class ObjectSurface(PathOp.ObjectOp):
pp.append(Path.Command('G0', {"Z": obj.SafeHeight.Value, 'F': self.vertRapid}))
pp.append(Path.Command('G0', {'X': p.x, "Y": p.y, 'F': self.horizRapid}))
pp.append(Path.Command('G1', {"Z": p.z, 'F': self.vertFeed}))
-
- for p in loop[1:]:
- pp.append(Path.Command('G1', {'X': p.x, "Y": p.y, "Z": p.z, 'F': self.horizFeed}))
+ prev = ocl.Point(float("inf"), float("inf"), float("inf"))
+ next = ocl.Point(float("inf"), float("inf"), float("inf"))
+ optimize = obj.Optimize
+ for i in range(1, len(loop)):
+ p = loop[i]
+ if i < len(loop) - 1:
+ next.x = loop[i + 1].x
+ next.y = loop[i + 1].y
+ next.z = loop[i + 1].z
+ else:
+ optimize = False
+ if not optimize or not self.isPointOnLine(FreeCAD.Vector(prev.x, prev.y, prev.z), FreeCAD.Vector(next.x, next.y, next.z), FreeCAD.Vector(p.x, p.y, p.z)):
+ pp.append(Path.Command('G1', {'X': p.x, "Y": p.y, "Z": p.z, 'F': self.horizFeed}))
+ prev.x = p.x
+ prev.y = p.y
+ prev.z = p.z
# zheight = p.z
p = loop[0]
pp.append(Path.Command('G1', {'X': p.x, "Y": p.y, "Z": p.z, 'F': self.horizFeed}))
@@ -194,7 +208,7 @@ class ObjectSurface(PathOp.ObjectOp):
return pp
depthparams = PathUtils.depth_params(obj.ClearanceHeight.Value, obj.SafeHeight.Value,
- obj.StartDepth.Value, obj.StepDown, obj.FinishDepth.Value, obj.FinalDepth.Value)
+ obj.StartDepth.Value, obj.StepDown, 0.0, obj.FinalDepth.Value)
t_before = time.time()
zheights = [i for i in depthparams]
@@ -321,7 +335,7 @@ class ObjectSurface(PathOp.ObjectOp):
output.append(Path.Command('G1', {'Z': clp[0].z, 'F': self.vertFeed}))
prev = ocl.Point(float("inf"), float("inf"), float("inf"))
next = ocl.Point(float("inf"), float("inf"), float("inf"))
- optimize = True
+ optimize = obj.Optimize
for i in range(0, len(clp)):
c = clp[i]
if i < len(clp) - 1:
@@ -347,6 +361,7 @@ class ObjectSurface(PathOp.ObjectOp):
# obj.ZigZagAngle = 45.0
obj.StepOver = 50
+ obj.Optimize = True
# need to overwrite the default depth calculations for facing
job = PathUtils.findParentJob(obj)
if job and job.Stock:
diff --git a/src/Mod/Path/PathScripts/PathSurfaceGui.py b/src/Mod/Path/PathScripts/PathSurfaceGui.py
index 5fab107eac..4dd722e887 100644
--- a/src/Mod/Path/PathScripts/PathSurfaceGui.py
+++ b/src/Mod/Path/PathScripts/PathSurfaceGui.py
@@ -25,8 +25,9 @@
import FreeCAD
import FreeCADGui
import PathScripts.PathSurface as PathSurface
+import PathScripts.PathGui as PathGui
import PathScripts.PathOpGui as PathOpGui
-#import PathScripts.PathPocketBaseGui as PathPocketBaseGui
+# import PathScripts.PathPocketBaseGui as PathPocketBaseGui
from PySide import QtCore
@@ -35,6 +36,7 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Surface operation page controller and command implementation."
+
class TaskPanelOpPage(PathOpGui.TaskPanelPage):
'''Page controller class for the Surface operation.'''
@@ -46,20 +48,84 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
'''getFields(obj) ... transfers values from UI to obj's proprties'''
# if obj.StartVertex != self.form.startVertex.value():
# obj.StartVertex = self.form.startVertex.value()
+ PathGui.updateInputField(obj, 'DepthOffset', self.form.depthOffset)
+ PathGui.updateInputField(obj, 'SampleInterval', self.form.sampleInterval)
+
+ if obj.StepOver != self.form.stepOver.value():
+ obj.StepOver = self.form.stepOver.value()
+
+ if obj.Algorithm != str(self.form.algorithmSelect.currentText()):
+ obj.Algorithm = str(self.form.algorithmSelect.currentText())
+
+ if obj.BoundBox != str(self.form.boundBoxSelect.currentText()):
+ obj.BoundBox = str(self.form.boundBoxSelect.currentText())
+
+ if obj.DropCutterDir != str(self.form.dropCutterDirSelect.currentText()):
+ obj.DropCutterDir = str(self.form.dropCutterDirSelect.currentText())
+
+ obj.DropCutterExtraOffset.x = FreeCAD.Units.Quantity(self.form.boundBoxExtraOffsetX.text()).Value
+ obj.DropCutterExtraOffset.y = FreeCAD.Units.Quantity(self.form.boundBoxExtraOffsetY.text()).Value
+
+ if obj.Optimize != self.form.optimizeEnabled.isChecked():
+ obj.Optimize = self.form.optimizeEnabled.isChecked()
+
self.updateToolController(obj, self.form.toolController)
def setFields(self, obj):
'''setFields(obj) ... transfers obj's property values to UI'''
- #self.form.startVertex.setValue(obj.StartVertex)
+ # self.form.startVertex.setValue(obj.StartVertex)
+ self.selectInComboBox(obj.Algorithm, self.form.algorithmSelect)
+ self.selectInComboBox(obj.BoundBox, self.form.boundBoxSelect)
+ self.selectInComboBox(obj.DropCutterDir, self.form.dropCutterDirSelect)
+
+ self.form.boundBoxExtraOffsetX.setText(str(obj.DropCutterExtraOffset.x))
+ self.form.boundBoxExtraOffsetY.setText(str(obj.DropCutterExtraOffset.y))
+ self.form.depthOffset.setText(FreeCAD.Units.Quantity(obj.DepthOffset.Value, FreeCAD.Units.Length).UserString)
+ self.form.sampleInterval.setText(str(obj.SampleInterval))
+ self.form.stepOver.setValue(obj.StepOver)
+
+ if obj.Optimize:
+ self.form.optimizeEnabled.setCheckState(QtCore.Qt.Checked)
+ else:
+ self.form.optimizeEnabled.setCheckState(QtCore.Qt.Unchecked)
+
self.setupToolController(obj, self.form.toolController)
def getSignalsForUpdate(self, obj):
'''getSignalsForUpdate(obj) ... return list of signals for updating obj'''
signals = []
- #signals.append(self.form.startVertex.editingFinished)
+ # signals.append(self.form.startVertex.editingFinished)
signals.append(self.form.toolController.currentIndexChanged)
+ signals.append(self.form.algorithmSelect.currentIndexChanged)
+ signals.append(self.form.boundBoxSelect.currentIndexChanged)
+ signals.append(self.form.dropCutterDirSelect.currentIndexChanged)
+ signals.append(self.form.boundBoxExtraOffsetX.editingFinished)
+ signals.append(self.form.boundBoxExtraOffsetY.editingFinished)
+ signals.append(self.form.sampleInterval.editingFinished)
+ signals.append(self.form.stepOver.editingFinished)
+ signals.append(self.form.depthOffset.editingFinished)
+ signals.append(self.form.optimizeEnabled.stateChanged)
+
return signals
+ def updateVisibility(self):
+ if self.form.algorithmSelect.currentText() == "OCL Dropcutter":
+ self.form.boundBoxExtraOffsetX.setEnabled(True)
+ self.form.boundBoxExtraOffsetY.setEnabled(True)
+ self.form.boundBoxSelect.setEnabled(True)
+ self.form.dropCutterDirSelect.setEnabled(True)
+ self.form.stepOver.setEnabled(True)
+ else:
+ self.form.boundBoxExtraOffsetX.setEnabled(False)
+ self.form.boundBoxExtraOffsetY.setEnabled(False)
+ self.form.boundBoxSelect.setEnabled(False)
+ self.form.dropCutterDirSelect.setEnabled(False)
+ self.form.stepOver.setEnabled(False)
+
+ def registerSignalHandlers(self, obj):
+ self.form.algorithmSelect.currentIndexChanged.connect(self.updateVisibility)
+
+
Command = PathOpGui.SetupOperation('Surface',
PathSurface.Create,
TaskPanelOpPage,
@@ -69,4 +135,3 @@ Command = PathOpGui.SetupOperation('Surface',
PathSurface.SetupProperties)
FreeCAD.Console.PrintLog("Loading PathSurfaceGui... done\n")
-