[TD] treat dimensions the same way, no matter if with unit or not

fixes the issue reported here: https://forum.freecadweb.org/viewtopic.php?f=35&t=52545&start=40#p454483
This commit is contained in:
donovaly
2020-12-05 03:58:39 +01:00
parent 60a6e8e36e
commit 36686f78b1

View File

@@ -691,21 +691,12 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
// - the value in the base unit but without displayed unit
// - the value + unit (not necessarily the base unit!)
// the user can overwrite the decimal settings, so we must in every case use the formatSpecifier
// if useDecimals(), then formatSpecifier = global decimals, otherwise it is %.2f
// the default is: if useDecimals(), then formatSpecifier = global decimals, otherwise it is %.2f
QLocale loc;
double userVal;
bool checkDecimals = true;
if (showUnits() || (Type.isValue("Angle")) || (Type.isValue("Angle3Pt"))) {
formattedValue = qUserString; // result value + unit (not necessarily base unit!)
// remove unit
formattedValue.remove(rxUnits);
// to number
userVal = loc.toDouble(formattedValue);
if (userVal >= 1.0)
// we can assure we didn't make an error > 10% via getUserString()
checkDecimals = false;
}
if (checkDecimals){
userVal = asQuantity.getValue();
} else {
// get value in the base unit with default decimals
// for the conversion we use the same method as in DlgUnitsCalculator::valueChanged
// get the conversion factor for the unit
@@ -750,7 +741,6 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
//qUserString from Quantity includes units - prefix + R + nnn ft + suffix
qMultiValueStr = formatPrefix + qGenPrefix + qUserString + formatSuffix;
}
formattedValue = qMultiValueStr;
}