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:
David Carter
2024-12-11 09:26:06 -05:00
committed by Chris Hennes
parent 939506007d
commit 7e1b1abddd
12 changed files with 179 additions and 86 deletions

View File

@@ -81,6 +81,8 @@
using namespace Part;
namespace sp = std::placeholders;
constexpr const int MaterialPrecision = 6;
FC_LOG_LEVEL_INIT("Part",true,true)
PROPERTY_SOURCE(Part::Feature, App::GeoFeature)
@@ -106,18 +108,24 @@ Feature::Feature()
static_cast<App::PropertyType>(App::Prop_ReadOnly | App::Prop_Output
| App::Prop_NoRecompute | App::Prop_NoPersist),
"Feature density");
Density.setFormat(
Base::QuantityFormat(Base::QuantityFormat::NumberFormat::Default, MaterialPrecision));
ADD_PROPERTY_TYPE(Mass,
(0.0),
group,
static_cast<App::PropertyType>(App::Prop_ReadOnly | App::Prop_Output
| App::Prop_NoRecompute | App::Prop_NoPersist),
"Feature mass");
Mass.setFormat(
Base::QuantityFormat(Base::QuantityFormat::NumberFormat::Default, MaterialPrecision));
ADD_PROPERTY_TYPE(Volume,
(1.0),
group,
static_cast<App::PropertyType>(App::Prop_ReadOnly | App::Prop_Output
| App::Prop_NoRecompute | App::Prop_NoPersist),
"Feature volume");
Volume.setFormat(
Base::QuantityFormat(Base::QuantityFormat::NumberFormat::Default, MaterialPrecision));
}
Feature::~Feature() = default;
@@ -1553,7 +1561,6 @@ void Feature::updatePhysicalProperties()
Mass.setValue(Volume.getValue() * Density.getValue());
} else {
// No shape
Base::Console().Log("No shape defined\n");
Volume.setValue(0.0);
Mass.setValue(0.0);
}