Gui: properly handle small quantities in property editor
This commit is contained in:
@@ -1051,8 +1051,8 @@ void PropertyUnitItem::setValue(const QVariant& value)
|
||||
return;
|
||||
const Base::Quantity& val = value.value<Base::Quantity>();
|
||||
|
||||
QString unit = QString::fromLatin1("'%1 %2'").arg(val.getValue(),0,'f',decimals())
|
||||
.arg(val.getUnit().getString());
|
||||
Base::QuantityFormat format(Base::QuantityFormat::Default, decimals());
|
||||
QString unit = Base::UnitsApi::toString(val, format);
|
||||
setPropertyValue(unit);
|
||||
}
|
||||
}
|
||||
@@ -1643,10 +1643,12 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant)
|
||||
Base::Quantity x = Base::Quantity(value.x, Base::Unit::Length);
|
||||
Base::Quantity y = Base::Quantity(value.y, Base::Unit::Length);
|
||||
Base::Quantity z = Base::Quantity(value.z, Base::Unit::Length);
|
||||
|
||||
Base::QuantityFormat format(Base::QuantityFormat::Default, decimals());
|
||||
QString data = QString::fromLatin1("(%1, %2, %3)")
|
||||
.arg(x.getValue(),0,'f',decimals())
|
||||
.arg(y.getValue(),0,'f',decimals())
|
||||
.arg(z.getValue(),0,'f',decimals());
|
||||
.arg(Base::UnitsApi::toNumber(x, format))
|
||||
.arg(Base::UnitsApi::toNumber(y, format))
|
||||
.arg(Base::UnitsApi::toNumber(z, format));
|
||||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
@@ -2368,16 +2370,17 @@ void PropertyPlacementItem::setValue(const QVariant& value)
|
||||
const Base::Placement& val = value.value<Base::Placement>();
|
||||
Base::Vector3d pos = val.getPosition();
|
||||
|
||||
Base::QuantityFormat format(Base::QuantityFormat::Default, decimals());
|
||||
QString data = QString::fromLatin1("App.Placement("
|
||||
"App.Vector(%1,%2,%3),"
|
||||
"App.Rotation(App.Vector(%4,%5,%6),%7))")
|
||||
.arg(pos.x, 0, 'f', decimals())
|
||||
.arg(pos.y, 0, 'f', decimals())
|
||||
.arg(pos.z, 0, 'f', decimals())
|
||||
.arg(rot_axis.x, 0, 'f', decimals())
|
||||
.arg(rot_axis.y, 0, 'f', decimals())
|
||||
.arg(rot_axis.z, 0, 'f', decimals())
|
||||
.arg(rot_angle, 0, 'f', decimals());
|
||||
.arg(Base::UnitsApi::toNumber(pos.x, format))
|
||||
.arg(Base::UnitsApi::toNumber(pos.y, format))
|
||||
.arg(Base::UnitsApi::toNumber(pos.z, format))
|
||||
.arg(Base::UnitsApi::toNumber(rot_axis.x, format))
|
||||
.arg(Base::UnitsApi::toNumber(rot_axis.y, format))
|
||||
.arg(Base::UnitsApi::toNumber(rot_axis.z, format))
|
||||
.arg(Base::UnitsApi::toNumber(rot_angle, format));
|
||||
setPropertyValue(data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user