Skip to content

Commit

Permalink
Resolve UI issues
Browse files Browse the repository at this point in the history
taskpanel threshold value
add constants to PathVoronoi calls
check for tool properties
set correct z height coloring exterior lines
  • Loading branch information
sliptonic committed Sep 28, 2020
1 parent b1e5b5a commit 8758cfc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
35 changes: 13 additions & 22 deletions src/Mod/Path/Gui/Resources/panels/PageOpVcarveEdit.ui
Expand Up @@ -81,28 +81,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="threshold">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Threshold is used by the medial axis filter to remove unwanted segments. If the resulting path contains unwanted segments, decrease this value. &lt;/p&gt;&lt;p&gt;Valid values are 0.0 - 1.0&lt;/p&gt;&lt;p&gt;Default = 0.8&lt;/p&gt;&lt;p&gt;1.0 will remove nothing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.800000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
Expand All @@ -113,6 +91,19 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="threshold">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Threshold is used by the medial axis filter to remove unwanted segments. If the resulting path contains unwanted segments, decrease this value. &lt;/p&gt;&lt;p&gt;Valid values are 0.0 - 1.0&lt;/p&gt;&lt;p&gt;Default = 0.8&lt;/p&gt;&lt;p&gt;1.0 will remove nothing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
32 changes: 22 additions & 10 deletions src/Mod/Path/PathScripts/PathVcarve.py
Expand Up @@ -40,6 +40,12 @@

__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())
Expand Down Expand Up @@ -113,14 +119,14 @@ def calculate_depth(MIC):
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]))
Expand All @@ -129,8 +135,7 @@ def getEdges(vd, color=[0]):
newedge.fixTolerance(obj.Tolerance, Part.Vertex)
geomList.append(newedge)

if geomList:
return geomList
return geomList

def sortEm(mywire, unmatched):
remaining = []
Expand Down Expand Up @@ -212,12 +217,13 @@ def cutWire(w):
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)

Expand All @@ -230,6 +236,12 @@ def opExecute(self, obj):
'''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",
Expand Down Expand Up @@ -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

0 comments on commit 8758cfc

Please sign in to comment.