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;
|
||||
void SetWidth(int width);
|
||||
|
||||
bool IsPortrait() const;
|
||||
|
||||
QSizeF GetSize() const;
|
||||
|
||||
QVector<QPointF> UniteWithContour(const VLayoutPiece &detail, int globalI, int detJ, BestFrom type) const;
|
||||
|
@ -93,8 +95,6 @@ private:
|
|||
QSharedDataPointer<VContourData> d;
|
||||
|
||||
void AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
||||
|
||||
bool IsPortrait() const;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE);
|
||||
|
|
|
@ -330,6 +330,8 @@ void VLayoutGenerator::GatherPages()
|
|||
int j = 0; // papers count
|
||||
|
||||
for (int i = 0; i < papers.size(); ++i)
|
||||
{
|
||||
if (IsPortrait())
|
||||
{
|
||||
int paperHeight = qRound(papers.at(i).DetailsBoundingRect().height());
|
||||
|
||||
|
@ -351,6 +353,29 @@ void VLayoutGenerator::GatherPages()
|
|||
length += paperHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int paperWidth = qRound(papers.at(i).DetailsBoundingRect().width());
|
||||
|
||||
if (i != papers.size()-1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVector<VLayoutPaper> nPapers;
|
||||
for (int i = 0; i < nDetails.size(); ++i)
|
||||
|
@ -386,6 +411,8 @@ void VLayoutGenerator::UnitePages()
|
|||
int j = 0; // papers count
|
||||
|
||||
for (int i = 0; i < papers.size(); ++i)
|
||||
{
|
||||
if (IsPortrait())
|
||||
{
|
||||
int paperHeight = 0;
|
||||
if (autoCrop)
|
||||
|
@ -417,11 +444,47 @@ void VLayoutGenerator::UnitePages()
|
|||
UnitePapers(j, papersLength, length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int paperWidth = 0;
|
||||
if (autoCrop)
|
||||
{
|
||||
paperWidth = qRound(papers.at(i).DetailsBoundingRect().width());
|
||||
}
|
||||
else
|
||||
{
|
||||
paperWidth = papers.at(i).GetWidth();
|
||||
}
|
||||
|
||||
if (i != papers.size()-1)
|
||||
{
|
||||
paperWidth = qRound(paperWidth + bank->GetLayoutWidth()*2);
|
||||
}
|
||||
|
||||
if (length + paperWidth <= QIMAGE_MAX)
|
||||
{
|
||||
UniteDetails(j, nDetails, length, i);
|
||||
length += paperWidth;
|
||||
UnitePapers(j, papersLength, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 0; // Start new paper
|
||||
++j;// New paper
|
||||
UniteDetails(j, nDetails, length, i);
|
||||
length += paperWidth;
|
||||
UnitePapers(j, papersLength, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVector<VLayoutPaper> nPapers;
|
||||
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.SetLayoutWidth(bank->GetLayoutWidth());
|
||||
paper.SetPaperIndex(static_cast<quint32>(i));
|
||||
|
@ -475,7 +538,7 @@ QList<VLayoutPiece> VLayoutGenerator::MoveDetails(qreal length, const QVector<VL
|
|||
QList<VLayoutPiece> newDetails;
|
||||
for (auto d : details)
|
||||
{
|
||||
d.Translate(0, length);
|
||||
IsPortrait() ? d.Translate(0, length) : d.Translate(length, 0);
|
||||
newDetails.append(d);
|
||||
}
|
||||
|
||||
|
|
|
@ -337,6 +337,9 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
|
|||
{
|
||||
scene->addItem(item);
|
||||
}
|
||||
|
||||
if (d->globalContour.IsPortrait())
|
||||
{
|
||||
const int height = scene->itemsBoundingRect().toRect().height();
|
||||
if (d->globalContour.GetHeight() > height) //-V807
|
||||
{
|
||||
|
@ -348,6 +351,19 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user