From 25fc7227f08c469599ea34f2082a3edf3f7e3677 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 2 Jan 2019 16:49:57 +0200 Subject: [PATCH] Fix strip optimization. It must follow paper sheet orientation settings. --HG-- branch : develop --- src/libs/vlayout/vlayoutgenerator.cpp | 21 ++++++++++++++++----- src/libs/vlayout/vlayoutgenerator.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index 8b0f832f7..3a86b1a6e 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -115,18 +115,23 @@ void VLayoutGenerator::Generate() if (bank->Prepare()) { - const int width = PageWidth(); + int width = PageWidth(); int height = PageHeight(); if (stripOptimization) { const qreal b = bank->GetBiggestDiagonal() * multiplier + bank->GetLayoutWidth(); - if (height >= b*2) + auto SetStrip = [this, b](int &side) { - stripOptimizationEnabled = true; - height = qFloor(height / qFloor(height/b)); - } + if (side >= b*2) + { + stripOptimizationEnabled = true; + side = qFloor(side / qFloor(side/b)); + } + }; + + IsPortrait() ? SetStrip(height) : SetStrip(width); } while (bank->AllDetailsCount() > 0) @@ -306,6 +311,12 @@ int VLayoutGenerator::PageWidth() const return static_cast(paperWidth - (margins.left() + margins.right())); } +//--------------------------------------------------------------------------------------------------------------------- +bool VLayoutGenerator::IsPortrait() const +{ + return PageHeight() >= PageWidth(); +} + //--------------------------------------------------------------------------------------------------------------------- void VLayoutGenerator::GatherPages() { diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index 83b7ec2b0..a586d3e76 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -147,6 +147,7 @@ private: int PageHeight() const; int PageWidth() const; + bool IsPortrait() const; void GatherPages(); void UnitePages();