From 381adf0ba058eeb274ec2cb46f6f235bf0c86d78 Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 30 May 2014 11:32:40 +0300 Subject: [PATCH] Dialog edit wrong formula (only for toolendline now). --HG-- branch : feature --- src/app/container/calculator.cpp | 21 +- src/app/dialogs/dialogs.pri | 9 +- src/app/dialogs/tools/dialogcutarc.cpp | 36 ++ src/app/dialogs/tools/dialogcutarc.h | 65 ++-- .../dialogs/tools/dialogeditwrongformula.cpp | 95 +++++ .../dialogs/tools/dialogeditwrongformula.h | 69 ++++ .../dialogs/tools/dialogeditwrongformula.ui | 347 ++++++++++++++++++ src/app/dialogs/tools/dialogtool.cpp | 5 +- src/app/main.cpp | 5 +- src/app/mainwindow.cpp | 7 + src/app/tools/drawTools/vtoolendline.cpp | 31 +- src/app/tools/drawTools/vtoolendline.h | 2 +- src/app/widgets/vapplication.cpp | 32 +- src/app/xml/vpattern.cpp | 14 +- src/app/xml/vpattern.h | 2 +- src/libs/qmuparser/qmuparser.cpp | 6 +- src/libs/qmuparser/qmuparsertokenreader.cpp | 3 +- 17 files changed, 649 insertions(+), 100 deletions(-) create mode 100644 src/app/dialogs/tools/dialogeditwrongformula.cpp create mode 100644 src/app/dialogs/tools/dialogeditwrongformula.h create mode 100644 src/app/dialogs/tools/dialogeditwrongformula.ui diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index 937547b71..4b8e56b6c 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -97,14 +97,7 @@ Calculator::Calculator(const QString &formula, bool fromUser) } SetExpr(formula); - try - { - Eval();//Need run for making tokens - } - catch(qmu::QmuParserError &e) - { - return;//Ignore all warnings - } + Eval();//Need run for making tokens } Calculator::~Calculator() @@ -217,15 +210,13 @@ void Calculator::InitVariables(const VContainer *data) if (qApp->patternType() == Pattern::Standard) { vVarVal[j] = i.value().GetValue(data->size(), data->height()); - DefineVar(i.key(), &vVarVal[j]); - ++j; } else { vVarVal[j] = i.value().GetValue(); - DefineVar(i.key(), &vVarVal[j]); - ++j; } + DefineVar(i.key(), &vVarVal[j]); + ++j; ++i; } } @@ -237,15 +228,13 @@ void Calculator::InitVariables(const VContainer *data) if (qApp->patternType() == Pattern::Standard) { vVarVal[j] = i.value().GetValue(data->size(), data->height()); - DefineVar(i.key(), &vVarVal[j]); - ++j; } else { vVarVal[j] = i.value().GetValue(); - DefineVar(i.key(), &vVarVal[j]); - ++j; } + DefineVar(i.key(), &vVarVal[j]); + ++j; ++i; } } diff --git a/src/app/dialogs/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/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 5ab00d16e..0a43e7e6d 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -30,6 +30,11 @@ #include "ui_dialogcutarc.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogCutArc create dialog. + * @param data container with data + * @param parent parent widget + */ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) : DialogTool(data, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(0) { @@ -62,6 +67,11 @@ DialogCutArc::~DialogCutArc() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. + * @param id id of point or detail + * @param type type of object + */ void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type) { if (type == Valentina::Arc) @@ -74,6 +84,9 @@ void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogAccepted save data and emit signal about closed dialog. + */ void DialogCutArc::DialogAccepted() { pointName = ui->lineEditNamePoint->text(); @@ -83,12 +96,21 @@ void DialogCutArc::DialogAccepted() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setArcId set id of arc + * @param value id + * @param id don't show this id in list + */ void DialogCutArc::setArcId(const quint32 &value, const quint32 &id) { setCurrentArcId(ui->comboBoxArc, arcId, value, id, ComboMode::CutArc); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setFormula set string with formula length + * @param value string with formula + */ void DialogCutArc::setFormula(const QString &value) { formula = qApp->FormulaToUser(value); @@ -96,8 +118,22 @@ void DialogCutArc::setFormula(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setPointName set name point on arc + * @param value name + */ void DialogCutArc::setPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getFormula return string with formula length + * @return formula + */ +QString DialogCutArc::getFormula() const +{ + return qApp->FormulaFromUser(formula); +} diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index e9df0964d..306e28256 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -43,54 +43,17 @@ class DialogCutArc : public DialogTool { Q_OBJECT public: - /** - * @brief DialogCutArc create dialog. - * @param data container with data - * @param parent parent widget - */ + DialogCutArc(const VContainer *data, QWidget *parent = nullptr); ~DialogCutArc(); - /** - * @brief getPointName return name point on arc - * @return name - */ - QString getPointName() const {return pointName;} - /** - * @brief setPointName set name point on arc - * @param value name - */ + QString getPointName() const; void setPointName(const QString &value); - /** - * @brief getFormula return string with formula length - * @return formula - */ - QString getFormula() const {return qApp->FormulaFromUser(formula);} - /** - * @brief setFormula set string with formula length - * @param value string with formula - */ + QString getFormula() const; void setFormula(const QString &value); - /** - * @brief getArcId return id of arc - * @return id - */ - quint32 getArcId() const {return arcId;} - /** - * @brief setArcId set id of arc - * @param value id - * @param id don't show this id in list - */ + quint32 getArcId() const; void setArcId(const quint32 &value, const quint32 &id); public slots: - /** - * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. - * @param id id of point or detail - * @param type type of object - */ virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); - /** - * @brief DialogAccepted save data and emit signal about closed dialog. - */ virtual void DialogAccepted(); private: Q_DISABLE_COPY(DialogCutArc) @@ -112,4 +75,24 @@ private: quint32 arcId; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPointName return name point on arc + * @return name + */ +inline QString DialogCutArc::getPointName() const +{ + return pointName; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getArcId return id of arc + * @return id + */ +inline quint32 DialogCutArc::getArcId() const +{ + return arcId; +} + #endif // DIALOGCUTARC_H diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp new file mode 100644 index 000000000..88d1e3bb8 --- /dev/null +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -0,0 +1,95 @@ +/************************************************************************ + ** + ** @file dialogeditwrongformula.cpp + ** @author Roman Telezhynskyi + ** @date 29 5, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialogeditwrongformula.h" +#include "ui_dialogeditwrongformula.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent) + :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()) +{ + ui->setupUi(this); + InitVariables(ui); + labelResultCalculation = ui->labelResult; + lineEditFormula = ui->lineEditFormula; + labelEditFormula = ui->labelFormula; + + InitOkCansel(ui); + flagFormula = false; + CheckState(); + + + connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); + connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); + + connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula); + connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogEditWrongFormula::~DialogEditWrongFormula() +{ + 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..9d9501d78 --- /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/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index a4e00f419..2338b476a 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -333,8 +333,9 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) try { const QString formula = qApp->FormulaFromUser(edit->text()); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + Calculator *cal = new Calculator(data); + const qreal result = cal->EvalFormula(formula); + delete cal; QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); diff --git a/src/app/main.cpp b/src/app/main.cpp index 52b453603..6a97593b0 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -74,9 +74,8 @@ void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, c switch (type) { case QtDebugMsg: - fprintf(stderr, "Debug: %s\n", localMsg.constData()); -// fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, -// context.function); + fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, + context.function); return; case QtWarningMsg: messageBox.setIcon(QMessageBox::Warning); diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index b7f028a29..85010b170 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1905,7 +1905,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/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 22c9639cc..f210ed6a3 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -30,6 +30,7 @@ #include "../../widgets/vmaingraphicsscene.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogendline.h" +#include "../../dialogs/tools/dialogeditwrongformula.h" const QString VToolEndLine::ToolType = QStringLiteral("endLine"); @@ -82,15 +83,39 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter //--------------------------------------------------------------------------------------------------------------------- void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qreal &angle, const quint32 &basePointId, + QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) { const VPointF *basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); - Calculator cal(data); - const qreal result = cal.EvalFormula(formula); + qreal result = 0; + + try + { + Calculator *cal = new Calculator(data); + result = cal->EvalFormula(formula); + delete cal; + } + catch(qmu::QmuParserError &e) + { + DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data); + dialog->setFormula(formula); + if (dialog->exec() == QDialog::Accepted) + { + formula = dialog->getFormula(); + delete dialog; + Calculator *cal = new Calculator(data); + result = cal->EvalFormula(formula); + delete cal; + } + else + { + delete dialog; + throw; + } + } line.setLength(qApp->toPixel(result)); line.setAngle(angle); diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index acf0bcf20..17a272f19 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -82,7 +82,7 @@ public: * @param typeCreation way we create this tool. */ static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx, + QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); static const QString ToolType; diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index 5fa41b309..36a246d13 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -1722,23 +1722,10 @@ QString VApplication::FormulaFromUser(const QString &formula) { QString newFormula = formula; - QMap tokens; - QMap numbers; - try - { - Calculator cal(formula); - tokens = cal.GetTokens(); - numbers = cal.GetNumbers(); - } - catch(qmu::QmuParserError &e) - { - qDebug() << "\nMath parser error:\n" - << "--------------------------------------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: " << e.GetExpr() << "\n" - << "--------------------------------------"; - return newFormula; - } + Calculator *cal = new Calculator(formula); + QMap tokens = cal->GetTokens(); + QMap numbers = cal->GetNumbers(); + delete cal; QList tKeys = tokens.keys(); QList tValues = tokens.values(); @@ -1799,7 +1786,7 @@ QString VApplication::FormulaFromUser(const QString &formula) { QList nKeys = numbers.keys(); QList nValues = numbers.values(); - for (int i = 0; i < tKeys.size(); ++i) + for (int i = 0; i < nKeys.size(); ++i) { bool ok = false; qreal d = loc.toDouble(nValues.at(i), &ok); @@ -1838,9 +1825,10 @@ QString VApplication::FormulaToUser(const QString &formula) QMap numbers; try { - Calculator cal(formula, false); - tokens = cal.GetTokens(); - numbers = cal.GetNumbers(); + Calculator *cal = new Calculator(formula, false); + tokens = cal->GetTokens(); + numbers = cal->GetNumbers(); + delete cal; } catch (qmu::QmuParserError &e) { @@ -1917,7 +1905,7 @@ QString VApplication::FormulaToUser(const QString &formula) { QList nKeys = numbers.keys(); QList nValues = numbers.values(); - for (int i = 0; i < tKeys.size(); ++i) + for (int i = 0; i < nKeys.size(); ++i) { QLocale loc = QLocale(QLocale::C); bool ok = false; diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 380a74b15..2f09edae4 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -656,7 +656,7 @@ 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; @@ -779,7 +779,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); @@ -842,11 +842,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, VToolEndLine::AttrLength, f); + haveLiteChange(); + } } catch (const VExceptionBadId &e) { diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 1c61de1f7..79ed6b197 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -334,7 +334,7 @@ private: * @param type type of point. * @param mode draw mode. */ - void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, + void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse, const QString &type); /** * @brief ParseLineElement parse line tag. 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/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; } }