diff --git a/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui index f27a8fd05c..a2143bac66 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageDepthsEdit.ui @@ -6,7 +6,7 @@ 0 0 - 270 + 296 235 @@ -15,17 +15,35 @@ - + <html><head/><body><p>Start Depth of the operation. The highest point in Z-axis the operation needs to process.</p></body></html> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + -999999999.000000000000000 + + + 999999999.000000000000000 + - + <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> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + -999999999.000000000000000 + + + 999999999.000000000000000 + @@ -36,10 +54,19 @@ - + <html><head/><body><p>Depth of the final cut of the operation. Can be used to produce a cleaner finish.</p></body></html> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + -999999999.000000000000000 + + + 999999999.000000000000000 + @@ -71,7 +98,7 @@ - + Qt::Vertical @@ -85,10 +112,19 @@ - + <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> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + -999999999.000000000000000 + + + 999999999.000000000000000 + @@ -131,13 +167,26 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + - Gui::InputField - QLineEdit -
Gui/InputField.h
+ Gui::QuantitySpinBox + QDoubleSpinBox +
Gui/QuantitySpinBox.h
diff --git a/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui index 808f68a104..3dbb2464fd 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui @@ -46,6 +46,9 @@ <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> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + -999999999.000000000000000 @@ -59,6 +62,9 @@ <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> + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + -999999999.000000000000000 diff --git a/src/Mod/Path/PathScripts/PathGui.py b/src/Mod/Path/PathScripts/PathGui.py index 551c38593d..d335023bf6 100644 --- a/src/Mod/Path/PathScripts/PathGui.py +++ b/src/Mod/Path/PathScripts/PathGui.py @@ -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) diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index 6230807184..19e807d86a 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -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(-)")