Merge with feature

--HG--
branch : develop
This commit is contained in:
dismine 2014-05-30 14:51:03 +03:00
commit 409e04bbcf
64 changed files with 1321 additions and 368 deletions

View file

@ -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;
}
}

View file

@ -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());

View file

@ -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

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>470</width>
<height>573</height>
<height>675</height>
</rect>
</property>
<property name="windowTitle">
@ -252,6 +252,12 @@
</item>
<item>
<widget class="QComboBox" name="comboBoxLineType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Show line from first point to this point</string>
</property>
@ -270,6 +276,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -280,6 +292,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -287,6 +305,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -294,6 +318,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -304,6 +334,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -314,6 +350,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>501</width>
<height>538</height>
<height>705</height>
</rect>
</property>
<property name="windowTitle">
@ -447,6 +447,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -457,6 +463,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -464,6 +476,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -474,6 +492,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -484,6 +508,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -494,6 +524,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>
@ -504,6 +540,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>587</height>
<height>686</height>
</rect>
</property>
<property name="windowTitle">
@ -309,6 +309,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -319,6 +325,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -326,6 +338,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -336,6 +354,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -346,6 +370,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -356,6 +386,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -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);
}

View file

@ -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

View file

@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>507</width>
<height>493</height>
<height>597</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Cut arc</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -236,6 +236,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -246,6 +252,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -253,6 +265,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -263,6 +281,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -273,6 +297,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -283,6 +313,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Cut curve</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -236,6 +236,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -246,6 +252,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -253,6 +265,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -263,6 +281,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -273,6 +297,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -283,6 +313,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Cut curve path</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -236,6 +236,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -246,6 +252,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -253,6 +265,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -263,6 +281,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -273,6 +297,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -283,6 +313,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -0,0 +1,103 @@
/************************************************************************
**
** @file dialogeditwrongformula.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialogeditwrongformula.h"
#include "ui_dialogeditwrongformula.h"
#include <container/calculator.h>
//---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString())
{
ui->setupUi(this);
InitVariables(ui);
labelResultCalculation = ui->labelResult;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelFormula;
InitOkCansel(ui);
flagFormula = false;
CheckState();
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
//Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
//---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::~DialogEditWrongFormula()
{
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::DialogAccepted()
{
formula = ui->lineEditFormula->text();
emit DialogClosed(QDialog::Accepted);
accepted();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::DialogRejected()
{
emit DialogClosed(QDialog::Rejected);
rejected();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::CheckState()
{
Q_CHECK_PTR(bOk);
bOk->setEnabled(flagFormula);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::setFormula(const QString &value)
{
formula = qApp->FormulaToUser(value);
ui->lineEditFormula->setText(formula);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogEditWrongFormula::getFormula() const
{
return qApp->FormulaFromUser(formula);
}

View file

@ -0,0 +1,69 @@
/************************************************************************
**
** @file dialogeditwrongformula.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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

View file

@ -0,0 +1,347 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogEditWrongFormula</class>
<widget class="QDialog" name="DialogEditWrongFormula">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>535</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit wrong formula</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Formula</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>First angle of arc counterclockwise</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="toolTip">
<string>Insert variable into formula</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHereLeft.png</normaloff>:/icon/24x24/putHereLeft.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="toolTip">
<string>Calculate value</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResult">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of first angle</string>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLineAngles">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle of lines</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogEditWrongFormula</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogEditWrongFormula</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -472,7 +472,7 @@
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -488,7 +488,7 @@
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -501,7 +501,7 @@
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -517,7 +517,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -533,7 +533,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -549,7 +549,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Height</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>

View file

@ -484,6 +484,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -494,6 +500,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -501,6 +513,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -511,6 +529,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -521,6 +545,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -531,6 +561,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -324,6 +324,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -334,6 +340,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -341,6 +353,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -351,6 +369,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -361,6 +385,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
@ -371,6 +401,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Point of intersection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>

View file

@ -345,6 +345,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Size and height</string>
</property>
@ -355,6 +361,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandardTable">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
</property>
@ -362,6 +374,12 @@
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Increments</string>
</property>
@ -372,6 +390,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -382,6 +406,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of lines</string>
</property>
@ -392,6 +422,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length of curves</string>
</property>

View file

@ -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());

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Triangle</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>

View file

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Union details</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">

View file

@ -66,6 +66,10 @@ void VException::CriticalMessageBox(const QString &situation, QWidget * parent)
QGridLayout* layout = static_cast<QGridLayout*>(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();
}

View file

@ -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);

View file

@ -784,9 +784,8 @@ void MainWindow::ToolBarOption()
{
ui->toolBarOption->addWidget(new QLabel(tr("Height: ")));
QStringList list;
list <<"92"<<"98"<<"104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176"
<<"182"<<"188";
QStringList list{"92", "98", "104", "110", "116", "122", "128", "134", "140", "146", "152", "158", "164", "170",
"176", "182", "188"};
QComboBox *comboBoxHeight = new QComboBox;
comboBoxHeight->addItems(list);
comboBoxHeight->setCurrentIndex(14);//176
@ -1905,7 +1904,14 @@ void MainWindow::LoadPattern(const QString &fileName)
}
SetEnableWidgets(true);
bool patternModified = doc->isPatternModified();
setCurrentFile(fileName);
if (patternModified)
{
//For situation where was fixed wrong formula need return for document status was modified.
doc->setPatternModified(patternModified);
PatternWasModified();
}
helpLabel->setText(tr("File loaded"));
}

View file

@ -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);
}
}

View file

@ -28,9 +28,22 @@
#include "vdrawtool.h"
#include <qmuparsererror.h>
#include <dialogs/tools/dialogeditwrongformula.h>
#include <container/calculator.h>
qreal VDrawTool::factor = 1;
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VDrawTool constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param parent parent object.
*/
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
:VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw()), dialog(nullptr)
@ -46,7 +59,15 @@ VDrawTool::~VDrawTool()
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
Q_UNUSED(id);
@ -55,6 +76,10 @@ void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace. name new active pattern peace.
*/
void VDrawTool::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
@ -68,6 +93,11 @@ void VDrawTool::ChangedActivDraw(const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedNameDraw save new name active pattern peace.
* @param oldName old name.
* @param newName new name active pattern peace. new name.
*/
void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
{
if (nameActivDraw == oldName)
@ -77,6 +107,10 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromGui refresh tool data after change in options.
* @param result keep result working dialog.
*/
void VDrawTool::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
@ -95,6 +129,10 @@ void VDrawTool::FullUpdateFromGui(int result)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VDrawTool::SetFactor(qreal factor)
{
if (factor <= 2 && factor >= 0.5)
@ -104,6 +142,55 @@ void VDrawTool::SetFactor(qreal factor)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CheckFormula check formula.
*
* Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
* successes case return result calculation and fixed formula string. If formula ok don't touch formula.
* @param formula [in|out] string with formula.
* @param data [in] container with variables. Need for math parser.
* @throw QmuParserError.
* @return result of calculation formula.
*/
qreal VDrawTool::CheckFormula(QString &formula, VContainer *data)
{
qreal result = 0;
Calculator *cal = nullptr;
try
{
cal = new Calculator(data);
result = cal->EvalFormula(formula);
delete cal;
}
catch(qmu::QmuParserError &e)
{
delete cal;
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data);
dialog->setFormula(formula);
if (dialog->exec() == QDialog::Accepted)
{
formula = dialog->getFormula();
//Need delete dialog here because parser in dialog don't allow use correct separator for parsing here.
//Don't know why.
delete dialog;
Calculator *cal = new Calculator(data);
result = cal->EvalFormula(formula);
delete cal;//Here can be memory leak, but dialog already check this formula and probability very low.
}
else
{
delete dialog;
throw;
}
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToCalculation add tool to calculation tag in pattern file.
* @param domElement tag in xml tree.
*/
void VDrawTool::AddToCalculation(const QDomElement &domElement)
{
QDomElement calcElement;

View file

@ -42,83 +42,42 @@ class VDrawTool : public VAbstractTool
{
Q_OBJECT
public:
/**
* @brief VDrawTool constructor.
* @param doc dom document container.
* @param data container with variables.
* @param id object id in container.
* @param parent parent object.
*/
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
virtual ~VDrawTool();
/**
* @brief setDialog set dialog when user want change tool option.
*/
/** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {}
/**
* @brief ignoreContextMenu set ignore contect menu tool.
* @param enable true - ignore.
*/
void ignoreContextMenu(bool enable) {ignoreContextMenuEvent = enable;}
void ignoreContextMenu(bool enable);
static qreal CheckFormula(QString &formula, VContainer *data);
public slots:
/**
* @brief ShowTool highlight tool.
* @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight.
*/
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace. name new active pattern peace.
*/
virtual void ChangedActivDraw(const QString &newName);
/**
* @brief ChangedNameDraw save new name active pattern peace.
* @param oldName old name.
* @param newName new name active pattern peace. new name.
*/
void ChangedNameDraw(const QString &oldName, const QString &newName);
/**
* @brief FullUpdateFromGui refresh tool data after change in options.
* @param result keep result working dialog.
*/
virtual void FullUpdateFromGui(int result);
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
virtual void SetFactor(qreal factor);
protected:
/**
* @brief ignoreContextMenuEvent ignore or not context menu events.
*/
/** @brief ignoreContextMenuEvent ignore or not context menu events. */
bool ignoreContextMenuEvent;
/**
* @brief ignoreFullUpdate ignore or not full updates.
*/
/** @brief ignoreFullUpdate ignore or not full updates. */
bool ignoreFullUpdate;
/**
* @brief nameActivDraw name of tool's pattern peace.
*/
/** @brief nameActivDraw name of tool's pattern peace. */
QString nameActivDraw;
/**
* @brief factor scene scale factor.
*/
/** @brief factor scene scale factor. */
static qreal factor;
/**
* @brief dialog dialog options.
*/
/** @brief dialog dialog options.*/
DialogTool *dialog;
/**
* @brief AddToCalculation add tool to calculation tag in pattern file.
* @param domElement tag in xml tree.
*/
void AddToCalculation(const QDomElement &domElement);
/**
* @brief SaveDialog save options into file after change in dialog.
*/
/** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement)=0;
template <typename Dialog, typename Tool>
/**
* @brief ContextMenu show context menu for tool.
@ -203,4 +162,14 @@ private:
Q_DISABLE_COPY(VDrawTool)
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ignoreContextMenu set ignore contect menu tool.
* @param enable true - ignore.
*/
inline void VDrawTool::ignoreContextMenu(bool enable)
{
ignoreContextMenuEvent = enable;
}
#endif // VDRAWTOOL_H

View file

@ -164,27 +164,25 @@ void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatt
DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(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<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(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)

View file

@ -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);

View file

@ -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<DialogArc*>(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 &center, 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 &center, 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<const VPointF *>(center);
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );

View file

@ -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 &center, 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 &center, 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:

View file

@ -94,17 +94,17 @@ void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
DialogBisector *dialogTool = qobject_cast<DialogBisector*>(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<const VPointF *>(secondPointId);
const VPointF *thirdPoint = data->GeometricObject<const VPointF *>(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));

View file

@ -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,

View file

@ -83,21 +83,20 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(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<const VArc *>(arcId);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
VArc arc1;
VArc arc2;

View file

@ -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;

View file

@ -83,22 +83,20 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(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<const VSpline *>(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);

View file

@ -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;

View file

@ -83,14 +83,14 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(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<const VSplinePath *>(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;

View file

@ -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:

View file

@ -30,6 +30,7 @@
#include "../../widgets/vmaingraphicsscene.h"
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogendline.h"
#include "../../dialogs/tools/dialogeditwrongformula.h"
const QString VToolEndLine::ToolType = QStringLiteral("endLine");
@ -71,28 +72,25 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter
Q_CHECK_PTR(dialog);
DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog);
Q_CHECK_PTR(dialogTool);
QString pointName = dialogTool->getPointName();
QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine();
QString formula = dialogTool->getFormula();
qreal angle = dialogTool->getAngle();
quint32 basePointId = dialogTool->getBasePointId();
const qreal angle = dialogTool->getAngle();
const quint32 basePointId = dialogTool->getBasePointId();
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId,
QString &formula, const qreal &angle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *basePoint = data->GeometricObject<const VPointF *>(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)

View file

@ -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;

View file

@ -70,11 +70,11 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogHeight *dialogTool = qobject_cast<DialogHeight*>(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);
}

View file

@ -76,9 +76,9 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
Q_CHECK_PTR(dialog);
DialogLine *dialogTool = qobject_cast<DialogLine*>(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);
}

View file

@ -70,11 +70,11 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(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);
}

View file

@ -72,17 +72,17 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(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<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(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);

View file

@ -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,

View file

@ -98,27 +98,25 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene,
DialogPointOfContact *dialogTool = qobject_cast<DialogPointOfContact*>(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 &center,
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 &center, 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<const VPointF *>(center);
const VPointF *firstP = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondP = data->GeometricObject<const VPointF *>(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());

View file

@ -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 &center,
static void Create(const quint32 _id, QString &arcRadius, const quint32 &center,
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);

View file

@ -67,9 +67,9 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
Q_CHECK_PTR(dialog);
DialogPointOfIntersection *dialogTool = qobject_cast<DialogPointOfIntersection*>(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);
}

View file

@ -100,17 +100,17 @@ void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
quint32 p1Line = dialogTool->getP1Line();
quint32 p2Line = dialogTool->getP2Line();
quint32 pShoulder = dialogTool->getPShoulder();
QString typeLine = dialogTool->getTypeLine();
QString pointName = dialogTool->getPointName();
const quint32 p1Line = dialogTool->getP1Line();
const quint32 p2Line = dialogTool->getP2Line();
const quint32 pShoulder = dialogTool->getPShoulder();
const QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const quint32 &p1Line,
void VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@ -120,8 +120,7 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(p2Line);
const VPointF *shoulderPoint = data->GeometricObject<const VPointF *>(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));

View file

@ -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);

View file

@ -95,13 +95,13 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(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);
}

View file

@ -70,11 +70,11 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogTriangle *dialogTool = qobject_cast<DialogTriangle*>(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);
}

View file

@ -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;
}

View file

@ -1722,23 +1722,10 @@ QString VApplication::FormulaFromUser(const QString &formula)
{
QString newFormula = formula;
QMap<int, QString> tokens;
QMap<int, QString> 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<int, QString> tokens = cal->GetTokens();
QMap<int, QString> numbers = cal->GetNumbers();
delete cal;
QList<int> tKeys = tokens.keys();
QList<QString> tValues = tokens.values();
@ -1799,7 +1786,7 @@ QString VApplication::FormulaFromUser(const QString &formula)
{
QList<int> nKeys = numbers.keys();
QList<QString> 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<int, QString> 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<int> nKeys = numbers.keys();
QList<QString> 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;

View file

@ -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))
{

View file

@ -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

View file

@ -214,9 +214,8 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
QStringList tags;
tags << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements
<< TagVersion;
QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements,
TagVersion};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagDraw
@ -487,8 +486,7 @@ Valentina::Units VPattern::MUnit() const
QDomElement element = list.at(0).toElement();
if (element.isElement())
{
QStringList units;
units << "mm" << "cm" << "inch";
QStringList units{"mm", "cm", "inch"};
QString unit = GetParametrString(element, AttrUnit);
switch (units.indexOf(unit))
{
@ -520,8 +518,7 @@ Pattern::Measurements VPattern::MType() const
if (element.isElement())
{
QString type = GetParametrString(element, AttrType);
QStringList types;
types << "standard" << "individual";
QStringList types{"standard", "individual"};
switch (types.indexOf(type))
{
case 0:// standard
@ -613,8 +610,7 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
QStringList tags;
tags << TagCalculation << TagModeling << TagDetails;
QStringList tags{TagCalculation, TagModeling, TagDetails};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagCalculation
@ -656,11 +652,10 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *
const qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
{
const QDomElement domElement = nodeList.at(i).toElement();
QDomElement domElement = nodeList.at(i).toElement();
if (domElement.isNull() == false)
{
QStringList tags;
tags << TagPoint << TagLine << TagSpline << TagArc << TagTools;
QStringList tags{TagPoint, TagLine, TagSpline, TagArc, TagTools};
switch (tags.indexOf(domElement.tagName()))
{
case 0: // TagPoint
@ -719,9 +714,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
const QString t = GetParametrString(element, AttrType, "NodePoint");
Valentina::Tools tool;
QStringList types;
types << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline <<
VToolDetail::NodeSplinePath;
QStringList types{VToolDetail::NodePoint, VToolDetail::NodeArc, VToolDetail::NodeSpline,
VToolDetail::NodeSplinePath};
switch (types.indexOf(t))
{
case 0: // VToolDetail::NodePoint
@ -779,7 +773,7 @@ void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &domElement,
void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString &type)
{
Q_CHECK_PTR(scene);
@ -787,12 +781,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
QStringList points;
points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType
<< VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType
<< VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType
<< VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType
<< VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType,
VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType,
VToolLineIntersect::ToolType, VToolPointOfContact::ToolType, VNodePoint::ToolType,
VToolHeight::ToolType, VToolTriangle::ToolType, VToolPointOfIntersection::ToolType,
VToolCutSpline::ToolType, VToolCutSplinePath::ToolType, VToolCutArc::ToolType};
switch (points.indexOf(type))
{
case 0: //VToolSinglePoint::ToolType
@ -842,11 +835,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId,
VToolEndLine::Create(id, name, typeLine, f, angle, basePointId,
mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -873,11 +874,18 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this,
VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -904,12 +912,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0");
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -936,12 +951,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -968,12 +990,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId,
VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId,
typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1020,12 +1049,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
QString f = radius;//need for saving fixed formula;
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != radius)
{
SetAttribute(domElement, VAbstractTool::AttrRadius, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1135,10 +1171,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
Valentina::FromFile);
VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1163,10 +1205,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my,
scene, this, data, parse, Valentina::FromFile);
VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse,
Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1191,9 +1240,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1248,8 +1304,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList splines;
splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType;
QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType,
VNodeSplinePath::ToolType};
switch (splines.indexOf(type))
{
case 0: //VToolSpline::ToolType
@ -1363,15 +1419,14 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
const Document::Documents &parse, const QString &type)
void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse,
const QString &type)
{
Q_CHECK_PTR(scene);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList arcs;
arcs << VToolArc::ToolType << VNodeArc::ToolType;
QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType};
switch (arcs.indexOf(type))
{
@ -1381,10 +1436,21 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom
const quint32 id = GetParametrId(domElement);
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
QString r = radius;//need for saving fixed formula;
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
QString f1Fix = f1;//need for saving fixed formula;
const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
QString f2Fix = f2;//need for saving fixed formula;
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Valentina::FromFile);
VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (r != radius || f1Fix != f1 || f2Fix != f2)
{
SetAttribute(domElement, VAbstractTool::AttrRadius, r);
SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix);
SetAttribute(domElement, VAbstractTool::AttrAngle2, f2Fix);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1434,8 +1500,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList tools;
tools << VToolUnionDetails::ToolType;
QStringList tools{VToolUnionDetails::ToolType};
switch (tools.indexOf(type))
{

View file

@ -334,7 +334,7 @@ private:
* @param type type of point.
* @param mode draw mode.
*/
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString &type);
/**
* @brief ParseLineElement parse line tag.
@ -363,7 +363,7 @@ private:
* @param type type of spline.
* @param mode draw mode.
*/
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseToolsElement parse tools tag.

View file

@ -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("/+-*^?<>=#!$%&|~'_") );
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -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{"<=", ">=", "!=", "==", "<", ">", "+", "-", "*", "/", "^", "&&", "||",
"=", "(", ")", "?", ":"};
//---------------------------------------------------------------------------------------------------------------------
/**

View file

@ -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;
}
}