From 1d1ae1acb465f0fdfac26f2ab1db6934009f3a45 Mon Sep 17 00:00:00 2001 From: dismine Date: Sat, 17 Jan 2015 16:00:46 +0200 Subject: [PATCH] Fixed creation global contour. --HG-- branch : feature --- src/libs/vlayout/vlayoutgenerator.cpp | 1 + src/libs/vlayout/vlayoutpaper.cpp | 29 ++++++++++++++++++++------- src/libs/vlayout/vlayoutpaper.h | 3 +++ src/libs/vlayout/vlayoutpaper_p.h | 8 +++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 01f5b6038..0501440da 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -99,6 +99,7 @@ void VLayoutGenerator::Generate() VLayoutPaper paper(paperHeight, paperWidth); paper.SetShift(shift); + paper.SetLayoutWidth(bank->GetLayoutWidth()); paper.SetPaperIndex(papers.count()); do { diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 34e86beaf..8d3f56ef3 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -164,6 +164,21 @@ void VLayoutPaper::SetWidth(int width) d->paperWidth = width; } +//--------------------------------------------------------------------------------------------------------------------- +qreal VLayoutPaper::GetLayoutWidth() const +{ + return d->layoutWidth; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPaper::SetLayoutWidth(qreal width) +{ + if (width >= 0) + { + d->layoutWidth = width; + } +} + //--------------------------------------------------------------------------------------------------------------------- unsigned int VLayoutPaper::GetShift() const { @@ -607,7 +622,7 @@ QVector VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int { if (j > nD) { - j=0; + j=1; } const QVector points = CutEdge(detail.Edge(j)); for (int i = 0; i < points.size()-1; ++i) @@ -616,7 +631,7 @@ QVector VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int } ++processedEdges; ++j; - }while (processedEdges < nD); + }while (processedEdges <= nD); } else { @@ -643,7 +658,7 @@ QVector VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int { if (j > nD) { - j=0; + j=1; } const QVector points = CutEdge(detail.Edge(j)); for (int i = 0; i < points.size()-1; ++i) @@ -652,7 +667,7 @@ QVector VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int } ++processedEdges; ++j; - }while (processedEdges < nD); + }while (processedEdges <= nD); } } } @@ -665,7 +680,7 @@ QLineF VLayoutPaper::GlobalEdge(int i) const if (d->details.isEmpty()) { // Because sheet is blank we have one global edge for all cases - Ox axis. - const QLineF axis = QLineF(0, 0, d->paperWidth, 0); + const QLineF axis = QLineF(0, 0, d->paperWidth - d->layoutWidth/2, 0); if (d->shift == 0) { return axis; @@ -831,8 +846,8 @@ void VLayoutPaper::DrawDebug(const VLayoutDetail &detail, int frame) const #endif paint.end(); - const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug/")+QString("%1_%2.png").arg(d->paperIndex) - .arg(frame); + const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug/")+QString("%1_%2_%3.png").arg(d->paperIndex) + .arg(d->details.count()).arg(frame); frameImage.save (path); } diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index 0bf62e1b6..bc950e5a4 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -55,6 +55,9 @@ public: int GetWidth() const; void SetWidth(int width); + qreal GetLayoutWidth() const; + void SetLayoutWidth(qreal width); + unsigned int GetShift() const; void SetShift(unsigned int shift); diff --git a/src/libs/vlayout/vlayoutpaper_p.h b/src/libs/vlayout/vlayoutpaper_p.h index 62e37923c..6acb7bef4 100644 --- a/src/libs/vlayout/vlayoutpaper_p.h +++ b/src/libs/vlayout/vlayoutpaper_p.h @@ -45,17 +45,18 @@ class VLayoutPaperData : public QSharedData public: VLayoutPaperData() :details(QVector()), globalContour(QVector()), paperHeight(0), paperWidth(0), shift(0), - paperIndex(0), frame(0) + paperIndex(0), frame(0), layoutWidth(0) {} VLayoutPaperData(int height, int width) :details(QVector()), globalContour(QVector()), paperHeight(height), paperWidth(width), - shift(0), paperIndex(0), frame(0) + shift(0), paperIndex(0), frame(0), layoutWidth(0) {} VLayoutPaperData(const VLayoutPaperData &paper) :QSharedData(paper), details(paper.details), globalContour(paper.globalContour), paperHeight(paper.paperHeight), - paperWidth(paper.paperWidth), shift(paper.shift), paperIndex(paper.paperIndex), frame(paper.frame) + paperWidth(paper.paperWidth), shift(paper.shift), paperIndex(paper.paperIndex), frame(paper.frame), + layoutWidth(paper.layoutWidth) {} ~VLayoutPaperData() {} @@ -75,6 +76,7 @@ public: unsigned int shift; quint32 paperIndex; quint32 frame; + qreal layoutWidth; }; #ifdef Q_CC_GNU