[TD] Add under- and overtolerances for Dimension Task layout, fixes for Dimension tolerance refresh and behavior.

This commit is contained in:
Aapo
2021-01-27 21:46:22 +02:00
committed by wwmayer
parent 5350a2c3d0
commit dbef970697
5 changed files with 93 additions and 23 deletions

View File

@@ -110,9 +110,9 @@ DrawViewDimension::DrawViewDimension(void)
ADD_PROPERTY_TYPE(References3D, (0,0), "", (App::Prop_None), "3D Geometry References");
References3D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output,"Dimension 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(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output,"Dimension format");
ADD_PROPERTY_TYPE(FormatSpecOverTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension overtolerance format");
ADD_PROPERTY_TYPE(FormatSpecUnderTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension undertolerance 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");
@@ -143,6 +143,7 @@ DrawViewDimension::DrawViewDimension(void)
// by default EqualTolerance is true, thus make UnderTolerance read-only
UnderTolerance.setStatus(App::Property::ReadOnly, true);
FormatSpecUnderTolerance.setStatus(App::Property::ReadOnly, true);
measurement = new Measure::Measurement();
//TODO: should have better initial datumLabel position than (0,0) in the DVP?? something closer to the object being measured?
@@ -213,11 +214,16 @@ void DrawViewDimension::onChanged(const App::Property* prop)
UnderTolerance.setValue(0.0);
OverTolerance.setReadOnly(true);
UnderTolerance.setReadOnly(true);
FormatSpecOverTolerance.setReadOnly(true);
FormatSpecUnderTolerance.setReadOnly(true);
}
else {
OverTolerance.setReadOnly(false);
if (!EqualTolerance.getValue())
FormatSpecOverTolerance.setReadOnly(false);
if (!EqualTolerance.getValue()) {
UnderTolerance.setReadOnly(false);
FormatSpecUnderTolerance.setReadOnly(false);
}
}
requestPaint();
}
@@ -233,11 +239,15 @@ void DrawViewDimension::onChanged(const App::Property* prop)
UnderTolerance.setValue(-1.0 * OverTolerance.getValue());
UnderTolerance.setUnit(OverTolerance.getUnit());
UnderTolerance.setReadOnly(true);
FormatSpecUnderTolerance.setValue(FormatSpecOverTolerance.getValue());
FormatSpecUnderTolerance.setReadOnly(true);
}
else {
OverTolerance.setConstraints(&ToleranceConstraint);
if (!TheoreticalExact.getValue())
if (!TheoreticalExact.getValue()) {
UnderTolerance.setReadOnly(false);
FormatSpecUnderTolerance.setReadOnly(false);
}
}
requestPaint();
}
@@ -249,8 +259,21 @@ void DrawViewDimension::onChanged(const App::Property* prop)
}
requestPaint();
}
else if (prop == &FormatSpecOverTolerance) {
if (!ArbitraryTolerances.getValue()) {
FormatSpecUnderTolerance.setValue(FormatSpecOverTolerance.getValue());
}
requestPaint();
}
else if (prop == &FormatSpecUnderTolerance) {
if (!ArbitraryTolerances.getValue()) {
FormatSpecOverTolerance.setValue(FormatSpecUnderTolerance.getValue());
}
requestPaint();
}
else if ( (prop == &FormatSpec) ||
(prop == &Arbitrary) ||
(prop == &ArbitraryTolerances) ||
(prop == &MeasureType) ||
(prop == &UnderTolerance) ||
(prop == &Inverted) ) {
@@ -323,6 +346,9 @@ short DrawViewDimension::mustExecute() const
Type.isTouched() ||
FormatSpec.isTouched() ||
Arbitrary.isTouched() ||
FormatSpecOverTolerance.isTouched() ||
FormatSpecUnderTolerance.isTouched() ||
ArbitraryTolerances.isTouched() ||
MeasureType.isTouched() ||
TheoreticalExact.isTouched() ||
EqualTolerance.isTouched() ||
@@ -847,7 +873,6 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
}
return result;
}
std::string DrawViewDimension::getFormattedToleranceValue(int partial)
@@ -1373,8 +1398,9 @@ bool DrawViewDimension::has3DReferences(void) const
bool DrawViewDimension::hasOverUnderTolerance(void) const
{
bool result = false;
if (!DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) ||
!DrawUtil::fpCompare(UnderTolerance.getValue(), 0.0) ) {
if (ArbitraryTolerances.getValue() ||
!DrawUtil::fpCompare(OverTolerance.getValue(), 0.0) ||
!DrawUtil::fpCompare(UnderTolerance.getValue(), 0.0)) {
result = true;
}
return result;

View File

@@ -102,8 +102,8 @@ public:
App::PropertyBool TheoreticalExact;
App::PropertyBool Inverted;
App::PropertyString FormatSpec;
App::PropertyString FormatSpecUnderTolerance;
App::PropertyString FormatSpecOverTolerance;
App::PropertyString FormatSpecUnderTolerance;
App::PropertyBool Arbitrary;
App::PropertyBool ArbitraryTolerances;
App::PropertyBool EqualTolerance;

View File

@@ -54,7 +54,6 @@ using namespace TechDrawGui;
TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *dimensionVP) :
ui(new Ui_TaskDimension)
{
int i = 0;
m_parent = parent;
m_dimensionVP = dimensionVP;
@@ -68,6 +67,8 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di
ui->cbEqualTolerance->setDisabled(true);
ui->qsbOvertolerance->setDisabled(true);
ui->qsbUndertolerance->setDisabled(true);
ui->leFormatSpecifierOverTolerance->setDisabled(true);
ui->leFormatSpecifierUnderTolerance->setDisabled(true);
}
ui->cbEqualTolerance->setChecked(parent->dvDimension->EqualTolerance.getValue());
connect(ui->cbEqualTolerance, SIGNAL(stateChanged(int)), this, SLOT(onEqualToleranceChanged()));
@@ -88,8 +89,10 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di
connect(ui->qsbOvertolerance, SIGNAL(valueChanged(double)), this, SLOT(onOvertoleranceChanged()));
connect(ui->qsbUndertolerance, SIGNAL(valueChanged(double)), this, SLOT(onUndertoleranceChanged()));
// undertolerance is disabled when EqualTolerance is true
if (ui->cbEqualTolerance->isChecked())
if (ui->cbEqualTolerance->isChecked()) {
ui->qsbUndertolerance->setDisabled(true);
ui->leFormatSpecifierUnderTolerance->setDisabled(true);
}
// Formatting
std::string StringValue = parent->dvDimension->FormatSpec.getValue();
@@ -100,8 +103,12 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di
connect(ui->cbArbitrary, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryChanged()));
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()));
ui->leFormatSpecifierOverTolerance->setText(qs);
StringValue = parent->dvDimension->FormatSpecUnderTolerance.getValue();
qs = QString::fromUtf8(StringValue.data(), StringValue.size());
ui->leFormatSpecifierUnderTolerance->setText(qs);
connect(ui->leFormatSpecifierOverTolerance, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierOverToleranceChanged()));
connect(ui->leFormatSpecifierUnderTolerance, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierUnderToleranceChanged()));
ui->cbArbitraryTolerances->setChecked(parent->dvDimension->ArbitraryTolerances.getValue());
connect(ui->cbArbitraryTolerances, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryTolerancesChanged()));
@@ -133,7 +140,8 @@ bool TaskDimension::accept()
m_parent->dvDimension->FormatSpec.setValue(ui->leFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->Arbitrary.setValue(ui->cbArbitrary->isChecked());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData());
m_parent->dvDimension->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData());
m_parent->dvDimension->ArbitraryTolerances.setValue(ui->cbArbitraryTolerances->isChecked());
m_dimensionVP->FlipArrowheads.setValue(ui->cbArrowheads->isChecked());
@@ -170,12 +178,17 @@ void TaskDimension::onTheoreticallyExactChanged()
ui->cbEqualTolerance->setDisabled(true);
ui->qsbOvertolerance->setDisabled(true);
ui->qsbUndertolerance->setDisabled(true);
ui->leFormatSpecifierOverTolerance->setDisabled(true);
ui->leFormatSpecifierUnderTolerance->setDisabled(true);
}
else {
ui->cbEqualTolerance->setDisabled(false);
ui->qsbOvertolerance->setDisabled(false);
if (!ui->cbEqualTolerance->isChecked())
ui->leFormatSpecifierOverTolerance->setDisabled(false);
if (!ui->cbEqualTolerance->isChecked()) {
ui->qsbUndertolerance->setDisabled(false);
ui->leFormatSpecifierUnderTolerance->setDisabled(false);
}
}
recomputeFeature();
}
@@ -193,13 +206,15 @@ void TaskDimension::onEqualToleranceChanged()
ui->qsbUndertolerance->setValue(-1.0 * ui->qsbOvertolerance->value().getValue());
ui->qsbUndertolerance->setUnit(ui->qsbOvertolerance->value().getUnit());
ui->qsbUndertolerance->setDisabled(true);
ui->leFormatSpecifierUnderTolerance->setDisabled(true);
}
else {
ui->qsbOvertolerance->setMinimum(-DBL_MAX);
if (!ui->cbTheoreticallyExact->isChecked())
if (!ui->cbTheoreticallyExact->isChecked()) {
ui->qsbUndertolerance->setDisabled(false);
ui->leFormatSpecifierUnderTolerance->setDisabled(false);
}
}
ui->qsbUndertolerance->setDisabled(ui->cbEqualTolerance->isChecked());
recomputeFeature();
}
@@ -232,9 +247,23 @@ void TaskDimension::onArbitraryChanged()
recomputeFeature();
}
void TaskDimension::onToleranceFormatSpecifierChanged()
void TaskDimension::onFormatSpecifierOverToleranceChanged()
{
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leToleranceFormatSpecifier->text().toUtf8().constData());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData());
if (!ui->cbArbitraryTolerances->isChecked()) {
ui->leFormatSpecifierUnderTolerance->setText(ui->leFormatSpecifierOverTolerance->text());
m_parent->dvDimension->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData());
}
recomputeFeature();
}
void TaskDimension::onFormatSpecifierUnderToleranceChanged()
{
m_parent->dvDimension->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData());
if (!ui->cbArbitraryTolerances->isChecked()) {
ui->leFormatSpecifierOverTolerance->setText(ui->leFormatSpecifierUnderTolerance->text());
m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData());
}
recomputeFeature();
}

View File

@@ -56,7 +56,8 @@ private Q_SLOTS:
void onUndertoleranceChanged();
void onFormatSpecifierChanged();
void onArbitraryChanged();
void onToleranceFormatSpecifierChanged();
void onFormatSpecifierOverToleranceChanged();
void onFormatSpecifierUnderToleranceChanged();
void onArbitraryTolerancesChanged();
void onFlipArrowheadsChanged();
void onColorChanged();

View File

@@ -145,18 +145,32 @@ be used instead if the dimension value</string>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Tolerance Format Specifier:</string>
<string>OverTolerance Format Specifier:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leToleranceFormatSpecifier">
<widget class="QLineEdit" name="leFormatSpecifierOverTolerance">
<property name="toolTip">
<string>Text to be displayed</string>
<string>Specifies the overtolerance format in printf() style, or arbitrary text</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>UnderTolerance Format Specifier:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="leFormatSpecifierUnderTolerance">
<property name="toolTip">
<string>Specifies the undertolerance format in printf() style, or arbitrary text</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="cbArbitraryTolerances">
<property name="toolTip">
<string>If checked the content of 'Format Spec' will