Show a measurement special units in description.

This commit is contained in:
Roman Telezhynskyi 2020-10-16 09:47:27 +03:00
parent a5298ea059
commit 0eaf15f09d
2 changed files with 22 additions and 17 deletions

View File

@ -191,44 +191,48 @@ void DialogEditWrongFormula::ValChanged(int row)
if (ui->radioButtonStandardTable->isChecked()) if (ui->radioButtonStandardTable->isChecked())
{ {
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name); const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
SetDescription(item->text(), *stable->GetValue(), UnitsToStr(qApp->patternUnits(), true), SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), stable->GetGuiText());
stable->GetGuiText());
} }
else if (ui->radioButtonIncrements->isChecked()) else if (ui->radioButtonIncrements->isChecked())
{ {
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(name); const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(name);
SetDescription(item->text(), *incr->GetValue(), UnitsToStr(qApp->patternUnits(), true), const bool specialUnits = false;
incr->GetDescription()); SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
} }
else if (ui->radioButtonPC->isChecked()) else if (ui->radioButtonPC->isChecked())
{ {
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(name); const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(name);
SetDescription(item->text(), *incr->GetValue(), UnitsToStr(qApp->patternUnits(), true), const bool specialUnits = false;
incr->GetDescription()); SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
} }
else if (ui->radioButtonLengthLine->isChecked()) else if (ui->radioButtonLengthLine->isChecked())
{ {
SetDescription(item->text(), *data->GetVariable<VLengthLine>(name)->GetValue(), const bool specialUnits = false;
UnitsToStr(qApp->patternUnits(), true), tr("Line length")); SetDescription(item->text(), *data->GetVariable<VLengthLine>(name)->GetValue(), specialUnits,
tr("Line length"));
} }
else if (ui->radioButtonLengthSpline->isChecked()) else if (ui->radioButtonLengthSpline->isChecked())
{ {
SetDescription(item->text(), *data->GetVariable<VCurveLength>(name)->GetValue(), const bool specialUnits = false;
UnitsToStr(qApp->patternUnits(), true), tr("Curve length")); SetDescription(item->text(), *data->GetVariable<VCurveLength>(name)->GetValue(), specialUnits,
tr("Curve length"));
} }
else if (ui->radioButtonAngleLine->isChecked()) else if (ui->radioButtonAngleLine->isChecked())
{ {
SetDescription(item->text(), *data->GetVariable<VLineAngle>(name)->GetValue(), degreeSymbol, const bool specialUnits = true;
SetDescription(item->text(), *data->GetVariable<VLineAngle>(name)->GetValue(), specialUnits,
tr("Line Angle")); tr("Line Angle"));
} }
else if (ui->radioButtonRadiusesArcs->isChecked()) else if (ui->radioButtonRadiusesArcs->isChecked())
{ {
SetDescription(item->text(), *data->GetVariable<VArcRadius>(name)->GetValue(), const bool specialUnits = false;
UnitsToStr(qApp->patternUnits(), true), tr("Arc radius")); SetDescription(item->text(), *data->GetVariable<VArcRadius>(name)->GetValue(), specialUnits,
tr("Arc radius"));
} }
else if (ui->radioButtonAnglesCurves->isChecked()) else if (ui->radioButtonAnglesCurves->isChecked())
{ {
SetDescription(item->text(), *data->GetVariable<VCurveAngle>(name)->GetValue(), degreeSymbol, const bool specialUnits = true;
SetDescription(item->text(), *data->GetVariable<VCurveAngle>(name)->GetValue(), specialUnits,
tr("Curve angle")); tr("Curve angle"));
} }
else if (ui->radioButtonFunctions->isChecked()) else if (ui->radioButtonFunctions->isChecked())
@ -503,10 +507,11 @@ void DialogEditWrongFormula::InitVariables()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, const QString &unit, void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, bool specialUnits,
const QString &description) const QString &description)
{ {
const QString desc = QStringLiteral("%1(%2 %3) - %4").arg(name).arg(value).arg(unit, description); const QString unit = specialUnits ? degreeSymbol : " " + UnitsToStr(qApp->patternUnits(), true);
const QString desc = QStringLiteral("%1(%2%3) - %4").arg(name).arg(value).arg(unit, description);
ui->labelDescription->setText(desc); ui->labelDescription->setText(desc);
} }

View File

@ -121,7 +121,7 @@ private:
void ShowFunctions(); void ShowFunctions();
void ShowIncrementsInPreviewCalculation(bool show); void ShowIncrementsInPreviewCalculation(bool show);
void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description); void SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description);
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------