diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 6c93bd068..daaf8c478 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -1803,6 +1803,10 @@ QString VApplication::PostfixOperator(const QString &name) const */ QString VApplication::FormulaFromUser(const QString &formula) { + if (formula.isEmpty()) + { + return formula; + } QString newFormula = formula;// Local copy for making changes Calculator *cal = new Calculator(formula);// Eval formula @@ -1901,6 +1905,11 @@ QString VApplication::FormulaFromUser(const QString &formula) */ QString VApplication::FormulaToUser(const QString &formula) { + if (formula.isEmpty()) + { + return formula; + } + QString newFormula = formula;// Local copy for making changes QMap tokens; diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index 54a8dd1dc..9d3cd576d 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -31,6 +31,7 @@ #include "../../visualization/vistoolalongline.h" #include "../../tools/vabstracttool.h" #include "../../widgets/vmaingraphicsscene.h" +#include "dialogeditwrongformula.h" #include @@ -45,7 +46,6 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, formula(QString()), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); - InitVariables(ui); InitFormulaUI(ui); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); labelEditNamePoint = ui->labelEditNamePoint; @@ -62,11 +62,10 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxLineColors(ui->comboBoxLineColor); - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); + connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogAlongLine::FXLength); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit); - connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal); connect(ui->comboBoxFirstPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogAlongLine::PointChanged); connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), @@ -100,6 +99,19 @@ void DialogAlongLine::PointChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::FXLength() +{ + DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + dialog->setWindowTitle(tr("Edit length")); + dialog->SetFormula(GetFormula()); + if (dialog->exec() == QDialog::Accepted) + { + SetFormula(dialog->GetFormula()); + } + delete dialog; +} + //--------------------------------------------------------------------------------------------------------------------- void DialogAlongLine::ShowVisualization() { diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index b82f23350..1ba3605f2 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -75,6 +75,8 @@ public slots: */ void FormulaTextChanged(); void PointChanged(); + + void FXLength(); protected: virtual void ShowVisualization(); /** diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui index ee68fb65e..a360a175b 100644 --- a/src/app/dialogs/tools/dialogalongline.ui +++ b/src/app/dialogs/tools/dialogalongline.ui @@ -6,8 +6,8 @@ 0 0 - 428 - 532 + 412 + 284 @@ -87,16 +87,13 @@ - - - Insert variable into the formula - + ... - :/icon/24x24/putHere.png:/icon/24x24/putHere.png + :/icon/24x24/fx.png:/icon/24x24/fx.png @@ -165,6 +162,9 @@ true + + + @@ -206,251 +206,98 @@ - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Point label - - - - - - - First point - - - - - - - First point of line - - - - - - - Second point - - - - - - - Second point of line - - - - - - - Type of line - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 110 - 16777215 - - - - Show line from first point to this point - - - - 80 - 14 - - - - - - - - Line color - - - - - - - - - - - - - - - Input data - - - - - - - - 0 - 0 - - - - Size and height - - - true - - - - - - - - 0 - 0 - - - - Measurements - - - - - - - - 0 - 0 - - - - Increments - - - - - - - - 0 - 0 - - - - Length of lines - - - - - - - true - - - - 0 - 0 - - - - Length of arcs - - - - - - - true - - - - 0 - 0 - - - - Length of curves - - - - - - - true - - - - 0 - 0 - - - - Angle of lines - - - - - - + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Point label + + - - - - - - Hide empty measurements - - - true - - - - - - - Variables - Click twice to insert into formula - - - - + + + + First point + + + + + + + First point of line + + + + + + + Second point + + + + + + + Second point of line + + + + + + + Type of line + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 110 + 16777215 + + + + Show line from first point to this point + + + + 80 + 14 + + + + + + + + Line color + + + + + + + + - - - - - - - true - - - @@ -465,21 +312,11 @@ plainTextEditFormula - toolButtonPutHere pushButtonGrowLength lineEditNamePoint comboBoxFirstPoint comboBoxSecondPoint comboBoxLineType - radioButtonSizeGrowth - radioButtonStandardTable - radioButtonIncrements - radioButtonLengthLine - radioButtonLengthArc - radioButtonLengthSpline - radioButtonAngleLine - checkBoxHideEmpty - listWidget buttonBox