2015-06-11 12:15:57 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtranslatevars.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 10 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-06-11 12:15:57 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-06-11 12:15:57 +02:00
|
|
|
**
|
|
|
|
** 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 VTRANSLATEVARS_H
|
|
|
|
#define VTRANSLATEVARS_H
|
|
|
|
|
2023-10-31 08:42:09 +01:00
|
|
|
#include <QMap>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
2023-10-31 08:42:09 +01:00
|
|
|
#include "../qmuparser/qmutranslation.h"
|
2022-08-02 19:12:23 +02:00
|
|
|
#include "../vmisc/defglobal.h"
|
2015-06-11 12:15:57 +02:00
|
|
|
|
2023-10-31 08:42:09 +01:00
|
|
|
class VTranslateVars
|
2015-06-11 12:15:57 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-05-23 17:23:39 +02:00
|
|
|
explicit VTranslateVars();
|
2023-10-31 08:42:09 +01:00
|
|
|
~VTranslateVars() = default;
|
2015-06-11 12:15:57 +02:00
|
|
|
|
2022-08-02 19:12:23 +02:00
|
|
|
auto InternalVarToUser(const QString &var) const -> QString;
|
2017-08-14 14:48:14 +02:00
|
|
|
|
2022-08-02 19:12:23 +02:00
|
|
|
auto VarToUser(const QString &var) const -> QString;
|
|
|
|
auto VarFromUser(const QString &var) const -> QString;
|
2015-06-11 12:15:57 +02:00
|
|
|
|
2022-08-02 19:12:23 +02:00
|
|
|
auto FormulaFromUser(const QString &formula, bool osSeparator) const -> QString;
|
|
|
|
static auto TryFormulaFromUser(const QString &formula, bool osSeparator) -> QString;
|
2017-09-26 16:24:02 +02:00
|
|
|
|
2022-08-02 19:12:23 +02:00
|
|
|
auto FormulaToUser(const QString &formula, bool osSeparator) const -> QString;
|
|
|
|
static auto TryFormulaToUser(const QString &formula, bool osSeparator) -> QString;
|
2015-06-11 12:15:57 +02:00
|
|
|
|
2023-10-31 08:42:09 +01:00
|
|
|
void Retranslate();
|
2016-08-23 13:02:09 +02:00
|
|
|
|
2022-08-02 19:12:23 +02:00
|
|
|
auto GetTranslatedFunctions() const -> QMap<QString, QString>;
|
|
|
|
auto GetFunctions() const -> QMap<QString, qmu::QmuTranslation>;
|
|
|
|
auto GetFunctionsDescriptions() const -> QMap<QString, qmu::QmuTranslation>;
|
|
|
|
auto GetFunctionsArguments() const -> QMap<QString, QString>;
|
2015-08-08 16:33:37 +02:00
|
|
|
|
2023-02-09 16:23:11 +01:00
|
|
|
static void BiasTokens(vsizetype position, vsizetype bias, QMap<vsizetype, QString> &tokens);
|
2017-08-08 16:43:41 +02:00
|
|
|
|
2015-06-11 12:15:57 +02:00
|
|
|
private:
|
2022-08-08 14:25:14 +02:00
|
|
|
// cppcheck-suppress unknownMacro
|
2023-07-13 16:49:20 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VTranslateVars) // NOLINT
|
2020-02-27 16:26:32 +01:00
|
|
|
QMap<QString, qmu::QmuTranslation> variables{};
|
|
|
|
QMap<QString, qmu::QmuTranslation> functions{};
|
2020-02-27 16:28:20 +01:00
|
|
|
QMap<QString, qmu::QmuTranslation> functionsDescriptions{};
|
2022-08-02 19:11:18 +02:00
|
|
|
QMap<QString, QString> functionsArguments{};
|
2020-02-27 16:26:32 +01:00
|
|
|
QMap<QString, qmu::QmuTranslation> stDescriptions{};
|
|
|
|
QMap<QString, QString> translatedFunctions{};
|
2015-06-11 12:15:57 +02:00
|
|
|
|
|
|
|
void InitVariables();
|
|
|
|
void InitFunctions();
|
|
|
|
|
2023-10-06 09:57:46 +02:00
|
|
|
auto VariablesFromUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const
|
|
|
|
-> bool;
|
|
|
|
auto FunctionsFromUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const
|
|
|
|
-> bool;
|
|
|
|
auto VariablesToUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const -> bool;
|
|
|
|
|
2017-12-04 10:44:29 +01:00
|
|
|
void PrepareFunctionTranslations();
|
|
|
|
|
2023-02-09 16:23:11 +01:00
|
|
|
static void CorrectionsPositions(vsizetype position, vsizetype bias, QMap<vsizetype, QString> &tokens,
|
|
|
|
QMap<vsizetype, QString> &numbers);
|
2017-08-08 16:43:41 +02:00
|
|
|
|
2023-02-09 16:23:11 +01:00
|
|
|
void TranslateVarsFromUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
|
|
|
|
QMap<vsizetype, QString> &numbers) const;
|
|
|
|
static void TranslateNumbersFromUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
|
|
|
|
QMap<vsizetype, QString> &numbers, bool osSeparator);
|
2022-08-02 19:12:23 +02:00
|
|
|
|
2023-02-09 16:23:11 +01:00
|
|
|
void TranslateVarsToUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
|
|
|
|
QMap<vsizetype, QString> &numbers) const;
|
|
|
|
static void TranslateNumbersToUser(QString &newFormula, QMap<vsizetype, QString> &tokens,
|
|
|
|
QMap<vsizetype, QString> &numbers, bool osSeparator);
|
2015-06-11 12:15:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTRANSLATEVARS_H
|