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())
{
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height"));
ui->labelDescription->setText(desc);
SetDescription(item->text(), data->height(), VDomDocument::UnitsToStr(qApp->patternUnit(), true),
tr("Height"));
return;
}
if (item->text()==data->SizeName())
{
const QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
ui->labelDescription->setText(desc);
SetDescription(item->text(), data->size(), VDomDocument::UnitsToStr(qApp->patternUnit(), true),
tr("Size"));
return;
}
return;
}
if (ui->radioButtonStandardTable->isChecked())
{
const QString name = qApp->TrVars()->VarFromUser(item->text());
const QSharedPointer<VMeasurement> stable = data->GetVariable<VMeasurement>(name);
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(data->GetTableValue(name, qApp->patternType()))
.arg(stable->GetGuiText());
ui->labelDescription->setText(desc);
SetDescription(item->text(), data->GetTableValue(name, qApp->patternType()),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), stable->GetGuiText());
return;
}
if (ui->radioButtonIncrements->isChecked())
{
const QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(item->text());
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(data->GetTableValue(item->text(), qApp->patternType()))
.arg(incr->GetDescription());
ui->labelDescription->setText(desc);
SetDescription(item->text(), data->GetTableValue(item->text(), qApp->patternType()),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), incr->GetDescription());
return;
}
if (ui->radioButtonLengthLine->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Line length"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VLengthLine>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Line length"));
return;
}
if (ui->radioButtonLengthArc->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VArcLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Arc length"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VArcLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Arc length"));
return;
}
if (ui->radioButtonLengthSpline->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VSplineLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Curve length"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VSplineLength>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Curve length"));
return;
}
if (ui->radioButtonAngleLine->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Line Angle"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VLineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
degreeSymbol, tr("Line Angle"));
return;
}
if (ui->radioButtonRadiusesArcs->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Arc radius"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VArcRadius>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
VDomDocument::UnitsToStr(qApp->patternUnit(), true), tr("Arc radius"));
return;
}
if (ui->radioButtonAnglesArcs->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VArcAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Arc angle"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VArcAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
degreeSymbol, tr("Arc angle"));
return;
}
if (ui->radioButtonAnglesCurves->isChecked())
{
const QString desc = QString("%1(%2) - %3").arg(item->text())
.arg(*data->GetVariable<VSplineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue())
.arg(tr("Curve angle"));
ui->labelDescription->setText(desc);
SetDescription(item->text(),
*data->GetVariable<VSplineAngle>(qApp->TrVars()->VarFromUser(item->text()))->GetValue(),
degreeSymbol, tr("Curve angle"));
return;
}
}
@ -417,6 +409,14 @@ void DialogEditWrongFormula::InitVariables()
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

View File

@ -48,7 +48,7 @@ class DialogEditWrongFormula : public DialogTool
{
Q_OBJECT
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;
QString GetFormula() const;
@ -98,6 +98,8 @@ private:
template <class key, class val>
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);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormula(dialog->GetFormula());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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