2015-01-11 14:11:56 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vbank.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 11 1, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-01-11 14:11:56 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-01-11 14:11:56 +01:00
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VBANK_H
|
|
|
|
#define VBANK_H
|
|
|
|
|
|
|
|
#include <QHash>
|
2023-11-28 15:40:27 +01:00
|
|
|
#include <QLoggingCategory>
|
2019-07-19 09:45:57 +02:00
|
|
|
#include <QMap>
|
2015-02-26 21:18:52 +01:00
|
|
|
#include <QRectF>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2019-07-19 09:45:57 +02:00
|
|
|
#include "../vmisc/typedef.h"
|
2020-12-23 14:29:55 +01:00
|
|
|
#include "vlayoutdef.h"
|
2023-11-28 15:40:27 +01:00
|
|
|
#include "vlayoutpiece.h"
|
2019-07-19 09:45:57 +02:00
|
|
|
|
2015-10-23 19:47:33 +02:00
|
|
|
// An annoying char define, from the Windows team in <rpcndr.h>
|
|
|
|
// #define small char
|
|
|
|
// http://stuartjames.info/Journal/c--visual-studio-2012-vs2012--win8--converting-projects-up-some-conflicts-i-found.aspx
|
2023-11-28 15:40:27 +01:00
|
|
|
#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
|
2015-10-23 19:47:33 +02:00
|
|
|
#pragma push_macro("small")
|
|
|
|
#undef small
|
|
|
|
#endif
|
|
|
|
|
2023-11-28 15:40:27 +01:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lBank) // NOLINT
|
2019-07-22 16:06:30 +02:00
|
|
|
|
2015-01-11 14:11:56 +01:00
|
|
|
class VBank
|
|
|
|
{
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VBank) // NOLINT
|
2023-11-28 15:40:27 +01:00
|
|
|
|
2015-01-11 14:11:56 +01:00
|
|
|
public:
|
|
|
|
VBank();
|
2023-11-28 15:40:27 +01:00
|
|
|
~VBank() = default;
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetLayoutWidth() const -> qreal;
|
2019-03-26 16:47:27 +01:00
|
|
|
void SetLayoutWidth(qreal value);
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetManualPriority() const -> bool;
|
2019-07-21 15:26:21 +02:00
|
|
|
void SetManualPriority(bool value);
|
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto IsNestQuantity() const -> bool;
|
2019-07-04 13:33:45 +02:00
|
|
|
void SetNestQuantity(bool value);
|
2019-03-30 10:17:54 +01:00
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
void SetDetails(const QVector<VLayoutPiece> &details);
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetNext() -> int;
|
|
|
|
auto GetDetail(int i) const -> VLayoutPiece;
|
2015-01-11 14:11:56 +01:00
|
|
|
|
|
|
|
void Arranged(int i);
|
|
|
|
void NotArranged(int i);
|
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto PrepareUnsorted() -> bool;
|
2023-11-28 15:40:27 +01:00
|
|
|
auto PrepareDetails(bool togetherWithNotches) -> bool;
|
2015-01-11 14:11:56 +01:00
|
|
|
void Reset();
|
|
|
|
void SetCaseType(Cases caseType);
|
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto AllDetailsCount() const -> vsizetype;
|
|
|
|
auto LeftToArrange() const -> vsizetype;
|
|
|
|
auto FailedToArrange() const -> vsizetype;
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetBiggestDiagonal() const -> qreal;
|
2019-03-30 10:17:54 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto IsRotationNeeded() const -> bool;
|
2015-01-12 13:12:15 +01:00
|
|
|
|
2015-01-11 14:11:56 +01:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VBank) // NOLINT
|
2019-07-27 08:02:41 +02:00
|
|
|
QVector<VLayoutPiece> details{};
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2019-07-27 08:02:41 +02:00
|
|
|
QMap<uint, QHash<int, qint64>> unsorted{};
|
|
|
|
QMap<uint, QHash<int, qint64>> big{};
|
|
|
|
QMap<uint, QHash<int, qint64>> middle{};
|
|
|
|
QMap<uint, QHash<int, qint64>> small{};
|
|
|
|
QMap<uint, QMultiMap<qint64, int>> desc{};
|
2019-07-19 09:45:57 +02:00
|
|
|
|
2019-07-27 08:02:41 +02:00
|
|
|
QVector<uint> groups{};
|
|
|
|
QVector<vidtype> arranged{};
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2019-07-27 08:02:41 +02:00
|
|
|
qreal layoutWidth{0};
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2019-07-27 08:02:41 +02:00
|
|
|
Cases caseType{Cases::CaseDesc};
|
|
|
|
bool prepare{false};
|
|
|
|
qreal diagonal{0};
|
2019-07-04 13:33:45 +02:00
|
|
|
bool m_nestQuantity{false};
|
2019-07-21 15:26:21 +02:00
|
|
|
bool m_manualPriority{false};
|
2015-01-11 14:11:56 +01:00
|
|
|
|
|
|
|
void PrepareGroup();
|
|
|
|
|
2019-07-19 09:45:57 +02:00
|
|
|
void PrepareThreeGroups(uint priority);
|
|
|
|
void PrepareTwoGroups(uint priority);
|
|
|
|
void PrepareDescGroup(uint priority);
|
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto GetNextThreeGroups(uint priority) const -> int;
|
|
|
|
auto GetNextTwoGroups(uint priority) const -> int;
|
|
|
|
auto GetNextDescGroup(uint priority) const -> int;
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2019-07-19 09:45:57 +02:00
|
|
|
void SqMaxMin(qint64 &sMax, qint64 &sMin, uint priority) const;
|
2015-01-11 14:11:56 +01:00
|
|
|
|
2023-05-03 13:07:02 +02:00
|
|
|
auto ArrangedDetail(QMap<uint, QHash<int, qint64>> &container, int i) -> bool;
|
|
|
|
auto ArrangedDetail(QMap<uint, QMultiMap<qint64, int>> &container, int i) -> bool;
|
2015-01-11 14:11:56 +01:00
|
|
|
};
|
|
|
|
|
2023-11-28 15:40:27 +01:00
|
|
|
#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
|
2015-10-23 19:47:33 +02:00
|
|
|
#pragma pop_macro("small")
|
|
|
|
#endif
|
|
|
|
|
2015-01-11 14:11:56 +01:00
|
|
|
#endif // VBANK_H
|