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
2942cfffbc
commit
ddf48e0daa
@@ -94,6 +94,7 @@ QVariant Array2DModel::data(const QModelIndex& index, int role) const
|
||||
auto column = _property->getColumnType(index.column());
|
||||
if (column == Materials::MaterialValue::Quantity) {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column()));
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
}
|
||||
@@ -237,6 +238,7 @@ QVariant Array3DDepthModel::data(const QModelIndex& index, int role) const
|
||||
|
||||
try {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(0));
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
catch (const Materials::InvalidIndex&) {
|
||||
@@ -291,7 +293,9 @@ bool Array3DDepthModel::insertRows(int row, int count, const QModelIndex& parent
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
_value->addDepth(row, Base::Quantity(0, _property->getColumnUnits(0)));
|
||||
auto qq = Base::Quantity(0, _property->getColumnUnits(0));
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
_value->addDepth(row, qq);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
@@ -392,6 +396,7 @@ QVariant Array3DModel::data(const QModelIndex& index, int role) const
|
||||
|
||||
try {
|
||||
Base::Quantity qq = Base::Quantity(0, _property->getColumnUnits(index.column() + 1));
|
||||
qq.setFormat(Materials::MaterialValue::getQuantityFormat());
|
||||
return QVariant::fromValue(qq);
|
||||
}
|
||||
catch (const Materials::InvalidIndex&) {
|
||||
|
||||
Reference in New Issue
Block a user