/************************************************************************ ** ** @file dialogeditwrongformula.h ** @author Roman Telezhynskyi ** @date 29 5, 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 ** 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 . ** *************************************************************************/ #ifndef DIALOGEDITWRONGFORMULA_H #define DIALOGEDITWRONGFORMULA_H #include #include #include #include #include #include #include #include #include "../vmisc/defglobal.h" class VMeasurement; struct FormulaData; class VContainer; 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 final : public QDialog { Q_OBJECT //NOLINT public: DialogEditWrongFormula(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); ~DialogEditWrongFormula() override; auto GetFormula() const -> QString; void SetFormula(const QString &value); void setCheckZero(bool value); void setCheckLessThanZero(bool value); void setPostfix(const QString &value); void SetMeasurementsMode(); void SetIncrementsMode(); void SetPreviewCalculationsMode(); public slots: virtual void DialogAccepted(); virtual void DialogRejected(); void EvalFormula(); void ValChanged(int row); void PutHere(); void PutVal(QTableWidgetItem * item); void Measurements(); void LengthLines(); void RadiusArcs(); void AnglesCurves(); void LengthCurves(); void CurvesCLength(); void AngleLines(); void Increments(); void PreviewCalculations(); void Functions(); signals: /** * @brief DialogClosed signal dialog closed * @param result keep result */ void DialogClosed(int result); /** * @brief DialogApplied emit signal dialog apply changes */ void DialogApplied(); protected: virtual auto IsValid() const -> bool final; void closeEvent(QCloseEvent *event) override; void showEvent( QShowEvent *event ) override; void resizeEvent(QResizeEvent *event) override; virtual void CheckState(); private slots: void FilterVariablesEdited(const QString &filter); private: Q_DISABLE_COPY_MOVE(DialogEditWrongFormula) //NOLINT Ui::DialogEditWrongFormula *ui; const VContainer *m_data; quint32 m_toolId; /** @brief formula string with formula */ QString formula{}; /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight{0}; bool checkZero{false}; bool checkLessThanZero{false}; QString postfix{}; bool restoreCursor{false}; QTimer *timerFormula; bool flagFormula{false}; /** @brief m_isInitialized true if window is initialized */ bool m_isInitialized{false}; void InitVariables(); template void ShowVariable(const QMap &var); void ShowMeasurements(const QMap > &var); void ShowFunctions(); void ShowIncrementsInPreviewCalculation(bool show); void SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description); auto Eval(const FormulaData &formulaData, bool &flag) -> qreal; }; //--------------------------------------------------------------------------------------------------------------------- inline auto DialogEditWrongFormula::IsValid() const -> bool { return flagFormula; } #endif // DIALOGEDITWRONGFORMULA_H