Switched Depths page to use QuantitySpinBox instead of InputField.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>270</width>
|
||||
<width>296</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -15,17 +15,35 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::InputField" name="startDepth">
|
||||
<widget class="Gui::QuantitySpinBox" name="startDepth">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Start Depth of the operation. The highest point in Z-axis the operation needs to process.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::InputField" name="finalDepth">
|
||||
<widget class="Gui::QuantitySpinBox" name="finalDepth">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The depth of the operation which corresponds to the lowest value in Z-axis the operation needs to process.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@@ -36,10 +54,19 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::InputField" name="finishDepth">
|
||||
<widget class="Gui::QuantitySpinBox" name="finishDepth">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Depth of the final cut of the operation. Can be used to produce a cleaner finish.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
@@ -71,7 +98,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<item row="5" column="0" colspan="4">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -85,10 +112,19 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::InputField" name="stepDown">
|
||||
<widget class="Gui::QuantitySpinBox" name="stepDown">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The depth in Z-axis the operation moves downwards between layers.</p><p><br/></p><p>This value depends on the tool being used, the material to be cut, available cooling and many other factors. Please consult the tool manufacturers data sheets for the proper value.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
@@ -131,13 +167,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<tabstops>
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The height above which it is safe to move the tool bit with rapid movements. Below this height all lateral and downward movements are performed with feed rate speeds.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
@@ -59,6 +62,9 @@
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The height where lateral movement of the toolbit is not obstructed by any fixtures or the part / stock material itself.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999999.000000000000000</double>
|
||||
</property>
|
||||
|
||||
@@ -40,6 +40,11 @@ __author__ = "sliptonic (Brad Collette)"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
__doc__ = "A collection of helper and utility functions for the Path GUI."
|
||||
|
||||
if False:
|
||||
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
|
||||
PathLog.trackModule(PathLog.thisModule())
|
||||
else:
|
||||
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
|
||||
|
||||
def updateInputField(obj, prop, widget, onBeforeChange = None):
|
||||
'''updateInputField(obj, prop, widget) ... helper function to update obj's property named prop with the value from widget, if it has changed.'''
|
||||
@@ -55,17 +60,20 @@ def updateInputField(obj, prop, widget, onBeforeChange = None):
|
||||
return False
|
||||
|
||||
class QuantitySpinBox:
|
||||
def __init__(self, widget, obj, propName):
|
||||
def __init__(self, widget, obj, propName, onBeforeChange=None):
|
||||
self.obj = obj
|
||||
self.widget = widget
|
||||
self.prop = propName
|
||||
self.onBeforeChange = onBeforeChange
|
||||
|
||||
widget.setProperty('unit', getattr(self.obj, self.prop).getUserPreferred()[2])
|
||||
widget.setProperty('binding', "%s.%s" % (obj.Name, propName))
|
||||
|
||||
def updateSpinBox(self):
|
||||
self.widget.setProperty('rawValue', getattr(self.obj, self.prop).Value)
|
||||
def updateSpinBox(self, quantity=None):
|
||||
if quantity is None:
|
||||
quantity = getattr(self.obj, self.prop)
|
||||
self.widget.setProperty('rawValue', quantity.Value)
|
||||
|
||||
def updateProperty(self):
|
||||
return updateInputField(self.obj, self.prop, self.widget)
|
||||
return updateInputField(self.obj, self.prop, self.widget, self.onBeforeChange)
|
||||
|
||||
|
||||
@@ -580,6 +580,11 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
self.form.finishDepth.hide()
|
||||
self.form.finishDepthLabel.hide()
|
||||
|
||||
self.startDepth = PathGui.QuantitySpinBox(self.form.startDepth, obj, 'StartDepth', self.lockStartDepth)
|
||||
self.finalDepth = PathGui.QuantitySpinBox(self.form.finalDepth, obj, 'FinalDepth', self.lockFinalDepth)
|
||||
self.finishDepth = PathGui.QuantitySpinBox(self.form.finishDepth, obj, 'FinishDepth')
|
||||
self.stepDown = PathGui.QuantitySpinBox(self.form.stepDown, obj, 'StepDown')
|
||||
|
||||
def getTitle(self, obj):
|
||||
return translate("PathOp", "Depths")
|
||||
|
||||
@@ -596,24 +601,24 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
if obj.FinalDepthLock != self.form.finalDepthLock.isChecked():
|
||||
obj.FinalDepthLock = self.form.finalDepthLock.isChecked()
|
||||
|
||||
PathGui.updateInputField(obj, 'StartDepth', self.form.startDepth, self.lockStartDepth)
|
||||
self.startDepth.updateProperty()
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
PathGui.updateInputField(obj, 'FinalDepth', self.form.finalDepth, self.lockFinalDepth)
|
||||
self.finalDepth.updateProperty()
|
||||
if PathOp.FeatureStepDown & self.features:
|
||||
PathGui.updateInputField(obj, 'StepDown', self.form.stepDown)
|
||||
self.stepDown.updateProperty()
|
||||
if PathOp.FeatureFinishDepth & self.features:
|
||||
PathGui.updateInputField(obj, 'FinishDepth', self.form.finishDepth)
|
||||
self.finishDepth.updateProperty()
|
||||
|
||||
def setFields(self, obj):
|
||||
self.form.startDepth.setText(FreeCAD.Units.Quantity(obj.StartDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.startDepth.updateSpinBox()
|
||||
self.form.startDepthLock.setChecked(obj.StartDepthLock)
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.form.finalDepth.setText(FreeCAD.Units.Quantity(obj.FinalDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.finalDepth.updateSpinBox()
|
||||
self.form.finalDepthLock.setChecked(obj.FinalDepthLock)
|
||||
if PathOp.FeatureStepDown & self.features:
|
||||
self.form.stepDown.setText(FreeCAD.Units.Quantity(obj.StepDown.Value, FreeCAD.Units.Length).UserString)
|
||||
self.stepDown.updateSpinBox()
|
||||
if PathOp.FeatureFinishDepth & self.features:
|
||||
self.form.finishDepth.setText(FreeCAD.Units.Quantity(obj.FinishDepth.Value, FreeCAD.Units.Length).UserString)
|
||||
self.finishDepth.updateSpinBox()
|
||||
self.updateSelection(obj, FreeCADGui.Selection.getSelectionEx())
|
||||
|
||||
def getSignalsForUpdate(self, obj):
|
||||
@@ -630,20 +635,20 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
return signals
|
||||
|
||||
def registerSignalHandlers(self, obj):
|
||||
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.form.startDepth))
|
||||
self.form.startDepthSet.clicked.connect(lambda: self.depthSet(obj, self.startDepth))
|
||||
if not PathOp.FeatureNoFinalDepth & self.features:
|
||||
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.form.finalDepth))
|
||||
self.form.finalDepthSet.clicked.connect(lambda: self.depthSet(obj, self.finalDepth))
|
||||
|
||||
def pageUpdateData(self, obj, prop):
|
||||
if prop in ['StartDepth', 'FinalDepth', 'StepDown', 'FinishDepth', 'FinalDepthLock', 'StartDepthLock']:
|
||||
self.setFields(obj)
|
||||
|
||||
def depthSet(self, obj, widget):
|
||||
def depthSet(self, obj, spinbox):
|
||||
z = self.selectionZLevel(FreeCADGui.Selection.getSelectionEx())
|
||||
if z is not None:
|
||||
PathLog.debug("depthSet(%.2f)" % z)
|
||||
widget.setText(FreeCAD.Units.Quantity(z, FreeCAD.Units.Length).UserString)
|
||||
self.getFields(obj)
|
||||
spinbox.updateSpinBox(FreeCAD.Units.Quantity(z, FreeCAD.Units.Length))
|
||||
spinbox.updateProperty()
|
||||
else:
|
||||
PathLog.info("depthSet(-)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user