2015-01-02 14:53:36 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vlayoutgenerator.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 2 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-02 14:53:36 +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-02 14:53:36 +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 VLAYOUTGENERATOR_H
|
|
|
|
#define VLAYOUTGENERATOR_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
2015-01-13 11:38:51 +01:00
|
|
|
#include <QList>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
2015-12-19 15:38:24 +01:00
|
|
|
#include <memory>
|
2017-02-22 13:04:47 +01:00
|
|
|
#include <atomic>
|
2019-04-05 14:42:22 +02:00
|
|
|
#include <QMargins>
|
2015-01-02 14:53:36 +01:00
|
|
|
|
2015-01-12 13:12:15 +01:00
|
|
|
#include "vbank.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "vlayoutdef.h"
|
|
|
|
|
2015-01-13 11:38:51 +01:00
|
|
|
class QGraphicsItem;
|
2016-08-08 13:44:49 +02:00
|
|
|
class VLayoutPaper;
|
2019-03-30 10:17:54 +01:00
|
|
|
class QElapsedTimer;
|
2015-01-02 14:53:36 +01:00
|
|
|
|
2015-01-12 13:12:15 +01:00
|
|
|
class VLayoutGenerator :public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-01-02 14:53:36 +01:00
|
|
|
public:
|
2016-03-23 16:27:17 +01:00
|
|
|
explicit VLayoutGenerator(QObject *parent = nullptr);
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual ~VLayoutGenerator() override;
|
2015-01-12 13:12:15 +01:00
|
|
|
|
2017-01-22 10:02:02 +01:00
|
|
|
void SetDetails(const QVector<VLayoutPiece> &details);
|
2015-01-12 13:12:15 +01:00
|
|
|
void SetLayoutWidth(qreal width);
|
|
|
|
void SetCaseType(Cases caseType);
|
|
|
|
int DetailsCount();
|
|
|
|
|
2015-11-09 12:58:45 +01:00
|
|
|
qreal GetPaperHeight() const;
|
|
|
|
void SetPaperHeight(qreal value);
|
2015-01-12 13:12:15 +01:00
|
|
|
|
2015-11-09 12:58:45 +01:00
|
|
|
qreal GetPaperWidth() const;
|
|
|
|
void SetPaperWidth(qreal value);
|
2015-01-12 13:12:15 +01:00
|
|
|
|
2019-03-29 10:31:17 +01:00
|
|
|
int GetNestingTime() const;
|
2019-04-03 12:29:42 +02:00
|
|
|
int GetNestingTimeMSecs() const;
|
2019-03-29 10:31:17 +01:00
|
|
|
void SetNestingTime(int value);
|
|
|
|
|
2019-03-29 18:52:37 +01:00
|
|
|
qreal GetEfficiencyCoefficient() const;
|
2019-03-29 10:31:17 +01:00
|
|
|
void SetEfficiencyCoefficient(qreal coefficient);
|
|
|
|
|
2016-09-30 18:33:10 +02:00
|
|
|
bool IsUsePrinterFields() const;
|
|
|
|
QMarginsF GetPrinterFields() const;
|
|
|
|
void SetPrinterFields(bool usePrinterFields, const QMarginsF &value);
|
2015-11-09 12:33:36 +01:00
|
|
|
|
2019-03-29 18:52:37 +01:00
|
|
|
qreal GetShift() const;
|
|
|
|
void SetShift(qreal shift);
|
2015-01-12 16:23:25 +01:00
|
|
|
|
2019-06-18 15:04:50 +02:00
|
|
|
void Generate(const QElapsedTimer &timer, qint64 timeout, LayoutErrors previousState = LayoutErrors::NoError);
|
2015-01-12 13:12:15 +01:00
|
|
|
|
2019-03-29 18:52:37 +01:00
|
|
|
qreal LayoutEfficiency() const;
|
|
|
|
|
2015-01-12 13:12:15 +01:00
|
|
|
LayoutErrors State() const;
|
|
|
|
|
2019-03-29 18:52:37 +01:00
|
|
|
int PapersCount() const {return papers.size();}
|
|
|
|
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetPapersItems() const;
|
2019-03-27 09:29:59 +01:00
|
|
|
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetGlobalContours() const;
|
2017-07-16 20:10:48 +02:00
|
|
|
Q_REQUIRED_RESULT QList<QList<QGraphicsItem *>> GetAllDetailsItems() const;
|
|
|
|
|
|
|
|
QVector<QVector<VLayoutPiece>> GetAllDetails() const;
|
2015-01-13 11:38:51 +01:00
|
|
|
|
2015-01-22 15:11:50 +01:00
|
|
|
bool GetRotate() const;
|
|
|
|
void SetRotate(bool value);
|
|
|
|
|
2018-12-27 14:54:29 +01:00
|
|
|
bool GetFollowGrainline() const;
|
|
|
|
void SetFollowGrainline(bool value);
|
|
|
|
|
2019-07-21 15:26:21 +02:00
|
|
|
bool GetManualPriority() const;
|
|
|
|
void SetManualPriority(bool value);
|
|
|
|
|
2019-07-04 13:33:45 +02:00
|
|
|
bool IsNestQuantity() const;
|
|
|
|
void SetNestQuantity(bool value);
|
|
|
|
|
2019-03-29 18:52:37 +01:00
|
|
|
int GetRotationNumber() const;
|
|
|
|
void SetRotationNumber(int value);
|
2015-01-22 15:11:50 +01:00
|
|
|
|
2019-10-16 10:16:16 +02:00
|
|
|
bool GetAutoCropLength() const;
|
|
|
|
void SetAutoCropLength(bool value);
|
|
|
|
|
|
|
|
bool GetAutoCropWidth() const;
|
|
|
|
void SetAutoCropWidth(bool value);
|
2015-05-02 18:21:47 +02:00
|
|
|
|
2015-05-08 12:10:56 +02:00
|
|
|
bool IsSaveLength() const;
|
|
|
|
void SetSaveLength(bool value);
|
|
|
|
|
2020-03-22 15:22:03 +01:00
|
|
|
bool IsPreferOneSheetSolution() const;
|
|
|
|
void SetPreferOneSheetSolution(bool value);
|
|
|
|
|
2015-05-18 13:26:37 +02:00
|
|
|
bool IsUnitePages() const;
|
|
|
|
void SetUnitePages(bool value);
|
|
|
|
|
2016-02-23 13:13:10 +01:00
|
|
|
quint8 GetMultiplier() const;
|
2019-01-02 15:52:07 +01:00
|
|
|
void SetMultiplier(quint8 value);
|
2016-02-23 13:13:10 +01:00
|
|
|
|
|
|
|
bool IsStripOptimization() const;
|
|
|
|
void SetStripOptimization(bool value);
|
|
|
|
|
2017-07-01 19:32:54 +02:00
|
|
|
bool IsTestAsPaths() const;
|
2019-03-26 16:30:25 +01:00
|
|
|
void SetTextAsPaths(bool value);
|
2017-07-01 19:32:54 +02:00
|
|
|
|
2019-03-30 10:17:54 +01:00
|
|
|
bool IsRotationNeeded() const;
|
|
|
|
|
2019-06-18 11:35:43 +02:00
|
|
|
bool IsPortrait() const;
|
|
|
|
|
2015-01-12 13:12:15 +01:00
|
|
|
public slots:
|
|
|
|
void Abort();
|
2019-04-02 14:29:33 +02:00
|
|
|
void Timeout();
|
2015-01-12 13:12:15 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VLayoutGenerator)
|
|
|
|
QVector<VLayoutPaper> papers;
|
|
|
|
VBank *bank;
|
2015-11-09 12:58:45 +01:00
|
|
|
qreal paperHeight;
|
|
|
|
qreal paperWidth;
|
2015-11-09 12:33:36 +01:00
|
|
|
QMarginsF margins;
|
2016-09-30 18:33:10 +02:00
|
|
|
bool usePrinterFields;
|
2017-02-22 13:04:47 +01:00
|
|
|
std::atomic_bool stopGeneration;
|
2015-01-12 13:12:15 +01:00
|
|
|
LayoutErrors state;
|
2019-03-29 18:52:37 +01:00
|
|
|
qreal shift;
|
2015-01-22 15:11:50 +01:00
|
|
|
bool rotate;
|
2018-12-27 14:54:29 +01:00
|
|
|
bool followGrainline;
|
2019-03-29 18:52:37 +01:00
|
|
|
int rotationNumber;
|
2019-10-16 10:16:16 +02:00
|
|
|
bool autoCropLength;
|
|
|
|
bool autoCropWidth;
|
2015-05-08 12:10:56 +02:00
|
|
|
bool saveLength;
|
2020-03-22 15:22:03 +01:00
|
|
|
bool preferOneSheetSolution{false};
|
2015-05-18 13:26:37 +02:00
|
|
|
bool unitePages;
|
2016-02-23 13:13:10 +01:00
|
|
|
bool stripOptimizationEnabled;
|
|
|
|
quint8 multiplier;
|
|
|
|
bool stripOptimization;
|
2017-07-01 19:32:54 +02:00
|
|
|
bool textAsPaths;
|
2019-03-29 10:31:17 +01:00
|
|
|
int nestingTime{1};
|
|
|
|
qreal efficiencyCoefficient{0.0};
|
2015-11-09 12:33:36 +01:00
|
|
|
|
|
|
|
int PageHeight() const;
|
|
|
|
int PageWidth() const;
|
2016-02-23 13:13:10 +01:00
|
|
|
|
|
|
|
void GatherPages();
|
|
|
|
void UnitePages();
|
2020-03-22 17:21:13 +01:00
|
|
|
void UniteDetails(int j, QList<QList<VLayoutPiece> > &nDetails, qreal length, int i) const;
|
2016-02-23 13:13:10 +01:00
|
|
|
void UnitePapers(int j, QList<qreal> &papersLength, qreal length);
|
2020-03-22 17:21:13 +01:00
|
|
|
QList<VLayoutPiece> MoveDetails(qreal length, const QVector<VLayoutPiece> &details) const;
|
|
|
|
VLayoutPaper MasterPage() const;
|
2015-01-02 14:53:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VLAYOUTGENERATOR_H
|