Fix auto cropping.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-03-12 19:45:27 +02:00
parent 0f226d6cdf
commit 1393be669b
2 changed files with 9 additions and 22 deletions

View File

@ -415,7 +415,7 @@ void VLayoutGenerator::UnitePages()
int paperHeight = 0; int paperHeight = 0;
if (autoCrop) if (autoCrop)
{ {
paperHeight = qRound(papers.at(i).DetailsBoundingRect().height()); paperHeight = qCeil(papers.at(i).DetailsBoundingRect().height());
} }
else else
{ {
@ -447,7 +447,7 @@ void VLayoutGenerator::UnitePages()
int paperWidth = 0; int paperWidth = 0;
if (autoCrop) if (autoCrop)
{ {
paperWidth = qRound(papers.at(i).DetailsBoundingRect().width()); paperWidth = qCeil(papers.at(i).DetailsBoundingRect().width());
} }
else else
{ {
@ -479,8 +479,8 @@ void VLayoutGenerator::UnitePages()
QVector<VLayoutPaper> nPapers; QVector<VLayoutPaper> nPapers;
for (int i = 0; i < nDetails.size(); ++i) for (int i = 0; i < nDetails.size(); ++i)
{ {
const int height = IsPortrait() ? qFloor(papersLength.at(i)) : PageHeight(); const int height = IsPortrait() ? qCeil(papersLength.at(i)) : PageHeight();
const int width = IsPortrait() ? PageWidth() : qFloor(papersLength.at(i)); const int width = IsPortrait() ? PageWidth() : qCeil(papersLength.at(i));
VLayoutPaper paper(height, width, bank->GetLayoutWidth()); VLayoutPaper paper(height, width, bank->GetLayoutWidth());
paper.SetShift(shift); paper.SetShift(shift);

View File

@ -345,29 +345,16 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) c
scene->addItem(item); scene->addItem(item);
} }
const QRect boundingRect = scene->itemsBoundingRect().toRect();
if (d->globalContour.IsPortrait()) if (d->globalContour.IsPortrait())
{ {
const int height = scene->itemsBoundingRect().toRect().height(); const int height = boundingRect.height() + boundingRect.y() + 1;
if (d->globalContour.GetHeight() > height) //-V807 paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), height));
{
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
{ {
const int width = scene->itemsBoundingRect().toRect().width(); const int width = boundingRect.width() + boundingRect.x() + 1;
if (d->globalContour.GetWidth() > width) //-V807 paper = new QGraphicsRectItem(QRectF(0, 0, width, d->globalContour.GetHeight()));
{
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