From 3da41785fc0e6135a68b1849320c0e1fbffe745d Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sat, 7 Oct 2017 19:17:10 -0700 Subject: [PATCH] Refactored QuantitySpinBox handling into separate class. --- .../Path/Gui/Resources/panels/PageHeightsEdit.ui | 6 ++++++ src/Mod/Path/PathScripts/PathGui.py | 15 +++++++++++++++ src/Mod/Path/PathScripts/PathOpGui.py | 14 ++++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui b/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui index 8a742e0ebb..808f68a104 100644 --- a/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PageHeightsEdit.ui @@ -43,6 +43,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> + -999999999.000000000000000 @@ -53,6 +56,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> + -999999999.000000000000000 diff --git a/src/Mod/Path/PathScripts/PathGui.py b/src/Mod/Path/PathScripts/PathGui.py index aee18a7ffc..551c38593d 100644 --- a/src/Mod/Path/PathScripts/PathGui.py +++ b/src/Mod/Path/PathScripts/PathGui.py @@ -54,3 +54,18 @@ def updateInputField(obj, prop, widget, onBeforeChange = None): return True return False +class QuantitySpinBox: + def __init__(self, widget, obj, propName): + self.obj = obj + self.widget = widget + self.prop = propName + + 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 updateProperty(self): + return updateInputField(self.obj, self.prop, self.widget) + diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index 7595578864..6230807184 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -535,21 +535,19 @@ class TaskPanelHeightsPage(TaskPanelPage): return FreeCADGui.PySideUic.loadUi(":/panels/PageHeightsEdit.ui") def initPage(self, obj): - self.form.safeHeight.setProperty('unit', obj.SafeHeight.getUserPreferred()[2]) - self.form.safeHeight.setProperty('binding', "%s.SafeHeight" % obj.Name) - self.form.clearanceHeight.setProperty('unit', obj.ClearanceHeight.getUserPreferred()[2]) - self.form.clearanceHeight.setProperty('binding', "%s.ClearanceHeight" % obj.Name) + self.safeHeight = PathGui.QuantitySpinBox(self.form.safeHeight, obj, 'SafeHeight') + self.clearanceHeight = PathGui.QuantitySpinBox(self.form.clearanceHeight, obj, 'ClearanceHeight') def getTitle(self, obj): return translate("Path", "Heights") def getFields(self, obj): - PathGui.updateInputField(obj, 'SafeHeight', self.form.safeHeight) - PathGui.updateInputField(obj, 'ClearanceHeight', self.form.clearanceHeight) + self.safeHeight.updateProperty() + self.clearanceHeight.updateProperty() def setFields(self, obj): - self.form.safeHeight.setProperty('rawValue', obj.SafeHeight.Value) - self.form.clearanceHeight.setProperty('rawValue', obj.ClearanceHeight.Value) + self.safeHeight.updateSpinBox() + self.clearanceHeight.updateSpinBox() def getSignalsForUpdate(self, obj): signals = []