Fix strip optimization. It must follow paper sheet orientation settings.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-01-02 16:49:57 +02:00
parent d5d8104d3a
commit 25fc7227f0
2 changed files with 17 additions and 5 deletions

View File

@ -115,18 +115,23 @@ void VLayoutGenerator::Generate()
if (bank->Prepare()) if (bank->Prepare())
{ {
const int width = PageWidth(); int width = PageWidth();
int height = PageHeight(); int height = PageHeight();
if (stripOptimization) if (stripOptimization)
{ {
const qreal b = bank->GetBiggestDiagonal() * multiplier + bank->GetLayoutWidth(); const qreal b = bank->GetBiggestDiagonal() * multiplier + bank->GetLayoutWidth();
if (height >= b*2) auto SetStrip = [this, b](int &side)
{ {
stripOptimizationEnabled = true; if (side >= b*2)
height = qFloor(height / qFloor(height/b)); {
} stripOptimizationEnabled = true;
side = qFloor(side / qFloor(side/b));
}
};
IsPortrait() ? SetStrip(height) : SetStrip(width);
} }
while (bank->AllDetailsCount() > 0) while (bank->AllDetailsCount() > 0)
@ -306,6 +311,12 @@ int VLayoutGenerator::PageWidth() const
return static_cast<int>(paperWidth - (margins.left() + margins.right())); return static_cast<int>(paperWidth - (margins.left() + margins.right()));
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::IsPortrait() const
{
return PageHeight() >= PageWidth();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::GatherPages() void VLayoutGenerator::GatherPages()
{ {

View File

@ -147,6 +147,7 @@ private:
int PageHeight() const; int PageHeight() const;
int PageWidth() const; int PageWidth() const;
bool IsPortrait() const;
void GatherPages(); void GatherPages();
void UnitePages(); void UnitePages();