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

View File

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