From 595e5b0bf55301c5c844103bf2bb8a1985611c0e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 23 Feb 2016 14:13:10 +0200 Subject: [PATCH] Resolved issue #306. Layout generator optimization. Divide into strips. --HG-- branch : develop --- ChangeLog.txt | 1 + .../dialogs/dialoglayoutsettings.cpp | 32 +++ .../valentina/dialogs/dialoglayoutsettings.h | 6 + .../valentina/dialogs/dialoglayoutsettings.ui | 59 ++++- src/app/valentina/mainwindowsnogui.cpp | 92 ------- src/app/valentina/mainwindowsnogui.h | 5 - src/libs/vlayout/vbank.cpp | 45 +--- src/libs/vlayout/vbank.h | 5 +- src/libs/vlayout/vlayoutdetail.cpp | 10 +- src/libs/vlayout/vlayoutdetail.h | 1 + src/libs/vlayout/vlayoutgenerator.cpp | 224 +++++++++++++++++- src/libs/vlayout/vlayoutgenerator.h | 15 ++ src/libs/vlayout/vlayoutpaper.cpp | 28 ++- src/libs/vlayout/vlayoutpaper.h | 10 +- src/libs/vmisc/vsettings.cpp | 38 +++ src/libs/vmisc/vsettings.h | 10 + 16 files changed, 437 insertions(+), 144 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index ee273b26d..b7e007eee 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,5 @@ # Version 0.5.0 +- [#306] Layout generator optimization. Divide into strips. - Fixed case with duplicate names of curves if they connect same points. - [#216] Better powerful way creation curved path. - Improved exporting to dxf. QPainterPath export as Polyline. diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 0a3badb41..b786d92b7 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -302,6 +302,30 @@ void DialogLayoutSettings::SetUnitePages(bool save) ui->checkBoxUnitePages->setChecked(save); } +//--------------------------------------------------------------------------------------------------------------------- +bool DialogLayoutSettings::IsStripOptimization() const +{ + return ui->groupBoxStrips->isChecked(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetStripOptimization(bool save) +{ + ui->groupBoxStrips->setChecked(save); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint8 DialogLayoutSettings::GetMultiplier() const +{ + return static_cast(ui->spinBoxMultiplier->value()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetMultiplier(const quint8 &value) +{ + ui->spinBoxMultiplier->setValue(static_cast(value)); +} + //--------------------------------------------------------------------------------------------------------------------- bool DialogLayoutSettings::IsIgnoreAllFields() const { @@ -537,6 +561,8 @@ void DialogLayoutSettings::DialogAccepted() generator->SetAutoCrop(GetAutoCrop()); generator->SetSaveLength(IsSaveLength()); generator->SetUnitePages(IsUnitePages()); + generator->SetStripOptimization(IsStripOptimization()); + generator->SetMultiplier(GetMultiplier()); if (IsIgnoreAllFields()) { @@ -603,6 +629,7 @@ void DialogLayoutSettings::RestoreDefaults() SetIncrease(VSettings::GetDefLayoutRotationIncrease()); SetFields(VSettings::GetDefFields()); SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields()); + SetMultiplier(VSettings::GetDefMultiplier()); CorrectMaxFileds(); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); @@ -953,6 +980,8 @@ void DialogLayoutSettings::ReadSettings() SetUnitePages(settings->GetLayoutUnitePages()); SetFields(settings->GetFields()); SetIgnoreAllFields(settings->GetIgnoreAllFields()); + SetStripOptimization(settings->GetStripOptimization()); + SetMultiplier(settings->GetMultiplier()); FindTemplate(); @@ -976,6 +1005,8 @@ void DialogLayoutSettings::WriteSettings() const settings->SetLayoutUnitePages(IsUnitePages()); settings->SetFields(GetFields()); settings->SetIgnoreAllFields(IsIgnoreAllFields()); + settings->SetStripOptimization(IsStripOptimization()); + settings->SetMultiplier(GetMultiplier()); } //--------------------------------------------------------------------------------------------------------------------- @@ -998,4 +1029,5 @@ void DialogLayoutSettings::SetAdditionalOptions(bool value) SetAutoCrop(value); SetSaveLength(value); SetUnitePages(value); + SetStripOptimization(value); } diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.h b/src/app/valentina/dialogs/dialoglayoutsettings.h index d5559467b..a3684a00b 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.h +++ b/src/app/valentina/dialogs/dialoglayoutsettings.h @@ -102,6 +102,12 @@ public: bool IsUnitePages() const; void SetUnitePages(bool save); + bool IsStripOptimization() const; + void SetStripOptimization(bool save); + + quint8 GetMultiplier() const; + void SetMultiplier(const quint8 &value); + bool IsIgnoreAllFields() const; void SetIgnoreAllFields(bool value); diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.ui b/src/app/valentina/dialogs/dialoglayoutsettings.ui index 77001fb39..6cdf43658 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.ui +++ b/src/app/valentina/dialogs/dialoglayoutsettings.ui @@ -6,8 +6,8 @@ 0 0 - 661 - 453 + 623 + 531 @@ -278,6 +278,13 @@ + + + + Qt::Vertical + + + @@ -587,6 +594,54 @@ + + + + Qt::Horizontal + + + + + + + Enabling for sheets that have big height will speed up creating. + + + Divide into strips + + + true + + + false + + + + + + Multiplier + + + + + + + Set multiplier for length of the biggest workpiece in layout. + + + x + + + 1 + + + 10 + + + + + + diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 8437c398a..1e1f9067d 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -124,10 +124,6 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator) CleanLayout(); papers = lGenerator.GetPapersItems();// Blank sheets details = lGenerator.GetAllDetails();// All details - if (lGenerator.IsUnitePages()) - { - UnitePages(); - } CreateShadows(); CreateScenes(); PrepareSceneList(); @@ -998,91 +994,3 @@ int MainWindowsNoGUI::ContinueIfLayoutStale() msgBox.exec(); return msgBox.result(); } - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::UnitePages() -{ - if (papers.size() < 2) - { - return; - } - - QList nPapers; - QList > nDetails; - qreal length = 0; - int j = 0; // papers count - - for (int i = 0; i < papers.size(); ++i) - { - QGraphicsRectItem *paper = qgraphicsitem_cast(papers.at(i)); - SCASSERT(paper != nullptr); - const QRectF rec = paper->rect(); - if (length + rec.height() <= QIMAGE_MAX) - { - UniteDetails(j, nDetails, length, i); - length += rec.height(); - UnitePapers(j, nPapers, rec.width(), length); - } - else - { - length = 0; // Strat new paper - ++j;// New paper - UniteDetails(j, nDetails, length, i); - length += rec.height(); - UnitePapers(j, nPapers, rec.width(), length); - } - } - - qDeleteAll (papers); - papers.clear(); - papers = nPapers; - - details.clear(); - details = nDetails; -} - -//--------------------------------------------------------------------------------------------------------------------- -QList MainWindowsNoGUI::MoveDetails(qreal length, const QList &details) -{ - if (qFuzzyCompare(length+1, 0+1)) - { - return details; - } - - for (int i = 0; i < details.size(); ++i) - { - details.at(i)->moveBy(0, length); - } - - return details; -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::UnitePapers(int j, QList &nPapers, qreal width, qreal length) -{ - if ((j == 0 && nPapers.isEmpty()) || j >= nPapers.size()) - {//First or new paper in list - QGraphicsRectItem *paper = new QGraphicsRectItem(0, 0, width, length); - paper->setPen(QPen(Qt::black, 1)); - paper->setBrush(QBrush(Qt::white)); - nPapers.insert(j, paper); - } - else - {// Avoid memory leak - QGraphicsRectItem *paper = qgraphicsitem_cast(nPapers.at(j)); - paper->setRect(0, 0, width, length); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::UniteDetails(int j, QList > &nDetails, qreal length, int i) -{ - if ((j == 0 && nDetails.isEmpty()) || j >= nDetails.size()) - {//First or new details in paper - nDetails.insert(j, MoveDetails(length, details.at(i))); - } - else - { - nDetails[j].append(MoveDetails(length, details.at(i))); - } -} diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 63ab1e799..1cb1d1926 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -130,11 +130,6 @@ private: QString FileName() const; int ContinueIfLayoutStale(); - - void UnitePages(); - QList MoveDetails(qreal length, const QList &details); - void UnitePapers(int j, QList &nPapers, qreal width, qreal length); - void UniteDetails(int j, QList > &nDetails, qreal length, int i); }; #endif // MAINWINDOWSNOGUI_H diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index f3adaecd8..108c97a0b 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -37,7 +37,7 @@ VBank::VBank() :details(QVector()), unsorted(QHash()), big(QHash()), middle(QHash()), small(QHash()), layoutWidth(0), caseType(Cases::CaseDesc), - prepare(false), boundingRect(QRectF()) + prepare(false), diagonal(0) {} //--------------------------------------------------------------------------------------------------------------------- @@ -168,10 +168,18 @@ bool VBank::Prepare() return prepare; } + diagonal = 0; for (int i=0; i < details.size(); ++i) { details[i].SetLayoutWidth(layoutWidth); details[i].SetLayoutAllowencePoints(); + + const qreal d = details.at(i).Diagonal(); + if (d > diagonal) + { + diagonal = d; + } + const qint64 square = details.at(i).Square(); if (square <= 0) { @@ -181,7 +189,6 @@ bool VBank::Prepare() unsorted.insert(i, square); } - BiggestBoundingRect(); PrepareGroup(); prepare = true; @@ -196,7 +203,7 @@ void VBank::Reset() big.clear(); middle.clear(); small.clear(); - boundingRect = QRectF(); + diagonal = 0; } //--------------------------------------------------------------------------------------------------------------------- @@ -218,37 +225,9 @@ int VBank::LeftArrange() const } //--------------------------------------------------------------------------------------------------------------------- -void VBank::BiggestBoundingRect() +qreal VBank::GetBiggestDiagonal() const { - int index = -1; - qint64 sMax = LLONG_MIN; - - QHash::const_iterator i = unsorted.constBegin(); - while (i != unsorted.constEnd()) - { - if (i.value() > sMax) - { - sMax = i.value(); - index = i.key(); - } - - ++i; - } - - if (index >= 0 && index < details.size()) - { - boundingRect = QPolygonF(details.at(index).GetLayoutAllowencePoints()).boundingRect(); - } - else - { - boundingRect = QRectF(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -QRectF VBank::GetBiggestBoundingRect() const -{ - return boundingRect; + return diagonal; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index 9987b1f67..232d93790 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -69,7 +69,7 @@ public: int LeftArrange() const; int ArrangedCount() const; - QRectF GetBiggestBoundingRect() const; + qreal GetBiggestDiagonal() const; private: Q_DISABLE_COPY(VBank) @@ -84,7 +84,7 @@ private: Cases caseType; bool prepare; - QRectF boundingRect; + qreal diagonal; void PrepareGroup(); @@ -97,7 +97,6 @@ private: int GetNextDescGroup() const; void SqMaxMin(qint64 &sMax, qint64 &sMin) const; - void BiggestBoundingRect(); }; #if defined (Q_OS_WIN) && defined (Q_CC_MSVC) diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 1c887948b..1f9be80b4 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -256,8 +256,14 @@ QRectF VLayoutDetail::BoundingRect() const { QVector points = GetLayoutAllowencePoints(); points.append(points.first()); - QRectF rec = QPolygonF(points).boundingRect(); - return rec; + return QPolygonF(points).boundingRect(); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VLayoutDetail::Diagonal() const +{ + const QRectF rec = BoundingRect(); + return qSqrt(pow(rec.height(), 2) + pow(rec.width(), 2)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 69dbb0e0c..ebb15472c 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -72,6 +72,7 @@ public: int EdgeByPoint(const QPointF &p1) const; QRectF BoundingRect() const; + qreal Diagonal() const; bool isNull() const; qint64 Square() const; diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 9df5dd755..99ec8dc1f 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -29,18 +29,21 @@ #include "vlayoutgenerator.h" #include "vlayoutpaper.h" #include "vlayoutdetail.h" +#include "../vmisc/def.h" #include #include #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- VLayoutGenerator::VLayoutGenerator(QObject *parent) :QObject(parent), papers(QVector()), bank(new VBank()), paperHeight(0), paperWidth(0), margins(), stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true), rotationIncrease(180), - autoCrop(false), saveLength(false), unitePages(false) + autoCrop(false), saveLength(false), unitePages(false), stripOptimizationEnabled(false), multiplier(1), + stripOptimization(false) {} //--------------------------------------------------------------------------------------------------------------------- @@ -92,6 +95,20 @@ void VLayoutGenerator::Generate() if (bank->Prepare()) { + const int width = PageWidth(); + int height = PageHeight(); + + if (stripOptimization) + { + const qreal b = bank->GetBiggestDiagonal() * multiplier + bank->GetLayoutWidth(); + + if (height >= b*2) + { + stripOptimizationEnabled = true; + height = qFloor(height / qFloor(height/b)); + } + } + while (bank->AllDetailsCount() > 0) { if (stopGeneration) @@ -99,7 +116,7 @@ void VLayoutGenerator::Generate() break; } - VLayoutPaper paper(PageHeight(), PageWidth()); + VLayoutPaper paper(height, width); paper.SetShift(shift); paper.SetLayoutWidth(bank->GetLayoutWidth()); paper.SetPaperIndex(static_cast(papers.count())); @@ -148,6 +165,17 @@ void VLayoutGenerator::Generate() emit Error(state); return; } + + if (stripOptimizationEnabled) + { + GatherPages(); + } + + if (IsUnitePages()) + { + UnitePages(); + } + emit Finished(); } @@ -174,7 +202,7 @@ QList > VLayoutGenerator::GetAllDetails() const QList > list; for (int i=0; i < papers.count(); ++i) { - list.append(papers.at(i).GetDetails()); + list.append(papers.at(i).GetItemDetails()); } return list; } @@ -189,6 +217,41 @@ void VLayoutGenerator::Abort() #endif } +//--------------------------------------------------------------------------------------------------------------------- +bool VLayoutGenerator::IsStripOptimization() const +{ + return stripOptimization; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::SetStripOptimization(bool value) +{ + stripOptimization = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint8 VLayoutGenerator::GetMultiplier() const +{ + return multiplier; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::SetMultiplier(const quint8 &value) +{ + if (value > 10) + { + multiplier = 10; + } + else if (value == 0) + { + multiplier = 1; + } + else + { + multiplier = value; + } +} + //--------------------------------------------------------------------------------------------------------------------- int VLayoutGenerator::PageHeight() const { @@ -201,6 +264,161 @@ int VLayoutGenerator::PageWidth() const return static_cast(paperWidth - (margins.left() + margins.right())); } +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::GatherPages() +{ + if (papers.size() < 2) + { + return; + } + + QList> nDetails; + qreal length = 0; + int j = 0; // papers count + + for (int i = 0; i < papers.size(); ++i) + { + const int paperHeight = qRound(papers.at(i).BoundingRect().height()); + if (length + paperHeight <= PageHeight()) + { + UniteDetails(j, nDetails, length, i); + length += paperHeight; + } + else + { + length = 0; // Start new paper + ++j;// New paper + UniteDetails(j, nDetails, length, i); + length += paperHeight; + } + } + + QVector nPapers; + for (int i = 0; i < nDetails.size(); ++i) + { + VLayoutPaper paper(PageHeight(), PageWidth()); + paper.SetShift(shift); + paper.SetLayoutWidth(bank->GetLayoutWidth()); + paper.SetPaperIndex(i); + paper.SetRotate(rotate); + paper.SetRotationIncrease(rotationIncrease); + paper.SetSaveLength(saveLength); + paper.SetDetails(nDetails.at(i)); + + nPapers.append(paper); + } + + papers.clear(); + papers = nPapers; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::UnitePages() +{ + if (papers.size() < 2) + { + return; + } + + QList papersLength; + QList > nDetails; + qreal length = 0; + int j = 0; // papers count + + for (int i = 0; i < papers.size(); ++i) + { + int paperHeight = 0; + if (autoCrop) + { + paperHeight = qRound(papers.at(i).BoundingRect().height()); + } + else + { + paperHeight = papers.at(i).GetHeight(); + } + + paperHeight = qRound(paperHeight + bank->GetLayoutWidth()); + + if (length + paperHeight <= QIMAGE_MAX) + { + UniteDetails(j, nDetails, length, i); + length += paperHeight; + UnitePapers(j, papersLength, length); + } + else + { + length = 0; // Start new paper + ++j;// New paper + UniteDetails(j, nDetails, length, i); + length += paperHeight; + UnitePapers(j, papersLength, length); + } + } + + QVector nPapers; + for (int i = 0; i < nDetails.size(); ++i) + { + VLayoutPaper paper(qFloor(papersLength.at(i)), PageWidth()); + paper.SetShift(shift); + paper.SetLayoutWidth(bank->GetLayoutWidth()); + paper.SetPaperIndex(i); + paper.SetRotate(rotate); + paper.SetRotationIncrease(rotationIncrease); + paper.SetSaveLength(saveLength); + paper.SetDetails(nDetails.at(i)); + + nPapers.append(paper); + } + + papers.clear(); + papers = nPapers; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::UniteDetails(int j, QList > &nDetails, qreal length, int i) +{ + if ((j == 0 && nDetails.isEmpty()) || j >= nDetails.size()) + {//First or new details in paper + nDetails.insert(j, MoveDetails(length, papers.at(i).GetDetails())); + } + else + { + nDetails[j].append(MoveDetails(length, papers.at(i).GetDetails())); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutGenerator::UnitePapers(int j, QList &papersLength, qreal length) +{ + if ((j == 0 && papersLength.isEmpty()) || j >= papersLength.size()) + { + papersLength.insert(j, length); + } + else + { + papersLength[j] = length; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QList VLayoutGenerator::MoveDetails(qreal length, const QVector &details) +{ + if (qFuzzyIsNull(length)) + { + return details.toList(); + } + + QList newDetails; + for (int i = 0; i < details.size(); ++i) + { + VLayoutDetail d = details.at(i); + d.Translate(0, length); + newDetails.append(d); + } + + return newDetails; +} + //--------------------------------------------------------------------------------------------------------------------- bool VLayoutGenerator::IsUnitePages() const { diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index 198b6bf45..b5261cc1d 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -92,6 +92,12 @@ public: bool IsUnitePages() const; void SetUnitePages(bool value); + quint8 GetMultiplier() const; + void SetMultiplier(const quint8 &value); + + bool IsStripOptimization() const; + void SetStripOptimization(bool value); + signals: void Start(); void Arranged(int count); @@ -116,9 +122,18 @@ private: bool autoCrop; bool saveLength; bool unitePages; + bool stripOptimizationEnabled; + quint8 multiplier; + bool stripOptimization; int PageHeight() const; int PageWidth() const; + + void GatherPages(); + void UnitePages(); + void UniteDetails(int j, QList > &nDetails, qreal length, int i); + void UnitePapers(int j, QList &papersLength, qreal length); + QList MoveDetails(qreal length, const QVector &details); }; typedef std::shared_ptr VLayoutGeneratorPtr; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 1d7c417fe..5f58a148a 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -281,7 +281,7 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const if (autoCrop) { QGraphicsScene *scene = new QGraphicsScene(); - QList list = GetDetails(); + QList list = GetItemDetails(); for (int i=0; i < list.size(); ++i) { scene->addItem(list.at(i)); @@ -307,7 +307,7 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const } //--------------------------------------------------------------------------------------------------------------------- -QList VLayoutPaper::GetDetails() const +QList VLayoutPaper::GetItemDetails() const { QList list; for (int i=0; i < d->details.count(); ++i) @@ -316,3 +316,27 @@ QList VLayoutPaper::GetDetails() const } return list; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPaper::GetDetails() const +{ + return d->details; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPaper::SetDetails(const QList &details) +{ + d->details = details.toVector(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QRectF VLayoutPaper::BoundingRect() const +{ + QRectF rec; + for (int i=0; i < d->details.count(); ++i) + { + rec = rec.united(d->details.at(i).BoundingRect()); + } + + return rec; +} diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index 8728cc8a1..42c956a10 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -37,6 +37,7 @@ class VLayoutDetail; class QGraphicsItem; class VBestSquare; class QGraphicsRectItem; +class QRectF; class VLayoutPaper { @@ -57,7 +58,7 @@ public: void SetLayoutWidth(qreal width); quint32 GetShift() const; - void SetShift(quint32 shift); + void SetShift(quint32 shift); bool GetRotate() const; void SetRotate(bool value); @@ -73,7 +74,12 @@ public: bool ArrangeDetail(const VLayoutDetail &detail, volatile bool &stop); int Count() const; QGraphicsRectItem *GetPaperItem(bool autoCrop) const; - QList GetDetails() const; + QList GetItemDetails() const; + + QVector GetDetails() const; + void SetDetails(const QList& details); + + QRectF BoundingRect() const; private: QSharedDataPointer d; diff --git a/src/libs/vmisc/vsettings.cpp b/src/libs/vmisc/vsettings.cpp index a0e94e241..017f4baae 100644 --- a/src/libs/vmisc/vsettings.cpp +++ b/src/libs/vmisc/vsettings.cpp @@ -75,6 +75,8 @@ const QString VSettings::SettingLayoutSaveLength = QStringLitera const QString VSettings::SettingLayoutUnitePages = QStringLiteral("layout/unitePages"); const QString VSettings::SettingFields = QStringLiteral("layout/fields"); const QString VSettings::SettingIgnoreFields = QStringLiteral("layout/ignoreFields"); +const QString VSettings::SettingStripOptimization = QStringLiteral("layout/stripOptimization"); +const QString VSettings::SettingMultiplier = QStringLiteral("layout/multiplier"); //--------------------------------------------------------------------------------------------------------------------- VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application, @@ -560,3 +562,39 @@ void VSettings::SetIgnoreAllFields(bool value) { setValue(SettingIgnoreFields, value); } + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetStripOptimization() const +{ + return value(SettingStripOptimization, GetDefStripOptimization()).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VSettings::GetDefStripOptimization() +{ + return false; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetStripOptimization(bool value) +{ + setValue(SettingStripOptimization, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint8 VSettings::GetMultiplier() const +{ + return static_cast(value(SettingMultiplier, GetDefMultiplier()).toUInt()); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint8 VSettings::GetDefMultiplier() +{ + return 1; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSettings::SetMultiplier(quint8 value) +{ + setValue(SettingMultiplier, value); +} diff --git a/src/libs/vmisc/vsettings.h b/src/libs/vmisc/vsettings.h index 2032d8ce7..d941e0672 100644 --- a/src/libs/vmisc/vsettings.h +++ b/src/libs/vmisc/vsettings.h @@ -134,6 +134,14 @@ public: static bool GetDefIgnoreAllFields(); void SetIgnoreAllFields(bool value); + bool GetStripOptimization() const; + static bool GetDefStripOptimization(); + void SetStripOptimization(bool value); + + quint8 GetMultiplier() const; + static quint8 GetDefMultiplier(); + void SetMultiplier(quint8 value); + private: Q_DISABLE_COPY(VSettings) static const QString SettingConfigurationLabelLanguage; @@ -166,6 +174,8 @@ private: static const QString SettingLayoutUnitePages; static const QString SettingFields; static const QString SettingIgnoreFields; + static const QString SettingStripOptimization; + static const QString SettingMultiplier; }; #endif // VSETTINGS_H