Enable rotation only for workpieces that forbid flipping. ref #560.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-09-06 16:00:25 +03:00
parent c72f57e7e2
commit ef576d7646
5 changed files with 89 additions and 67 deletions

View File

@ -250,20 +250,6 @@ qreal VBank::GetBiggestDiagonal() const
return diagonal; return diagonal;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VBank::IsForbiddenFlipping() const
{
for (int i = 0; i < details.size(); ++i)
{
if (details.at(i).getForbidFlipping())
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VBank::ArrangedCount() const int VBank::ArrangedCount() const
{ {

View File

@ -72,8 +72,6 @@ public:
qreal GetBiggestDiagonal() const; qreal GetBiggestDiagonal() const;
bool IsForbiddenFlipping() const;
private: private:
Q_DISABLE_COPY(VBank) Q_DISABLE_COPY(VBank)
QVector<VLayoutDetail> details; QVector<VLayoutDetail> details;

View File

@ -85,12 +85,6 @@ void VLayoutGenerator::Generate()
papers.clear(); papers.clear();
state = LayoutErrors::NoError; state = LayoutErrors::NoError;
if (bank->IsForbiddenFlipping() && not rotate)
{ // Compensate forbidden flipping by rotating. 180 degree will be enough.
rotate = true;
rotationIncrease = 180;
}
#ifdef LAYOUT_DEBUG #ifdef LAYOUT_DEBUG
const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug"); const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug");
QDir debugDir(path); QDir debugDir(path);

View File

@ -135,30 +135,35 @@ void VLayoutPaper::SetShift(quint32 shift)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VLayoutPaper::GetRotate() const bool VLayoutPaper::GetRotate() const
{ {
return d->rotate; return d->globalRotate;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetRotate(bool value) void VLayoutPaper::SetRotate(bool value)
{ {
d->rotate = value; d->globalRotate = value;
d->localRotate = d->globalRotate;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VLayoutPaper::GetRotationIncrease() const int VLayoutPaper::GetRotationIncrease() const
{ {
return d->rotationIncrease; return d->globalRotationIncrease;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetRotationIncrease(int value) void VLayoutPaper::SetRotationIncrease(int value)
{ {
d->rotationIncrease = value; d->globalRotationIncrease = value;
if ((d->rotationIncrease >= 1 && d->rotationIncrease <= 180 && 360 % d->rotationIncrease == 0) == false) if ((d->globalRotationIncrease >= 1
&& d->globalRotationIncrease <= 180
&& 360 % d->globalRotationIncrease == 0) == false)
{ {
d->rotationIncrease = 180; d->globalRotationIncrease = 180;
} }
d->localRotationIncrease = d->globalRotationIncrease;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -193,6 +198,17 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, volatile bool &sto
return false;//Not enough edges return false;//Not enough edges
} }
if (detail.getForbidFlipping() && not d->globalRotate)
{ // Compensate forbidden flipping by rotating. 180 degree will be enough.
d->localRotate = true;
d->localRotationIncrease = 180;
}
else
{ // Return to global values if was changed
d->localRotate = d->globalRotate;
d->localRotationIncrease = d->globalRotationIncrease;
}
d->frame = 0; d->frame = 0;
return AddToSheet(detail, stop); return AddToSheet(detail, stop);
@ -216,7 +232,8 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop)
{ {
for (int i=1; i<= detail.EdgesCount(); ++i) for (int i=1; i<= detail.EdgesCount(); ++i)
{ {
VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop, d->rotate, d->rotationIncrease, VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop, d->localRotate,
d->localRotationIncrease,
d->saveLength); d->saveLength);
//Info for debug //Info for debug
#ifdef LAYOUT_DEBUG #ifdef LAYOUT_DEBUG
@ -230,7 +247,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop)
threads.append(thread); threads.append(thread);
thread_pool->start(thread); thread_pool->start(thread);
d->frame = d->frame + 3 + static_cast<quint32>(360/d->rotationIncrease*2); d->frame = d->frame + 3 + static_cast<quint32>(360/d->localRotationIncrease*2);
} }
} }

View File

@ -43,19 +43,44 @@ class VLayoutPaperData : public QSharedData
{ {
public: public:
VLayoutPaperData() VLayoutPaperData()
:details(QVector<VLayoutDetail>()), globalContour(VContour()), paperIndex(0), frame(0), layoutWidth(0), : details(QVector<VLayoutDetail>()),
rotate(true), rotationIncrease(180), saveLength(false) globalContour(VContour()),
paperIndex(0),
frame(0),
layoutWidth(0),
globalRotate(true),
localRotate(true),
globalRotationIncrease(180),
localRotationIncrease(180),
saveLength(false)
{} {}
VLayoutPaperData(int height, int width) VLayoutPaperData(int height,
:details(QVector<VLayoutDetail>()), globalContour(VContour(height, width)), paperIndex(0), frame(0), int width)
layoutWidth(0), rotate(true), rotationIncrease(180), saveLength(false) : details(QVector<VLayoutDetail>()),
globalContour(VContour(height, width)),
paperIndex(0),
frame(0),
layoutWidth(0),
globalRotate(true),
localRotate(true),
globalRotationIncrease(180),
localRotationIncrease(180),
saveLength(false)
{} {}
VLayoutPaperData(const VLayoutPaperData &paper) VLayoutPaperData(const VLayoutPaperData &paper)
:QSharedData(paper), details(paper.details), globalContour(paper.globalContour), paperIndex(paper.paperIndex), : QSharedData(paper),
frame(paper.frame), layoutWidth(paper.layoutWidth), rotate(paper.rotate), details(paper.details),
rotationIncrease(paper.rotationIncrease), saveLength(paper.saveLength) globalContour(paper.globalContour),
paperIndex(paper.paperIndex),
frame(paper.frame),
layoutWidth(paper.layoutWidth),
globalRotate(paper.globalRotate),
localRotate(paper.localRotate),
globalRotationIncrease(paper.globalRotationIncrease),
localRotationIncrease(paper.localRotationIncrease),
saveLength(paper.saveLength)
{} {}
~VLayoutPaperData() {} ~VLayoutPaperData() {}
@ -69,8 +94,10 @@ public:
quint32 paperIndex; quint32 paperIndex;
quint32 frame; quint32 frame;
qreal layoutWidth; qreal layoutWidth;
bool rotate; bool globalRotate;
int rotationIncrease; bool localRotate;
int globalRotationIncrease;
int localRotationIncrease;
bool saveLength; bool saveLength;
private: private: