Show unit in description of the Internal data.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-07-03 18:54:25 +03:00
parent 82a24587c5
commit f3f5982d3f
17 changed files with 65 additions and 42 deletions

View File

@ -124,89 +124,81 @@ void DialogEditWrongFormula::ValChenged(int row)
{ {
if (item->text()==data->HeightName()) if (item->text()==data->HeightName())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height")); SetDescription(item->text(), data->height(), VDomDocument::UnitsToStr(qApp->patternUnit(), true),
ui->labelDescription->setText(desc); tr("Height"));
return;
} }
if (item->text()==data->SizeName()) if (item->text()==data->SizeName())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size")); SetDescription(item->text(), data->size(), VDomDocument::UnitsToStr(qApp->patternUnit(), true),
ui->labelDescription->setText(desc); tr("Size"));
}
return; return;
} }
}
if (ui->radioButtonStandardTable->isChecked()) if (ui->radioButtonStandardTable->isChecked())
{ {
const QString name = qApp->TrVars()->VarFromUser(item->text()); const QString name = qApp->TrVars()->VarFromUser(item->text());
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name); const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(), data->GetTableValue(name, qApp->patternType()),
.arg(data->GetTableValue(name, qApp->patternType())) VDomDocument::UnitsToStr(qApp->patternUnit(), true), stable->GetGuiText());
.arg(stable->GetGuiText());
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonIncrements->isChecked()) if (ui->radioButtonIncrements->isChecked())
{ {
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text()); const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(), data->GetTableValue(item->text(), qApp->patternType()),
.arg(data->GetTableValue(item->text(), qApp->patternType())) VDomDocument::UnitsToStr(qApp->patternUnit(), true), incr->GetDescription());
.arg(incr->GetDescription());
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonLengthLine->isChecked()) if (ui->radioButtonLengthLine->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Line length")); VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Line length"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonLengthArc->isChecked()) if (ui->radioButtonLengthArc->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VArcLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VArcLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Arc length")); VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Arc length"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonLengthSpline->isChecked()) if (ui->radioButtonLengthSpline->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VSplineLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VSplineLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Curve length")); VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Curve length"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonAngleLine->isChecked()) if (ui->radioButtonAngleLine->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Line Angle")); degreeSymbol, tr("Line Angle"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonRadiusesArcs->isChecked()) if (ui->radioButtonRadiusesArcs->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Arc radius")); VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Arc radius"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonAnglesArcs->isChecked()) if (ui->radioButtonAnglesArcs->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VArcAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VArcAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Arc angle")); degreeSymbol, tr("Arc angle"));
ui->labelDescription->setText(desc);
return; return;
} }
if (ui->radioButtonAnglesCurves->isChecked()) if (ui->radioButtonAnglesCurves->isChecked())
{ {
const QString desc = QString("%1(%2) - %3").arg(item->text()) SetDescription(item->text(),
.arg(*data->GetVariable<VSplineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue()) *data->GetVariable<VSplineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
.arg(tr("Curve angle")); degreeSymbol, tr("Curve angle"));
ui->labelDescription->setText(desc);
return; return;
} }
} }
@ -417,6 +409,14 @@ void DialogEditWrongFormula::InitVariables()
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves); connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::SetDescription(const QString &name, qreal value, const QString &unit,
const QString &description)
{
const QString desc = QString("%1(%2 %3) - %4").arg(name).arg(value).arg(unit).arg(description);
ui->labelDescription->setText(desc);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ShowVariable show variables in list * @brief ShowVariable show variables in list

View File

@ -48,7 +48,7 @@ class DialogEditWrongFormula : public DialogTool
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogEditWrongFormula() Q_DECL_OVERRIDE; virtual ~DialogEditWrongFormula() Q_DECL_OVERRIDE;
QString GetFormula() const; QString GetFormula() const;
@ -98,6 +98,8 @@ private:
template <class key, class val> template <class key, class val>
void ShowVariable(const QMap<key, val> var); void ShowVariable(const QMap<key, val> var);
void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description);
}; };

View File

@ -108,6 +108,7 @@ void DialogAlongLine::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -305,6 +305,7 @@ void DialogArc::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius()); dialog->SetFormula(GetRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius(dialog->GetFormula()); SetRadius(dialog->GetFormula());
@ -318,6 +319,7 @@ void DialogArc::FXF1()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit first angle")); dialog->setWindowTitle(tr("Edit first angle"));
dialog->SetFormula(GetF1()); dialog->SetFormula(GetF1());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetF1(dialog->GetFormula()); SetF1(dialog->GetFormula());
@ -331,6 +333,7 @@ void DialogArc::FXF2()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit second angle")); dialog->setWindowTitle(tr("Edit second angle"));
dialog->SetFormula(GetF2()); dialog->SetFormula(GetF2());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetF2(dialog->GetFormula()); SetF2(dialog->GetFormula());

View File

@ -258,6 +258,7 @@ void DialogArcWithLength::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius()); dialog->SetFormula(GetRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetRadius(dialog->GetFormula()); SetRadius(dialog->GetFormula());
@ -271,6 +272,7 @@ void DialogArcWithLength::FXF1()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit the first angle")); dialog->setWindowTitle(tr("Edit the first angle"));
dialog->SetFormula(GetF1()); dialog->SetFormula(GetF1());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetF1(dialog->GetFormula()); SetF1(dialog->GetFormula());
@ -284,6 +286,7 @@ void DialogArcWithLength::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit the arc length")); dialog->setWindowTitle(tr("Edit the arc length"));
dialog->SetFormula(GetLength()); dialog->SetFormula(GetLength());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetLength(dialog->GetFormula()); SetLength(dialog->GetFormula());

View File

@ -116,6 +116,7 @@ void DialogBisector::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -262,6 +262,7 @@ void DialogCurveIntersectAxis::FXAngle()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle")); dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle()); dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetAngle(dialog->GetFormula()); SetAngle(dialog->GetFormula());

View File

@ -82,6 +82,7 @@ void DialogCutArc::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -201,6 +201,7 @@ void DialogCutSpline::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -201,6 +201,7 @@ void DialogCutSplinePath::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -127,6 +127,7 @@ void DialogEndLine::FXAngle()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle")); dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle()); dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetAngle(dialog->GetFormula()); SetAngle(dialog->GetFormula());
@ -140,6 +141,7 @@ void DialogEndLine::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -329,6 +329,7 @@ void DialogLineIntersectAxis::FXAngle()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle")); dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle()); dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetAngle(dialog->GetFormula()); SetAngle(dialog->GetFormula());

View File

@ -106,6 +106,7 @@ void DialogNormal::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());

View File

@ -251,6 +251,7 @@ void DialogPointFromCircleAndTangent::FXCircleRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetCircleRadius()); dialog->SetFormula(GetCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetCircleRadius(dialog->GetFormula()); SetCircleRadius(dialog->GetFormula());

View File

@ -119,6 +119,7 @@ void DialogPointOfContact::FXRadius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius")); dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(getRadius()); dialog->SetFormula(getRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
setRadius(dialog->GetFormula()); setRadius(dialog->GetFormula());

View File

@ -306,6 +306,7 @@ void DialogPointOfIntersectionCircles::FXCircle1Radius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit first circle radius")); dialog->setWindowTitle(tr("Edit first circle radius"));
dialog->SetFormula(GetFirstCircleRadius()); dialog->SetFormula(GetFirstCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFirstCircleRadius(dialog->GetFormula()); SetFirstCircleRadius(dialog->GetFormula());
@ -319,6 +320,7 @@ void DialogPointOfIntersectionCircles::FXCircle2Radius()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit second circle radius")); dialog->setWindowTitle(tr("Edit second circle radius"));
dialog->SetFormula(GetSecondCircleRadius()); dialog->SetFormula(GetSecondCircleRadius());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetSecondCircleRadius(dialog->GetFormula()); SetSecondCircleRadius(dialog->GetFormula());

View File

@ -117,6 +117,7 @@ void DialogShoulderPoint::FXLength()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
SetFormula(dialog->GetFormula()); SetFormula(dialog->GetFormula());