[TD] Make tolerance labels use the same formatValue() conversion as dimension labels. Support MultiValueSchemas for tolerances, too.

This commit is contained in:
Aapo
2020-11-27 17:43:38 +02:00
committed by wwmayer
parent c695b4009b
commit 768a2b1f11
2 changed files with 11 additions and 9 deletions

View File

@@ -577,6 +577,7 @@ 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;
} else if ((unitSystem == Base::UnitSystem::ImperialCivil) &&
angularMeasure) {
QString dispMinute = QString::fromUtf8("\'");
@@ -591,6 +592,7 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
// prefix + 48*30'30" + suffix
qMultiValueStr = formatPrefix + qGenPrefix + displaySub + formatSuffix;
}
formattedValue = qMultiValueStr;
} else {
//handle single value schemes
if (formatSpecifier.isEmpty()) {
@@ -702,7 +704,7 @@ QStringList DrawViewDimension::getPrefixSuffixSpec(QString fSpec)
QString formatSuffix;
QString formatted;
//find the %x.y tag in FormatSpec
QRegExp rxFormat(QString::fromUtf8("%[0-9]*\\.*[0-9]*[aefgAEFG]")); //printf double format spec
QRegExp rxFormat(QString::fromUtf8("%[+-]*[0-9]*\\.*[0-9]*[aefgAEFG]")); //printf double format spec
QString match;
int pos = 0;
if ((pos = rxFormat.indexIn(fSpec, 0)) != -1) {

View File

@@ -357,14 +357,14 @@ void QGIDatumLabel::setTolString()
QString overFormat;
QString underFormat;
#if QT_VERSION >= 0x050000
overFormat = QString::asprintf(qsFormatOver.toStdString().c_str(), overTol);
underFormat = QString::asprintf(qsFormatUnder.toStdString().c_str(), underTol);
#else
QString qs2;
overFormat = qs2.sprintf(qsFormatOver.toStdString().c_str(), overTol);
underFormat = qs2.sprintf(qsFormatUnder.toStdString().c_str(), underTol);
#endif
if (dim->isMultiValueSchema()) {
overFormat = QString::fromUtf8(dim->formatValue(overTol, qsFormatOver, 0).c_str());
underFormat = QString::fromUtf8(dim->formatValue(underTol, qsFormatUnder, 0).c_str());
} else {
overFormat = QString::fromUtf8(dim->formatValue(overTol, qsFormatOver, 1).c_str());
underFormat = QString::fromUtf8(dim->formatValue(underTol, qsFormatUnder, 1).c_str());
}
m_tolTextOver->setPlainText(overFormat + tolSuffix);
m_tolTextUnder->setPlainText(underFormat + tolSuffix);