Seamly2D
Code documentation
vformula.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vformula.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 28 8, 2014
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #ifndef VFORMULA_H
53 #define VFORMULA_H
54 
55 #include <QCoreApplication>
56 #include <QMetaType>
57 #include <QString>
58 #include <QtGlobal>
59 
60 enum class FormulaType : char{ToUser, FromUser};
61 
62 class VContainer;
63 
64 class VFormula
65 {
66  Q_DECLARE_TR_FUNCTIONS(VFormula)
67 public:
68  VFormula();
69  VFormula(const QString &formula, const VContainer *container);
71  VFormula(const VFormula &formula);
72  bool operator==(const VFormula &formula) const;
73  bool operator!=(const VFormula &formula) const;
74 
75  QString GetFormula(FormulaType type = FormulaType::ToUser) const;
76  void SetFormula(const QString &value, FormulaType type = FormulaType::ToUser);
77 
78  QString getStringValue() const;
79  qreal getDoubleValue() const;
80 
81  bool getCheckZero() const;
82  void setCheckZero(bool value);
83 
84  const VContainer *getData() const;
85  void setData(const VContainer *value);
86 
87  quint32 getToolId() const;
88  void setToolId(const quint32 &value);
89 
90  QString getPostfix() const;
91  void setPostfix(const QString &value);
92 
93  bool error() const;
94 
95  static int FormulaTypeId();
96  void Eval();
97 
98 private:
99  QString formula;
100  QString value;
101  bool checkZero;
102  const VContainer *data;
103  quint32 toolId;
104  QString postfix;
105  bool _error;
106  qreal dValue;
107 
108 
109 };
110 Q_DECLARE_METATYPE(VFormula)
111 
112 #endif // VFORMULA_H
The VContainer class container of all variables.
Definition: vcontainer.h:141
void Eval()
Definition: vformula.cpp:250
bool _error
Definition: vformula.h:105
qreal dValue
Definition: vformula.h:106
QString postfix
Definition: vformula.h:104
QString formula
Definition: vformula.h:99
void setData(const VContainer *value)
Definition: vformula.cpp:200
bool checkZero
Definition: vformula.h:101
QString getPostfix() const
Definition: vformula.cpp:222
const VContainer * getData() const
Definition: vformula.cpp:194
bool getCheckZero() const
Definition: vformula.cpp:178
bool error() const
Definition: vformula.cpp:238
qreal getDoubleValue() const
Definition: vformula.cpp:172
QString value
Definition: vformula.h:100
QString GetFormula(FormulaType type=FormulaType::ToUser) const
Definition: vformula.cpp:135
static int FormulaTypeId()
Definition: vformula.cpp:244
bool operator!=(const VFormula &formula) const
Definition: vformula.cpp:129
VFormula()
Definition: vformula.cpp:70
QString getStringValue() const
Definition: vformula.cpp:166
const VContainer * data
Definition: vformula.h:102
quint32 toolId
Definition: vformula.h:103
bool operator==(const VFormula &formula) const
Definition: vformula.cpp:116
quint32 getToolId() const
Definition: vformula.cpp:210
void setToolId(const quint32 &value)
Definition: vformula.cpp:216
void setCheckZero(bool value)
Definition: vformula.cpp:184
VFormula & operator=(const VFormula &formula)
Definition: vformula.cpp:91
void SetFormula(const QString &value, FormulaType type=FormulaType::ToUser)
Definition: vformula.cpp:148
void setPostfix(const QString &value)
Definition: vformula.cpp:228
FormulaType
Definition: vformula.h:60