From 8758cfce9f443ee90ab0c08da76aa994dad79f8d Mon Sep 17 00:00:00 2001 From: sliptonic Date: Mon, 21 Sep 2020 17:02:23 -0500 Subject: [PATCH] Resolve UI issues taskpanel threshold value add constants to PathVoronoi calls check for tool properties set correct z height coloring exterior lines --- .../Gui/Resources/panels/PageOpVcarveEdit.ui | 35 +++++++------------ src/Mod/Path/PathScripts/PathVcarve.py | 32 +++++++++++------ 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui index b10575eea4..21316a699c 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui @@ -81,28 +81,6 @@ - - - - <html><head/><body><p>Threshold is used by the medial axis filter to remove unwanted segments. If the resulting path contains unwanted segments, decrease this value. </p><p>Valid values are 0.0 - 1.0</p><p>Default = 0.8</p><p>1.0 will remove nothing.</p></body></html> - - - 2 - - - 0.000000000000000 - - - 1.000000000000000 - - - 0.100000000000000 - - - 0.800000000000000 - - - @@ -113,6 +91,19 @@ + + + + <html><head/><body><p>Threshold is used by the medial axis filter to remove unwanted segments. If the resulting path contains unwanted segments, decrease this value. </p><p>Valid values are 0.0 - 1.0</p><p>Default = 0.8</p><p>1.0 will remove nothing.</p></body></html> + + + 180 + + + 10 + + + diff --git a/src/Mod/Path/PathScripts/PathVcarve.py b/src/Mod/Path/PathScripts/PathVcarve.py index 29e81523ed..0273c8e190 100644 --- a/src/Mod/Path/PathScripts/PathVcarve.py +++ b/src/Mod/Path/PathScripts/PathVcarve.py @@ -40,6 +40,12 @@ from PySide import QtCore __doc__ = "Class and implementation of Path Vcarve operation" +PRIMARY = 0 +EXTERIOR1 = 1 +EXTERIOR2 = 4 +TWIN = 2 +COLINEAR = 3 +OTHER = 5 if False: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) @@ -113,14 +119,14 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): d = round(MIC / math.tan(math.radians(toolangle / 2)), 4) return d if d <= maxdepth else maxdepth - def getEdges(vd, color=[0]): + def getEdges(vd, color=[PRIMARY]): if type(color) == int: color = [color] geomList = [] for e in vd.Edges: if e.Color not in color: continue - if e.toGeom(8) is None: + if e.toGeom() is None: continue p1 = e.Vertices[0].toGeom(calculate_depth(0-e.getDistances()[0])) p2 = e.Vertices[-1].toGeom(calculate_depth(0-e.getDistances()[-1])) @@ -129,8 +135,7 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): newedge.fixTolerance(obj.Tolerance, Part.Vertex) geomList.append(newedge) - if geomList: - return geomList + return geomList def sortEm(mywire, unmatched): remaining = [] @@ -212,12 +217,13 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): vd.construct() for e in vd.Edges: - e.Color = 0 if e.isPrimary() else 5 - vd.colorExterior(1) - vd.colorExterior(4, lambda v: not f.isInside(v.toGeom(), + e.Color = PRIMARY if e.isPrimary() else OTHER + vd.colorExterior(EXTERIOR1) + vd.colorExterior(EXTERIOR2, + lambda v: not f.isInside(v.toGeom(f.BoundBox.ZMin), obj.Tolerance, True)) - vd.colorColinear(3, obj.Threshold) - vd.colorTwins(2) + vd.colorColinear(COLINEAR, obj.Threshold) + vd.colorTwins(TWIN) edgelist = getEdges(vd) @@ -230,6 +236,12 @@ class ObjectVcarve(PathEngraveBase.ObjectOp): '''opExecute(obj) ... process engraving operation''' PathLog.track() + if not (hasattr(obj.ToolController.Tool, "CuttingEdgeAngle") and + hasattr(obj.ToolController.Tool, "CuttingEdgeHeight")): + FreeCAD.Console.PrintError( + translate("Path_Vcarve", "VCarve requires an engraving \ + cutter with CuttingEdgeAngle and CuttingEdgeHeight") + "\n") + if obj.ToolController.Tool.CuttingEdgeAngle >= 180.0: FreeCAD.Console.PrintError( translate("Path_Vcarve", @@ -276,5 +288,5 @@ def Create(name, obj=None): '''Create(name) ... Creates and returns a Vcarve operation.''' if obj is None: obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name) - proxy = ObjectVcarve(obj, name) + ObjectVcarve(obj, name) return obj