2014-08-29 11:19:11 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vformula.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 28 8, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-08-29 11:19:11 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-08-29 11:19:11 +02:00
|
|
|
** <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 VFORMULA_H
|
|
|
|
#define VFORMULA_H
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
2019-04-17 12:02:22 +02:00
|
|
|
#include <QSharedDataPointer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaType>
|
2019-04-17 12:02:22 +02:00
|
|
|
#include <QTypeInfo>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
2014-08-29 11:19:11 +02:00
|
|
|
|
2019-07-11 12:47:55 +02:00
|
|
|
enum class FormulaType : char
|
|
|
|
{
|
|
|
|
ToUser = 0,
|
|
|
|
FromUser = 1,
|
|
|
|
ToSystem = FromUser,
|
|
|
|
FromSystem = ToUser
|
|
|
|
};
|
2014-08-29 15:42:53 +02:00
|
|
|
|
2014-08-29 11:19:11 +02:00
|
|
|
class VContainer;
|
2019-04-17 12:02:22 +02:00
|
|
|
class VFormulaData;
|
2014-08-29 11:19:11 +02:00
|
|
|
|
|
|
|
class VFormula
|
|
|
|
{
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(VFormula)
|
|
|
|
public:
|
|
|
|
VFormula();
|
|
|
|
VFormula(const QString &formula, const VContainer *container);
|
|
|
|
VFormula &operator=(const VFormula &formula);
|
|
|
|
VFormula(const VFormula &formula);
|
2019-04-17 12:02:22 +02:00
|
|
|
~VFormula();
|
|
|
|
|
2014-08-29 11:19:11 +02:00
|
|
|
bool operator==(const VFormula &formula) const;
|
|
|
|
bool operator!=(const VFormula &formula) const;
|
|
|
|
|
2015-02-03 11:17:04 +01:00
|
|
|
QString GetFormula(FormulaType type = FormulaType::ToUser) const;
|
2019-07-11 12:47:55 +02:00
|
|
|
void SetFormula(const QString &value, FormulaType type = FormulaType::FromSystem);
|
2014-08-29 11:19:11 +02:00
|
|
|
|
2014-09-01 16:34:45 +02:00
|
|
|
QString getStringValue() const;
|
|
|
|
qreal getDoubleValue() const;
|
2014-08-29 11:19:11 +02:00
|
|
|
|
|
|
|
bool getCheckZero() const;
|
|
|
|
void setCheckZero(bool value);
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
bool getCheckLessThanZero() const;
|
|
|
|
void setCheckLessThanZero(bool value);
|
|
|
|
|
2014-08-29 11:19:11 +02:00
|
|
|
const VContainer *getData() const;
|
|
|
|
void setData(const VContainer *value);
|
|
|
|
|
|
|
|
quint32 getToolId() const;
|
2019-04-17 12:02:22 +02:00
|
|
|
void setToolId(quint32 value);
|
2014-08-29 11:19:11 +02:00
|
|
|
|
|
|
|
QString getPostfix() const;
|
|
|
|
void setPostfix(const QString &value);
|
|
|
|
|
|
|
|
bool error() const;
|
2019-04-17 12:02:22 +02:00
|
|
|
QString Reason() const;
|
2014-08-29 11:19:11 +02:00
|
|
|
|
|
|
|
static int FormulaTypeId();
|
2018-01-20 14:37:15 +01:00
|
|
|
|
|
|
|
void Eval();
|
2014-08-29 11:19:11 +02:00
|
|
|
private:
|
2019-04-17 12:02:22 +02:00
|
|
|
QSharedDataPointer<VFormulaData> d;
|
|
|
|
|
|
|
|
void ResetState();
|
2014-08-29 11:19:11 +02:00
|
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(VFormula)
|
2019-04-17 12:02:22 +02:00
|
|
|
Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE);
|
2014-08-29 11:19:11 +02:00
|
|
|
|
|
|
|
#endif // VFORMULA_H
|