Seamly2D
Code documentation
vpatternconverter.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vpatternconverter.h
3  ** @author Douglas S Caskey
4  ** @date Dec 27, 2022
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2022 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25 /**************************************************************************
26  **
27  ** @file vpatternconverter.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 11 12, 2014
30  **
31  ** @brief
32  ** @copyright
33  ** This source code is part of the Valentina project, a pattern making
34  ** program, whose allow create and modeling patterns of clothing.
35  ** Copyright (C) 2014 Valentina project
36  ** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
37  **
38  ** Valentina is free software: you can redistribute it and/or modify
39  ** it under the terms of the GNU General Public License as published by
40  ** the Free Software Foundation, either version 3 of the License, or
41  ** (at your option) any later version.
42  **
43  ** Valentina is distributed in the hope that it will be useful,
44  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
45  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  ** GNU General Public License for more details.
47  **
48  ** You should have received a copy of the GNU General Public License
49  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
50  **
51  *************************************************************************/
52 
53 #ifndef VPATTERNCONVERTER_H
54 #define VPATTERNCONVERTER_H
55 
56 #include <qcompilerdetection.h>
57 #include <QCoreApplication>
58 #include <QDomElement>
59 #include <QMap>
60 #include <QSet>
61 #include <QString>
62 #include <QStringList>
63 #include <QVector>
64 #include <QtGlobal>
65 
66 #include "vabstractconverter.h"
67 
68 class QDomElement;
69 
71 {
72  Q_DECLARE_TR_FUNCTIONS(VPatternConverter)
73 public:
74  explicit VPatternConverter(const QString &fileName);
75  virtual ~VPatternConverter() Q_DECL_EQ_DEFAULT;
76 
77  static const QString PatternMaxVerStr;
78  static const QString CurrentSchema;
79  static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
80  static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 8);
81 
82 protected:
83  virtual int MinVer() const Q_DECL_OVERRIDE;
84  virtual int MaxVer() const Q_DECL_OVERRIDE;
85 
86  virtual QString MinVerStr() const Q_DECL_OVERRIDE;
87  virtual QString MaxVerStr() const Q_DECL_OVERRIDE;
88 
89  virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
90  virtual void ApplyPatches() Q_DECL_OVERRIDE;
91  virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
92 
93  virtual bool IsReadOnly() const Q_DECL_OVERRIDE;
94 
95 private:
96  Q_DISABLE_COPY(VPatternConverter)
97  static const QString PatternMinVerStr;
98 
99  void toVersion0_1_1();
100  void toVersion0_1_2();
101  void toVersion0_1_3();
102  void toVersion0_1_4();
103  void toVersion0_2_0();
104  void toVersion0_2_1();
105  void toVersion0_2_2();
106  void toVersion0_2_3();
107  void toVersion0_2_4();
108  void toVersion0_2_5();
109  void toVersion0_2_6();
110  void toVersion0_2_7();
111  void toVersion0_3_0();
112  void toVersion0_3_1();
113  void toVersion0_3_2();
114  void toVersion0_3_3();
115  void toVersion0_3_4();
116  void toVersion0_3_5();
117  void toVersion0_3_6();
118  void toVersion0_3_7();
119  void toVersion0_3_8();
120  void toVersion0_3_9();
121  void toVersion0_4_0();
122  void toVersion0_4_1();
123  void toVersion0_4_2();
124  void toVersion0_4_3();
125  void toVersion0_4_4();
126  void toVersion0_4_5();
127  void toVersion0_4_6();
128  void toVersion0_4_7();
129  void toVersion0_4_8();
130  void toVersion0_5_0();
131  void toVersion0_5_1();
132  void toVersion0_6_0();
133  void toVersion0_6_1();
134  void toVersion0_6_2();
135  void toVersion0_6_3();
136  void toVersion0_6_4();
137  void toVersion0_6_5();
138  void toVersion0_6_6();
139  void toVersion0_6_7();
140  void toVersion0_6_8();
141 
142  void TagUnitToV0_2_0();
143  void TagIncrementToV0_2_0();
146 
148 
150 
151  QSet<QString> FixIncrementsToV0_2_0();
152  QString FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet<QString> &names);
153  void FixPointExpressionsToV0_2_0(const QSet<QString> &names);
154  void FixArcExpressionsToV0_2_0(const QSet<QString> &names);
155  void FixPathPointExpressionsToV0_2_0(const QSet<QString> &names);
156 
157  void ConvertPointExpressionsToV0_2_0(const QMap<QString, QString> &names);
158  void ConvertArcExpressionsToV0_2_0(const QMap<QString, QString> &names);
159  void ConvertPathPointExpressionsToV0_2_0(const QMap<QString, QString> &names);
160  QString FixMeasurementInFormulaToV0_2_0(const QString &formula, const QMap<QString, QString> &names);
161 
162  QString MUnitV0_1_4() const;
163  QDomElement TagMeasurementsV0_1_4() const;
164  QDomElement TagIncrementsV0_1_4() const;
165 
166  void FixToolUnionToV0_2_4();
167  void ParseModelingToV0_2_4(const QDomElement &modeling);
168  void SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<quint32> &children);
169 
170  static QMap<QString, QString> OldNamesToNewNames_InV0_2_0();
171  static QMap<QString, QString> OldNamesToNewNames_InV0_2_1();
172 
173  void FixCutPoint();
174  void FixSubPaths(int i, quint32 id, quint32 baseCurve);
175 
177  void TagDetailToV0_4_0();
179  QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail);
180  QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
181 
182  void LabelTagToV0_4_4(const QString &tagName);
183 
184  QDomElement AddTagPatternLabelV0_5_1();
185  void PortPatternLabeltoV0_6_0(QDomElement &label);
186  void AddLabelTemplateLineV0_6_0(QDomElement &label, const QString &text, bool bold,
187  bool italic, int alignment, int fontSizeIncrement);
189  void RemoveUnusedTagsV0_6_0();
190  void RemoveUniqueTagV0_6_0(const QString &tag);
191  void renameAttribute(QDomElement &element, const QString &oldName,
192  const QString &newName, const QString &value) const;
193 };
194 
195 //---------------------------------------------------------------------------------------------------------------------
196 inline int VPatternConverter::MinVer() const
197 {
198  return PatternMinVer;
199 }
200 
201 //---------------------------------------------------------------------------------------------------------------------
202 inline int VPatternConverter::MaxVer() const
203 {
204  return PatternMaxVer;
205 }
206 
207 //---------------------------------------------------------------------------------------------------------------------
208 inline QString VPatternConverter::MinVerStr() const
209 {
210  return PatternMinVerStr;
211 }
212 
213 //---------------------------------------------------------------------------------------------------------------------
214 inline QString VPatternConverter::MaxVerStr() const
215 {
216  return PatternMaxVerStr;
217 }
218 
219 #endif // VPATTERNCONVERTER_H
static const QString CurrentSchema
virtual int MaxVer() const Q_DECL_OVERRIDE
static const QString PatternMinVerStr
void ConvertArcExpressionsToV0_2_0(const QMap< QString, QString > &names)
virtual QString MinVerStr() const Q_DECL_OVERRIDE
void RemoveUniqueTagV0_6_0(const QString &tag)
VPatternConverter(const QString &fileName)
QDomElement AddTagPatternLabelV0_5_1()
void TagRemoveAttributeTypeObjectInV0_4_0()
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail)
QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail)
void FixSubPaths(int i, quint32 id, quint32 baseCurve)
static const QString PatternMaxVerStr
virtual ~VPatternConverter() Q_DECL_EQ_DEFAULT
void FixArcExpressionsToV0_2_0(const QSet< QString > &names)
void LabelTagToV0_4_4(const QString &tagName)
void ConvertPointExpressionsToV0_2_0(const QMap< QString, QString > &names)
virtual QString MaxVerStr() const Q_DECL_OVERRIDE
void SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector< quint32 > &children)
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE
QString FixMeasurementInFormulaToV0_2_0(const QString &formula, const QMap< QString, QString > &names)
QDomElement TagMeasurementsV0_1_4() const
void PortPatternLabeltoV0_6_0(QDomElement &label)
QSet< QString > FixIncrementsToV0_2_0()
void renameAttribute(QDomElement &element, const QString &oldName, const QString &newName, const QString &value) const
static QMap< QString, QString > OldNamesToNewNames_InV0_2_0()
virtual void ApplyPatches() Q_DECL_OVERRIDE
QString MUnitV0_1_4() const
static QMap< QString, QString > OldNamesToNewNames_InV0_2_1()
void FixPathPointExpressionsToV0_2_0(const QSet< QString > &names)
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE
static Q_DECL_CONSTEXPR const int PatternMinVer
static Q_DECL_CONSTEXPR const int PatternMaxVer
void FixPointExpressionsToV0_2_0(const QSet< QString > &names)
QString FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet< QString > &names)
void AddLabelTemplateLineV0_6_0(QDomElement &label, const QString &text, bool bold, bool italic, int alignment, int fontSizeIncrement)
virtual int MinVer() const Q_DECL_OVERRIDE
virtual bool IsReadOnly() const Q_DECL_OVERRIDE
void ParseModelingToV0_2_4(const QDomElement &modeling)
void ConvertPathPointExpressionsToV0_2_0(const QMap< QString, QString > &names)
QDomElement TagIncrementsV0_1_4() const
#define CONVERTER_VERSION_CHECK(major, minor, patch)