Enable rotation only for workpieces that forbid flipping. ref #560.
--HG-- branch : develop
This commit is contained in:
parent
c72f57e7e2
commit
ef576d7646
|
@ -250,20 +250,6 @@ qreal VBank::GetBiggestDiagonal() const
|
|||
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
|
||||
{
|
||||
|
|
|
@ -72,8 +72,6 @@ public:
|
|||
|
||||
qreal GetBiggestDiagonal() const;
|
||||
|
||||
bool IsForbiddenFlipping() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VBank)
|
||||
QVector<VLayoutDetail> details;
|
||||
|
|
|
@ -85,12 +85,6 @@ void VLayoutGenerator::Generate()
|
|||
papers.clear();
|
||||
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
|
||||
const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug");
|
||||
QDir debugDir(path);
|
||||
|
|
|
@ -135,30 +135,35 @@ void VLayoutPaper::SetShift(quint32 shift)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPaper::GetRotate() const
|
||||
{
|
||||
return d->rotate;
|
||||
return d->globalRotate;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutPaper::SetRotate(bool value)
|
||||
{
|
||||
d->rotate = value;
|
||||
d->globalRotate = value;
|
||||
d->localRotate = d->globalRotate;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VLayoutPaper::GetRotationIncrease() const
|
||||
{
|
||||
return d->rotationIncrease;
|
||||
return d->globalRotationIncrease;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
//Info for debug
|
||||
#ifdef LAYOUT_DEBUG
|
||||
|
@ -230,7 +247,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop)
|
|||
threads.append(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,19 +43,44 @@ class VLayoutPaperData : public QSharedData
|
|||
{
|
||||
public:
|
||||
VLayoutPaperData()
|
||||
:details(QVector<VLayoutDetail>()), globalContour(VContour()), paperIndex(0), frame(0), layoutWidth(0),
|
||||
rotate(true), rotationIncrease(180), saveLength(false)
|
||||
: details(QVector<VLayoutDetail>()),
|
||||
globalContour(VContour()),
|
||||
paperIndex(0),
|
||||
frame(0),
|
||||
layoutWidth(0),
|
||||
globalRotate(true),
|
||||
localRotate(true),
|
||||
globalRotationIncrease(180),
|
||||
localRotationIncrease(180),
|
||||
saveLength(false)
|
||||
{}
|
||||
|
||||
VLayoutPaperData(int height, int width)
|
||||
:details(QVector<VLayoutDetail>()), globalContour(VContour(height, width)), paperIndex(0), frame(0),
|
||||
layoutWidth(0), rotate(true), rotationIncrease(180), saveLength(false)
|
||||
VLayoutPaperData(int height,
|
||||
int width)
|
||||
: 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)
|
||||
:QSharedData(paper), details(paper.details), globalContour(paper.globalContour), paperIndex(paper.paperIndex),
|
||||
frame(paper.frame), layoutWidth(paper.layoutWidth), rotate(paper.rotate),
|
||||
rotationIncrease(paper.rotationIncrease), saveLength(paper.saveLength)
|
||||
: QSharedData(paper),
|
||||
details(paper.details),
|
||||
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() {}
|
||||
|
@ -69,8 +94,10 @@ public:
|
|||
quint32 paperIndex;
|
||||
quint32 frame;
|
||||
qreal layoutWidth;
|
||||
bool rotate;
|
||||
int rotationIncrease;
|
||||
bool globalRotate;
|
||||
bool localRotate;
|
||||
int globalRotationIncrease;
|
||||
int localRotationIncrease;
|
||||
bool saveLength;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user