Skip to content

Commit

Permalink
[TD] Make tolerance labels use the same formatValue() conversion as d…
Browse files Browse the repository at this point in the history
…imension labels. Support MultiValueSchemas for tolerances, too.
  • Loading branch information
aapo-aapo authored and wwmayer committed Dec 2, 2020
1 parent c695b40 commit 768a2b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -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("\'");
Expand All @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 8 additions & 8 deletions src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 768a2b1

Please sign in to comment.