Seamly2D
Code documentation
vlayoutgenerator.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vlayoutgenerator.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 vlayoutgenerator.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 2 1, 2015
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) 2013-2015 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 VLAYOUTGENERATOR_H
54 #define VLAYOUTGENERATOR_H
55 
56 #include <qcompilerdetection.h>
57 #include <QList>
58 #include <QMetaObject>
59 #include <QObject>
60 #include <QString>
61 #include <QVector>
62 #include <QtGlobal>
63 #include <memory>
64 #include <atomic>
65 #include <QMargins>
66 
67 #include "vbank.h"
68 #include "vlayoutdef.h"
69 
70 class QMarginsF;
71 class QGraphicsItem;
72 class VLayoutPaper;
73 
74 class VLayoutGenerator :public QObject
75 {
76  Q_OBJECT
77 public:
78  explicit VLayoutGenerator(QObject *parent = nullptr);
79  virtual ~VLayoutGenerator() Q_DECL_OVERRIDE;
80 
81  void setPieces(const QVector<VLayoutPiece> &details);
82  void SetLayoutWidth(qreal width);
83  void SetCaseType(Cases caseType);
84  int PieceCount();
85 
86  qreal GetPaperHeight() const;
87  void SetPaperHeight(qreal value);
88 
89  qreal GetPaperWidth() const;
90  void SetPaperWidth(qreal value);
91 
92  bool IsUsePrinterFields() const;
93  QMarginsF GetPrinterFields() const;
94  void SetPrinterFields(bool usePrinterFields, const QMarginsF &value);
95 
96  quint32 GetShift() const;
97  void SetShift(quint32 shift);
98 
99  void Generate();
100 
101  LayoutErrors State() const;
102 
103  Q_REQUIRED_RESULT QList<QGraphicsItem *> GetPapersItems() const;
104  Q_REQUIRED_RESULT QList<QList<QGraphicsItem *>> getAllPieceItems() const;
105 
107 
108  bool GetRotate() const;
109  void SetRotate(bool value);
110 
111  int GetRotationIncrease() const;
112  void SetRotationIncrease(int value);
113 
114  bool GetAutoCrop() const;
115  void SetAutoCrop(bool value);
116 
117  bool IsSaveLength() const;
118  void SetSaveLength(bool value);
119 
120  bool IsUnitePages() const;
121  void SetUnitePages(bool value);
122 
123  quint8 GetMultiplier() const;
124  void SetMultiplier(const quint8 &value);
125 
126  bool IsStripOptimization() const;
127  void SetStripOptimization(bool value);
128 
129  bool IsTestAsPaths() const;
130  void SetTestAsPaths(bool value);
131 
132 signals:
133  void Start();
134  void Arranged(int count);
135  void Error(const LayoutErrors &state);
136  void Finished();
137 
138 public slots:
139  void Abort();
140 
141 private:
142  Q_DISABLE_COPY(VLayoutGenerator)
145  qreal paperHeight;
146  qreal paperWidth;
147  QMarginsF margins;
149  std::atomic_bool stopGeneration;
151  quint32 shift;
152  bool rotate;
154  bool autoCrop;
158  quint8 multiplier;
161 
162  int PageHeight() const;
163  int PageWidth() const;
164 
165  void GatherPages();
166  void UnitePages();
167  void unitePieces(int j, QList<QList<VLayoutPiece> > &pieces, qreal length, int i);
168  void UnitePapers(int j, QList<qreal> &papersLength, qreal length);
169  QList<VLayoutPiece> movePieces(qreal length, const QVector<VLayoutPiece> &pieces);
170 };
171 
172 #endif // VLAYOUTGENERATOR_H
Definition: vbank.h:74
qreal GetPaperHeight() const
void SetPaperHeight(qreal value)
void SetLayoutWidth(qreal width)
void SetPaperWidth(qreal value)
Q_REQUIRED_RESULT QList< QGraphicsItem * > GetPapersItems() const
void SetAutoCrop(bool value)
void Arranged(int count)
void setPieces(const QVector< VLayoutPiece > &details)
int GetRotationIncrease() const
void SetUnitePages(bool value)
quint8 GetMultiplier() const
void UnitePapers(int j, QList< qreal > &papersLength, qreal length)
void SetRotationIncrease(int value)
QList< VLayoutPiece > movePieces(qreal length, const QVector< VLayoutPiece > &pieces)
Q_REQUIRED_RESULT QList< QList< QGraphicsItem * > > getAllPieceItems() const
bool IsUnitePages() const
void SetRotate(bool value)
void SetTestAsPaths(bool value)
virtual ~VLayoutGenerator() Q_DECL_OVERRIDE
void SetPrinterFields(bool usePrinterFields, const QMarginsF &value)
bool GetAutoCrop() const
bool IsSaveLength() const
void SetCaseType(Cases caseType)
qreal GetPaperWidth() const
void unitePieces(int j, QList< QList< VLayoutPiece > > &pieces, qreal length, int i)
QMarginsF GetPrinterFields() const
LayoutErrors state
bool GetRotate() const
void SetMultiplier(const quint8 &value)
std::atomic_bool stopGeneration
void SetStripOptimization(bool value)
void SetShift(quint32 shift)
LayoutErrors State() const
void Error(const LayoutErrors &state)
bool IsTestAsPaths() const
QVector< VLayoutPaper > papers
bool IsStripOptimization() const
quint32 GetShift() const
VLayoutGenerator(QObject *parent=nullptr)
QVector< QVector< VLayoutPiece > > getAllPieces() const
void SetSaveLength(bool value)
bool IsUsePrinterFields() const
Cases
Definition: vbank.h:71
LayoutErrors
Definition: vlayoutdef.h:60