Improvement for option "Save layout length".

This option worked only for portrait orientation. In landscape orientation
instead of width need save height. Additionally we keep original comaprison for
the smallest bounding rect. This creates more humanlike output.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-12-28 15:53:18 +02:00
parent f678174729
commit 55a3ecb8cb
2 changed files with 12 additions and 5 deletions

View File

@ -33,7 +33,7 @@
//---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare(const QSizeF &sheetSize, bool saveLength)
:resI(0), resJ(0), resMatrix(QMatrix()), bestSize(QSizeF(sheetSize.width()+10, sheetSize.height()+10)),
sheetWidth(sheetSize.width()), valideResult(false), resMirror(false), type (BestFrom::Rotation),
sheetSize(sheetSize), valideResult(false), resMirror(false), type (BestFrom::Rotation),
saveLength(saveLength)
{}
@ -42,10 +42,17 @@ void VBestSquare::NewResult(const QSizeF &candidate, int i, int j, const QTransf
{
if (saveLength)
{
const QSizeF saveLengthSize(sheetWidth, candidate.height());
if (Square(saveLengthSize) <= Square(bestSize) && Square(saveLengthSize) > 0 && type >= this->type)
const bool isPortrait = sheetSize.height() >= sheetSize.width();
const QSizeF saveSpaceSize = isPortrait ? QSizeF(sheetSize.width(), candidate.height()) :
QSizeF(candidate.width(), sheetSize.height());
const QSizeF saveSpaceBestSize = isPortrait ? QSizeF(sheetSize.width(), bestSize.height()) :
QSizeF(bestSize.width(), sheetSize.height());
if (Square(saveSpaceSize) <= Square(saveSpaceBestSize) && Square(candidate) <= Square(bestSize)
&& Square(saveSpaceSize) > 0 && Square(saveSpaceBestSize) > 0 && type >= this->type)
{
bestSize = saveLengthSize;
bestSize = candidate;
}
else
{

View File

@ -59,7 +59,7 @@ private:
int resJ; // Edge of detail
QTransform resMatrix; // Matrix for rotation and translation detail
QSizeF bestSize;
qreal sheetWidth;
QSizeF sheetSize;
bool valideResult;
bool resMirror;
BestFrom type;