From 5350a2c3d088c873dcf757ccfb775128b37ad72a Mon Sep 17 00:00:00 2001 From: Aapo Date: Sun, 24 Jan 2021 18:39:31 +0200 Subject: [PATCH] [TD] Fix degree sign processing for equilateral angular plusminus dimensions. --- src/Mod/TechDraw/App/DrawViewDimension.cpp | 23 ++++++++++++++++++++++ src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 11 ----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index bb28a7ca53..cccbef2aac 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -902,6 +902,29 @@ std::string DrawViewDimension::getFormattedDimensionValue(int partial) return FormatSpec.getStrValue(); } + // if there is an equal over-/undertolerance and not theoretically exact, add the tolerance to dimension + if (EqualTolerance.getValue() && !DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) + && !TheoreticalExact.getValue()) { + QString labelText = QString::fromUtf8(formatValue(getDimValue(), qFormatSpec, 1).c_str()); //just the number pref/spec/suf + QString unitText = QString::fromUtf8(formatValue(getDimValue(), qFormatSpec, 2).c_str()); //just the unit + QString tolerance = QString::fromStdString(getFormattedToleranceValue(1).c_str()); + QString result; + // tolerance might start with a plus sign that we don't want, so cut it off + if (tolerance.at(0) == QChar::fromLatin1('+')) + tolerance.remove(0, 1); + if ((Type.isValue("Angle")) || (Type.isValue("Angle3Pt"))) { + result = labelText + unitText + QString::fromUtf8(" \xC2\xB1 ") + tolerance; + } else { + // add the tolerance to the dimension using the ± sign + result = labelText + QString::fromUtf8(" \xC2\xB1 ") + tolerance; + } + if (partial == 2) { + result = unitText; + } + + return result.toStdString(); + } + return formatValue(getDimValue(), qFormatSpec, partial); } diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index b16d4c7763..56068b52c4 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -646,17 +646,6 @@ void QGIViewDimension::updateDim() labelText = QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); //just the number pref/spec/suf unitText = QString::fromUtf8(dim->getFormattedDimensionValue(2).c_str()); //just the unit } - // if there is an equal over-/undertolerance and not theoretically exact, add the tolerance to dimension - if (dim->EqualTolerance.getValue() && !DrawUtil::fpCompare(dim->OverTolerance.getValue(), 0.0) - && !dim->TheoreticalExact.getValue()) { - std::pair ToleranceText, ToleranceUnit; - QString tolerance = QString::fromStdString(dim->getFormattedToleranceValue(1).c_str()); - // tolerance might start with a plus sign that we don't want, so cut it off - if (tolerance.at(0) == QChar::fromLatin1('+')) - tolerance.remove(0, 1); - // add the tolerance to the dimension using the ± sign - labelText = labelText + QString::fromUtf8(" \xC2\xB1 ") + tolerance; - } } QFont font = datumLabel->getFont(); font.setFamily(QString::fromUtf8(vp->Font.getValue()));