[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
This commit is contained in:
@@ -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<std::string, std::string> DimensionFormatter::getFormattedToleranceValues(const int partial) const
|
||||
{
|
||||
QString underFormatSpec = QString::fromUtf8(m_dimension->FormatSpecUnderTolerance.getStrValue().data());
|
||||
@@ -219,30 +222,14 @@ std::pair<std::string, std::string> 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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user