diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index b0ba3332b..31671ed08 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -45,8 +45,9 @@ */ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), - timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()), f1(QString()), - f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr) + timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()), + f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), + angleF1(0), angleF2(0) { ui->setupUi(this); @@ -65,10 +66,10 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); timerF1 = new QTimer(this); - connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF1); + connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF); timerF2 = new QTimer(this); - connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF2); + connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF); InitOkCancelApply(ui); @@ -81,8 +82,8 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius); - connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); - connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2); + connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF); + connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged); connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArc::F1Changed); @@ -356,22 +357,17 @@ void DialogArc::EvalRadius() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief EvalF1 calculate value of first angle + * @brief EvalF1 calculate value of angle */ -void DialogArc::EvalF1() +void DialogArc::EvalF() { labelEditFormula = ui->labelEditF1; - Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false); -} + angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false); -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief EvalF2 calculate value of second angle - */ -void DialogArc::EvalF2() -{ labelEditFormula = ui->labelEditF2; - Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false); + angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false); + + CheckAngles(); } //--------------------------------------------------------------------------------------------------------------------- @@ -394,3 +390,20 @@ void DialogArc::ShowLineAngles() } ui->listWidget->setCurrentRow (0); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::CheckAngles() +{ + if (qFuzzyCompare(angleF1 + 1, angleF2 + 1)) + { + flagF1 = false; + ChangeColor(ui->labelEditF1, Qt::red); + ui->labelResultF1->setToolTip(tr("Angles equal")); + + flagF2 = false; + ChangeColor(ui->labelEditF2, Qt::red); + ui->labelResultF2->setToolTip(tr("Angles equal")); + } + + DialogArc::CheckState(); +} diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h index 823d7f69f..b042268ea 100644 --- a/src/app/dialogs/tools/dialogarc.h +++ b/src/app/dialogs/tools/dialogarc.h @@ -126,11 +126,13 @@ private: VisToolArc *path; - void EvalRadius(); - void EvalF1(); - void EvalF2(); - void ShowLineAngles(); + qreal angleF1; + qreal angleF2; + void EvalRadius(); + void EvalF(); + void ShowLineAngles(); + void CheckAngles(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index dca1e7965..e5942bc19 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -473,10 +473,13 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim * @param postfix unit name * @param checkZero true - if formula can't be equal zero */ -void DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero) +qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero) { SCASSERT(label != nullptr); SCASSERT(labelEditFormula != nullptr); + + qreal result = 0; + if (text.isEmpty()) { flag = false; @@ -493,7 +496,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QStr formula.replace("\n", " "); formula = qApp->FormulaFromUser(formula); Calculator *cal = new Calculator(data); - const qreal result = cal->EvalFormula(formula); + result = cal->EvalFormula(formula); delete cal; //if result equal 0 @@ -537,6 +540,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QStr } } CheckState(); + return result; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 0cf27043d..32e76d892 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -225,7 +225,7 @@ protected: void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); - void Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, + qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, bool checkZero = true); void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const; void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value,