Skip to content

Commit

Permalink
[TD] Fix regression in Dimensions: Setting arbitrary under tolerance …
Browse files Browse the repository at this point in the history
…was somehow lost.
  • Loading branch information
aapo-aapo authored and wwmayer committed Jan 31, 2021
1 parent 4ab3c95 commit d26b654
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -111,7 +111,8 @@ DrawViewDimension::DrawViewDimension(void)
References3D.setScope(App::LinkScope::Global);

ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output,"Dimension Format");
ADD_PROPERTY_TYPE(FormatSpecTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension tolerance format");
ADD_PROPERTY_TYPE(FormatSpecUnderTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension tolerance format");
ADD_PROPERTY_TYPE(FormatSpecOverTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension tolerance format");
ADD_PROPERTY_TYPE(Arbitrary,(false), "Format", App::Prop_Output, "Value overridden by user");
ADD_PROPERTY_TYPE(ArbitraryTolerances, (false), "Format", App::Prop_Output, "Tolerance values overridden by user");

Expand Down Expand Up @@ -846,11 +847,12 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
}

return result;

}

std::string DrawViewDimension::getFormattedToleranceValue(int partial)
{
QString FormatSpec = QString::fromUtf8(FormatSpecTolerance.getStrValue().data());
QString FormatSpec = QString::fromUtf8(FormatSpecOverTolerance.getStrValue().data());
QString ToleranceString;

if (ArbitraryTolerances.getValue())
Expand All @@ -863,25 +865,26 @@ std::string DrawViewDimension::getFormattedToleranceValue(int partial)

std::pair<std::string, std::string> DrawViewDimension::getFormattedToleranceValues(int partial)
{
QString FormatSpec = QString::fromUtf8(FormatSpecTolerance.getStrValue().data());
QString underFormatSpec = QString::fromUtf8(FormatSpecUnderTolerance.getStrValue().data());
QString overFormatSpec = QString::fromUtf8(FormatSpecOverTolerance.getStrValue().data());
std::pair<std::string, std::string> tolerances;
QString underTolerance, overTolerance;

if (ArbitraryTolerances.getValue()) {
underTolerance = FormatSpec;
overTolerance = FormatSpec;
underTolerance = underFormatSpec;
overTolerance = overFormatSpec;
} else {
if (DrawUtil::fpCompare(UnderTolerance.getValue(), 0.0)) {
underTolerance = QString::fromUtf8(formatValue(UnderTolerance.getValue(), QString::fromUtf8("%.0f"), partial).c_str());
}
else {
underTolerance = QString::fromUtf8(formatValue(UnderTolerance.getValue(), FormatSpec, partial).c_str());
underTolerance = QString::fromUtf8(formatValue(UnderTolerance.getValue(), underFormatSpec, partial).c_str());
}
if (DrawUtil::fpCompare(OverTolerance.getValue(), 0.0)) {
overTolerance = QString::fromUtf8(formatValue(OverTolerance.getValue(), QString::fromUtf8("%.0f"), partial).c_str());
}
else {
overTolerance = QString::fromUtf8(formatValue(OverTolerance.getValue(), FormatSpec, partial).c_str());
overTolerance = QString::fromUtf8(formatValue(OverTolerance.getValue(), overFormatSpec, partial).c_str());
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Mod/TechDraw/App/DrawViewDimension.h
Expand Up @@ -102,7 +102,8 @@ class TechDrawExport DrawViewDimension : public TechDraw::DrawView
App::PropertyBool TheoreticalExact;
App::PropertyBool Inverted;
App::PropertyString FormatSpec;
App::PropertyString FormatSpecTolerance;
App::PropertyString FormatSpecUnderTolerance;
App::PropertyString FormatSpecOverTolerance;
App::PropertyBool Arbitrary;
App::PropertyBool ArbitraryTolerances;
App::PropertyBool EqualTolerance;
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/TaskDimension.cpp
Expand Up @@ -98,7 +98,7 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di
connect(ui->leFormatSpecifier, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierChanged()));
ui->cbArbitrary->setChecked(parent->dvDimension->Arbitrary.getValue());
connect(ui->cbArbitrary, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryChanged()));
StringValue = parent->dvDimension->FormatSpecTolerance.getValue();
StringValue = parent->dvDimension->FormatSpecOverTolerance.getValue();
qs = QString::fromUtf8(StringValue.data(), StringValue.size());
ui->leToleranceFormatSpecifier->setText(qs);
connect(ui->leToleranceFormatSpecifier, SIGNAL(textChanged(QString)), this, SLOT(onToleranceFormatSpecifierChanged()));
Expand Down Expand Up @@ -133,7 +133,7 @@ bool TaskDimension::accept()

m_parent->dvDimension->FormatSpec.setValue(ui->leFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->Arbitrary.setValue(ui->cbArbitrary->isChecked());
m_parent->dvDimension->FormatSpecTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->ArbitraryTolerances.setValue(ui->cbArbitraryTolerances->isChecked());

m_dimensionVP->FlipArrowheads.setValue(ui->cbArrowheads->isChecked());
Expand Down Expand Up @@ -234,7 +234,7 @@ void TaskDimension::onArbitraryChanged()

void TaskDimension::onToleranceFormatSpecifierChanged()
{
m_parent->dvDimension->FormatSpecTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
recomputeFeature();
}

Expand Down

0 comments on commit d26b654

Please sign in to comment.