diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp
index 937547b71..4b8e56b6c 100644
--- a/src/app/container/calculator.cpp
+++ b/src/app/container/calculator.cpp
@@ -97,14 +97,7 @@ Calculator::Calculator(const QString &formula, bool fromUser)
}
SetExpr(formula);
- try
- {
- Eval();//Need run for making tokens
- }
- catch(qmu::QmuParserError &e)
- {
- return;//Ignore all warnings
- }
+ Eval();//Need run for making tokens
}
Calculator::~Calculator()
@@ -217,15 +210,13 @@ void Calculator::InitVariables(const VContainer *data)
if (qApp->patternType() == Pattern::Standard)
{
vVarVal[j] = i.value().GetValue(data->size(), data->height());
- DefineVar(i.key(), &vVarVal[j]);
- ++j;
}
else
{
vVarVal[j] = i.value().GetValue();
- DefineVar(i.key(), &vVarVal[j]);
- ++j;
}
+ DefineVar(i.key(), &vVarVal[j]);
+ ++j;
++i;
}
}
@@ -237,15 +228,13 @@ void Calculator::InitVariables(const VContainer *data)
if (qApp->patternType() == Pattern::Standard)
{
vVarVal[j] = i.value().GetValue(data->size(), data->height());
- DefineVar(i.key(), &vVarVal[j]);
- ++j;
}
else
{
vVarVal[j] = i.value().GetValue();
- DefineVar(i.key(), &vVarVal[j]);
- ++j;
}
+ DefineVar(i.key(), &vVarVal[j]);
+ ++j;
++i;
}
}
diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp
index bc8a538c4..01d2b10dd 100644
--- a/src/app/dialogs/app/dialogstandardmeasurements.cpp
+++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp
@@ -136,8 +136,7 @@ void DialogStandardMeasurements::CheckState()
//---------------------------------------------------------------------------------------------------------------------
void DialogStandardMeasurements::LoadStandardTables()
{
- QStringList filters;
- filters << "*.vst";
+ QStringList filters{"*.vst"};
QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters);
tablesDir.setCurrent(qApp->pathToTables());
diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri
index 62dd44ef5..01e895748 100644
--- a/src/app/dialogs/dialogs.pri
+++ b/src/app/dialogs/dialogs.pri
@@ -29,7 +29,8 @@ HEADERS += \
dialogs/app/dialogmeasurements.h \
dialogs/app/dialogstandardmeasurements.h \
dialogs/app/dialogindividualmeasurements.h \
- dialogs/app/dialogaboutapp.h
+ dialogs/app/dialogaboutapp.h \
+ dialogs/tools/dialogeditwrongformula.h
SOURCES += \
dialogs/tools/dialogtriangle.cpp \
@@ -61,7 +62,8 @@ SOURCES += \
dialogs/app/dialogmeasurements.cpp \
dialogs/app/dialogstandardmeasurements.cpp \
dialogs/app/dialogindividualmeasurements.cpp \
- dialogs/app/dialogaboutapp.cpp
+ dialogs/app/dialogaboutapp.cpp \
+ dialogs/tools/dialogeditwrongformula.cpp
FORMS += \
dialogs/tools/dialogtriangle.ui \
@@ -90,4 +92,5 @@ FORMS += \
dialogs/app/dialogmeasurements.ui \
dialogs/app/dialogstandardmeasurements.ui \
dialogs/app/dialogindividualmeasurements.ui \
- dialogs/app/dialogaboutapp.ui
+ dialogs/app/dialogaboutapp.ui \
+ dialogs/tools/dialogeditwrongformula.ui
diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui
index be82913a8..9113f9e04 100644
--- a/src/app/dialogs/tools/dialogalongline.ui
+++ b/src/app/dialogs/tools/dialogalongline.ui
@@ -7,7 +7,7 @@
0
0
470
- 573
+ 675
@@ -252,6 +252,12 @@
-
+
+
+ 0
+ 0
+
+
Show line from first point to this point
@@ -270,6 +276,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -280,6 +292,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -287,6 +305,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -294,6 +318,12 @@
-
+
+
+ 0
+ 0
+
+
Length of lines
@@ -304,6 +334,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -314,6 +350,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogarc.ui b/src/app/dialogs/tools/dialogarc.ui
index c40c5a1c9..f5705908f 100644
--- a/src/app/dialogs/tools/dialogarc.ui
+++ b/src/app/dialogs/tools/dialogarc.ui
@@ -7,7 +7,7 @@
0
0
501
- 538
+ 705
@@ -447,6 +447,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -457,6 +463,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -464,6 +476,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -474,6 +492,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -484,6 +508,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -494,6 +524,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
@@ -504,6 +540,12 @@
true
+
+
+ 0
+ 0
+
+
Angle of lines
diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui
index b6285890c..1c5221267 100644
--- a/src/app/dialogs/tools/dialogbisector.ui
+++ b/src/app/dialogs/tools/dialogbisector.ui
@@ -7,7 +7,7 @@
0
0
480
- 587
+ 686
@@ -309,6 +309,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -319,6 +325,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -326,6 +338,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -336,6 +354,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -346,6 +370,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -356,6 +386,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp
index 5ab00d16e..0a43e7e6d 100644
--- a/src/app/dialogs/tools/dialogcutarc.cpp
+++ b/src/app/dialogs/tools/dialogcutarc.cpp
@@ -30,6 +30,11 @@
#include "ui_dialogcutarc.h"
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief DialogCutArc create dialog.
+ * @param data container with data
+ * @param parent parent widget
+ */
DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(0)
{
@@ -62,6 +67,11 @@ DialogCutArc::~DialogCutArc()
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
+ * @param id id of point or detail
+ * @param type type of object
+ */
void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type)
{
if (type == Valentina::Arc)
@@ -74,6 +84,9 @@ void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief DialogAccepted save data and emit signal about closed dialog.
+ */
void DialogCutArc::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
@@ -83,12 +96,21 @@ void DialogCutArc::DialogAccepted()
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief setArcId set id of arc
+ * @param value id
+ * @param id don't show this id in list
+ */
void DialogCutArc::setArcId(const quint32 &value, const quint32 &id)
{
setCurrentArcId(ui->comboBoxArc, arcId, value, id, ComboMode::CutArc);
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief setFormula set string with formula length
+ * @param value string with formula
+ */
void DialogCutArc::setFormula(const QString &value)
{
formula = qApp->FormulaToUser(value);
@@ -96,8 +118,22 @@ void DialogCutArc::setFormula(const QString &value)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief setPointName set name point on arc
+ * @param value name
+ */
void DialogCutArc::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
+
+//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief getFormula return string with formula length
+ * @return formula
+ */
+QString DialogCutArc::getFormula() const
+{
+ return qApp->FormulaFromUser(formula);
+}
diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h
index e9df0964d..306e28256 100644
--- a/src/app/dialogs/tools/dialogcutarc.h
+++ b/src/app/dialogs/tools/dialogcutarc.h
@@ -43,54 +43,17 @@ class DialogCutArc : public DialogTool
{
Q_OBJECT
public:
- /**
- * @brief DialogCutArc create dialog.
- * @param data container with data
- * @param parent parent widget
- */
+
DialogCutArc(const VContainer *data, QWidget *parent = nullptr);
~DialogCutArc();
- /**
- * @brief getPointName return name point on arc
- * @return name
- */
- QString getPointName() const {return pointName;}
- /**
- * @brief setPointName set name point on arc
- * @param value name
- */
+ QString getPointName() const;
void setPointName(const QString &value);
- /**
- * @brief getFormula return string with formula length
- * @return formula
- */
- QString getFormula() const {return qApp->FormulaFromUser(formula);}
- /**
- * @brief setFormula set string with formula length
- * @param value string with formula
- */
+ QString getFormula() const;
void setFormula(const QString &value);
- /**
- * @brief getArcId return id of arc
- * @return id
- */
- quint32 getArcId() const {return arcId;}
- /**
- * @brief setArcId set id of arc
- * @param value id
- * @param id don't show this id in list
- */
+ quint32 getArcId() const;
void setArcId(const quint32 &value, const quint32 &id);
public slots:
- /**
- * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
- * @param id id of point or detail
- * @param type type of object
- */
virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type);
- /**
- * @brief DialogAccepted save data and emit signal about closed dialog.
- */
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogCutArc)
@@ -112,4 +75,24 @@ private:
quint32 arcId;
};
+//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief getPointName return name point on arc
+ * @return name
+ */
+inline QString DialogCutArc::getPointName() const
+{
+ return pointName;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief getArcId return id of arc
+ * @return id
+ */
+inline quint32 DialogCutArc::getArcId() const
+{
+ return arcId;
+}
+
#endif // DIALOGCUTARC_H
diff --git a/src/app/dialogs/tools/dialogcutarc.ui b/src/app/dialogs/tools/dialogcutarc.ui
index 6939c61d4..bfbff85fa 100644
--- a/src/app/dialogs/tools/dialogcutarc.ui
+++ b/src/app/dialogs/tools/dialogcutarc.ui
@@ -7,11 +7,11 @@
0
0
507
- 493
+ 597
- Dialog
+ Cut arc
-
@@ -236,6 +236,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -246,6 +252,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -253,6 +265,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -263,6 +281,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -273,6 +297,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -283,6 +313,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogcutspline.ui b/src/app/dialogs/tools/dialogcutspline.ui
index 658fcdb5a..4fb194f59 100644
--- a/src/app/dialogs/tools/dialogcutspline.ui
+++ b/src/app/dialogs/tools/dialogcutspline.ui
@@ -11,7 +11,7 @@
- Dialog
+ Cut curve
-
@@ -236,6 +236,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -246,6 +252,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -253,6 +265,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -263,6 +281,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -273,6 +297,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -283,6 +313,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogcutsplinepath.ui b/src/app/dialogs/tools/dialogcutsplinepath.ui
index c37d9b06b..26351262b 100644
--- a/src/app/dialogs/tools/dialogcutsplinepath.ui
+++ b/src/app/dialogs/tools/dialogcutsplinepath.ui
@@ -11,7 +11,7 @@
- Dialog
+ Cut curve path
-
@@ -236,6 +236,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -246,6 +252,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -253,6 +265,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -263,6 +281,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -273,6 +297,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -283,6 +313,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp
new file mode 100644
index 000000000..f82e5ef4b
--- /dev/null
+++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp
@@ -0,0 +1,103 @@
+/************************************************************************
+ **
+ ** @file dialogeditwrongformula.cpp
+ ** @author Roman Telezhynskyi
+ ** @date 29 5, 2014
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2014 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#include "dialogeditwrongformula.h"
+#include "ui_dialogeditwrongformula.h"
+
+#include
+
+//---------------------------------------------------------------------------------------------------------------------
+DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent)
+ :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString())
+{
+ ui->setupUi(this);
+ InitVariables(ui);
+ labelResultCalculation = ui->labelResult;
+ lineEditFormula = ui->lineEditFormula;
+ labelEditFormula = ui->labelFormula;
+
+ InitOkCansel(ui);
+ flagFormula = false;
+ CheckState();
+
+
+ connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
+ connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
+
+ connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula);
+ connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
+
+ //Disable Qt::WaitCursor
+#ifndef QT_NO_CURSOR
+ QApplication::restoreOverrideCursor();
+#endif
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+DialogEditWrongFormula::~DialogEditWrongFormula()
+{
+#ifndef QT_NO_CURSOR
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+#endif
+ delete ui;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogEditWrongFormula::DialogAccepted()
+{
+ formula = ui->lineEditFormula->text();
+ emit DialogClosed(QDialog::Accepted);
+ accepted();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogEditWrongFormula::DialogRejected()
+{
+ emit DialogClosed(QDialog::Rejected);
+ rejected();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogEditWrongFormula::CheckState()
+{
+ Q_CHECK_PTR(bOk);
+ bOk->setEnabled(flagFormula);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void DialogEditWrongFormula::setFormula(const QString &value)
+{
+ formula = qApp->FormulaToUser(value);
+ ui->lineEditFormula->setText(formula);
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+QString DialogEditWrongFormula::getFormula() const
+{
+ return qApp->FormulaFromUser(formula);
+}
diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h
new file mode 100644
index 000000000..d76873046
--- /dev/null
+++ b/src/app/dialogs/tools/dialogeditwrongformula.h
@@ -0,0 +1,69 @@
+/************************************************************************
+ **
+ ** @file dialogeditwrongformula.h
+ ** @author Roman Telezhynskyi
+ ** @date 29 5, 2014
+ **
+ ** @brief
+ ** @copyright
+ ** This source code is part of the Valentine project, a pattern making
+ ** program, whose allow create and modeling patterns of clothing.
+ ** Copyright (C) 2014 Valentina project
+ ** All Rights Reserved.
+ **
+ ** Valentina is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** Valentina is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with Valentina. If not, see .
+ **
+ *************************************************************************/
+
+#ifndef DIALOGEDITWRONGFORMULA_H
+#define DIALOGEDITWRONGFORMULA_H
+
+#include "dialogtool.h"
+
+namespace Ui {
+class DialogEditWrongFormula;
+}
+
+/**
+ * @brief The DialogEditWrongFormula class dialog for editing wrong formula.
+ *
+ * When math parser find in formula error user can try fix issue. Dialog will show all variables that user can use in
+ * this formula. Dialog check fixed variant of formula.
+ *
+ * Don't implemant button "Apply" for this dialog!!
+ */
+class DialogEditWrongFormula : public DialogTool
+{
+ Q_OBJECT
+public:
+ explicit DialogEditWrongFormula(const VContainer *data, QWidget *parent = nullptr);
+ ~DialogEditWrongFormula();
+ QString getFormula() const;
+ void setFormula(const QString &value);
+public slots:
+ virtual void DialogAccepted();
+ virtual void DialogRejected();
+protected:
+ virtual void CheckState();
+private:
+ Q_DISABLE_COPY(DialogEditWrongFormula)
+ Ui::DialogEditWrongFormula *ui;
+ /**
+ * @brief formula string with formula
+ */
+ QString formula;
+};
+
+
+#endif // DIALOGEDITWRONGFORMULA_H
diff --git a/src/app/dialogs/tools/dialogeditwrongformula.ui b/src/app/dialogs/tools/dialogeditwrongformula.ui
new file mode 100644
index 000000000..15e900f08
--- /dev/null
+++ b/src/app/dialogs/tools/dialogeditwrongformula.ui
@@ -0,0 +1,347 @@
+
+
+ DialogEditWrongFormula
+
+
+
+ 0
+ 0
+ 607
+ 535
+
+
+
+ Edit wrong formula
+
+
+
-
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 159
+ 158
+ 158
+
+
+
+
+
+
+
+ Formula
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ First angle of arc counterclockwise
+
+
+
+ -
+
+
+ Insert variable into formula
+
+
+ ...
+
+
+
+ :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+ Calculate value
+
+
+ ...
+
+
+
+ :/icon/24x24/equal.png:/icon/24x24/equal.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 87
+ 0
+
+
+
+ Value of first angle
+
+
+ _
+
+
+
+
+
+ -
+
+
-
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Input data
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Size and height
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Standard table
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Increments
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ Length of lines
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ Length of arcs
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ Length of curves
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ Angle of lines
+
+
+
+
+
+
+
+ -
+
+
+ Variables
+
+
+
+
+
+ -
+
+
+
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ DialogEditWrongFormula
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ DialogEditWrongFormula
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui
index 377942edb..1b88dd92b 100644
--- a/src/app/dialogs/tools/dialogendline.ui
+++ b/src/app/dialogs/tools/dialogendline.ui
@@ -472,7 +472,7 @@
-
-
+
0
0
@@ -488,7 +488,7 @@
-
-
+
0
0
@@ -501,7 +501,7 @@
-
-
+
0
0
@@ -517,7 +517,7 @@
true
-
+
0
0
@@ -533,7 +533,7 @@
true
-
+
0
0
@@ -549,7 +549,7 @@
true
-
+
0
0
diff --git a/src/app/dialogs/tools/dialogheight.ui b/src/app/dialogs/tools/dialogheight.ui
index db3460197..305abeef7 100644
--- a/src/app/dialogs/tools/dialogheight.ui
+++ b/src/app/dialogs/tools/dialogheight.ui
@@ -11,7 +11,7 @@
- Dialog
+ Height
diff --git a/src/app/dialogs/tools/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui
index b88a49da9..781fd810d 100644
--- a/src/app/dialogs/tools/dialognormal.ui
+++ b/src/app/dialogs/tools/dialognormal.ui
@@ -484,6 +484,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -494,6 +500,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -501,6 +513,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -511,6 +529,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -521,6 +545,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -531,6 +561,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogpointofcontact.ui
index 17d34bba4..532648eeb 100644
--- a/src/app/dialogs/tools/dialogpointofcontact.ui
+++ b/src/app/dialogs/tools/dialogpointofcontact.ui
@@ -324,6 +324,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -334,6 +340,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -341,6 +353,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -351,6 +369,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -361,6 +385,12 @@
true
+
+
+ 0
+ 0
+
+
Length of arcs
@@ -371,6 +401,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogpointofintersection.ui b/src/app/dialogs/tools/dialogpointofintersection.ui
index 9295f65ee..58595d555 100644
--- a/src/app/dialogs/tools/dialogpointofintersection.ui
+++ b/src/app/dialogs/tools/dialogpointofintersection.ui
@@ -11,7 +11,7 @@
- Dialog
+ Point of intersection
-
diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui
index df2fe865c..27bd11328 100644
--- a/src/app/dialogs/tools/dialogshoulderpoint.ui
+++ b/src/app/dialogs/tools/dialogshoulderpoint.ui
@@ -345,6 +345,12 @@
-
+
+
+ 0
+ 0
+
+
Size and height
@@ -355,6 +361,12 @@
-
+
+
+ 0
+ 0
+
+
Standard table
@@ -362,6 +374,12 @@
-
+
+
+ 0
+ 0
+
+
Increments
@@ -372,6 +390,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -382,6 +406,12 @@
true
+
+
+ 0
+ 0
+
+
Length of lines
@@ -392,6 +422,12 @@
true
+
+
+ 0
+ 0
+
+
Length of curves
diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp
index a4e00f419..2338b476a 100644
--- a/src/app/dialogs/tools/dialogtool.cpp
+++ b/src/app/dialogs/tools/dialogtool.cpp
@@ -333,8 +333,9 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
try
{
const QString formula = qApp->FormulaFromUser(edit->text());
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ Calculator *cal = new Calculator(data);
+ const qreal result = cal->EvalFormula(formula);
+ delete cal;
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
diff --git a/src/app/dialogs/tools/dialogtriangle.ui b/src/app/dialogs/tools/dialogtriangle.ui
index 4121e7e01..129de36a1 100644
--- a/src/app/dialogs/tools/dialogtriangle.ui
+++ b/src/app/dialogs/tools/dialogtriangle.ui
@@ -11,7 +11,7 @@
- Dialog
+ Triangle
diff --git a/src/app/dialogs/tools/dialoguniondetails.ui b/src/app/dialogs/tools/dialoguniondetails.ui
index 24e84b14a..529030b1c 100644
--- a/src/app/dialogs/tools/dialoguniondetails.ui
+++ b/src/app/dialogs/tools/dialoguniondetails.ui
@@ -11,7 +11,7 @@
- Dialog
+ Union details
diff --git a/src/app/exception/vexception.cpp b/src/app/exception/vexception.cpp
index 5cbc0192c..1812d7337 100644
--- a/src/app/exception/vexception.cpp
+++ b/src/app/exception/vexception.cpp
@@ -66,6 +66,10 @@ void VException::CriticalMessageBox(const QString &situation, QWidget * parent)
QGridLayout* layout = static_cast(msgBox.layout());
Q_CHECK_PTR(layout);
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
+ //Disable Qt::WaitCursor for error message.
+#ifndef QT_NO_CURSOR
+ QApplication::restoreOverrideCursor();
+#endif
msgBox.exec();
}
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 52b453603..6a97593b0 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -74,9 +74,8 @@ void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, c
switch (type)
{
case QtDebugMsg:
- fprintf(stderr, "Debug: %s\n", localMsg.constData());
-// fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
-// context.function);
+ fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
+ context.function);
return;
case QtWarningMsg:
messageBox.setIcon(QMessageBox::Warning);
diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp
index b7f028a29..e0ed7f41f 100644
--- a/src/app/mainwindow.cpp
+++ b/src/app/mainwindow.cpp
@@ -784,9 +784,8 @@ void MainWindow::ToolBarOption()
{
ui->toolBarOption->addWidget(new QLabel(tr("Height: ")));
- QStringList list;
- list <<"92"<<"98"<<"104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176"
- <<"182"<<"188";
+ QStringList list{"92", "98", "104", "110", "116", "122", "128", "134", "140", "146", "152", "158", "164", "170",
+ "176", "182", "188"};
QComboBox *comboBoxHeight = new QComboBox;
comboBoxHeight->addItems(list);
comboBoxHeight->setCurrentIndex(14);//176
@@ -1905,7 +1904,14 @@ void MainWindow::LoadPattern(const QString &fileName)
}
SetEnableWidgets(true);
+ bool patternModified = doc->isPatternModified();
setCurrentFile(fileName);
+ if (patternModified)
+ {
+ //For situation where was fixed wrong formula need return for document status was modified.
+ doc->setPatternModified(patternModified);
+ PatternWasModified();
+ }
helpLabel->setText(tr("File loaded"));
}
diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp
index 87c4801f0..64e5af6eb 100644
--- a/src/app/tablewindow.cpp
+++ b/src/app/tablewindow.cpp
@@ -228,8 +228,7 @@ void TableWindow::saveScene()
shadowPaper->setVisible(false);
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
QFileInfo fi( name );
- QStringList suffix;
- suffix << "svg" << "png" << "pdf" << "eps" << "ps";
+ QStringList suffix{"svg", "png", "pdf", "eps", "ps"};
switch (suffix.indexOf(fi.suffix()))
{
case 0: //svg
@@ -510,10 +509,7 @@ void TableWindow::EpsFile(const QString &name) const
if (tmp.open())
{
PdfFile(tmp.fileName());
-
- QStringList params;
- params << "-eps" << tmp.fileName() << name;
-
+ QStringList params{"-eps", tmp.fileName(), name};
PdfToPs(params);
}
}
@@ -525,10 +521,7 @@ void TableWindow::PsFile(const QString &name) const
if (tmp.open())
{
PdfFile(tmp.fileName());
-
- QStringList params;
- params << tmp.fileName() << name;
-
+ QStringList params{tmp.fileName(), name};
PdfToPs(params);
}
}
diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp
index 25f329719..457de4522 100644
--- a/src/app/tools/drawTools/vdrawtool.cpp
+++ b/src/app/tools/drawTools/vdrawtool.cpp
@@ -28,9 +28,22 @@
#include "vdrawtool.h"
+#include
+
+#include
+
+#include
+
qreal VDrawTool::factor = 1;
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief VDrawTool constructor.
+ * @param doc dom document container.
+ * @param data container with variables.
+ * @param id object id in container.
+ * @param parent parent object.
+ */
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
:VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw()), dialog(nullptr)
@@ -46,7 +59,15 @@ VDrawTool::~VDrawTool()
delete dialog;
}
+
+
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief ShowTool highlight tool.
+ * @param id object id in container.
+ * @param color highlight color.
+ * @param enable enable or disable highlight.
+ */
void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
Q_UNUSED(id);
@@ -55,6 +76,10 @@ void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
+ * @param newName new name active pattern peace. name new active pattern peace.
+ */
void VDrawTool::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
@@ -68,6 +93,11 @@ void VDrawTool::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief ChangedNameDraw save new name active pattern peace.
+ * @param oldName old name.
+ * @param newName new name active pattern peace. new name.
+ */
void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
{
if (nameActivDraw == oldName)
@@ -77,6 +107,10 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief FullUpdateFromGui refresh tool data after change in options.
+ * @param result keep result working dialog.
+ */
void VDrawTool::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
@@ -95,6 +129,10 @@ void VDrawTool::FullUpdateFromGui(int result)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief SetFactor set current scale factor of scene.
+ * @param factor scene scale factor.
+ */
void VDrawTool::SetFactor(qreal factor)
{
if (factor <= 2 && factor >= 0.5)
@@ -104,6 +142,55 @@ void VDrawTool::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief CheckFormula check formula.
+ *
+ * Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
+ * successes case return result calculation and fixed formula string. If formula ok don't touch formula.
+ * @param formula [in|out] string with formula.
+ * @param data [in] container with variables. Need for math parser.
+ * @throw QmuParserError.
+ * @return result of calculation formula.
+ */
+qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
+{
+ qreal result = 0;
+ Calculator *cal = nullptr;
+ try
+ {
+ cal = new Calculator(data);
+ result = cal->EvalFormula(formula);
+ delete cal;
+ }
+ catch(qmu::QmuParserError &e)
+ {
+ delete cal;
+ DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data);
+ dialog->setFormula(formula);
+ if (dialog->exec() == QDialog::Accepted)
+ {
+ formula = dialog->getFormula();
+ //Need delete dialog here because parser in dialog don't allow use correct separator for parsing here.
+ //Don't know why.
+ delete dialog;
+ Calculator *cal = new Calculator(data);
+ result = cal->EvalFormula(formula);
+ delete cal;//Here can be memory leak, but dialog already check this formula and probability very low.
+ }
+ else
+ {
+ delete dialog;
+ throw;
+ }
+ }
+ return result;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief AddToCalculation add tool to calculation tag in pattern file.
+ * @param domElement tag in xml tree.
+ */
void VDrawTool::AddToCalculation(const QDomElement &domElement)
{
QDomElement calcElement;
diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h
index af389a880..e665ba67f 100644
--- a/src/app/tools/drawTools/vdrawtool.h
+++ b/src/app/tools/drawTools/vdrawtool.h
@@ -42,83 +42,42 @@ class VDrawTool : public VAbstractTool
{
Q_OBJECT
public:
- /**
- * @brief VDrawTool constructor.
- * @param doc dom document container.
- * @param data container with variables.
- * @param id object id in container.
- * @param parent parent object.
- */
- VDrawTool(VPattern *doc, VContainer *data, quint32 id);
+
+ VDrawTool(VPattern *doc, VContainer *data, quint32 id);
virtual ~VDrawTool();
- /**
- * @brief setDialog set dialog when user want change tool option.
- */
+
+ /** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {}
- /**
- * @brief ignoreContextMenu set ignore contect menu tool.
- * @param enable true - ignore.
- */
- void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;}
+
+ void ignoreContextMenu(bool enable);
+ static qreal CheckFormula(QString &formula, VContainer *data);
public slots:
- /**
- * @brief ShowTool highlight tool.
- * @param id object id in container.
- * @param color highlight color.
- * @param enable enable or disable highlight.
- */
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
- /**
- * @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
- * @param newName new name active pattern peace. name new active pattern peace.
- */
virtual void ChangedActivDraw(const QString &newName);
- /**
- * @brief ChangedNameDraw save new name active pattern peace.
- * @param oldName old name.
- * @param newName new name active pattern peace. new name.
- */
void ChangedNameDraw(const QString &oldName, const QString &newName);
- /**
- * @brief FullUpdateFromGui refresh tool data after change in options.
- * @param result keep result working dialog.
- */
virtual void FullUpdateFromGui(int result);
- /**
- * @brief SetFactor set current scale factor of scene.
- * @param factor scene scale factor.
- */
virtual void SetFactor(qreal factor);
protected:
- /**
- * @brief ignoreContextMenuEvent ignore or not context menu events.
- */
+ /** @brief ignoreContextMenuEvent ignore or not context menu events. */
bool ignoreContextMenuEvent;
- /**
- * @brief ignoreFullUpdate ignore or not full updates.
- */
+
+ /** @brief ignoreFullUpdate ignore or not full updates. */
bool ignoreFullUpdate;
- /**
- * @brief nameActivDraw name of tool's pattern peace.
- */
+
+ /** @brief nameActivDraw name of tool's pattern peace. */
QString nameActivDraw;
- /**
- * @brief factor scene scale factor.
- */
+
+ /** @brief factor scene scale factor. */
static qreal factor;
- /**
- * @brief dialog dialog options.
- */
+
+ /** @brief dialog dialog options.*/
DialogTool *dialog;
- /**
- * @brief AddToCalculation add tool to calculation tag in pattern file.
- * @param domElement tag in xml tree.
- */
+
void AddToCalculation(const QDomElement &domElement);
- /**
- * @brief SaveDialog save options into file after change in dialog.
- */
+
+ /** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement)=0;
+
template
/**
* @brief ContextMenu show context menu for tool.
@@ -203,4 +162,14 @@ private:
Q_DISABLE_COPY(VDrawTool)
};
+//---------------------------------------------------------------------------------------------------------------------
+/**
+ * @brief ignoreContextMenu set ignore contect menu tool.
+ * @param enable true - ignore.
+ */
+inline void VDrawTool::ignoreContextMenu(bool enable)
+{
+ ignoreContextMenuEvent = enable;
+}
+
#endif // VDRAWTOOL_H
diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp
index 1d8613d48..b6ca59ec2 100644
--- a/src/app/tools/drawTools/vtoolalongline.cpp
+++ b/src/app/tools/drawTools/vtoolalongline.cpp
@@ -164,27 +164,25 @@ void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatt
DialogAlongLine *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
- quint32 firstPointId = dialogTool->getFirstPointId();
- quint32 secondPointId = dialogTool->getSecondPointId();
- QString typeLine = dialogTool->getTypeLine();
- QString pointName = dialogTool->getPointName();
+ const quint32 firstPointId = dialogTool->getFirstPointId();
+ const quint32 secondPointId = dialogTool->getSecondPointId();
+ const QString typeLine = dialogTool->getTypeLine();
+ const QString pointName = dialogTool->getPointName();
Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
- const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
- const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
- VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
+void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
+ const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
+ VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
+ const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *firstPoint = data->GeometricObject(firstPointId);
const VPointF *secondPoint = data->GeometricObject(secondPointId);
QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF());
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
- line.setLength(qApp->toPixel(result));
+ line.setLength(qApp->toPixel(CheckFormula(formula, data)));
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h
index f9a50f86e..8276c3954 100644
--- a/src/app/tools/drawTools/vtoolalongline.h
+++ b/src/app/tools/drawTools/vtoolalongline.h
@@ -81,7 +81,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &formula,
+ static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp
index af9754b26..9664f2528 100644
--- a/src/app/tools/drawTools/vtoolarc.cpp
+++ b/src/app/tools/drawTools/vtoolarc.cpp
@@ -73,13 +73,12 @@ void VToolArc::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
- VContainer *data)
+void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
Q_CHECK_PTR(dialog);
DialogArc *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 center = dialogTool->GetCenter();
+ const quint32 center = dialogTool->GetCenter();
QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1();
QString f2 = dialogTool->GetF2();
@@ -87,19 +86,16 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *d
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolArc::Create(const quint32 _id, const quint32 ¢er, const QString &radius, const QString &f1,
- const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
- const Document::Documents &parse, const Valentina::Sources &typeCreation)
+void VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
+ VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
+ const Valentina::Sources &typeCreation)
{
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
- Calculator cal(data);
+ calcRadius = qApp->toPixel(CheckFormula(radius, data));
- qreal result = cal.EvalFormula(radius);
- calcRadius = qApp->toPixel(result);
-
- calcF1 = cal.EvalFormula(f1);
- calcF2 = cal.EvalFormula(f2);
+ calcF1 = CheckFormula(f1, data);
+ calcF2 = CheckFormula(f2, data);
VPointF c = *data->GeometricObject(center);
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );
diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h
index f6ae530a9..b601a230a 100644
--- a/src/app/tools/drawTools/vtoolarc.h
+++ b/src/app/tools/drawTools/vtoolarc.h
@@ -75,9 +75,9 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const quint32 ¢er, const QString &radius, const QString &f1,
- const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
- const Document::Documents &parse, const Valentina::Sources &typeCreation);
+ static void Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
+ VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
+ const Valentina::Sources &typeCreation);
static const QString TagName;
static const QString ToolType;
public slots:
diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp
index 36d3436e6..07a136106 100644
--- a/src/app/tools/drawTools/vtoolbisector.cpp
+++ b/src/app/tools/drawTools/vtoolbisector.cpp
@@ -94,17 +94,17 @@ void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
DialogBisector *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
- quint32 firstPointId = dialogTool->getFirstPointId();
- quint32 secondPointId = dialogTool->getSecondPointId();
- quint32 thirdPointId = dialogTool->getThirdPointId();
- QString typeLine = dialogTool->getTypeLine();
- QString pointName = dialogTool->getPointName();
+ const quint32 firstPointId = dialogTool->getFirstPointId();
+ const quint32 secondPointId = dialogTool->getSecondPointId();
+ const quint32 thirdPointId = dialogTool->getThirdPointId();
+ const QString typeLine = dialogTool->getTypeLine();
+ const QString pointName = dialogTool->getPointName();
Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolBisector::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
+void VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@@ -114,8 +114,7 @@ void VToolBisector::Create(const quint32 _id, const QString &formula, const quin
const VPointF *secondPoint = data->GeometricObject(secondPointId);
const VPointF *thirdPoint = data->GeometricObject(thirdPointId);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
thirdPoint->toQPointF(), qApp->toPixel(result));
diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h
index 9af080e12..f49d6fa5b 100644
--- a/src/app/tools/drawTools/vtoolbisector.h
+++ b/src/app/tools/drawTools/vtoolbisector.h
@@ -93,7 +93,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
+ static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,
diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp
index 2f1a8cf81..50521d867 100644
--- a/src/app/tools/drawTools/vtoolcutarc.cpp
+++ b/src/app/tools/drawTools/vtoolcutarc.cpp
@@ -83,21 +83,20 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogCutArc *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- QString pointName = dialogTool->getPointName();
+ const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
- quint32 arcId = dialogTool->getArcId();
+ const quint32 arcId = dialogTool->getArcId();
Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolCutArc::Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId,
+void VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VArc *arc = data->GeometricObject(arcId);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
VArc arc1;
VArc arc2;
diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h
index e9933f812..53dbcd740 100644
--- a/src/app/tools/drawTools/vtoolcutarc.h
+++ b/src/app/tools/drawTools/vtoolcutarc.h
@@ -80,7 +80,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId,
+ static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp
index 1f1f14c1f..4e74b31d6 100644
--- a/src/app/tools/drawTools/vtoolcutspline.cpp
+++ b/src/app/tools/drawTools/vtoolcutspline.cpp
@@ -83,22 +83,20 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogCutSpline *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- QString pointName = dialogTool->getPointName();
+ const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
- quint32 splineId = dialogTool->getSplineId();
+ const quint32 splineId = dialogTool->getSplineId();
Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolCutSpline::Create(const quint32 _id, const QString &pointName,
- const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my,
- VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
- const Document::Documents &parse, const Valentina::Sources &typeCreation)
+void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
+ const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
+ VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VSpline *spl = data->GeometricObject(splineId);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h
index 0bff6ea89..b5cae8641 100644
--- a/src/app/tools/drawTools/vtoolcutspline.h
+++ b/src/app/tools/drawTools/vtoolcutspline.h
@@ -78,9 +78,8 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &pointName,
- const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my,
- VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
+ static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
+ const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
static const QString AttrSpline;
diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp
index 290aa92ef..e21db71cd 100644
--- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp
+++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp
@@ -83,14 +83,14 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogCutSplinePath *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- QString pointName = dialogTool->getPointName();
+ const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
- quint32 splinePathId = dialogTool->getSplinePathId();
+ const quint32 splinePathId = dialogTool->getSplinePathId();
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, const QString &formula,
+void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
@@ -98,8 +98,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con
const VSplinePath *splPath = data->GeometricObject(splinePathId);
Q_CHECK_PTR(splPath);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
quint32 id = _id;
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h
index e2c288291..9bd1c9dcd 100644
--- a/src/app/tools/drawTools/vtoolcutsplinepath.h
+++ b/src/app/tools/drawTools/vtoolcutsplinepath.h
@@ -81,10 +81,9 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &pointName, const QString &formula,
- const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
- VPattern *doc, VContainer *data, const Document::Documents &parse,
- const Valentina::Sources &typeCreation);
+ static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId,
+ const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
+ const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
static const QString AttrSplinePath;
public slots:
diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp
index 22c9639cc..107a6e107 100644
--- a/src/app/tools/drawTools/vtoolendline.cpp
+++ b/src/app/tools/drawTools/vtoolendline.cpp
@@ -30,6 +30,7 @@
#include "../../widgets/vmaingraphicsscene.h"
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogendline.h"
+#include "../../dialogs/tools/dialogeditwrongformula.h"
const QString VToolEndLine::ToolType = QStringLiteral("endLine");
@@ -71,28 +72,25 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter
Q_CHECK_PTR(dialog);
DialogEndLine *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- QString pointName = dialogTool->getPointName();
- QString typeLine = dialogTool->getTypeLine();
+ const QString pointName = dialogTool->getPointName();
+ const QString typeLine = dialogTool->getTypeLine();
QString formula = dialogTool->getFormula();
- qreal angle = dialogTool->getAngle();
- quint32 basePointId = dialogTool->getBasePointId();
+ const qreal angle = dialogTool->getAngle();
+ const quint32 basePointId = dialogTool->getBasePointId();
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
- const QString &formula, const qreal &angle, const quint32 &basePointId,
+ QString &formula, const qreal &angle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *basePoint = data->GeometricObject(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
-
- line.setLength(qApp->toPixel(result));
+ line.setLength(qApp->toPixel(CheckFormula(formula, data)));
line.setAngle(angle);
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h
index acf0bcf20..17a272f19 100644
--- a/src/app/tools/drawTools/vtoolendline.h
+++ b/src/app/tools/drawTools/vtoolendline.h
@@ -82,7 +82,7 @@ public:
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const QString &typeLine,
- const QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx,
+ QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp
index ab1381ac0..88b92801e 100644
--- a/src/app/tools/drawTools/vtoolheight.cpp
+++ b/src/app/tools/drawTools/vtoolheight.cpp
@@ -70,11 +70,11 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogHeight *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList);
- QString pointName = dialogTool->getPointName();
- QString typeLine = dialogTool->getTypeLine();
- quint32 basePointId = dialogTool->getBasePointId();
- quint32 p1LineId = dialogTool->getP1LineId();
- quint32 p2LineId = dialogTool->getP2LineId();
+ const QString pointName = dialogTool->getPointName();
+ const QString typeLine = dialogTool->getTypeLine();
+ const quint32 basePointId = dialogTool->getBasePointId();
+ const quint32 p1LineId = dialogTool->getP1LineId();
+ const quint32 p2LineId = dialogTool->getP2LineId();
Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp
index d4aab43df..49014357d 100644
--- a/src/app/tools/drawTools/vtoolline.cpp
+++ b/src/app/tools/drawTools/vtoolline.cpp
@@ -76,9 +76,9 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
Q_CHECK_PTR(dialog);
DialogLine *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 firstPoint = dialogTool->getFirstPoint();
- quint32 secondPoint = dialogTool->getSecondPoint();
- QString typeLine = dialogTool->getTypeLine();
+ const quint32 firstPoint = dialogTool->getFirstPoint();
+ const quint32 secondPoint = dialogTool->getSecondPoint();
+ const QString typeLine = dialogTool->getTypeLine();
Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp
index 1f737fe20..b73cafaf0 100644
--- a/src/app/tools/drawTools/vtoollineintersect.cpp
+++ b/src/app/tools/drawTools/vtoollineintersect.cpp
@@ -70,11 +70,11 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogLineIntersect *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 p1Line1Id = dialogTool->getP1Line1();
- quint32 p2Line1Id = dialogTool->getP2Line1();
- quint32 p1Line2Id = dialogTool->getP1Line2();
- quint32 p2Line2Id = dialogTool->getP2Line2();
- QString pointName = dialogTool->getPointName();
+ const quint32 p1Line1Id = dialogTool->getP1Line1();
+ const quint32 p2Line1Id = dialogTool->getP2Line1();
+ const quint32 p1Line2Id = dialogTool->getP1Line2();
+ const quint32 p2Line2Id = dialogTool->getP2Line2();
+ const QString pointName = dialogTool->getPointName();
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp
index 93f8a3efa..ef5b9ba9b 100644
--- a/src/app/tools/drawTools/vtoolnormal.cpp
+++ b/src/app/tools/drawTools/vtoolnormal.cpp
@@ -72,17 +72,17 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogNormal *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
- quint32 firstPointId = dialogTool->getFirstPointId();
- quint32 secondPointId = dialogTool->getSecondPointId();
- QString typeLine = dialogTool->getTypeLine();
- QString pointName = dialogTool->getPointName();
- qreal angle = dialogTool->getAngle();
+ const quint32 firstPointId = dialogTool->getFirstPointId();
+ const quint32 secondPointId = dialogTool->getSecondPointId();
+ const QString typeLine = dialogTool->getTypeLine();
+ const QString pointName = dialogTool->getPointName();
+ const qreal angle = dialogTool->getAngle();
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolNormal::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
+void VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,
@@ -91,8 +91,7 @@ void VToolNormal::Create(const quint32 _id, const QString &formula, const quint3
const VPointF *firstPoint = data->GeometricObject(firstPointId);
const VPointF *secondPoint = data->GeometricObject(secondPointId);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
qApp->toPixel(result), angle);
diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h
index 415b70e33..f054b3280 100644
--- a/src/app/tools/drawTools/vtoolnormal.h
+++ b/src/app/tools/drawTools/vtoolnormal.h
@@ -84,7 +84,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
+ static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,
diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp
index ae836dea3..25d942d7c 100644
--- a/src/app/tools/drawTools/vtoolpointofcontact.cpp
+++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp
@@ -98,27 +98,25 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene,
DialogPointOfContact *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
QString radius = dialogTool->getRadius();
- quint32 center = dialogTool->getCenter();
- quint32 firstPointId = dialogTool->getFirstPoint();
- quint32 secondPointId = dialogTool->getSecondPoint();
- QString pointName = dialogTool->getPointName();
+ const quint32 center = dialogTool->getCenter();
+ const quint32 firstPointId = dialogTool->getFirstPoint();
+ const quint32 secondPointId = dialogTool->getSecondPoint();
+ const QString pointName = dialogTool->getPointName();
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolPointOfContact::Create(const quint32 _id, const QString &radius, const quint32 ¢er,
- const quint32 &firstPointId, const quint32 &secondPointId,
- const QString &pointName, const qreal &mx, const qreal &my,
- VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
+void VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er, const quint32 &firstPointId,
+ const quint32 &secondPointId, const QString &pointName, const qreal &mx,
+ const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *centerP = data->GeometricObject(center);
const VPointF *firstP = data->GeometricObject(firstPointId);
const VPointF *secondP = data->GeometricObject(secondPointId);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(radius);
+ const qreal result = CheckFormula(radius, data);
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(),
firstP->toQPointF(), secondP->toQPointF());
diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h
index b283f238a..ce02fdd50 100644
--- a/src/app/tools/drawTools/vtoolpointofcontact.h
+++ b/src/app/tools/drawTools/vtoolpointofcontact.h
@@ -91,7 +91,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &arcRadius, const quint32 ¢er,
+ static void Create(const quint32 _id, QString &arcRadius, const quint32 ¢er,
const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation);
diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp
index 8d0a35a14..9ff688a39 100644
--- a/src/app/tools/drawTools/vtoolpointofintersection.cpp
+++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp
@@ -67,9 +67,9 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
Q_CHECK_PTR(dialog);
DialogPointOfIntersection *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 firstPointId = dialogTool->getFirstPointId();
- quint32 secondPointId = dialogTool->getSecondPointId();
- QString pointName = dialogTool->getPointName();
+ const quint32 firstPointId = dialogTool->getFirstPointId();
+ const quint32 secondPointId = dialogTool->getSecondPointId();
+ const QString pointName = dialogTool->getPointName();
Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp
index cd29ce3b1..354aec712 100644
--- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp
+++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp
@@ -100,17 +100,17 @@ void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
DialogShoulderPoint *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
- quint32 p1Line = dialogTool->getP1Line();
- quint32 p2Line = dialogTool->getP2Line();
- quint32 pShoulder = dialogTool->getPShoulder();
- QString typeLine = dialogTool->getTypeLine();
- QString pointName = dialogTool->getPointName();
+ const quint32 p1Line = dialogTool->getP1Line();
+ const quint32 p2Line = dialogTool->getP2Line();
+ const quint32 pShoulder = dialogTool->getPShoulder();
+ const QString typeLine = dialogTool->getTypeLine();
+ const QString pointName = dialogTool->getPointName();
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
-void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const quint32 &p1Line,
+void VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@@ -120,8 +120,7 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const
const VPointF *secondPoint = data->GeometricObject(p2Line);
const VPointF *shoulderPoint = data->GeometricObject(pShoulder);
- Calculator cal(data);
- const qreal result = cal.EvalFormula(formula);
+ const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
shoulderPoint->toQPointF(), qApp->toPixel(result));
diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h
index ba5e2b96f..9e9462d9d 100644
--- a/src/app/tools/drawTools/vtoolshoulderpoint.h
+++ b/src/app/tools/drawTools/vtoolshoulderpoint.h
@@ -94,7 +94,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
- static void Create(const quint32 _id, const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
+ static void Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp
index ca87c745a..0e0a5e844 100644
--- a/src/app/tools/drawTools/vtoolspline.cpp
+++ b/src/app/tools/drawTools/vtoolspline.cpp
@@ -95,13 +95,13 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogSpline *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 p1 = dialogTool->getP1();
- quint32 p4 = dialogTool->getP4();
- qreal kAsm1 = dialogTool->getKAsm1();
- qreal kAsm2 = dialogTool->getKAsm2();
- qreal angle1 = dialogTool->getAngle1();
- qreal angle2 = dialogTool->getAngle2();
- qreal kCurve = dialogTool->getKCurve();
+ const quint32 p1 = dialogTool->getP1();
+ const quint32 p4 = dialogTool->getP4();
+ const qreal kAsm1 = dialogTool->getKAsm1();
+ const qreal kAsm2 = dialogTool->getKAsm2();
+ const qreal angle1 = dialogTool->getAngle1();
+ const qreal angle2 = dialogTool->getAngle2();
+ const qreal kCurve = dialogTool->getKCurve();
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}
diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp
index d9c679201..28ca05b8c 100644
--- a/src/app/tools/drawTools/vtooltriangle.cpp
+++ b/src/app/tools/drawTools/vtooltriangle.cpp
@@ -70,11 +70,11 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogTriangle *dialogTool = qobject_cast(dialog);
Q_CHECK_PTR(dialogTool);
- quint32 axisP1Id = dialogTool->getAxisP1Id();
- quint32 axisP2Id = dialogTool->getAxisP2Id();
- quint32 firstPointId = dialogTool->getFirstPointId();
- quint32 secondPointId = dialogTool->getSecondPointId();
- QString pointName = dialogTool->getPointName();
+ const quint32 axisP1Id = dialogTool->getAxisP1Id();
+ const quint32 axisP2Id = dialogTool->getAxisP2Id();
+ const quint32 firstPointId = dialogTool->getFirstPointId();
+ const quint32 secondPointId = dialogTool->getSecondPointId();
+ const QString pointName = dialogTool->getPointName();
Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp
index 523d702fe..ce800920d 100644
--- a/src/app/tools/vabstracttool.cpp
+++ b/src/app/tools/vabstracttool.cpp
@@ -309,9 +309,8 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre
const QStringList VAbstractTool::Styles()
{
//Keep synchronize with DialogTool lineStyles list!!!
- QStringList styles;
- styles << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << TypeLineDashDotLine
- << TypeLineDashDotDotLine;
+ QStringList styles{TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine,
+ TypeLineDashDotDotLine};
return styles;
}
diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp
index 5fa41b309..36a246d13 100644
--- a/src/app/widgets/vapplication.cpp
+++ b/src/app/widgets/vapplication.cpp
@@ -1722,23 +1722,10 @@ QString VApplication::FormulaFromUser(const QString &formula)
{
QString newFormula = formula;
- QMap tokens;
- QMap numbers;
- try
- {
- Calculator cal(formula);
- tokens = cal.GetTokens();
- numbers = cal.GetNumbers();
- }
- catch(qmu::QmuParserError &e)
- {
- qDebug() << "\nMath parser error:\n"
- << "--------------------------------------\n"
- << "Message: " << e.GetMsg() << "\n"
- << "Expression: " << e.GetExpr() << "\n"
- << "--------------------------------------";
- return newFormula;
- }
+ Calculator *cal = new Calculator(formula);
+ QMap tokens = cal->GetTokens();
+ QMap numbers = cal->GetNumbers();
+ delete cal;
QList tKeys = tokens.keys();
QList tValues = tokens.values();
@@ -1799,7 +1786,7 @@ QString VApplication::FormulaFromUser(const QString &formula)
{
QList nKeys = numbers.keys();
QList nValues = numbers.values();
- for (int i = 0; i < tKeys.size(); ++i)
+ for (int i = 0; i < nKeys.size(); ++i)
{
bool ok = false;
qreal d = loc.toDouble(nValues.at(i), &ok);
@@ -1838,9 +1825,10 @@ QString VApplication::FormulaToUser(const QString &formula)
QMap numbers;
try
{
- Calculator cal(formula, false);
- tokens = cal.GetTokens();
- numbers = cal.GetNumbers();
+ Calculator *cal = new Calculator(formula, false);
+ tokens = cal->GetTokens();
+ numbers = cal->GetNumbers();
+ delete cal;
}
catch (qmu::QmuParserError &e)
{
@@ -1917,7 +1905,7 @@ QString VApplication::FormulaToUser(const QString &formula)
{
QList nKeys = numbers.keys();
QList nValues = numbers.values();
- for (int i = 0; i < tKeys.size(); ++i)
+ for (int i = 0; i < nKeys.size(); ++i)
{
QLocale loc = QLocale(QLocale::C);
bool ok = false;
diff --git a/src/app/xml/vdomdocument.cpp b/src/app/xml/vdomdocument.cpp
index c65e1b50c..28bed1d6b 100644
--- a/src/app/xml/vdomdocument.cpp
+++ b/src/app/xml/vdomdocument.cpp
@@ -338,8 +338,7 @@ void VDomDocument::setContent(const QString &fileName)
//---------------------------------------------------------------------------------------------------------------------
Valentina::Units VDomDocument::StrToUnits(const QString &unit)
{
- QStringList units;
- units << UnitMM << UnitCM << UnitINCH;
+ QStringList units{UnitMM, UnitCM, UnitINCH};
Valentina::Units result = Valentina::Cm;
switch (units.indexOf(unit))
{
diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp
index 3ea2f8149..107784f50 100644
--- a/src/app/xml/vindividualmeasurements.cpp
+++ b/src/app/xml/vindividualmeasurements.cpp
@@ -305,8 +305,7 @@ QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Gend
//---------------------------------------------------------------------------------------------------------------------
VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex)
{
- QStringList genders;
- genders << SexMale << SexFemale;
+ QStringList genders{SexMale, SexFemale};
switch (genders.indexOf(sex))
{
case 0: // SexMale
diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp
index 380a74b15..67fb89c45 100644
--- a/src/app/xml/vpattern.cpp
+++ b/src/app/xml/vpattern.cpp
@@ -214,9 +214,8 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
- QStringList tags;
- tags << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements
- << TagVersion;
+ QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements,
+ TagVersion};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagDraw
@@ -487,8 +486,7 @@ Valentina::Units VPattern::MUnit() const
QDomElement element = list.at(0).toElement();
if (element.isElement())
{
- QStringList units;
- units << "mm" << "cm" << "inch";
+ QStringList units{"mm", "cm", "inch"};
QString unit = GetParametrString(element, AttrUnit);
switch (units.indexOf(unit))
{
@@ -520,8 +518,7 @@ Pattern::Measurements VPattern::MType() const
if (element.isElement())
{
QString type = GetParametrString(element, AttrType);
- QStringList types;
- types << "standard" << "individual";
+ QStringList types{"standard", "individual"};
switch (types.indexOf(type))
{
case 0:// standard
@@ -613,8 +610,7 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
- QStringList tags;
- tags << TagCalculation << TagModeling << TagDetails;
+ QStringList tags{TagCalculation, TagModeling, TagDetails};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagCalculation
@@ -656,11 +652,10 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *
const qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
{
- const QDomElement domElement = nodeList.at(i).toElement();
+ QDomElement domElement = nodeList.at(i).toElement();
if (domElement.isNull() == false)
{
- QStringList tags;
- tags << TagPoint << TagLine << TagSpline << TagArc << TagTools;
+ QStringList tags{TagPoint, TagLine, TagSpline, TagArc, TagTools};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagPoint
@@ -719,9 +714,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
const QString t = GetParametrString(element, AttrType, "NodePoint");
Valentina::Tools tool;
- QStringList types;
- types << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline <<
- VToolDetail::NodeSplinePath;
+ QStringList types{VToolDetail::NodePoint, VToolDetail::NodeArc, VToolDetail::NodeSpline,
+ VToolDetail::NodeSplinePath};
switch (types.indexOf(t))
{
case 0: // VToolDetail::NodePoint
@@ -779,7 +773,7 @@ void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
-void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &domElement,
+void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString &type)
{
Q_CHECK_PTR(scene);
@@ -787,12 +781,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
- QStringList points;
- points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType
- << VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType
- << VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType
- << VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType
- << VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
+ QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType,
+ VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType,
+ VToolLineIntersect::ToolType, VToolPointOfContact::ToolType, VNodePoint::ToolType,
+ VToolHeight::ToolType, VToolTriangle::ToolType, VToolPointOfIntersection::ToolType,
+ VToolCutSpline::ToolType, VToolCutSplinePath::ToolType, VToolCutArc::ToolType};
switch (points.indexOf(type))
{
case 0: //VToolSinglePoint::ToolType
@@ -842,11 +835,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
+ QString f = formula;//need for saving fixed formula;
+
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
- VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId,
+ VToolEndLine::Create(id, name, typeLine, f, angle, basePointId,
mx, my, scene, this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -873,11 +874,18 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
+ QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
- VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this,
+ VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this,
data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -904,12 +912,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
+ QString f = formula;//need for saving fixed formula;
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0");
- VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
+ VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -936,12 +951,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
+ QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
- VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
+ VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -968,12 +990,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
+ QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
- VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId,
+ VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId,
typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1020,12 +1049,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
+ QString f = radius;//need for saving fixed formula;
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
- VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
+ VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != radius)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrRadius, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1135,10 +1171,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
+ QString f = formula;//need for saving fixed formula;
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
- VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
- Valentina::FromFile);
+ VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1163,10 +1205,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
+ QString f = formula;//need for saving fixed formula;
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
- VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my,
- scene, this, data, parse, Valentina::FromFile);
+ VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse,
+ Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1191,9 +1240,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
+ QString f = formula;//need for saving fixed formula;
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
- VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
+ VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (f != formula)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrLength, f);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1248,8 +1304,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
- QStringList splines;
- splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType;
+ QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType,
+ VNodeSplinePath::ToolType};
switch (splines.indexOf(type))
{
case 0: //VToolSpline::ToolType
@@ -1363,15 +1419,14 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
-void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
- const Document::Documents &parse, const QString &type)
+void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse,
+ const QString &type)
{
Q_CHECK_PTR(scene);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
- QStringList arcs;
- arcs << VToolArc::ToolType << VNodeArc::ToolType;
+ QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType};
switch (arcs.indexOf(type))
{
@@ -1381,10 +1436,21 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom
const quint32 id = GetParametrId(domElement);
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
+ QString r = radius;//need for saving fixed formula;
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
+ QString f1Fix = f1;//need for saving fixed formula;
const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
+ QString f2Fix = f2;//need for saving fixed formula;
- VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Valentina::FromFile);
+ VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Valentina::FromFile);
+ //Rewrite attribute formula. Need for situation when we have wrong formula.
+ if (r != radius || f1Fix != f1 || f2Fix != f2)
+ {
+ SetAttribute(domElement, VAbstractTool::AttrRadius, r);
+ SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix);
+ SetAttribute(domElement, VAbstractTool::AttrAngle2, f2Fix);
+ haveLiteChange();
+ }
}
catch (const VExceptionBadId &e)
{
@@ -1434,8 +1500,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
- QStringList tools;
- tools << VToolUnionDetails::ToolType;
+ QStringList tools{VToolUnionDetails::ToolType};
switch (tools.indexOf(type))
{
diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h
index 1c61de1f7..8d32ed97a 100644
--- a/src/app/xml/vpattern.h
+++ b/src/app/xml/vpattern.h
@@ -334,7 +334,7 @@ private:
* @param type type of point.
* @param mode draw mode.
*/
- void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
+ void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString &type);
/**
* @brief ParseLineElement parse line tag.
@@ -363,7 +363,7 @@ private:
* @param type type of spline.
* @param mode draw mode.
*/
- void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
+ void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseToolsElement parse tools tag.
diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp
index 6180f2310..4772f42ec 100644
--- a/src/libs/qmuparser/qmuparser.cpp
+++ b/src/libs/qmuparser/qmuparser.cpp
@@ -245,9 +245,9 @@ QmuParser::QmuParser():QmuParserBase()
*/
void QmuParser::InitCharSets()
{
- DefineNameChars( "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" );
- DefineOprtChars( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}" );
- DefineInfixOprtChars( "/+-*^?<>=#!$%&|~'_" );
+ DefineNameChars( QStringLiteral("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") );
+ DefineOprtChars( QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") );
+ DefineInfixOprtChars( QStringLiteral("/+-*^?<>=#!$%&|~'_") );
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp
index 21ff321df..6354c8b03 100644
--- a/src/libs/qmuparser/qmuparserbase.cpp
+++ b/src/libs/qmuparser/qmuparserbase.cpp
@@ -50,9 +50,8 @@ bool QmuParserBase::g_DbgDumpStack = false;
* When defining custom binary operators with #AddOprt(...) make sure not to choose
* names conflicting with these definitions.
*/
-const QStringList QmuParserBase::c_DefaultOprt = QStringList() << "<=" << ">=" << "!=" << "==" << "<" << ">"
- << "+" << "-" << "*" << "/" << "^" << "&&"
- << "||" << "=" << "(" << ")" << "?" << ":";
+const QStringList QmuParserBase::c_DefaultOprt{"<=", ">=", "!=", "==", "<", ">", "+", "-", "*", "/", "^", "&&", "||",
+ "=", "(", ")", "?", ":"};
//---------------------------------------------------------------------------------------------------------------------
/**
diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp
index d21bc93be..baff8cf16 100644
--- a/src/libs/qmuparser/qmuparsertokenreader.cpp
+++ b/src/libs/qmuparser/qmuparsertokenreader.cpp
@@ -541,8 +541,7 @@ bool QmuParserTokenReader::IsEOF ( token_type &a_Tok )
}
catch (qmu::QmuParserError &e)
{
- qDebug() << "\n "
- << " Code:" << e.GetCode() << "(" << e.GetMsg() << ")";
+ qDebug() << " Code:" << e.GetCode() << "(" << e.GetMsg() << ")";
throw;
}
}