Seamly2D
Code documentation
vpiecepath.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vpiecepath.h
3  ** @author Douglas S Caskey
4  ** @date Dec 11, 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
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 22 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 VPIECEPATH_H
54 #define VPIECEPATH_H
55 
56 #include <QtGlobal>
57 #include <QSharedDataPointer>
58 
59 #include "../vmisc/def.h"
60 #include "../vgeometry/vabstractcurve.h"
61 
62 class VPiecePathData;
63 class VSAPoint;
64 class VContainer;
65 class QPainterPath;
66 class VPointF;
67 class VPieceNode;
68 
70 {
71 public:
72  VPiecePath();
73  explicit VPiecePath(PiecePathType type);
74  VPiecePath(const VPiecePath &path);
75 
76  ~VPiecePath();
77 
78  VPiecePath &operator=(const VPiecePath &path);
79 
80 #ifdef Q_COMPILER_RVALUE_REFS
81  VPiecePath &operator=(VPiecePath &&path) Q_DECL_NOTHROW;
82 #endif
83 
84  void Swap(VPiecePath &path) Q_DECL_NOTHROW;
85  void Append(const VPieceNode &node);
86  void Clear();
87  qint32 CountNodes() const;
88 
89  VPieceNode &operator[](int indx);
90  const VPieceNode &at (int indx) const;
91 
93  void SetNodes(const QVector<VPieceNode> &nodes);
94 
95  PiecePathType GetType() const;
96  void SetType(PiecePathType type);
97 
98  QString GetName() const;
99  void SetName(const QString &name);
100 
101  Qt::PenStyle GetPenType() const;
102  void SetPenType(const Qt::PenStyle &type);
103 
104  bool IsCutPath() const;
105  void SetCutPath(bool cut);
106 
107  QVector<QPointF> PathPoints(const VContainer *data) const;
108  QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const;
109  QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const;
110 
111  QPainterPath PainterPath(const VContainer *data) const;
112 
113  QVector<quint32> MissingNodes(const VPiecePath &path) const;
114 
115  int indexOfNode(quint32 id) const;
116  void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const;
117  bool Contains(quint32 id) const;
118  bool OnEdge(quint32 p1, quint32 p2) const;
119  int Edge(quint32 p1, quint32 p2) const;
120 
122 
123  VPiecePath RemoveEdge(quint32 index) const;
124 
125  VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const;
126  VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const;
127 
128  QPointF NodePreviousPoint(const VContainer *data, int i) const;
129  QPointF NodeNextPoint(const VContainer *data, int i) const;
130 
131  static int indexOfNode(const QVector<VPieceNode> &nodes, quint32 id);
132 
133  static int FindInLoopNotExcludedUp(int start, const QVector<VPieceNode> &nodes);
134  static int FindInLoopNotExcludedDown(int start, const QVector<VPieceNode> &nodes);
135 
136  static VSAPoint StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
137  static VSAPoint EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
138 
139  static VSAPoint PreparePointEkv(const VPieceNode &node, const VContainer *data);
140 
142  const QSharedPointer<VAbstractCurve> &curve,
143  int i, bool reverse, qreal width);
144 
145 private:
146  QSharedDataPointer<VPiecePathData> d;
147 };
148 
150 
151 #endif // VPIECEPATH_H
The VContainer class container of all variables.
Definition: vcontainer.h:141
QVector< QPointF > PathPoints(const VContainer *data) const
Definition: vpiecepath.cpp:287
PiecePathType GetType() const
Definition: vpiecepath.cpp:239
bool Contains(quint32 id) const
Definition: vpiecepath.cpp:539
void SetType(PiecePathType type)
Definition: vpiecepath.cpp:245
QVector< VSAPoint > SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const
Definition: vpiecepath.cpp:357
qint32 CountNodes() const
Definition: vpiecepath.cpp:209
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
NodeOnEdge return nodes located on edge with index.
Definition: vpiecepath.cpp:519
QSharedDataPointer< VPiecePathData > d
Definition: vpiecepath.h:146
VPiecePath & operator=(const VPiecePath &path)
Definition: vpiecepath.cpp:182
void Clear()
Definition: vpiecepath.cpp:203
void SetCutPath(bool cut)
Definition: vpiecepath.cpp:281
static QVector< VSAPoint > CurveSeamAllowanceSegment(const VContainer *data, const QVector< VPieceNode > &nodes, const QSharedPointer< VAbstractCurve > &curve, int i, bool reverse, qreal width)
Definition: vpiecepath.cpp:905
void Append(const VPieceNode &node)
Definition: vpiecepath.cpp:197
void Swap(VPiecePath &path) Q_DECL_NOTHROW
Definition: vpiecepath.cpp:163
static int FindInLoopNotExcludedUp(int start, const QVector< VPieceNode > &nodes)
Definition: vpiecepath.cpp:818
int Edge(quint32 p1, quint32 p2) const
Edge return edge index in detail. Edge is line between two points. If between two points located arcs...
Definition: vpiecepath.cpp:604
VPieceNode & operator[](int indx)
Definition: vpiecepath.cpp:215
QVector< VPointF > PathNodePoints(const VContainer *data, bool showExcluded=true) const
Definition: vpiecepath.cpp:328
QVector< VPieceNode > GetNodes() const
Definition: vpiecepath.cpp:227
VPiecePath RemoveEdge(quint32 index) const
RemoveEdge return path without edge with index.
Definition: vpiecepath.cpp:652
QVector< quint32 > MissingNodes(const VPiecePath &path) const
Definition: vpiecepath.cpp:473
void SetNodes(const QVector< VPieceNode > &nodes)
Definition: vpiecepath.cpp:233
void SetPenType(const Qt::PenStyle &type)
Definition: vpiecepath.cpp:269
void SetName(const QString &name)
Definition: vpiecepath.cpp:257
QPointF NodePreviousPoint(const VContainer *data, int i) const
Definition: vpiecepath.cpp:701
bool OnEdge(quint32 p1, quint32 p2) const
OnEdge checks if two poins located on the edge. Edge is line between two points. If between two point...
Definition: vpiecepath.cpp:559
QPointF NodeNextPoint(const VContainer *data, int i) const
Definition: vpiecepath.cpp:752
Qt::PenStyle GetPenType() const
Definition: vpiecepath.cpp:263
const VPieceNode & at(int indx) const
Definition: vpiecepath.cpp:221
static VSAPoint PreparePointEkv(const VPieceNode &node, const VContainer *data)
Definition: vpiecepath.cpp:890
static int FindInLoopNotExcludedDown(int start, const QVector< VPieceNode > &nodes)
Definition: vpiecepath.cpp:854
bool IsCutPath() const
Definition: vpiecepath.cpp:275
QVector< VPieceNode > ListNodePoint() const
listNodePoint return list nodes only with points.
Definition: vpiecepath.cpp:633
VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const
Definition: vpiecepath.cpp:689
int indexOfNode(quint32 id) const
Definition: vpiecepath.cpp:507
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const
Definition: vpiecepath.cpp:695
QPainterPath PainterPath(const VContainer *data) const
Definition: vpiecepath.cpp:396
QString GetName() const
Definition: vpiecepath.cpp:251
The VPointF class keep data of point.
Definition: vpointf.h:75
The VSAPoint class seam allowance point.
PiecePathType
Definition: def.h:157
Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE)