diff --git a/README b/README index 84349b95e..2cd83e0cf 100644 --- a/README +++ b/README @@ -13,14 +13,14 @@ Supported Platforms The standalone binary packages support the following platforms: Windows XP SP2 or later -Ubuntu Linux 11.10 (32-bit) or later +Ubuntu Linux 14.04 (32-bit) or later -Building the sources requires Qt 5.1.0 or later. +Building the sources requires Qt 5.2.1 or later. Compiling Valentina ==================== Prerequisites: - * Qt 5.1.0 or later (On Unix development packages needed) + * Qt 5.2.1 or later (On Unix development packages needed) * mercurial * On Unix: - ccache diff --git a/Valentina.pro b/Valentina.pro index fc3aa522f..7134680c9 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -1,9 +1,9 @@ include(Valentina.pri) #version check qt -!minQtVersion(5, 1, 0) { +!minQtVersion(5, 2, 1) { message("Cannot build Valentina with Qt version $${QT_VERSION}.") - error("Use at least Qt 5.1.0.") + error("Use at least Qt 5.2.1.") } TEMPLATE = subdirs diff --git a/dist/debian/valentina.1 b/dist/debian/valentina.1 index 488473b7f..53996aa5c 100644 --- a/dist/debian/valentina.1 +++ b/dist/debian/valentina.1 @@ -1,13 +1,19 @@ .\" Manpage for valentina. .\" Contact dismine@gmail.com.in to correct errors. -.TH man 1 "25 Nov 2013" "1.0" "valentina man page" +.TH man 1 "29 May 2014" "valentina man page" .SH NAME valentina \- Pattern making program. .SH SYNOPSIS -valentina +valentina [options] file .SH DESCRIPTION Open source project of creating a pattern making program, whose allow create and modeling patterns of clothing. .SH OPTIONS -The valentina does not take any options. +-help Show summary of options. + +-version + Show version of program. + +file + Pattern file to load. .SH AUTHOR -Roman Telezhinsky (dismine@gmail.com) \ No newline at end of file +This manual page was written by Roman Telezhynskyi diff --git a/src/app/app.pro b/src/app/app.pro index 909719a1e..bbc31238c 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -219,9 +219,9 @@ for(DIR, INSTALL_STANDARD_MEASHUREMENTS) { copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard)) -win32:CONFIG(release, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 -else:win32:CONFIG(debug, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 -else:unix: LIBS += -L../libs/qmuparser/bin -lqmuparser +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2 +else:unix: LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser -INCLUDEPATH += ../libs/qmuparser -DEPENDPATH += ../libs/qmuparser +INCLUDEPATH += $$PWD/../libs/qmuparser +DEPENDPATH += $$PWD/../libs/qmuparser diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index 238616e74..df87bea96 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -28,13 +28,24 @@ #include "calculator.h" #include +#include #include "../widgets/vapplication.h" int Calculator::iVal = -1; //--------------------------------------------------------------------------------------------------------------------- /** - * @brief Calculator class constructor. + * @brief Calculator class constructor. Make easy initialization math parser. + * + * This constructor hide initialization variables, operators, character sets. + * Use this constuctor for evaluation formula. All formulas must be converted to internal look. + * Example: + * + * const QString formula = qApp->FormulaFromUser(edit->text()); + * Calculator *cal = new Calculator(data); + * const qreal result = cal->EvalFormula(formula); + * delete cal; + * * @param data pointer to a variable container. */ Calculator::Calculator(const VContainer *data) @@ -55,6 +66,21 @@ Calculator::Calculator(const VContainer *data) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Calculator class constructor. Make easy initialization math parser. + * + * This constructor hide initialization variables, operators, character sets. + * Use this constuctor to get tokens from formula. All formulas must be converted to external look. + * Example: + * + * Calculator *cal = new Calculator(formula, false); + * tokens = cal->GetTokens(); + * numbers = cal->GetNumbers(); + * delete cal; + * + * @param data pointer to a variable container. + * @param fromUser true if we parse formula from user + */ Calculator::Calculator(const QString &formula, bool fromUser) :QmuParser(), vVarVal(nullptr) { @@ -68,10 +94,22 @@ Calculator::Calculator(const QString &formula, bool fromUser) DefinePostfixOprt(qApp->PostfixOperator(mm_Oprt), MmUnit); DefinePostfixOprt(qApp->PostfixOperator(in_Oprt), InchUnit); - QLocale loc = QLocale::system(); - SetDecSep(loc.decimalPoint().toLatin1()); - SetThousandsSep(loc.groupSeparator().toLatin1()); - SetArgSep(';'); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool(); + + if (osSeparatorValue) + { + QLocale loc = QLocale::system(); + SetDecSep(loc.decimalPoint().toLatin1()); + SetThousandsSep(loc.groupSeparator().toLatin1()); + SetArgSep(';'); + } + else + { + SetArgSep(','); + SetDecSep('.'); + } } else { @@ -84,14 +122,8 @@ Calculator::Calculator(const QString &formula, bool fromUser) } SetExpr(formula); - try - { - Eval();//Need run for making tokens - } - catch(qmu::QmuParserError &e) - { - return;//Ignore all warnings - } + //Need run for making tokens. Don't catch exception here, because it will show us in dialog that formula has error. + Eval(); } Calculator::~Calculator() @@ -204,15 +236,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; } } @@ -224,20 +254,19 @@ 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; } } } +//--------------------------------------------------------------------------------------------------------------------- void Calculator::InitCharacterSets() { //String with all unique symbols for supported alpabets. diff --git a/src/app/container/calculator.h b/src/app/container/calculator.h index 2961f6498..f9eb9e297 100644 --- a/src/app/container/calculator.h +++ b/src/app/container/calculator.h @@ -34,6 +34,25 @@ #include "../../libs/qmuparser/qmuparser.h" using namespace qmu; +/** + * @brief The Calculator class for calculation formula. + * + * Main purpose make easy evaluate value of formula and get tokens. + * Note. If created to many parser for different purpes in the same time parser can work wrong. + * Example: + * 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. + * } + */ class Calculator:public QmuParser { public: 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/app/pages.cpp b/src/app/dialogs/app/pages.cpp index 476c941da..1e17fd272 100644 --- a/src/app/dialogs/app/pages.cpp +++ b/src/app/dialogs/app/pages.cpp @@ -51,7 +51,7 @@ void ConfigurationPage::Apply() QApplication::applicationName()); settings.setValue("configuration/autosave/state", autoSaveCheck->isChecked()); settings.setValue("configuration/autosave/time", autoTime->value()); - //settings.setValue("configuration/osSeparator", osOptionCheck->isChecked()); + settings.setValue("configuration/osSeparator", osOptionCheck->isChecked()); if (langChanged) { QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); @@ -157,10 +157,9 @@ QGroupBox *ConfigurationPage::LangGroup() QLabel *separatorLabel = new QLabel(tr("Decimal separator parts")); - osOptionCheck = new QCheckBox(tr("With OS options (.)")); - //bool osOptionValue = settings.value("configuration/osSeparator", 1).toBool(); - //osOptionCheck->setChecked(osOptionValue); - osOptionCheck->setEnabled(false); + osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); + bool osOptionValue = settings.value("configuration/osSeparator", 1).toBool(); + osOptionCheck->setChecked(osOptionValue); QHBoxLayout *separatorLayout = new QHBoxLayout; separatorLayout->addWidget(separatorLabel); 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 010315fba..d4a306bbc 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 060de71ac..3c2fa5dbe 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(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. @@ -116,4 +79,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..d488ad260 --- /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; + + InitOkCancel(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 40a932257..862afb117 100644 --- a/src/app/dialogs/tools/dialogendline.ui +++ b/src/app/dialogs/tools/dialogendline.ui @@ -522,7 +522,7 @@ - + 0 0 @@ -538,7 +538,7 @@ - + 0 0 @@ -551,7 +551,7 @@ - + 0 0 @@ -567,7 +567,7 @@ true - + 0 0 @@ -583,7 +583,7 @@ true - + 0 0 @@ -599,7 +599,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 29ef6ff1d..58d57f4c2 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -374,11 +374,24 @@ 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; - QLocale loc = QLocale::system(); - label->setText(loc.toString(result)); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool(); + + if (osSeparatorValue) + { + QLocale loc = QLocale::system(); + label->setText(loc.toString(result)); + } + else + { + QLocale loc = QLocale(QLocale::C); + label->setText(loc.toString(result)); + } flag = true; palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); emit ToolTip(""); 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 3f6a00fc3..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); @@ -126,7 +125,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(theme); - QT_REQUIRE_VERSION(argc, argv, "5.1.0"); + QT_REQUIRE_VERSION(argc, argv, "5.2.1"); VApplication app(argc, argv); #ifdef QT_DEBUG @@ -175,36 +174,18 @@ int main(int argc, char *argv[]) QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen); QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed); - const QStringList args = app.arguments(); - QString fileName; - QRegExp rxArgOpenFile("-o");//parameter open file + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::translate("main", "Pattern making program.")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file.")); + parser.process(app); + const QStringList args = parser.positionalArguments(); + if (args.size() > 0) + { + w.LoadPattern(args.at(0)); - if (args.size()>1) - { - for (int i = 1; i < args.size(); ++i) - { - if (rxArgOpenFile.indexIn(args.at(i)) != -1 ) - { - if (args.at(i+1).isEmpty() == false) - { - fileName = args.at(i+1); - qDebug() << args.at(i)<< ":" << fileName; - w.LoadPattern(fileName); - } - w.show(); - break; - } - else - { - qDebug() << "Uknown arg:" << args.at(i); - w.show(); - break; - } - } - } - else - { - w.show(); } + w.show(); return app.exec(); } diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 5dbde55ba..9cafbc319 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -89,6 +89,7 @@ MainWindow::MainWindow(QWidget *parent) doc = new VPattern(pattern, comboBoxDraws, &mode); connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); + connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); InitAutoSave(); @@ -889,9 +890,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 @@ -1354,12 +1354,23 @@ void MainWindow::Open() dir = QFileInfo(files.first()).absolutePath(); } QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter); - if (fileName.isEmpty() == false) + if (fileName.isEmpty() == false && fileName != curFile) { - LoadPattern(fileName); + if (curFile.isEmpty()) + { + LoadPattern(fileName); - VAbstractTool::NewSceneRect(sceneDraw, view); - VAbstractTool::NewSceneRect(sceneDetails, view); + VAbstractTool::NewSceneRect(sceneDraw, view); + VAbstractTool::NewSceneRect(sceneDetails, view); + } + else + { + QProcess *v = new QProcess(this); + QStringList arguments; + arguments << fileName; + v->startDetached(QCoreApplication::applicationFilePath(), arguments); + delete v; + } } } } @@ -1386,6 +1397,7 @@ void MainWindow::Clear() setCurrentFile(""); pattern->Clear(); doc->clear(); + doc->setPatternModified(false); sceneDraw->clear(); sceneDetails->clear(); CancelTool(); @@ -1408,9 +1420,12 @@ void MainWindow::Clear() */ void MainWindow::NewPattern() { - QProcess *v = new QProcess(this); - v->startDetached(QCoreApplication::applicationFilePath ()); - delete v; + if (doc->isPatternModified() || curFile.isEmpty() == false) + { + QProcess *v = new QProcess(this); + v->startDetached(QCoreApplication::applicationFilePath ()); + delete v; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1978,6 +1993,25 @@ void MainWindow::LoadPattern(const QString &fileName) Clear(); return; } + catch (const std::bad_alloc &) + { +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error!")); + msgBox.setText(tr("Error parsing file.")); + msgBox.setInformativeText("std::bad_alloc"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + Clear(); + return; + } connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, &MainWindow::currentDrawChanged); QString nameDraw = doc->GetNameActivDraw(); @@ -1996,7 +2030,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/mainwindow.h b/src/app/mainwindow.h index 23ff7549e..eac2e1886 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -56,25 +56,32 @@ public: void LoadPattern(const QString &curFile); public slots: void mouseMove(const QPointF &scenePos); + void ActionAroowTool(); void ActionDraw(bool checked); void ActionDetails(bool checked); void ActionNewDraw(); + void ActionLayout(bool checked); + void ActionTable(bool checked); + void ActionHistory(bool checked); + + void tableClosed(); + void ClosedActionTable(); + void ClosedActionHistory(); + bool SaveAs(); bool Save(); void Open(); void Options(); void NewPattern(); - void ActionTable(bool checked); - void ActionHistory(bool checked); - void ActionLayout(bool checked); + void currentDrawChanged( int index ); void OptionDraw(); - void PatternWasModified(); void ChangedSize(const QString &text); void ChangedHeight(const QString & text); - void ClosedActionTable(); - void ClosedActionHistory(); + + void PatternWasModified(); + void ToolEndLine(bool checked); void ToolLine(bool checked); void ToolAlongLine(bool checked); @@ -94,6 +101,7 @@ public slots: void ToolPointOfIntersection(bool checked); void ToolUnionDetails(bool checked); void ToolCutArc(bool checked); + void ClosedDialogEndLine(int result); void ApplyDialogEndLine(); void ClosedDialogLine(int result); @@ -114,12 +122,14 @@ public slots: void ClosedDialogUnionDetails(int result); void ClosedDialogCutSpline(int result); void ClosedDialogCutArc(int result); + void About(); void AboutQt(); - void ShowToolTip(const QString &toolTip); - void tableClosed(); - void OpenRecentFile(); void PatternProperties(); + + void ShowToolTip(const QString &toolTip); + void OpenRecentFile(); + void Clear(); signals: /** * @brief ModelChosen emit after calculation all details. @@ -131,80 +141,63 @@ protected: virtual void keyPressEvent ( QKeyEvent * event ); virtual void showEvent( QShowEvent *event ); virtual void closeEvent( QCloseEvent * event ); - void Clear(); private: Q_DISABLE_COPY(MainWindow) - /** - * @brief ui keeps information about user interface - */ + /** @brief ui keeps information about user interface */ Ui::MainWindow *ui; - /** - * @brief pattern container with data (points, arcs, splines, spline paths, variables) - */ + + /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */ VContainer *pattern; - /** - * @brief doc dom document container - */ + + /** @brief doc dom document container */ VPattern *doc; - /** - * @brief tool current tool - */ + + /** @brief tool current tool */ Valentina::Tools tool; - /** - * @brief currentScene pointer to current scene. - */ + + /** @brief currentScene pointer to current scene. */ VMainGraphicsScene *currentScene; - /** - * @brief sceneDraw draw scene. - */ + + /** @brief sceneDraw draw scene. */ VMainGraphicsScene *sceneDraw; - /** - * @brief sceneDetails details scene. - */ + + /** @brief sceneDetails details scene. */ VMainGraphicsScene *sceneDetails; - /** - * @brief mouseCoordinate pointer to label who show mouse coordinate. - */ + + /** @brief mouseCoordinate pointer to label who show mouse coordinate. */ QLabel *mouseCoordinate; - /** - * @brief helpLabel help show tooltip. - */ + + /** @brief helpLabel help show tooltip. */ QLabel *helpLabel; - /** - * @brief view show current scene. - */ + + /** @brief view show current scene. */ VMainGraphicsView *view; - /** - * @brief isInitialized true after first show window. - */ + + /** @brief isInitialized true after first show window. */ bool isInitialized; + DialogIncrements *dialogTable; DialogTool *dialogTool; DialogHistory *dialogHistory; - /** - * @brief comboBoxDraws comboc who show name of pattern peaces. - */ + + /** @brief comboBoxDraws comboc who show name of pattern peaces. */ QComboBox *comboBoxDraws; - /** - * @brief fileName name current pattern file. - */ + + /** @brief fileName name current pattern file. */ QString curFile; - /** - * @brief mode keep current draw mode. - */ + + /** @brief mode keep current draw mode. */ Valentina::Draws mode; - /** - * @brief currentDrawIndex save current selected pattern peace. - */ + + /** @brief currentDrawIndex save current selected pattern peace. */ qint32 currentDrawIndex; - /** - * @brief currentToolBoxIndex save current set of tools. - */ + + /** @brief currentToolBoxIndex save current set of tools. */ qint32 currentToolBoxIndex; - /** - * @brief drawMode true if we current draw scene. - */ + + /** @brief drawMode true if we current draw scene. */ bool drawMode; + enum { MaxRecentFiles = 5 }; QAction *recentFileActs[MaxRecentFiles]; QAction *separatorAct; @@ -218,6 +211,8 @@ private: void SetEnableTool(bool enable); void SaveCurrentScene(); void RestoreCurrentScene(); + void MinimumScrollBar(); + template // TODO ISSUE 79 : delete void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, @@ -226,7 +221,6 @@ private: // TODO ISSUE 79 : copy void SetToolButton2(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, Func closeDialogSlot, Func2 applyDialogSlot); - void MinimumScrollBar(); template void ClosedDialog(int result); template diff --git a/src/app/share/resources/tables/standard/GOST_man_ru.vst b/src/app/share/resources/tables/standard/GOST_man_ru.vst index 0240a7df5..0174079d7 100644 --- a/src/app/share/resources/tables/standard/GOST_man_ru.vst +++ b/src/app/share/resources/tables/standard/GOST_man_ru.vst @@ -7,147 +7,147 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - - - - - + + + + + + + - - + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 4a331c016..e0f98abec 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) @@ -47,6 +60,12 @@ VDrawTool::~VDrawTool() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 +74,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 +91,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 +105,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) @@ -114,6 +146,10 @@ void VDrawTool::DialogLinkDestroy() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VDrawTool::SetFactor(qreal factor) { if (factor <= 2 && factor >= 0.5) @@ -123,6 +159,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 e77e6a099..a8f26f32f 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -42,91 +42,50 @@ 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 DialogLinkDestroy removes dialog pointer - */ + * @brief DialogLinkDestroy removes dialog pointer + */ virtual void DialogLinkDestroy(); - /** - * @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 FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog */ virtual void FullUpdateFromGuiApply(); - /** - * @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. @@ -212,4 +171,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 1512c8e17..dbc613bd4 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -71,16 +71,17 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene 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(); VToolEndLine *point = nullptr; point=Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); - if (point != nullptr) { + if (point != nullptr) + { point->dialog=dialogTool; } return point; @@ -88,17 +89,14 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene //--------------------------------------------------------------------------------------------------------------------- VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const 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) + 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) @@ -114,15 +112,6 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, { doc->UpdateToolData(id, data); } - else - { - data->UpdateGObject(id, new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); - data->AddLine(basePointId, id); - if (parse != Document::FullParse) - { - doc->UpdateToolData(id, data); - } - } } VDrawTool::AddRecord(id, Valentina::EndLineTool, doc); if (parse == Document::FullParse) diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index ecda77ed0..2e65d6e89 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -84,7 +84,7 @@ public: * @return the created tool */ static VToolEndLine *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 b7da6c023..354aec712 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -65,6 +65,7 @@ void VToolShoulderPoint::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +//TODO find better way calculate point. QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length) { @@ -99,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, @@ -119,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 6718e9b1f..36a246d13 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -1721,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(); @@ -1789,12 +1777,16 @@ QString VApplication::FormulaFromUser(const QString &formula) } } + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool(); + QLocale loc = QLocale::system(); - if(loc != QLocale(QLocale::C)) + if(loc != QLocale(QLocale::C) && osSeparatorValue) { 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); @@ -1833,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) { @@ -1903,12 +1896,16 @@ QString VApplication::FormulaToUser(const QString &formula) } } + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); + bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool(); + QLocale loc = QLocale::system(); - if(loc != QLocale::C) + if(loc != QLocale::C && osSeparatorValue) { 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 a3a8834a4..67bd9edc1 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -39,7 +39,8 @@ #include "vindividualmeasurements.h" #include -#include +#include "../../libs/qmuparser/qmuparsererror.h" +#include const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); @@ -214,9 +215,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 +487,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 +519,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 @@ -559,14 +557,53 @@ bool VPattern::SaveDocument(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- void VPattern::FullUpdateTree() { - VMainGraphicsScene *scene = new VMainGraphicsScene(); + VMainGraphicsScene *scene = nullptr; try { + scene = new VMainGraphicsScene(); Parse(Document::LiteParse, scene, scene); } + catch (const VExceptionObjectError &e) + { + delete scene; + e.CriticalMessageBox(tr("Error parsing file.")); + emit ClearMainWindow(); + return; + } + catch (const VExceptionConversionError &e) + { + delete scene; + e.CriticalMessageBox(tr("Error can't convert value.")); + emit ClearMainWindow(); + return; + } + catch (const VExceptionEmptyParameter &e) + { + delete scene; + e.CriticalMessageBox(tr("Error empty parameter.")); + emit ClearMainWindow(); + return; + } + catch (const VExceptionWrongId &e) + { + delete scene; + e.CriticalMessageBox(tr("Error wrong id.")); + emit ClearMainWindow(); + return; + } + catch (VException &e) + { + delete scene; + e.CriticalMessageBox(tr("Error parsing file.")); + emit ClearMainWindow(); + return; + } catch (const std::bad_alloc &) { delete scene; +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif QMessageBox msgBox; msgBox.setWindowTitle(tr("Error!")); msgBox.setText(tr("Error parsing file.")); @@ -575,13 +612,12 @@ void VPattern::FullUpdateTree() msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + emit ClearMainWindow(); return; } - catch (...) - { - delete scene; - throw; - } delete scene; setCurrentData(); @@ -613,8 +649,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 +691,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 +753,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 +812,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 +820,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 +874,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 +913,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 +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 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 +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 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 +1029,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 +1088,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 +1210,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 +1244,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 +1279,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 +1343,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 +1458,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 +1475,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 +1539,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..ac8546813 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -236,6 +236,7 @@ signals: * @param id tool id. */ void ChangedCursor(quint32 id); + void ClearMainWindow(); public slots: /** * @brief FullUpdateTree lite parse file. @@ -334,7 +335,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 +364,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/app/xml/vstandardmeasurements.cpp b/src/app/xml/vstandardmeasurements.cpp index 5c82c89fa..1af4aa15a 100644 --- a/src/app/xml/vstandardmeasurements.cpp +++ b/src/app/xml/vstandardmeasurements.cpp @@ -34,7 +34,7 @@ const QString VStandardMeasurements::TagDescription = QStringLiteral("descr const QString VStandardMeasurements::TagSize = QStringLiteral("size"); const QString VStandardMeasurements::TagHeight = QStringLiteral("height"); const QString VStandardMeasurements::AttrValue = QStringLiteral("value"); -const QString VStandardMeasurements::AttrSize_increace = QStringLiteral("size_increace"); +const QString VStandardMeasurements::AttrSize_increase = QStringLiteral("size_increase"); const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase"); //--------------------------------------------------------------------------------------------------------------------- @@ -217,17 +217,17 @@ void VStandardMeasurements::Measurement(const QString &tag) if (domElement.isNull() == false) { const qreal value = GetParametrDouble(domElement, AttrValue, "0.0"); - const qreal size_increace = GetParametrDouble(domElement, AttrSize_increace, "0.0"); + const qreal size_increase = GetParametrDouble(domElement, AttrSize_increase, "0.0"); const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); if (Unit() == Valentina::Mm)// Convert to Cm. { - data->AddMeasurement(tag, VMeasurement(value/10.0, size_increace/10.0, height_increase/10.0, + data->AddMeasurement(tag, VMeasurement(value/10.0, size_increase/10.0, height_increase/10.0, qApp->GuiText(tag), qApp->Description(tag), tag)); } else// Cm or inch. { - data->AddMeasurement(tag, VMeasurement(value, size_increace, height_increase, qApp->GuiText(tag), + data->AddMeasurement(tag, VMeasurement(value, size_increase, height_increase, qApp->GuiText(tag), qApp->Description(tag), tag)); } } diff --git a/src/app/xml/vstandardmeasurements.h b/src/app/xml/vstandardmeasurements.h index a970f46c4..5b2b89c18 100644 --- a/src/app/xml/vstandardmeasurements.h +++ b/src/app/xml/vstandardmeasurements.h @@ -53,7 +53,7 @@ public: static const QString TagSize; static const QString TagHeight; static const QString AttrValue; - static const QString AttrSize_increace; + static const QString AttrSize_increase; static const QString AttrHeight_increase; private: void Measurement(const QString &tag); diff --git a/src/libs/libs.pro b/src/libs/libs.pro new file mode 100644 index 000000000..5d08776e9 --- /dev/null +++ b/src/libs/libs.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = qmuparser 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; } } diff --git a/src/src.pro b/src/src.pro index 6e951fd25..dbc4d1aaa 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,52 +1,7 @@ TEMPLATE = subdirs +CONFIG += ordered + SUBDIRS = \ - sub_app \ - sub_lib_qmuparser \ - test/ParserTest - -sub_lib_qmuparser.file = libs/qmuparser/qmuparser.pro -sub_parser_tests.file = test/ParserTest/ParserTest.pro -sub_parser_tests.depends = sub_lib_qmuparser -sub_app.file = app/app.pro -sub_app.depends = sub_lib_qmuparser - - -#This makes it possible to use make -j 4 on your fancy quad-core system with a project that consists of several -#components that depend on each other. To simplify the process a bit, the following test function can be defined: - -# addSubdirs(subdirs,deps): Adds directories to the project that depend on -# other directories -defineTest(addSubdirs) { - for(subdirs, 1) { - entries = $$files($$subdirs) - for(entry, entries) { - name = $$replace(entry, [/\\\\], _) - SUBDIRS += $$name - eval ($${name}.subdir = $$entry) - for(dep, 2):eval ($${name}.depends += $$replace(dep, [/\\\\], _)) - export ($${name}.subdir) - export ($${name}.depends) - } - } - export (SUBDIRS) -} -#You can then use it like to define a project that has: - -#several contributed modules that should be compiled first -#addSubdirs (contrib/*) - -#a kernel lib for non-gui related stuff that depends on some contrib modules -#addSubdirs (src/lib/kernel, contrib/module1 contrib/module2) - -#a gui lib that depends on the kernel lib and some other contrib modules -#addSubdirs (src/lib/gui, src/lib/kernel contrib/module3 contrib/module4) - -#test benches for the kernel and gui libs -#addSubdirs (src/tests/kernel, src/lib/kernel) -#addSubdirs (src/tests/gui, src/lib/gui) - -#a main program that uses the gui and kernel libs -#addSubdirs (src/main, src/lib/gui src/lib/kernel) - -#several modules that only depend on the kernel lib -#addSubdirs (src/modules/*, src/lib/kernel) + libs \ + app \ + test diff --git a/src/test/ParserTest/ParserTest.pro b/src/test/ParserTest/ParserTest.pro index e7da26428..3be053f5d 100644 --- a/src/test/ParserTest/ParserTest.pro +++ b/src/test/ParserTest/ParserTest.pro @@ -58,9 +58,10 @@ CONFIG(debug, debug|release){ QMAKE_DISTCLEAN += $${DESTDIR}/* \ $${OBJECTS_DIR}/* -win32:CONFIG(release, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 -else:win32:CONFIG(debug, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 -else:unix: LIBS += -L../../libs/qmuparser/bin -lqmuparser -INCLUDEPATH += ../../libs/qmuparser -DEPENDPATH += ../../libs/qmuparser +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:unix: LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser + +INCLUDEPATH += $$PWD/../../libs/qmuparser +DEPENDPATH += $$PWD/../../libs/qmuparser diff --git a/src/test/test.pro b/src/test/test.pro new file mode 100644 index 000000000..db8b1c7c4 --- /dev/null +++ b/src/test/test.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = ParserTest