Seamly2D
Code documentation
vmeasurements.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 vmeasurements.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 14 7, 2015
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) 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 VMEASUREMENTS_H
53 #define VMEASUREMENTS_H
54 
55 #include <qcompilerdetection.h>
56 #include <QCoreApplication>
57 #include <QDomElement>
58 #include <QString>
59 #include <QStringList>
60 #include <QtGlobal>
61 
62 #include "../ifc/xml/vdomdocument.h"
63 #include "../vmisc/def.h"
64 #include "../vpatterndb/vcontainer.h"
65 
66 enum class GenderType : char { Male, Female, Unknown };
67 
69 {
70  Q_DECLARE_TR_FUNCTIONS(VMeasurements)
71 public:
72  explicit VMeasurements(VContainer *data);
74  VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data);
75  virtual ~VMeasurements() Q_DECL_EQ_DEFAULT;
76 
77  virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE;
78  virtual bool SaveDocument(const QString &fileName, QString &error) Q_DECL_OVERRIDE;
79 
80  void addEmpty(const QString &name, const QString &formula = QString());
81  void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
82  void Remove(const QString &name);
83  void MoveTop(const QString &name);
84  void MoveUp(const QString &name);
85  void MoveDown(const QString &name);
86  void MoveBottom(const QString &name);
87 
88  void ReadMeasurements() const;
89  void ClearForExport();
90 
91  MeasurementsType Type() const;
92  int BaseSize() const;
93  int BaseHeight() const;
94 
95  QString Notes() const;
96  void SetNotes(const QString &text);
97 
98  QString FamilyName() const;
99  void SetFamilyName(const QString &text);
100 
101  QString GivenName() const;
102  void SetGivenName(const QString &text);
103 
104  QDate BirthDate() const;
105  void SetBirthDate(const QDate &date);
106 
107  GenderType Gender() const;
108  void SetGender(const GenderType &gender);
109 
110  QString PMSystem() const;
111  void SetPMSystem(const QString &system);
112 
113  QString Email() const;
114  void SetEmail(const QString &text);
115 
116  bool IsReadOnly() const;
117  void SetReadOnly(bool ro);
118 
119  void SetSize(qreal *size);
120  void SetHeight(qreal *height);
121 
122  void SetMName(const QString &name, const QString &text);
123  void SetMValue(const QString &name, const QString &text);
124  void SetMBaseValue(const QString &name, double value);
125  void SetMSizeIncrease(const QString &name, double value);
126  void SetMHeightIncrease(const QString &name, double value);
127  void SetMDescription(const QString &name, const QString &text);
128  void SetMFullName(const QString &name, const QString &text);
129 
130  static const QString TagVST;
131  static const QString TagVIT;
132  static const QString TagBodyMeasurements;
133  static const QString TagNotes;
134  static const QString TagSize;
135  static const QString TagHeight;
136  static const QString TagPersonal;
137  static const QString TagFamilyName;
138  static const QString TagGivenName;
139  static const QString TagBirthDate;
140  static const QString TagGender;
141  static const QString TagPMSystem;
142  static const QString TagEmail;
143  static const QString TagReadOnly;
144  static const QString TagMeasurement;
145 
146  static const QString AttrBase;
147  static const QString AttrValue;
148  static const QString AttrSizeIncrease;
149  static const QString AttrHeightIncrease;
150  static const QString AttrDescription;
151  static const QString AttrName;
152  static const QString AttrFullName;
153 
154  static const QString GenderMale;
155  static const QString GenderFemale;
156  static const QString GenderUnknown;
157 
158  static QString GenderToStr(const GenderType &sex);
159  static GenderType StrToGender(const QString &sex);
160 
161  QStringList ListAll() const;
162  QStringList listKnown() const;
163 
164  bool IsDefinedKnownNamesValid() const;
165 
166  VContainer *GetData() const;
167 
168 private:
169  Q_DISABLE_COPY(VMeasurements)
170 
171  /** @brief data container with data. */
174 
177 
178  void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight);
179  void CreateEmptyIndividualFile(Unit unit);
180 
181  qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
182 
183  QDomElement MakeEmpty(const QString &name, const QString &formula);
184  QDomElement FindM(const QString &name) const;
185  MeasurementsType ReadType() const;
186 
187  qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
188 
189  QString ClearPMCode(const QString &code) const;
190 };
191 
192 #endif // VMEASUREMENTS_H
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VDomDocument class represents a Seamly2D document (.val file).
Definition: vdomdocument.h:105
void MoveUp(const QString &name)
MeasurementsType ReadType() const
void MoveTop(const QString &name)
static const QString TagSize
void SetMDescription(const QString &name, const QString &text)
void MoveDown(const QString &name)
static const QString AttrValue
static const QString TagNotes
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const
static const QString AttrSizeIncrease
static const QString TagPMSystem
void addEmpty(const QString &name, const QString &formula=QString())
static GenderType StrToGender(const QString &sex)
virtual ~VMeasurements() Q_DECL_EQ_DEFAULT
static const QString TagGender
VMeasurements(VContainer *data)
QString PMSystem() const
void SetGender(const GenderType &gender)
void SetNotes(const QString &text)
static const QString AttrFullName
void SetMBaseValue(const QString &name, double value)
static const QString GenderFemale
void SetEmail(const QString &text)
QStringList ListAll() const
QStringList listKnown() const
static const QString TagBirthDate
static QString GenderToStr(const GenderType &sex)
MeasurementsType type
static const QString AttrBase
static const QString AttrName
QString ClearPMCode(const QString &code) const
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight)
void SetFamilyName(const QString &text)
static const QString TagHeight
void ReadMeasurements() const
static const QString TagReadOnly
static const QString TagFamilyName
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const
static const QString TagPersonal
void SetSize(qreal *size)
void SetPMSystem(const QString &system)
QDomElement MakeEmpty(const QString &name, const QString &formula)
qreal * m_currentSize
void Remove(const QString &name)
VContainer * GetData() const
static const QString AttrDescription
void SetReadOnly(bool ro)
int BaseSize() const
void SetMFullName(const QString &name, const QString &text)
QDate BirthDate() const
QDomElement FindM(const QString &name) const
static const QString TagBodyMeasurements
void SetHeight(qreal *height)
void SetMValue(const QString &name, const QString &text)
MeasurementsType Type() const
void SetMSizeIncrease(const QString &name, double value)
void MoveBottom(const QString &name)
static const QString TagVIT
int BaseHeight() const
static const QString TagMeasurement
QString Email() const
void CreateEmptyIndividualFile(Unit unit)
static const QString TagGivenName
VContainer * data
data container with data.
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula=QString())
static const QString GenderMale
bool IsReadOnly() const
static const QString TagVST
void SetGivenName(const QString &text)
void SetMHeightIncrease(const QString &name, double value)
QString FamilyName() const
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE
static const QString GenderUnknown
qreal * m_currentHeight
GenderType Gender() const
static const QString TagEmail
virtual bool SaveDocument(const QString &fileName, QString &error) Q_DECL_OVERRIDE
static const QString AttrHeightIncrease
QString GivenName() const
QString Notes() const
bool IsDefinedKnownNamesValid() const
void SetMName(const QString &name, const QString &text)
void SetBirthDate(const QDate &date)
MeasurementsType
Definition: def.h:104
Unit
Definition: def.h:105
GenderType
Definition: vmeasurements.h:66