diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index e2ac943bd..a3756fe29 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1539,6 +1539,7 @@ void MainWindow::CleanLayout() scenes.clear(); shadows.clear(); papers.clear(); + gcontours.clear(); ui->listWidget->clear(); SetLayoutModeActions(); } diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 9daba19fa..925b02087 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -108,6 +108,21 @@ void RemoveLayoutPath(const QString &path, bool usedNotExistedDir) dir.rmpath(QChar('.')); } } + +//--------------------------------------------------------------------------------------------------------------------- +Q_DECL_UNUSED void InsertGlobalContours(const QList &scenes, const QList &gcontours); +void InsertGlobalContours(const QList &scenes, const QList &gcontours) +{ + if (scenes.size() != gcontours.size()) + { + return; + } + + for(int i = 0; i < scenes.size(); ++i) + { + scenes.at(i)->addItem(gcontours.at(i)); + } +} } //--------------------------------------------------------------------------------------------------------------------- @@ -122,6 +137,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) shadows(), scenes(), details(), + gcontours(), detailsOnLayout(), undoAction(nullptr), redoAction(nullptr), @@ -228,6 +244,9 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator) detailsOnLayout = lGenerator.GetAllDetails();// All details items shadows = CreateShadows(papers); scenes = CreateScenes(papers, shadows, details); + //Uncomment to debug, shows global contour +// gcontours = lGenerator.GetGlobalContours(); // uncomment for debugging +// InsertGlobalContours(scenes, gcontours); // uncomment for debugging PrepareSceneList(); ignorePrinterFields = not lGenerator.IsUsePrinterFields(); margins = lGenerator.GetPrinterFields(); diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 63dc20a4b..bdb7223c4 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -99,6 +99,7 @@ protected: QList shadows; QList scenes; QList > details; + QList gcontours; QVector > detailsOnLayout; diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 7994264af..6e2fe97f8 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -221,6 +221,17 @@ QList VLayoutGenerator::GetPapersItems() const return list; } +//--------------------------------------------------------------------------------------------------------------------- +QList VLayoutGenerator::GetGlobalContours() const +{ + QList list; + for (auto &paper : papers) + { + list.append(paper.GetGlobalContour()); + } + return list; +} + //--------------------------------------------------------------------------------------------------------------------- QList > VLayoutGenerator::GetAllDetailsItems() const { diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index 322cb8b94..d9069f62f 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -83,6 +83,7 @@ public: LayoutErrors State() const; Q_REQUIRED_RESULT QList GetPapersItems() const; + Q_REQUIRED_RESULT QList GetGlobalContours() const; Q_REQUIRED_RESULT QList> GetAllDetailsItems() const; QVector> GetAllDetails() const; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index ced887ebd..07d79ff64 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -366,6 +366,32 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c return paper; } +//--------------------------------------------------------------------------------------------------------------------- +QGraphicsPathItem *VLayoutPaper::GetGlobalContour() const +{ + // contour + const QVector points = d->globalContour.GetContour(); + + QPainterPath path; + if (points.size() > 0) + { + path.moveTo(points.at(0)); + for (auto point : points) + { + path.lineTo(point); + } + path.lineTo(points.at(0)); + } + + const qreal radius = 1; + for (auto point : points) + { + path.addEllipse(point.x()-radius, point.y()-radius, radius*2, radius*2); + } + + return new QGraphicsPathItem(path); +} + //--------------------------------------------------------------------------------------------------------------------- QList VLayoutPaper::GetItemDetails(bool textAsPaths) const { diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index de20dcd45..7ea6489d1 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -34,6 +34,7 @@ #include #include #include +#include #include "vlayoutdef.h" @@ -92,10 +93,11 @@ public: bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop); int Count() const; Q_REQUIRED_RESULT QGraphicsRectItem *GetPaperItem(bool autoCrop, bool textAsPaths) const; + Q_REQUIRED_RESULT QGraphicsPathItem *GetGlobalContour() const; Q_REQUIRED_RESULT QList GetItemDetails(bool textAsPaths) const; QVector GetDetails() const; - void SetDetails(const QList& details); + void SetDetails(const QList& details); QRectF DetailsBoundingRect() const;