Fixed creation global contour.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-17 16:00:46 +02:00
parent 56aa09a639
commit 1d1ae1acb4
4 changed files with 31 additions and 10 deletions

View File

@ -99,6 +99,7 @@ void VLayoutGenerator::Generate()
VLayoutPaper paper(paperHeight, paperWidth);
paper.SetShift(shift);
paper.SetLayoutWidth(bank->GetLayoutWidth());
paper.SetPaperIndex(papers.count());
do
{

View File

@ -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<QPointF> VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int
{
if (j > nD)
{
j=0;
j=1;
}
const QVector<QPointF> points = CutEdge(detail.Edge(j));
for (int i = 0; i < points.size()-1; ++i)
@ -616,7 +631,7 @@ QVector<QPointF> VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int
}
++processedEdges;
++j;
}while (processedEdges < nD);
}while (processedEdges <= nD);
}
else
{
@ -643,7 +658,7 @@ QVector<QPointF> VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int
{
if (j > nD)
{
j=0;
j=1;
}
const QVector<QPointF> points = CutEdge(detail.Edge(j));
for (int i = 0; i < points.size()-1; ++i)
@ -652,7 +667,7 @@ QVector<QPointF> 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);
}

View File

@ -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);

View File

@ -45,17 +45,18 @@ class VLayoutPaperData : public QSharedData
public:
VLayoutPaperData()
:details(QVector<VLayoutDetail>()), globalContour(QVector<QPointF>()), paperHeight(0), paperWidth(0), shift(0),
paperIndex(0), frame(0)
paperIndex(0), frame(0), layoutWidth(0)
{}
VLayoutPaperData(int height, int width)
:details(QVector<VLayoutDetail>()), globalContour(QVector<QPointF>()), 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