Seamly2D
Code documentation
dialogvariables.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 dialogvariables.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
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 DIALOG_VARIABLES_H
53 #define DIALOG_VARIABLES_H
54 
55 #include "../vtools/dialogs/tools/dialogtool.h"
56 #include "../xml/vpattern.h"
57 #include "../vmisc/vtablesearch.h"
58 
59 #include <QPair>
60 #include <QList>
61 
62 class VIndividualMeasurements;
63 
64 namespace Ui
65 {
66  class DialogVariables;
67 }
68 
69 /**
70  * @brief The DialogVariables class show dialog increments. Tables of all variables in program will be here.
71  */
73 {
74  Q_OBJECT
75 public:
76  DialogVariables(VContainer *data, VPattern *doc, QWidget *parent = nullptr);
77  virtual ~DialogVariables() Q_DECL_OVERRIDE;
78 
79 signals:
81 
82 protected:
83  virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
84  virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
85  virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
86  virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
87  virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
88 
89 private slots:
91  void filterVariables(const QString &filterString);
92  void addCustomVariable();
93  void removeCustomVariable();
94  void moveUp();
95  void moveDown();
96  void saveCustomVariableName(const QString &text);
99  void Fx();
100  void FullUpdateFromFile();
101  void refreshPattern();
102 
103 private:
104  Q_DISABLE_COPY(DialogVariables)
105 
106  /** @brief ui keeps information about user interface */
108 
109  /** @brief data container with data */
110  VContainer *data; // need because we must change data //-V703
111 
112  /** @brief doc dom document container */
114 
116 
118 
119  QVector<QPair<QString, QString>> renameList;
120 
122  bool isSorted;
124 
125 
126  template <typename T>
127  void fillTable(const QMap<QString, T> &varTable, QTableWidget *table);
128 
129  void fillCustomVariables(bool freshCall = false);
130  void fillLineLengths();
131  void fillLineAngles();
132  void fillCurveLengths();
134  void fillArcsRadiuses();
135  void fillCurveAngles();
136 
137  void showUnits();
138  void showHeaderUnits(QTableWidget *table, int column, const QString &unit);
139 
140  void addCell(QTableWidget *table, const QString &text, int row, int column,
141  int aligment, bool ok = true);
142 
143  QString getCustomVariableName() const;
144  QString clearCustomVariableName(const QString &name) const;
145 
146  bool evalVariableFormula(const QString &formula, bool fromUser,
147  VContainer *data, QLabel *label);
148  void setMoveControls();
149  void enablePieces(bool enabled);
150 
151  void localUpdateTree();
152 
153  bool variableUsed(const QString &name) const;
154 
155  void renameCache(const QString &name, const QString &newName);
156 };
157 
158 #endif // DIALOG_VARIABLES_H
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
The DialogVariables class show dialog increments. Tables of all variables in program will be here.
void saveCustomVariableName(const QString &text)
QList< QSharedPointer< QTableWidget > > tableList
void addCustomVariable()
clickedToolButtonAdd create new row in table
QString clearCustomVariableName(const QString &name) const
void fillControlPointLengths()
QString getCustomVariableName() const
void fillCustomVariables(bool freshCall=false)
fillCustomVariables fill data for variables table
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
VPattern * doc
doc dom document container
void saveCustomVariableDescription()
void enablePieces(bool enabled)
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
void saveCustomVariableFormula()
void fillTable(const QMap< QString, T > &varTable, QTableWidget *table)
void showHeaderUnits(QTableWidget *table, int column, const QString &unit)
DialogVariables(VContainer *data, VPattern *doc, QWidget *parent=nullptr)
DialogVariables create dialog.
virtual ~DialogVariables() Q_DECL_OVERRIDE
QVector< QPair< QString, QString > > renameList
void removeCustomVariable()
clickedToolButtonRemove remove one row from table
void fillLineLengths()
FillLengthLines fill data for table of lines lengths.
Ui::DialogVariables * ui
ui keeps information about user interface
void renameCache(const QString &name, const QString &newName)
void FullUpdateFromFile()
FullUpdateFromFile update information in tables form file.
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
VContainer * data
data container with data
void fillCurveLengths()
FillLengthSplines fill data for table of splines lengths.
bool variableUsed(const QString &name) const
void showCustomVariableDetails()
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void addCell(QTableWidget *table, const QString &text, int row, int column, int aligment, bool ok=true)
void filterVariables(const QString &filterString)
bool evalVariableFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
void updateProperties()
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
showEvent handle when window show
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VPattern class working with pattern file.
Definition: vpattern.h:68