valentina/src/libs/vpatterndb/vformula.h

101 lines
2.9 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vformula.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 8, 2014
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://gitlab.com/smart-pattern/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>
#include <QMetaType>
2023-07-15 09:58:28 +02:00
#include <QSharedDataPointer>
#include <QString>
2023-07-15 09:58:28 +02:00
#include <QTypeInfo>
#include <QtGlobal>
enum class FormulaType : qint8
{
ToUser = 0,
FromUser = 1,
ToSystem = FromUser,
FromSystem = ToUser
};
class VContainer;
class VFormulaData;
class VFormula
{
2022-08-12 17:50:13 +02:00
Q_DECLARE_TR_FUNCTIONS(VFormula) // NOLINT
2023-07-15 09:58:28 +02:00
public:
VFormula();
VFormula(const QString &formula, const VContainer *container);
2023-05-03 13:07:02 +02:00
auto operator=(const VFormula &formula) -> VFormula &;
VFormula(const VFormula &formula);
~VFormula();
2023-05-03 13:07:02 +02:00
auto operator==(const VFormula &formula) const -> bool;
auto operator!=(const VFormula &formula) const -> bool;
2023-05-03 13:07:02 +02:00
auto GetFormula(FormulaType type = FormulaType::ToUser) const -> QString;
void SetFormula(const QString &value, FormulaType type = FormulaType::FromSystem);
2023-05-03 13:07:02 +02:00
auto getStringValue() const -> QString;
auto getDoubleValue() const -> qreal;
2023-05-03 13:07:02 +02:00
auto getCheckZero() const -> bool;
void setCheckZero(bool value);
2023-05-03 13:07:02 +02:00
auto getCheckLessThanZero() const -> bool;
void setCheckLessThanZero(bool value);
2023-05-03 13:07:02 +02:00
auto getData() const -> const VContainer *;
void setData(const VContainer *value);
2023-05-03 13:07:02 +02:00
auto getToolId() const -> quint32;
void setToolId(quint32 value);
2023-05-03 13:07:02 +02:00
auto getPostfix() const -> QString;
void setPostfix(const QString &value);
2023-05-03 13:07:02 +02:00
auto error() const -> bool;
auto Reason() const -> QString;
2023-05-03 13:07:02 +02:00
static auto FormulaTypeId() -> int;
void Eval();
2023-07-15 09:58:28 +02:00
private:
QSharedDataPointer<VFormulaData> d;
void ResetState();
};
2023-07-15 09:58:28 +02:00
Q_DECLARE_METATYPE(VFormula) // NOLINT
2022-08-12 17:50:13 +02:00
Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE); // NOLINT
#endif // VFORMULA_H