Fix uniting and cropping pages.
Code missed handling landscape orienation. --HG-- branch : develop
This commit is contained in:
parent
a7332adc75
commit
2f717fd365
|
@ -73,6 +73,8 @@ public:
|
||||||
int GetWidth() const;
|
int GetWidth() const;
|
||||||
void SetWidth(int width);
|
void SetWidth(int width);
|
||||||
|
|
||||||
|
bool IsPortrait() const;
|
||||||
|
|
||||||
QSizeF GetSize() const;
|
QSizeF GetSize() const;
|
||||||
|
|
||||||
QVector<QPointF> UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const;
|
QVector<QPointF> UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const;
|
||||||
|
@ -93,8 +95,6 @@ private:
|
||||||
QSharedDataPointer<VContourData> d;
|
QSharedDataPointer<VContourData> d;
|
||||||
|
|
||||||
void AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
void AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
||||||
|
|
||||||
bool IsPortrait() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE);
|
||||||
|
|
|
@ -331,24 +331,49 @@ void VLayoutGenerator::GatherPages()
|
||||||
|
|
||||||
for (int i = 0; i < papers.size(); ++i)
|
for (int i = 0; i < papers.size(); ++i)
|
||||||
{
|
{
|
||||||
int paperHeight = qRound(papers.at(i).DetailsBoundingRect().height());
|
if (IsPortrait())
|
||||||
|
|
||||||
if (i != papers.size()-1)
|
|
||||||
{
|
{
|
||||||
paperHeight += qRound(bank->GetLayoutWidth()*2);
|
int paperHeight = qRound(papers.at(i).DetailsBoundingRect().height());
|
||||||
}
|
|
||||||
|
|
||||||
if (length + paperHeight <= PageHeight())
|
if (i != papers.size()-1)
|
||||||
{
|
{
|
||||||
UniteDetails(j, nDetails, length, i);
|
paperHeight += qRound(bank->GetLayoutWidth()*2);
|
||||||
length += paperHeight;
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
int paperWidth = qRound(papers.at(i).DetailsBoundingRect().width());
|
||||||
++j;// New paper
|
|
||||||
UniteDetails(j, nDetails, length, i);
|
if (i != papers.size()-1)
|
||||||
length += paperHeight;
|
{
|
||||||
|
paperWidth += qRound(bank->GetLayoutWidth()*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length + paperWidth <= PageWidth())
|
||||||
|
{
|
||||||
|
UniteDetails(j, nDetails, length, i);
|
||||||
|
length += paperWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
length = 0; // Start new paper
|
||||||
|
++j;// New paper
|
||||||
|
UniteDetails(j, nDetails, length, i);
|
||||||
|
length += paperWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,41 +412,79 @@ void VLayoutGenerator::UnitePages()
|
||||||
|
|
||||||
for (int i = 0; i < papers.size(); ++i)
|
for (int i = 0; i < papers.size(); ++i)
|
||||||
{
|
{
|
||||||
int paperHeight = 0;
|
if (IsPortrait())
|
||||||
if (autoCrop)
|
|
||||||
{
|
{
|
||||||
paperHeight = qRound(papers.at(i).DetailsBoundingRect().height());
|
int paperHeight = 0;
|
||||||
|
if (autoCrop)
|
||||||
|
{
|
||||||
|
paperHeight = qRound(papers.at(i).DetailsBoundingRect().height());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paperHeight = papers.at(i).GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != papers.size()-1)
|
||||||
|
{
|
||||||
|
paperHeight = qRound(paperHeight + bank->GetLayoutWidth()*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
paperHeight = papers.at(i).GetHeight();
|
int paperWidth = 0;
|
||||||
}
|
if (autoCrop)
|
||||||
|
{
|
||||||
|
paperWidth = qRound(papers.at(i).DetailsBoundingRect().width());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paperWidth = papers.at(i).GetWidth();
|
||||||
|
}
|
||||||
|
|
||||||
if (i != papers.size()-1)
|
if (i != papers.size()-1)
|
||||||
{
|
{
|
||||||
paperHeight = qRound(paperHeight + bank->GetLayoutWidth()*2);
|
paperWidth = qRound(paperWidth + bank->GetLayoutWidth()*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length + paperHeight <= QIMAGE_MAX)
|
if (length + paperWidth <= QIMAGE_MAX)
|
||||||
{
|
{
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperHeight;
|
length += paperWidth;
|
||||||
UnitePapers(j, papersLength, length);
|
UnitePapers(j, papersLength, length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
length = 0; // Start new paper
|
||||||
++j;// New paper
|
++j;// New paper
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperHeight;
|
length += paperWidth;
|
||||||
UnitePapers(j, papersLength, length);
|
UnitePapers(j, papersLength, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<VLayoutPaper> nPapers;
|
QVector<VLayoutPaper> nPapers;
|
||||||
for (int i = 0; i < nDetails.size(); ++i)
|
for (int i = 0; i < nDetails.size(); ++i)
|
||||||
{
|
{
|
||||||
VLayoutPaper paper(qFloor(papersLength.at(i)), PageWidth());
|
const int height = IsPortrait() ? qFloor(papersLength.at(i)) : PageHeight();
|
||||||
|
const int width = IsPortrait() ? PageWidth() : qFloor(papersLength.at(i));
|
||||||
|
|
||||||
|
VLayoutPaper paper(height, width);
|
||||||
paper.SetShift(shift);
|
paper.SetShift(shift);
|
||||||
paper.SetLayoutWidth(bank->GetLayoutWidth());
|
paper.SetLayoutWidth(bank->GetLayoutWidth());
|
||||||
paper.SetPaperIndex(static_cast<quint32>(i));
|
paper.SetPaperIndex(static_cast<quint32>(i));
|
||||||
|
@ -475,7 +538,7 @@ QList<VLayoutPiece> VLayoutGenerator::MoveDetails(qreal length, const QVector<VL
|
||||||
QList<VLayoutPiece> newDetails;
|
QList<VLayoutPiece> newDetails;
|
||||||
for (auto d : details)
|
for (auto d : details)
|
||||||
{
|
{
|
||||||
d.Translate(0, length);
|
IsPortrait() ? d.Translate(0, length) : d.Translate(length, 0);
|
||||||
newDetails.append(d);
|
newDetails.append(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,14 +337,30 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
|
||||||
{
|
{
|
||||||
scene->addItem(item);
|
scene->addItem(item);
|
||||||
}
|
}
|
||||||
const int height = scene->itemsBoundingRect().toRect().height();
|
|
||||||
if (d->globalContour.GetHeight() > height) //-V807
|
if (d->globalContour.IsPortrait())
|
||||||
{
|
{
|
||||||
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), height));
|
const int height = scene->itemsBoundingRect().toRect().height();
|
||||||
|
if (d->globalContour.GetHeight() > height) //-V807
|
||||||
|
{
|
||||||
|
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), height));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
|
const int width = scene->itemsBoundingRect().toRect().width();
|
||||||
|
if (d->globalContour.GetWidth() > width) //-V807
|
||||||
|
{
|
||||||
|
paper = new QGraphicsRectItem(QRectF(0, 0, width, d->globalContour.GetHeight()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user