Materials: Change display of Quantity values
The default display type of quantity objects is fixed point resulting in insufficient accuracy when changing unit systems, or when the values are small. This fix changes the default format from 'Fixed' to the more apt 'Default' format. This allows the displayed values to scale as appropriate. Fixes #18149
This commit is contained in:
committed by
Chris Hennes
parent
939506007d
commit
7e1b1abddd
@@ -48,7 +48,9 @@ TYPESYSTEM_SOURCE(App::PropertyQuantity, App::PropertyFloat)
|
||||
|
||||
Base::Quantity PropertyQuantity::getQuantityValue() const
|
||||
{
|
||||
return Quantity(_dValue, _Unit);
|
||||
Quantity quantity(_dValue, _Unit);
|
||||
quantity.setFormat(_Format);
|
||||
return quantity;
|
||||
}
|
||||
|
||||
const char* PropertyQuantity::getEditorName() const
|
||||
@@ -129,7 +131,9 @@ void PropertyQuantity::setPathValue(const ObjectIdentifier& /*path*/, const boos
|
||||
|
||||
const boost::any PropertyQuantity::getPathValue(const ObjectIdentifier& /*path*/) const
|
||||
{
|
||||
return Quantity(_dValue, _Unit);
|
||||
Quantity quantity(_dValue, _Unit);
|
||||
quantity.setFormat(_Format);
|
||||
return quantity;
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
||||
@@ -73,6 +73,15 @@ public:
|
||||
return PropertyFloat::getValue();
|
||||
}
|
||||
|
||||
const Base::QuantityFormat& getFormat() const
|
||||
{
|
||||
return _Format;
|
||||
}
|
||||
void setFormat(const Base::QuantityFormat& fmt)
|
||||
{
|
||||
_Format = fmt;
|
||||
}
|
||||
|
||||
void setPathValue(const App::ObjectIdentifier& path, const boost::any& value) override;
|
||||
const boost::any getPathValue(const App::ObjectIdentifier& path) const override;
|
||||
|
||||
@@ -89,6 +98,7 @@ public:
|
||||
protected:
|
||||
Base::Quantity createQuantityFromPy(PyObject* value);
|
||||
Base::Unit _Unit;
|
||||
Base::QuantityFormat _Format;
|
||||
};
|
||||
|
||||
/** Float with Unit property
|
||||
|
||||
Reference in New Issue
Block a user