Increased tolerance for accepting tags.

This commit is contained in:
Markus Lampert
2017-11-20 20:37:40 -08:00
parent 99a2fd16f4
commit 9c9faab428
3 changed files with 68 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<width>294</width>
<height>182</height>
</rect>
</property>
@@ -18,27 +18,21 @@
<widget class="QWidget" name="wPoint" native="true">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="lValueX">
<widget class="QLabel" name="globalXLabel">
<property name="text">
<string>Global X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::InputField" name="ifValueX"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lValueY">
<widget class="QLabel" name="globalYLabel">
<property name="text">
<string>Global Y</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="ifValueY"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lValueZ">
<widget class="QLabel" name="globalZLabel">
<property name="enabled">
<bool>false</bool>
</property>
@@ -47,11 +41,46 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="globalX">
<property name="decimals">
<number>6</number>
</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="globalY">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="ifValueZ">
<widget class="Gui::QuantitySpinBox" name="globalZ">
<property name="enabled">
<bool>false</bool>
</property>
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
@@ -68,9 +97,9 @@
</widget>
<customwidgets>
<customwidget>
<class>Gui::InputField</class>
<extends>QLineEdit</extends>
<header>Gui/InputField.h</header>
<class>Gui::QuantitySpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>

View File

@@ -22,7 +22,6 @@
# * *
# ***************************************************************************
import FreeCAD
import DraftGeomUtils
import Part
import Path
import PathScripts
@@ -640,13 +639,13 @@ class PathData:
def sortedTags(self, tags):
ordered = []
for edge in self.bottomEdges:
ts = [t for t in tags if DraftGeomUtils.isPtOnEdge(t.originAt(self.minZ), edge)]
ts = [t for t in tags if PathGeom.isRoughly(0, Part.Vertex(t.originAt(self.minZ)).distToShape(edge)[0], 0.1)]
for t in sorted(ts, key=lambda t: (t.originAt(self.minZ) - edge.valueAt(edge.FirstParameter)).Length):
tags.remove(t)
ordered.append(t)
# disable all tags that are not on the base wire.
for tag in tags:
PathLog.info("Tag #%d (%.2f, %.2f) not on base wire - disabling\n" % (len(ordered), tag.x, tag.y))
PathLog.info("Tag #%d (%.2f, %.2f, %.2f) not on base wire - disabling\n" % (len(ordered), tag.x, tag.y, self.minZ))
tag.enabled = False
ordered.append(tag)
return ordered
@@ -657,7 +656,7 @@ class PathData:
for e in self.bottomEdges:
indent = "{} ".format(e.distToShape(v)[0])
debugEdge(e, indent, True)
if PathGeom.isRoughly(v.distToShape(e)[0], 0.0, 1.0):
if PathGeom.isRoughly(0.0, v.distToShape(e)[0], 0.1):
return True
return False

View File

@@ -63,9 +63,13 @@ class TaskPanel:
self.formPoint.buttonBox.accepted.connect(self.pointAccept)
self.formPoint.buttonBox.rejected.connect(self.pointReject)
self.formPoint.ifValueX.editingFinished.connect(self.updatePoint)
self.formPoint.ifValueY.editingFinished.connect(self.updatePoint)
self.formPoint.ifValueZ.editingFinished.connect(self.updatePoint)
self.formPoint.globalX.editingFinished.connect(self.updatePoint)
self.formPoint.globalY.editingFinished.connect(self.updatePoint)
self.formPoint.globalZ.editingFinished.connect(self.updatePoint)
self.formPoint.globalX.setProperty('unit', FreeCAD.Units.MilliMetre.getUserPreferred()[2])
self.formPoint.globalY.setProperty('unit', FreeCAD.Units.MilliMetre.getUserPreferred()[2])
self.formPoint.globalZ.setProperty('unit', FreeCAD.Units.MilliMetre.getUserPreferred()[2])
def addEscapeShortcut(self):
'''addEscapeShortcut() ... internal function - do not call.'''
@@ -93,11 +97,12 @@ class TaskPanel:
until the user explicitly closes Snapper. This lets the user enter multiple points in quick succession.'''
def displayPoint(p):
self.formPoint.ifValueX.setText(FreeCAD.Units.Quantity(p.x, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueY.setText(FreeCAD.Units.Quantity(p.y, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueZ.setText(FreeCAD.Units.Quantity(p.z, FreeCAD.Units.Length).UserString)
self.formPoint.ifValueX.setFocus()
self.formPoint.ifValueX.selectAll()
self.point = p
self.formPoint.globalX.setProperty('rawValue', p.x)
self.formPoint.globalY.setProperty('rawValue', p.y)
self.formPoint.globalZ.setProperty('rawValue', p.z)
self.formPoint.globalX.setFocus()
self.formPoint.globalX.selectAll()
def mouseMove(cb):
p = None
@@ -114,6 +119,7 @@ class TaskPanel:
if hasattr(obj, 'Path'):
self.obj = obj
p = FreeCAD.Vector(snapInfo['x'], snapInfo['y'], snapInfo['z'])
self.pt = p
else:
self.obj = None
else:
@@ -124,6 +130,7 @@ class TaskPanel:
plane = FreeCAD.DraftWorkingPlane
p = plane.getLocalCoords(self.pt)
self.obj = FreeCADGui.Snapper.lastSnappedObject
if p:
displayPoint(p)
@@ -206,8 +213,11 @@ class TaskPanel:
def updatePoint(self):
'''updatePoint() ... internal function - do not call.'''
x = FreeCAD.Units.Quantity(self.formPoint.ifValueX.text()).Value
y = FreeCAD.Units.Quantity(self.formPoint.ifValueY.text()).Value
z = FreeCAD.Units.Quantity(self.formPoint.ifValueZ.text()).Value
self.pt = FreeCAD.Vector(x, y, z)
if self.point:
self.pt = self.point
else:
x = FreeCAD.Units.Quantity(self.formPoint.globalX.text()).Value
y = FreeCAD.Units.Quantity(self.formPoint.globalY.text()).Value
z = FreeCAD.Units.Quantity(self.formPoint.globalZ.text()).Value
self.pt = FreeCAD.Vector(x, y, z)