Seamly2D
Code documentation
vbank.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file vbank.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 vbank.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 11 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 VBANK_H
54 #define VBANK_H
55 
56 #include <QHash>
57 #include <QRectF>
58 #include <QVector>
59 #include <QtGlobal>
60 
61 // An annoying char define, from the Windows team in <rpcndr.h>
62 // #define small char
63 // http://stuartjames.info/Journal/c--visual-studio-2012-vs2012--win8--converting-projects-up-some-conflicts-i-found.aspx
64 #if defined (Q_OS_WIN) && defined (Q_CC_MSVC)
65 #pragma push_macro("small")
66 #undef small
67 #endif
68 
69 class VLayoutPiece;
70 
72 
73 class VBank
74 {
75 public:
76  VBank();
77 
78  qreal GetLayoutWidth() const;
79  void SetLayoutWidth(const qreal &value);
80 
82  int GetTiket();
83  VLayoutPiece getPiece(int i) const;
84 
85  void Arranged(int i);
86  void NotArranged(int i);
87 
88  bool Prepare();
89  void Reset();
91 
92  int allPieceCount() const;
93  int LeftArrange() const;
94  int ArrangedCount() const;
95 
96  qreal GetBiggestDiagonal() const;
97 
98 private:
99  Q_DISABLE_COPY(VBank)
101  QHash<int, qint64> unsorted;
102 
103  QHash<int, qint64> big;
104  QHash<int, qint64> middle;
105  QHash<int, qint64> small;
106 
107  qreal layoutWidth;
108 
110  bool prepare;
111  qreal diagonal;
112 
113  void PrepareGroup();
114 
115  void PrepareThreeGroups();
116  void PrepareTwoGroups();
117  void PrepareDescGroup();
118 
119  int GetNextThreeGroups() const;
120  int GetNextTwoGroups() const;
121  int GetNextDescGroup() const;
122 
123  void SqMaxMin(qint64 &sMax, qint64 &sMin) const;
124 };
125 
126 #if defined (Q_OS_WIN) && defined (Q_CC_MSVC)
127 #pragma pop_macro("small")
128 #endif
129 
130 #endif // VBANK_H
Definition: vbank.h:74
void PrepareThreeGroups()
Definition: vbank.cpp:306
bool prepare
Definition: vbank.h:110
int LeftArrange() const
Definition: vbank.cpp:269
void SetCaseType(Cases caseType)
Definition: vbank.cpp:257
QVector< VLayoutPiece > pieces
Definition: vbank.h:100
void SetLayoutWidth(const qreal &value)
Definition: vbank.cpp:96
int GetNextThreeGroups() const
Definition: vbank.cpp:369
int ArrangedCount() const
Definition: vbank.cpp:281
int allPieceCount() const
Definition: vbank.cpp:263
VBank()
Definition: vbank.cpp:78
VLayoutPiece getPiece(int i) const
Definition: vbank.cpp:143
QHash< int, qint64 > middle
Definition: vbank.h:104
void setPieces(const QVector< VLayoutPiece > &pieces)
Definition: vbank.cpp:103
QHash< int, qint64 > big
Definition: vbank.h:103
qreal GetLayoutWidth() const
Definition: vbank.cpp:90
QHash< int, qint64 > unsorted
Definition: vbank.h:101
void PrepareGroup()
Definition: vbank.cpp:287
qreal layoutWidth
Definition: vbank.h:107
void PrepareDescGroup()
Definition: vbank.cpp:362
int GetTiket()
Definition: vbank.cpp:110
void Arranged(int i)
Definition: vbank.cpp:156
qreal diagonal
Definition: vbank.h:111
void Reset()
Definition: vbank.cpp:246
QHash< int, qint64 > small
Definition: vbank.h:105
void PrepareTwoGroups()
Definition: vbank.cpp:337
qreal GetBiggestDiagonal() const
Definition: vbank.cpp:275
int GetNextTwoGroups() const
Definition: vbank.cpp:393
int GetNextDescGroup() const
Definition: vbank.cpp:411
Cases caseType
Definition: vbank.h:109
bool Prepare()
Definition: vbank.cpp:201
void NotArranged(int i)
Definition: vbank.cpp:177
void SqMaxMin(qint64 &sMax, qint64 &sMin) const
Definition: vbank.cpp:432
Cases
Definition: vbank.h:71
@ CaseDesc
@ CaseThreeGroup
@ UnknownCase
@ CaseTwoGroup