Seamly2D
Code documentation
vlayoutpiece.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 vlayoutdetail.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 2 1, 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) 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 VLAYOUTDETAIL_H
53 #define VLAYOUTDETAIL_H
54 
55 #include <qcompilerdetection.h>
56 #include <QDate>
57 #include <QLineF>
58 #include <QMatrix>
59 #include <QPointF>
60 #include <QRectF>
61 #include <QSharedDataPointer>
62 #include <QString>
63 #include <QTypeInfo>
64 #include <QVector>
65 #include <QtGlobal>
66 
67 #include "../ifc/xml/vabstractpattern.h"
68 #include "../vpatterndb/floatItemData/vpatternlabeldata.h"
69 #include "../vpatterndb/floatItemData/vpiecelabeldata.h"
70 #include "../vpatterndb/vcontainer.h"
71 #include "vabstractpiece.h"
72 
73 class VLayoutPieceData;
74 class VLayoutPiecePath;
75 class QGraphicsItem;
76 class QGraphicsPathItem;
77 class VTextManager;
78 
80 {
81  Q_DECLARE_TR_FUNCTIONS(VLayoutPiece)
82 public:
83  VLayoutPiece();
84  VLayoutPiece(const VLayoutPiece &detail);
85 
86  virtual ~VLayoutPiece() Q_DECL_OVERRIDE;
87 
88  VLayoutPiece &operator=(const VLayoutPiece &detail);
89 
90 #ifdef Q_COMPILER_RVALUE_REFS
91  VLayoutPiece &operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW;
92 #endif
93 
94  void Swap(VLayoutPiece &detail) Q_DECL_NOTHROW;
95 
96  static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern);
97 
99  void SetCountourPoints(const QVector<QPointF> &points, bool hideMainPath = false);
100 
102  void setSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance = true,
103  bool seamAllowanceBuiltIn = false);
104 
107 
108  QVector<QLineF> getNotches() const;
109  void setNotches(const QVector<QLineF> &notches);
110 
113  void setInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
114 
116  void setCutoutPaths(const QVector<VLayoutPiecePath> &cutoutPaths);
117 
118  QPointF GetPieceTextPosition() const;
119  QStringList GetPieceText() const;
120  void SetPieceText(const QString &qsName, const VPieceLabelData& data,
121  const QFont& font, const VContainer *pattern);
122 
123  QPointF GetPatternTextPosition() const;
124  QStringList GetPatternText() const;
125  void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData& geom,
126  const QFont& font, const VContainer *pattern);
127 
128  void setGrainline(const VGrainlineData& geom, const VContainer *pattern);
130 
131  QTransform getTransform() const;
132  void setTransform(const QTransform &transform);
133 
134  qreal GetLayoutWidth() const;
135  void SetLayoutWidth(const qreal &value);
136 
137  bool isMirror() const;
138  void SetMirror(bool value);
139 
140  void Translate(qreal dx, qreal dy);
141  void Rotate(const QPointF &originPoint, qreal degrees);
142  void Mirror(const QLineF &edge);
143 
144  int pieceEdgesCount() const;
145  int LayoutEdgesCount() const;
146 
147  QLineF pieceEdge(int i) const;
148  QLineF LayoutEdge(int i) const;
149 
150  int pieceEdgeByPoint(const QPointF &p1) const;
151  int LayoutEdgeByPoint(const QPointF &p1) const;
152 
153  QRectF pieceBoundingRect() const;
154  QRectF LayoutBoundingRect() const;
155  qreal Diagonal() const;
156 
157  bool isNull() const;
158  qint64 Square() const;
159 
160  QPainterPath createMainPath() const;
161  QPainterPath createAllowancePath() const;
162  QPainterPath createNotchesPath() const;
163 
164  QPainterPath LayoutAllowancePath() const;
165 
166  Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const;
167 
168 private:
169  QSharedDataPointer<VLayoutPieceData> d;
170 
171  QVector<QPointF> piecePath() const;
172 
173  Q_REQUIRED_RESULT QGraphicsPathItem *createMainItem() const;
174  void createAllowanceItem(QGraphicsItem *parent) const;
175  void createNotchesItem(QGraphicsItem *parent) const;
176  Q_REQUIRED_RESULT QGraphicsPathItem *getMainPathItem() const;
177 
178  void createInternalPathItem(int i, QGraphicsItem *parent) const;
179  void createCutoutPathItem(int i, QGraphicsItem *parent) const;
180  void createLabelItem(QGraphicsItem *parent, const QVector<QPointF> &labelShape,
181  const VTextManager &tm, bool textAsPaths) const;
182  void createGrainlineItem(QGraphicsItem *parent, bool textAsPaths) const;
183 
184  template <class T>
185  QVector<T> Map(const QVector<T> &points) const;
186 
187  QLineF Edge(const QVector<QPointF> &path, int i) const;
188  int EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const;
189 };
190 
192 
193 #endif // VLAYOUTDETAIL_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...
qint64 Square() const
int pieceEdgesCount() const
int EdgeByPoint(const QVector< QPointF > &path, const QPointF &p1) const
void SetPieceText(const QString &qsName, const VPieceLabelData &data, const QFont &font, const VContainer *pattern)
void createGrainlineItem(QGraphicsItem *parent, bool textAsPaths) const
bool isNull() const
QStringList GetPieceText() const
void SetCountourPoints(const QVector< QPointF > &points, bool hideMainPath=false)
void SetLayoutWidth(const qreal &value)
void Mirror(const QLineF &edge)
QTransform getTransform() const
QPainterPath createMainPath() const
VLayoutPiece & operator=(const VLayoutPiece &detail)
QVector< QPointF > getContourPoints() const
QRectF LayoutBoundingRect() const
void Translate(qreal dx, qreal dy)
QSharedDataPointer< VLayoutPieceData > d
Definition: vlayoutpiece.h:169
void setInternalPaths(const QVector< VLayoutPiecePath > &internalPaths)
void setGrainline(const VGrainlineData &geom, const VContainer *pattern)
void createLabelItem(QGraphicsItem *parent, const QVector< QPointF > &labelShape, const VTextManager &tm, bool textAsPaths) const
void createInternalPathItem(int i, QGraphicsItem *parent) const
void setNotches(const QVector< QLineF > &notches)
Q_REQUIRED_RESULT QGraphicsPathItem * createMainItem() const
int pieceEdgeByPoint(const QPointF &p1) const
QRectF pieceBoundingRect() const
qreal Diagonal() const
int LayoutEdgesCount() const
virtual ~VLayoutPiece() Q_DECL_OVERRIDE
QVector< QLineF > getNotches() const
QVector< VLayoutPiecePath > getCutoutPaths() const
void SetLayoutAllowancePoints()
QVector< QVector< QPointF > > InternalPathsForCut(bool cut) const
Q_REQUIRED_RESULT QGraphicsPathItem * getMainPathItem() const
QPainterPath createNotchesPath() const
QVector< QPointF > piecePath() const
QLineF pieceEdge(int i) const
QVector< QPointF > getLayoutAllowancePoints() const
void setTransform(const QTransform &transform)
QVector< QPointF > GetSeamAllowancePoints() const
void Swap(VLayoutPiece &detail) Q_DECL_NOTHROW
void createCutoutPathItem(int i, QGraphicsItem *parent) const
QPointF GetPieceTextPosition() const
void setSeamAllowancePoints(const QVector< QPointF > &points, bool seamAllowance=true, bool seamAllowanceBuiltIn=false)
QLineF LayoutEdge(int i) const
void SetMirror(bool value)
int LayoutEdgeByPoint(const QPointF &p1) const
Q_REQUIRED_RESULT QGraphicsItem * GetItem(bool textAsPaths) const
static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern)
void setCutoutPaths(const QVector< VLayoutPiecePath > &cutoutPaths)
QPainterPath createAllowancePath() const
bool isMirror() const
void createNotchesItem(QGraphicsItem *parent) const
QLineF Edge(const QVector< QPointF > &path, int i) const
QVector< T > Map(const QVector< T > &points) const
void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font, const VContainer *pattern)
QStringList GetPatternText() const
QPainterPath LayoutAllowancePath() const
QVector< VLayoutPiecePath > getInternalPaths() const
qreal GetLayoutWidth() const
void Rotate(const QPointF &originPoint, qreal degrees)
void createAllowanceItem(QGraphicsItem *parent) const
QPointF GetPatternTextPosition() const
QVector< QPointF > getGrainline() const
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
The VTextManager class this class is used to determine whether a collection of text lines can fit int...
Definition: vtextmanager.h:66
Q_DECLARE_TYPEINFO(VLayoutPiece, Q_MOVABLE_TYPE)