Path: Fix bug with inaccurate Task Panel values upon new op creation
Path: Fix bug with inaccurate Task Panel values upon new op creation
This commit is contained in:
@@ -100,6 +100,7 @@ class QuantitySpinBox:
|
||||
self.widget = widget
|
||||
self.onBeforeChange = onBeforeChange
|
||||
self.prop = None
|
||||
self.obj = obj
|
||||
self.attachTo(obj, prop)
|
||||
|
||||
def attachTo(self, obj, prop = None):
|
||||
@@ -139,9 +140,14 @@ class QuantitySpinBox:
|
||||
If no value is provided the value of the bound property is used.
|
||||
quantity can be of type Quantity or Float.'''
|
||||
PathLog.track(self.prop, self.valid)
|
||||
|
||||
if self.valid:
|
||||
expr = self._hasExpression()
|
||||
if quantity is None:
|
||||
quantity = PathUtil.getProperty(self.obj, self.prop)
|
||||
if expr:
|
||||
quantity = FreeCAD.Units.Quantity(self.obj.evalExpression(expr))
|
||||
else:
|
||||
quantity = PathUtil.getProperty(self.obj, self.prop)
|
||||
value = quantity.Value if hasattr(quantity, 'Value') else quantity
|
||||
self.widget.setProperty('rawValue', value)
|
||||
|
||||
@@ -151,3 +157,9 @@ class QuantitySpinBox:
|
||||
if self.valid:
|
||||
return updateInputField(self.obj, self.prop, self.widget, self.onBeforeChange)
|
||||
return None
|
||||
|
||||
def _hasExpression(self):
|
||||
for (prop, exp) in self.obj.ExpressionEngine:
|
||||
if prop == self.prop:
|
||||
return exp
|
||||
return None
|
||||
|
||||
@@ -1203,7 +1203,18 @@ class TaskPanel(object):
|
||||
page.clearBase()
|
||||
page.addBaseGeometry(sel)
|
||||
|
||||
# Update properties based upon expressions in case expression value has changed
|
||||
for (prp, expr) in self.obj.ExpressionEngine:
|
||||
val = FreeCAD.Units.Quantity(self.obj.evalExpression(expr))
|
||||
value = val.Value if hasattr(val, 'Value') else val
|
||||
prop = getattr(self.obj, prp)
|
||||
if hasattr(prop, "Value"):
|
||||
prop.Value = value
|
||||
else:
|
||||
prop = value
|
||||
|
||||
self.panelSetFields()
|
||||
|
||||
for page in self.featurePages:
|
||||
page.pageRegisterSignalHandlers()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user