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;
}
//---------------------------------------------------------------------------------------------------------------------
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
{

View File

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

View File

@ -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);

View File

@ -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);
}
}

View File

@ -1,30 +1,30 @@
/************************************************************************
**
** @file vlayoutpaper_p.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 8 1, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
**
** @file vlayoutpaper_p.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 8 1, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VLAYOUTPAPER_P_H
#define VLAYOUTPAPER_P_H
@ -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,12 +94,14 @@ public:
quint32 paperIndex;
quint32 frame;
qreal layoutWidth;
bool rotate;
int rotationIncrease;
bool globalRotate;
bool localRotate;
int globalRotationIncrease;
int localRotationIncrease;
bool saveLength;
private:
VLayoutPaperData &operator=(const VLayoutPaperData &) Q_DECL_EQ_DELETE;
VLayoutPaperData& operator=(const VLayoutPaperData&) Q_DECL_EQ_DELETE;
};
QT_WARNING_POP