[TD] Improve arbitrary tolerance and unit handling for Equal Tolerances.

This commit is contained in:
Aapo
2021-01-29 01:35:12 +02:00
committed by wwmayer
parent dbef970697
commit f362930664
2 changed files with 19 additions and 16 deletions

View File

@@ -923,17 +923,21 @@ std::string DrawViewDimension::getFormattedDimensionValue(int partial)
{
QString qFormatSpec = QString::fromUtf8(FormatSpec.getStrValue().data());
if (Arbitrary.getValue()) {
if (Arbitrary.getValue() && !EqualTolerance.getValue()) {
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()) {
if (EqualTolerance.getValue() && !TheoreticalExact.getValue() &&
(!DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) || ArbitraryTolerances.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;
if (Arbitrary.getValue()) {
labelText = QString::fromStdString(FormatSpec.getStrValue());
unitText = QString();
}
// 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);

View File

@@ -337,14 +337,10 @@ void QGIDatumLabel::setToleranceString()
if( dim == nullptr ) {
return;
// don't show if both are zero or if EqualTolerance is true
} else if (!dim->hasOverUnderTolerance() || dim->EqualTolerance.getValue()) {
} else if (!dim->hasOverUnderTolerance() || dim->EqualTolerance.getValue() || dim->TheoreticalExact.getValue()) {
m_tolTextOver->hide();
m_tolTextUnder->hide();
return;
} else if (dim->TheoreticalExact.getValue()) {
m_tolTextOver->hide();
m_tolTextUnder->hide();
// we must explicitly empy the text other wise the frame drawn for
// we must explicitly empty the text otherwise the frame drawn for
// TheoreticalExact would be as wide as necessary for the text
m_tolTextOver->setPlainText(QString());
m_tolTextUnder->setPlainText(QString());
@@ -353,11 +349,6 @@ void QGIDatumLabel::setToleranceString()
m_tolTextOver->show();
m_tolTextUnder->show();
QString tolSuffix;
if ((dim->Type.isValue("Angle")) || (dim->Type.isValue("Angle3Pt"))) {
tolSuffix = QString::fromUtf8(dim->getFormattedDimensionValue(2).c_str()); //just the unit
}
std::pair<std::string, std::string> labelTexts, unitTexts;
if (dim->ArbitraryTolerances.getValue()) {
@@ -637,14 +628,22 @@ void QGIViewDimension::updateDim()
QString labelText;
QString unitText;
if (dim->Arbitrary.getValue()) {
if (dim->Arbitrary.getValue() && !dim->EqualTolerance.getValue()) {
labelText = QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); //just the number pref/spec/suf
} else {
if (dim->isMultiValueSchema()) {
labelText = QString::fromUtf8(dim->getFormattedDimensionValue(0).c_str()); //don't format multis
} else {
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 (dim->EqualTolerance.getValue()) {
if (dim->ArbitraryTolerances.getValue()) {
unitText = QString();
} else {
unitText = QString::fromUtf8(dim->getFormattedToleranceValue(2).c_str()); //just the unit
}
} else {
unitText = QString::fromUtf8(dim->getFormattedDimensionValue(2).c_str()); //just the unit
}
}
}
QFont font = datumLabel->getFont();