Pass original paper orientation. We cannot rely on paper size because it can be

stripped.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-06-18 14:36:20 +03:00
parent b80103e088
commit 3ca666fba3
6 changed files with 16 additions and 13 deletions

View file

@ -42,8 +42,8 @@ Q_DECL_CONSTEXPR inline qint64 Square(QSizeF size)
} // anonymous namespace
//---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare(QSizeF sheetSize, bool saveLength)
: d(new VBestSquareData(sheetSize, saveLength))
VBestSquare::VBestSquare(QSizeF sheetSize, bool saveLength, bool isPortrait)
: d(new VBestSquareData(sheetSize, saveLength, isPortrait))
{}
//---------------------------------------------------------------------------------------------------------------------
@ -190,5 +190,5 @@ bool VBestSquare::IsImprovedSidePosition(qreal sidePosition) const
//---------------------------------------------------------------------------------------------------------------------
bool VBestSquare::IsPortrait() const
{
return d->sheetSize.height() >= d->sheetSize.width();
return d->isPortrait;
}

View file

@ -42,7 +42,7 @@ class VBestSquareData;
class VBestSquare
{
public:
VBestSquare(QSizeF sheetSize, bool saveLength);
VBestSquare(QSizeF sheetSize, bool saveLength, bool isPortrait);
VBestSquare(const VBestSquare &res);
virtual ~VBestSquare();

View file

@ -41,9 +41,10 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VBestSquareData : public QSharedData
{
public:
VBestSquareData(const QSizeF &sheetSize, bool saveLength)
VBestSquareData(const QSizeF &sheetSize, bool saveLength, bool isPortrait)
: sheetSize(sheetSize),
saveLength(saveLength)
saveLength(saveLength),
isPortrait(isPortrait)
{
data.bestSize = QSizeF(sheetSize.width()+10, sheetSize.height()+10);
}
@ -54,7 +55,8 @@ public:
valideResult(res.valideResult),
saveLength(res.saveLength),
depthPosition(res.depthPosition),
data(res.data)
data(res.data),
isPortrait(res.isPortrait)
{}
~VBestSquareData() {}
@ -64,6 +66,7 @@ public:
bool saveLength;
qreal depthPosition{INT_MAX};
VBestSquareResData data{};
bool isPortrait{true};
private:
VBestSquareData &operator=(const VBestSquareData &) Q_DECL_EQ_DELETE;

View file

@ -106,6 +106,9 @@ void VLayoutGenerator::Generate(QElapsedTimer timer, qint64 timeout)
bank->Reset();
state = LayoutErrors::NoError;
int width = PageWidth();
int height = PageHeight();
if (VFuzzyComparePossibleNulls(shift, -1))
{
if (bank->PrepareDetails())
@ -118,9 +121,6 @@ void VLayoutGenerator::Generate(QElapsedTimer timer, qint64 timeout)
return;
}
int width = PageWidth();
int height = PageHeight();
if (stripOptimization)
{
const qreal b = bank->GetBiggestDiagonal() * multiplier + bank->GetLayoutWidth();
@ -172,7 +172,7 @@ void VLayoutGenerator::Generate(QElapsedTimer timer, qint64 timeout)
return;
}
VLayoutPaper paper(PageHeight(), PageWidth(), bank->GetLayoutWidth());
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
paper.SetShift(shift);
paper.SetPaperIndex(static_cast<quint32>(papers.count()));
paper.SetRotate(rotate);

View file

@ -243,7 +243,7 @@ int VLayoutPaper::Count() const
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPaper::AddToSheet(const VLayoutPiece &detail, std::atomic_bool &stop)
{
VBestSquare bestResult(d->globalContour.GetSize(), d->saveLength);
VBestSquare bestResult(d->globalContour.GetSize(), d->saveLength, d->originPaperOrientation);
QThreadPool *thread_pool = QThreadPool::globalInstance();
thread_pool->setExpiryTimeout(1000);
QVector<VPosition *> threads;

View file

@ -136,7 +136,7 @@ QPainterPath DrawDetails(const QVector<VLayoutPiece> &details)
//---------------------------------------------------------------------------------------------------------------------
VPosition::VPosition(const VPositionData &data, std::atomic_bool *stop, bool saveLength)
: QRunnable(),
m_bestResult(VBestSquare(data.gContour.GetSize(), saveLength)),
m_bestResult(VBestSquare(data.gContour.GetSize(), saveLength, data.isOriginPaperOrientationPortrait)),
m_data(data),
#ifdef LAYOUT_DEBUG
paperIndex(0),