From fca3b80da88fb5089aae4e5e851d03259dacad0b Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 14 Mar 2024 14:22:29 -0400 Subject: [PATCH] [TD]fix over/under tolerance - left justify tolerances - use format spec for tolerance == zero - prevent uncommanded tolerance format changes - use 'w' format for HoleShaftFit - allow zero tolerance values for HoleShaftFit --- src/Mod/TechDraw/App/DimensionFormatter.cpp | 25 +++++-------------- src/Mod/TechDraw/App/DrawViewDimension.cpp | 4 +-- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 13 +++------- .../TechDrawTools/TaskHoleShaftFit.py | 10 +++----- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/Mod/TechDraw/App/DimensionFormatter.cpp b/src/Mod/TechDraw/App/DimensionFormatter.cpp index 7508a9d9c4..1c78d2357e 100644 --- a/src/Mod/TechDraw/App/DimensionFormatter.cpp +++ b/src/Mod/TechDraw/App/DimensionFormatter.cpp @@ -191,6 +191,9 @@ std::string DimensionFormatter::formatValue(const qreal value, return formattedValueString; } + +//! get the formatted OverTolerance value +// wf: is this a leftover from when we only had 1 tolerance instead of over/under? std::string DimensionFormatter::getFormattedToleranceValue(const int partial) const { QString FormatSpec = QString::fromUtf8(m_dimension->FormatSpecOverTolerance.getStrValue().data()); @@ -207,7 +210,7 @@ std::string DimensionFormatter::getFormattedToleranceValue(const int partial) co return ToleranceString.toStdString(); } -//get over and under tolerances +//! get formatted over and under tolerances std::pair DimensionFormatter::getFormattedToleranceValues(const int partial) const { QString underFormatSpec = QString::fromUtf8(m_dimension->FormatSpecUnderTolerance.getStrValue().data()); @@ -219,30 +222,14 @@ std::pair DimensionFormatter::getFormattedToleranceVal underTolerance = underFormatSpec; overTolerance = overFormatSpec; } else { - if (DrawUtil::fpCompare(m_dimension->UnderTolerance.getValue(), 0.0)) { - underTolerance = QString::fromUtf8(formatValue(m_dimension->UnderTolerance.getValue(), - QString::fromUtf8("%.0f"), - partial, - false).c_str()); - } - else { - underTolerance = QString::fromUtf8(formatValue(m_dimension->UnderTolerance.getValue(), + underTolerance = QString::fromUtf8(formatValue(m_dimension->UnderTolerance.getValue(), underFormatSpec, partial, false).c_str()); - } - if (DrawUtil::fpCompare(m_dimension->OverTolerance.getValue(), 0.0)) { - overTolerance = QString::fromUtf8(formatValue(m_dimension->OverTolerance.getValue(), - QString::fromUtf8("%.0f"), - partial, - false).c_str()); - } - else { - overTolerance = QString::fromUtf8(formatValue(m_dimension->OverTolerance.getValue(), + overTolerance = QString::fromUtf8(formatValue(m_dimension->OverTolerance.getValue(), overFormatSpec, partial, false).c_str()); - } } tolerances.first = underTolerance.toStdString(); diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index dfff03bf85..6a2c692796 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -302,12 +302,12 @@ void DrawViewDimension::onChanged(const App::Property* prop) } } else if (prop == &FormatSpecOverTolerance) { - if (!ArbitraryTolerances.getValue()) { + if (EqualTolerance.getValue() && !ArbitraryTolerances.getValue()) { FormatSpecUnderTolerance.setValue(FormatSpecOverTolerance.getValue()); } } else if (prop == &FormatSpecUnderTolerance) { - if (!ArbitraryTolerances.getValue()) { + if (EqualTolerance.getValue() && !ArbitraryTolerances.getValue()) { FormatSpecOverTolerance.setValue(FormatSpecUnderTolerance.getValue()); } } diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index 1064c7d17f..451217ed51 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -275,20 +275,13 @@ void QGIDatumLabel::setPosFromCenter(const double& xCenter, const double& yCente //set tolerance position QRectF overBox = m_tolTextOver->boundingRect(); - double overWidth = overBox.width(); - QRectF underBox = m_tolTextUnder->boundingRect(); - double underWidth = underBox.width(); - double width = underWidth; - if (overWidth > underWidth) { - width = overWidth; - } - double tolRight = unitRight + width; + double tolLeft = unitRight; // Adjust for difference in tight and original bounding box sizes, note the y-coord down system QPointF tol_adj = m_tolTextOver->tightBoundingAdjust(); - m_tolTextOver->justifyRightAt(tolRight + tol_adj.x(), middle - tol_adj.y(), false); + m_tolTextOver->justifyLeftAt(tolLeft + tol_adj.x(), middle - tol_adj.y(), false); tol_adj = m_tolTextUnder->tightBoundingAdjust(); - m_tolTextUnder->justifyRightAt(tolRight + tol_adj.x(), middle + overBox.height() - tol_adj.y(), + m_tolTextUnder->justifyLeftAt(tolLeft + tol_adj.x(), middle + overBox.height() - tol_adj.y(), false); } diff --git a/src/Mod/TechDraw/TechDrawTools/TaskHoleShaftFit.py b/src/Mod/TechDraw/TechDrawTools/TaskHoleShaftFit.py index ff216862d1..a96aa0062e 100644 --- a/src/Mod/TechDraw/TechDrawTools/TaskHoleShaftFit.py +++ b/src/Mod/TechDraw/TechDrawTools/TaskHoleShaftFit.py @@ -116,7 +116,8 @@ class TaskHoleShaftFit: mainFormat = dim.FormatSpec dim.FormatSpec = mainFormat+' '+selectedField dim.EqualTolerance = False - dim.FormatSpecOverTolerance = '(%+.3f)' + dim.FormatSpecOverTolerance = '(%-0.6w)' + dim.FormatSpecUnderTolerance = '(%-0.6w)' dim.OverTolerance = rangeValues[0] dim.UnderTolerance = rangeValues[1] Gui.Control.closeDialog() @@ -178,12 +179,9 @@ class ISO286: if fieldChar == 'H': self.upperValue = -self.lowerValue self.lowerValue = 0 - # hack to print zero tolerance value as (+0.000) - if self.upperValue == 0: - self.upperValue = 0.1 - if self.lowerValue == 0: - self.lowerValue = 0.1 def getValues(self): '''return range values in mm''' return (self.upperValue/1000,self.lowerValue/1000) + +