Draft: Added grid extension control in WorkingPlane task panel

This commit is contained in:
Yorik van Havre
2020-10-15 12:30:16 +02:00
parent c6374bc102
commit 5193120ff5
2 changed files with 33 additions and 4 deletions

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>547</height>
<width>210</width>
<height>568</height>
</rect>
</property>
<property name="windowTitle">
@@ -192,7 +192,7 @@ will be moved to the center of the view</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QSpinBox" name="fieldSnapRadius">
<property name="toolTip">
<string>The distance at which a point can be snapped to
@@ -201,7 +201,7 @@ value by using the [ and ] keys while drawing</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="toolTip">
<string>The distance at which a point can be snapped to
@@ -213,6 +213,26 @@ value by using the [ and ] keys while drawing</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Grid extension</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="fieldGridExtension">
<property name="suffix">
<string> lines</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -102,6 +102,7 @@ class Draft_SelectPlane:
q = FreeCAD.Units.Quantity(self.param.GetFloat("gridSpacing", 1.0), FreeCAD.Units.Length)
self.taskd.form.fieldGridSpacing.setText(q.UserString)
self.taskd.form.fieldGridMainLine.setValue(self.param.GetInt("gridEvery", 10))
self.taskd.form.fieldGridExtension.setValue(self.param.GetInt("gridSize", 100))
self.taskd.form.fieldSnapRadius.setValue(self.param.GetInt("snapRange", 8))
# Set icons
@@ -126,6 +127,7 @@ class Draft_SelectPlane:
self.taskd.form.buttonPrevious.clicked.connect(self.onClickPrevious)
self.taskd.form.fieldGridSpacing.textEdited.connect(self.onSetGridSize)
self.taskd.form.fieldGridMainLine.valueChanged.connect(self.onSetMainline)
self.taskd.form.fieldGridExtension.valueChanged.connect(self.onSetExtension)
self.taskd.form.fieldSnapRadius.valueChanged.connect(self.onSetSnapRadius)
# Try to find a WP from the current selection
@@ -475,6 +477,13 @@ class Draft_SelectPlane:
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.setGrid()
def onSetExtension(self, i):
"""Execute when setting grid extension."""
if i > 1:
self.param.SetInt("gridSize", i)
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.setGrid()
def onSetSnapRadius(self, i):
"""Execute when setting the snap radius."""
self.param.SetInt("snapRange", i)