Merge pull request #4109 from donovaly/TD-dimensioning-fix

[TD] treat dimensions the same way, no matter if with unit or not
This commit is contained in:
Yorik van Havre
2020-12-14 12:08:46 +01:00
committed by GitHub

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;
}