Shows global contour.

For debugging purposes.
* * *
Show nodes on global contour.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-03-27 10:29:59 +02:00
parent 715389d35d
commit c2672b4b69
7 changed files with 62 additions and 1 deletions

View file

@ -1539,6 +1539,7 @@ void MainWindow::CleanLayout()
scenes.clear();
shadows.clear();
papers.clear();
gcontours.clear();
ui->listWidget->clear();
SetLayoutModeActions();
}

View file

@ -108,6 +108,21 @@ void RemoveLayoutPath(const QString &path, bool usedNotExistedDir)
dir.rmpath(QChar('.'));
}
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_UNUSED void InsertGlobalContours(const QList<QGraphicsScene *> &scenes, const QList<QGraphicsItem *> &gcontours);
void InsertGlobalContours(const QList<QGraphicsScene *> &scenes, const QList<QGraphicsItem *> &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();

View file

@ -99,6 +99,7 @@ protected:
QList<QGraphicsItem *> shadows;
QList<QGraphicsScene *> scenes;
QList<QList<QGraphicsItem *> > details;
QList<QGraphicsItem *> gcontours;
QVector<QVector<VLayoutPiece> > detailsOnLayout;

View file

@ -221,6 +221,17 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
return list;
}
//---------------------------------------------------------------------------------------------------------------------
QList<QGraphicsItem *> VLayoutGenerator::GetGlobalContours() const
{
QList<QGraphicsItem *> list;
for (auto &paper : papers)
{
list.append(paper.GetGlobalContour());
}
return list;
}
//---------------------------------------------------------------------------------------------------------------------
QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetailsItems() const
{

View file

@ -83,6 +83,7 @@ public:
LayoutErrors State() const;
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetPapersItems() const;
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetGlobalContours() const;
Q_REQUIRED_RESULT QList<QList<QGraphicsItem *>> GetAllDetailsItems() const;
QVector<QVector<VLayoutPiece>> GetAllDetails() const;

View file

@ -366,6 +366,32 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
return paper;
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsPathItem *VLayoutPaper::GetGlobalContour() const
{
// contour
const QVector<QPointF> 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<QGraphicsItem *> VLayoutPaper::GetItemDetails(bool textAsPaths) const
{

View file

@ -34,6 +34,7 @@
#include <QTypeInfo>
#include <QtGlobal>
#include <atomic>
#include <QGraphicsPathItem>
#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<QGraphicsItem *> GetItemDetails(bool textAsPaths) const;
QVector<VLayoutPiece> GetDetails() const;
void SetDetails(const QList<VLayoutPiece>& details);
void SetDetails(const QList<VLayoutPiece>& details);
QRectF DetailsBoundingRect() const;