Seamly2D
Code documentation
vpiece.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vpiece.h
3  ** @author Douglas S Caskey
4  ** @date Jan 3, 2023
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2023 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 vpiece.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 3 11, 2016
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) 2016 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 VPIECE_H
54 #define VPIECE_H
55 
56 #include <QtGlobal>
57 #include <QLineF>
58 #include <QSharedDataPointer>
59 #include <QSharedPointer>
60 
61 #include "../vlayout/vabstractpiece.h"
62 
63 struct NotchData
64 {
65  QLineF line {};
68  qreal length {};
69  qreal width {};
70  qreal angle {};
71  qreal offset {};
72  int count {};
73 };
74 
75 class VPieceData;
76 class VPieceNode;
77 template <class T> class QVector;
78 template <class T>class QSharedPointer;
79 class VPiecePath;
80 class VPatternLabelData;
81 class VPieceLabelData;
82 class VGrainlineData;
83 class VContainer;
84 class QPainterPath;
85 class VPointF;
86 
87 class VPiece : public VAbstractPiece
88 {
89 public:
90  VPiece();
91  VPiece(const VPiece &piece);
92 
93  virtual ~VPiece();
94 
95  VPiece &operator=(const VPiece &piece);
96 
97 #ifdef Q_COMPILER_RVALUE_REFS
98  VPiece &operator=(VPiece &&piece) Q_DECL_NOTHROW;
99 #endif
100 
101  void Swap(VPiece &piece) Q_DECL_NOTHROW;
102 
103  VPiecePath GetPath() const;
104  VPiecePath &GetPath();
105  void SetPath(const VPiecePath &path);
106 
107  QVector<QPointF> MainPathPoints(const VContainer *data) const;
108  QVector<VPointF> MainPathNodePoints(const VContainer *data, bool showExcluded = false) const;
111  const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
112 
113  QPainterPath MainPathPath(const VContainer *data) const;
114  QPainterPath SeamAllowancePath(const VContainer *data) const;
115  QPainterPath SeamAllowancePath(const QVector<QPointF> &points) const;
116  QPainterPath getNotchesPath(const VContainer *data,
117  const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
118 
119  bool isInLayout() const;
120  void SetInLayout(bool inLayout);
121 
122  bool isLocked() const;
123  void setIsLocked(bool isLocked);
124 
125  bool IsUnited() const;
126  void SetUnited(bool united);
127 
128  QString getSeamAllowanceWidthFormula() const;
129  void setSeamAllowanceWidthFormula(const QString &formula, qreal value);
130 
133  void SetInternalPaths(const QVector<quint32> &iPaths);
134 
137  void SetCustomSARecords(const QVector<CustomSARecord> &records);
138 
141  void setAnchors(const QVector<quint32> &anchors);
142 
143  QVector<quint32> MissingNodes(const VPiece &piece) const;
144  QVector<quint32> MissingCSAPath(const VPiece &piece) const;
145  QVector<quint32> MissingInternalPaths(const VPiece &piece) const;
146  QVector<quint32> missingAnchors(const VPiece &piece) const;
147 
148  void SetPatternPieceData(const VPieceLabelData &data);
150  const VPieceLabelData& GetPatternPieceData() const;
151 
152  void SetPatternInfo(const VPatternLabelData &info);
154  const VPatternLabelData &GetPatternInfo() const;
155 
157  const VGrainlineData& GetGrainlineGeometry() const;
158 
159 private:
160  QSharedDataPointer<VPieceData> d;
161 
162  QVector<VPieceNode> GetUnitedPath(const VContainer *data) const;
163 
166 
168  const VContainer *data) const;
169 
170  bool getNotchSAPoint(const QVector<VPieceNode> &path, int index,
171  const VContainer *data, VSAPoint &point) const;
172  bool getNotchPreviousSAPoints(const QVector<VPieceNode> &path, int index,
173  const VSAPoint &notchSAPoint,
174  const VContainer *data, VSAPoint &point) const;
175  int getNextNotchSAPoints(const QVector<VPieceNode> &path, int index,
176  const VSAPoint &notchSAPoint,
177  const VContainer *data, VSAPoint &point) const;
178  bool getSeamNotchSAPoint(const VSAPoint &previousSAPoint, const VSAPoint &notchSAPoint,
179  const VSAPoint &nextSAPoint, const VContainer *data,
180  QPointF &point) const;
181 
182  bool isNotchVisible(const QVector<VPieceNode> &path, int notchIndex) const;
183 
184  QVector<QLineF> createNotch(const QVector<VPieceNode> &path, int previousIndex, int notchIndex,
185  int nextIndex, const VContainer *data,
186  const QVector<QPointF> &pathPoints = QVector<QPointF>()) const;
187 
189  const VSAPoint &notchSAPoint, VSAPoint &nextSAPoint,
190  const VContainer *data, int notchIndex,
191  const QVector<QPointF> &pathPoints = QVector<QPointF>()) const;
192 
193  QVector<QLineF> createBuiltInSaNotch(const QVector<VPieceNode> &path, const VSAPoint &previousSAPoint,
194  const VSAPoint &notchSAPoint, const VSAPoint &nextSAPoint,
195  const VContainer *data, int notchIndex,
196  const QVector<QPointF> &pathPoints) const;
197 
198  static int IsCSAStart(const QVector<CustomSARecord> &records, quint32 id);
199 
200  QVector<QLineF> createSlitNotch(NotchData notchData, const QVector<QPointF> &seamAllowance) const;
201  QVector<QLineF> createTNotch(NotchData notchData, const QVector<QPointF> &pathPoints) const;
202  QVector<QLineF> createUNotch(const NotchData notchData, const QVector<QPointF> &seamAllowance) const;
203  QVector<QLineF> createVInternalNotch(NotchData notchData, const QVector<QPointF> &pathPoints) const;
204  QVector<QLineF> createVExternalNotch(NotchData notchData, const QVector<QPointF> &seamAllowance) const;
205  QVector<QLineF> createCastleNotch(const NotchData notchData, const QVector<QPointF> &seamAllowance) const;
206  QVector<QLineF> createDiamondNotch(NotchData notchData, const QVector<QPointF> &seamAllowance) const;
207  QVector<QLineF> createNotches(NotchData notchData, const QVector<QPointF> &seamAllowance) const;
208  QLineF findIntersection(const QVector<QPointF> &seamAllowance, const QLineF &line) const;
209 };
210 
211 Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE);
212 
213 #endif // VPIECE_H
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VGrainlineData class holds information about a grainline like position, size, rotation and visibi...
The VPatternLabelData class holds the information about pattern info label geometry.
The VPieceLabelData class holds some information about a single piece like letter,...
Definition: vpiece.h:88
QVector< CustomSARecord > FilterRecords(QVector< CustomSARecord > records) const
Definition: vpiece.cpp:680
void setIsLocked(bool isLocked)
Definition: vpiece.cpp:394
QPainterPath SeamAllowancePath(const VContainer *data) const
Definition: vpiece.cpp:323
bool isNotchVisible(const QVector< VPieceNode > &path, int notchIndex) const
Definition: vpiece.cpp:889
QVector< VPieceNode > GetUnitedPath(const VContainer *data) const
Definition: vpiece.cpp:594
bool getSeamNotchSAPoint(const VSAPoint &previousSAPoint, const VSAPoint &notchSAPoint, const VSAPoint &nextSAPoint, const VContainer *data, QPointF &point) const
Definition: vpiece.cpp:842
VPieceLabelData & GetPatternPieceData()
Returns full access to the pattern piece data object.
Definition: vpiece.cpp:532
QVector< CustomSARecord > GetCustomSARecords() const
Definition: vpiece.cpp:444
bool getNotchSAPoint(const QVector< VPieceNode > &path, int index, const VContainer *data, VSAPoint &point) const
Definition: vpiece.cpp:758
bool getNotchPreviousSAPoints(const QVector< VPieceNode > &path, int index, const VSAPoint &notchSAPoint, const VContainer *data, VSAPoint &point) const
Definition: vpiece.cpp:775
QString getSeamAllowanceWidthFormula() const
Definition: vpiece.cpp:412
QSharedDataPointer< VPieceData > d
Definition: vpiece.h:160
QVector< QLineF > createNotchLines(const VContainer *data, const QVector< QPointF > &seamAllowance=QVector< QPointF >()) const
Definition: vpiece.cpp:275
QVector< VSAPoint > getNodeSAPoints(const QVector< VPieceNode > &path, int index, const VContainer *data) const
Definition: vpiece.cpp:731
void Swap(VPiece &piece) Q_DECL_NOTHROW
Definition: vpiece.cpp:124
QPainterPath getNotchesPath(const VContainer *data, const QVector< QPointF > &seamAllowance=QVector< QPointF >()) const
Definition: vpiece.cpp:352
QVector< QLineF > createBuiltInSaNotch(const QVector< VPieceNode > &path, const VSAPoint &previousSAPoint, const VSAPoint &notchSAPoint, const VSAPoint &nextSAPoint, const VContainer *data, int notchIndex, const QVector< QPointF > &pathPoints) const
Definition: vpiece.cpp:1074
bool isInLayout() const
Definition: vpiece.cpp:376
QVector< quint32 > GetInternalPaths() const
Definition: vpiece.cpp:426
QVector< QLineF > createTNotch(NotchData notchData, const QVector< QPointF > &pathPoints) const
Definition: vpiece.cpp:1132
QVector< QLineF > createNotch(const QVector< VPieceNode > &path, int previousIndex, int notchIndex, int nextIndex, const VContainer *data, const QVector< QPointF > &pathPoints=QVector< QPointF >()) const
Definition: vpiece.cpp:929
QVector< QLineF > createSlitNotch(NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1117
void SetPath(const VPiecePath &path)
Definition: vpiece.cpp:168
void SetInLayout(bool inLayout)
Definition: vpiece.cpp:382
QVector< quint32 > missingAnchors(const VPiece &piece) const
Definition: vpiece.cpp:516
QVector< quint32 > getAnchors() const
Definition: vpiece.cpp:462
virtual ~VPiece()
Definition: vpiece.cpp:152
VPiece & operator=(const VPiece &piece)
Definition: vpiece.cpp:140
void setAnchors(const QVector< quint32 > &anchors)
Definition: vpiece.cpp:474
QVector< QPointF > SeamAllowancePoints(const VContainer *data) const
Definition: vpiece.cpp:188
QVector< QLineF > createVExternalNotch(NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1237
static int IsCSAStart(const QVector< CustomSARecord > &records, quint32 id)
Definition: vpiece.cpp:1103
QPainterPath MainPathPath(const VContainer *data) const
Definition: vpiece.cpp:303
QVector< QLineF > createDiamondNotch(NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1292
QVector< quint32 > MissingInternalPaths(const VPiece &piece) const
Definition: vpiece.cpp:510
void SetPatternPieceData(const VPieceLabelData &data)
Definition: vpiece.cpp:522
QVector< VPointF > MainPathNodePoints(const VContainer *data, bool showExcluded=false) const
Definition: vpiece.cpp:182
QVector< quint32 > MissingNodes(const VPiece &piece) const
MissingNodes find missing nodes in piece. When we deleted object in piece and return this piece need ...
Definition: vpiece.cpp:486
void SetCustomSARecords(const QVector< CustomSARecord > &records)
Definition: vpiece.cpp:456
QVector< QLineF > createVInternalNotch(NotchData notchData, const QVector< QPointF > &pathPoints) const
Definition: vpiece.cpp:1200
VPiece()
Definition: vpiece.cpp:128
void setSeamAllowanceWidthFormula(const QString &formula, qreal value)
Definition: vpiece.cpp:418
void SetInternalPaths(const QVector< quint32 > &iPaths)
Definition: vpiece.cpp:438
QVector< QLineF > createUNotch(const NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1169
QVector< QLineF > createSeamAllowanceNotch(const QVector< VPieceNode > &path, VSAPoint &previousSAPoint, const VSAPoint &notchSAPoint, VSAPoint &nextSAPoint, const VContainer *data, int notchIndex, const QVector< QPointF > &pathPoints=QVector< QPointF >()) const
Definition: vpiece.cpp:984
void SetUnited(bool united)
Definition: vpiece.cpp:406
QLineF findIntersection(const QVector< QPointF > &seamAllowance, const QLineF &line) const
Definition: vpiece.cpp:1502
QVector< QPointF > MainPathPoints(const VContainer *data) const
Definition: vpiece.cpp:174
QVector< CustomSARecord > GetValidRecords() const
Definition: vpiece.cpp:655
bool IsUnited() const
Definition: vpiece.cpp:400
QVector< QLineF > createCastleNotch(const NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1270
void SetPatternInfo(const VPatternLabelData &info)
Definition: vpiece.cpp:548
VGrainlineData & GetGrainlineGeometry()
VDetail::GetGrainlineGeometry full access to the grainline geometry object.
Definition: vpiece.cpp:578
QVector< QLineF > createNotches(NotchData notchData, const QVector< QPointF > &seamAllowance) const
Definition: vpiece.cpp:1308
VPatternLabelData & GetPatternInfo()
Returns full access to the pattern info geometry object.
Definition: vpiece.cpp:558
int getNextNotchSAPoints(const QVector< VPieceNode > &path, int index, const VSAPoint &notchSAPoint, const VContainer *data, VSAPoint &point) const
Definition: vpiece.cpp:808
QVector< quint32 > MissingCSAPath(const VPiece &piece) const
Definition: vpiece.cpp:492
bool isLocked() const
Definition: vpiece.cpp:388
VPiecePath GetPath() const
Definition: vpiece.cpp:156
The VPointF class keep data of point.
Definition: vpointf.h:75
The VSAPoint class seam allowance point.
NotchType
Definition: def.h:123
NotchSubType
Definition: def.h:137
qreal length
Definition: vpiece.h:68
qreal width
Definition: vpiece.h:69
qreal angle
Definition: vpiece.h:70
int count
Definition: vpiece.h:72
QLineF line
Definition: vpiece.h:65
NotchType type
Definition: vpiece.h:66
qreal offset
Definition: vpiece.h:71
NotchSubType subType
Definition: vpiece.h:67
Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE)