New Layout setting "Save length of the sheet".
--HG-- branch : develop
This commit is contained in:
parent
cfca4b55de
commit
56c027686d
|
@ -214,6 +214,18 @@ void DialogLayoutSettings::SetAutoCrop(bool autoCrop)
|
||||||
ui->checkBoxAutoCrop->setChecked(autoCrop);
|
ui->checkBoxAutoCrop->setChecked(autoCrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogLayoutSettings::IsSaveLength() const
|
||||||
|
{
|
||||||
|
return ui->checkBoxSaveLength->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLayoutSettings::SetSaveLength(bool save)
|
||||||
|
{
|
||||||
|
ui->checkBoxSaveLength->setChecked(save);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLayoutSettings::TemplateSelected()
|
void DialogLayoutSettings::TemplateSelected()
|
||||||
{
|
{
|
||||||
|
@ -315,6 +327,7 @@ void DialogLayoutSettings::DialogAccepted()
|
||||||
generator->SetRotate(GetRotate());
|
generator->SetRotate(GetRotate());
|
||||||
generator->SetRotationIncrease(GetIncrease());
|
generator->SetRotationIncrease(GetIncrease());
|
||||||
generator->SetAutoCrop(GetAutoCrop());
|
generator->SetAutoCrop(GetAutoCrop());
|
||||||
|
generator->SetSaveLength(IsSaveLength());
|
||||||
|
|
||||||
accepted();
|
accepted();
|
||||||
}
|
}
|
||||||
|
@ -402,61 +415,85 @@ QSizeF DialogLayoutSettings::Template()
|
||||||
{
|
{
|
||||||
case PaperSizeTemplate::A0:
|
case PaperSizeTemplate::A0:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(1189, Unit::Mm, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(1189, Unit::Mm, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::A1:
|
case PaperSizeTemplate::A1:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::A2:
|
case PaperSizeTemplate::A2:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::A3:
|
case PaperSizeTemplate::A3:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::A4:
|
case PaperSizeTemplate::A4:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(210, Unit::Mm, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(210, Unit::Mm, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Letter:
|
case PaperSizeTemplate::Letter:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(8.5, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(8.5, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Legal:
|
case PaperSizeTemplate::Legal:
|
||||||
SetAutoCrop(false);
|
SetAutoCrop(false);
|
||||||
|
SetSaveLength(false);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(17, Unit::Inch, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(17, Unit::Inch, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll24in:
|
case PaperSizeTemplate::Roll24in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
|
SetSaveLength(true);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll30in:
|
case PaperSizeTemplate::Roll30in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
|
SetSaveLength(true);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll36in:
|
case PaperSizeTemplate::Roll36in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
|
SetSaveLength(true);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll42in:
|
case PaperSizeTemplate::Roll42in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
|
SetSaveLength(true);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
case PaperSizeTemplate::Roll44in:
|
case PaperSizeTemplate::Roll44in:
|
||||||
SetAutoCrop(true);
|
SetAutoCrop(true);
|
||||||
|
SetSaveLength(true);
|
||||||
|
|
||||||
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
|
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
|
||||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
|
|
|
@ -72,6 +72,9 @@ public:
|
||||||
bool GetAutoCrop() const;
|
bool GetAutoCrop() const;
|
||||||
void SetAutoCrop(bool crop);
|
void SetAutoCrop(bool crop);
|
||||||
|
|
||||||
|
bool IsSaveLength() const;
|
||||||
|
void SetSaveLength(bool save);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ConvertPaperSize();
|
void ConvertPaperSize();
|
||||||
void ConvertLayoutSize();
|
void ConvertLayoutSize();
|
||||||
|
|
|
@ -17,10 +17,6 @@
|
||||||
<iconset resource="../../share/resources/icon.qrc">
|
<iconset resource="../../share/resources/icon.qrc">
|
||||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
|
||||||
<iconset resource="../../share/resources/icon.qrc">
|
|
||||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
@ -429,6 +425,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxSaveLength">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save length of the sheet</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxCase">
|
<widget class="QGroupBox" name="groupBoxCase">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
|
@ -29,39 +29,60 @@
|
||||||
#include "vbestsquare.h"
|
#include "vbestsquare.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VBestSquare::VBestSquare()
|
VBestSquare::VBestSquare(const QSizeF &sheetSize, bool saveLength)
|
||||||
:resI(0), resJ(0), resMatrix(QMatrix()), resSquare(LLONG_MAX), valideResult(false), resMirror(false),
|
:resI(0), resJ(0), resMatrix(QMatrix()), bestSize(QSizeF(sheetSize.width()+10, sheetSize.height()+10)),
|
||||||
type (BestFrom::Rotation)
|
sheetWidth(sheetSize.width()), valideResult(false), resMirror(false), type (BestFrom::Rotation),
|
||||||
|
saveLength(saveLength)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VBestSquare::NewResult(qint64 square, int i, int j, const QTransform &matrix, bool mirror, BestFrom type)
|
void VBestSquare::NewResult(const QSizeF &candidate, int i, int j, const QTransform &matrix, bool mirror, BestFrom type)
|
||||||
{
|
{
|
||||||
if (square <= resSquare && square > 0 && type >= this->type)
|
if (saveLength)
|
||||||
{
|
{
|
||||||
|
const QSizeF saveLengthSize(sheetWidth, candidate.height());
|
||||||
|
if (Square(saveLengthSize) <= Square(bestSize) && Square(saveLengthSize) > 0 && type >= this->type)
|
||||||
|
{
|
||||||
|
bestSize = saveLengthSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Square(candidate) <= Square(bestSize) && Square(candidate) > 0 && type >= this->type)
|
||||||
|
{
|
||||||
|
bestSize = candidate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resI = i;
|
resI = i;
|
||||||
resJ = j;
|
resJ = j;
|
||||||
resMatrix = matrix;
|
resMatrix = matrix;
|
||||||
resSquare = square;
|
|
||||||
valideResult = true;
|
valideResult = true;
|
||||||
resMirror = mirror;
|
resMirror = mirror;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VBestSquare::NewResult(const VBestSquare &best)
|
void VBestSquare::NewResult(const VBestSquare &best)
|
||||||
{
|
{
|
||||||
if (best.ValidResult())
|
if (best.ValidResult() && saveLength == best.IsSaveLength())
|
||||||
{
|
{
|
||||||
NewResult(best.BestSquare(), best.GContourEdge(), best.DetailEdge(), best.Matrix(), best.Mirror(), best.Type());
|
NewResult(best.BestSize(), best.GContourEdge(), best.DetailEdge(), best.Matrix(), best.Mirror(), best.Type());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qint64 VBestSquare::BestSquare() const
|
QSizeF VBestSquare::BestSize() const
|
||||||
{
|
{
|
||||||
return resSquare;
|
return bestSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -99,3 +120,15 @@ BestFrom VBestSquare::Type() const
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VBestSquare::IsSaveLength() const
|
||||||
|
{
|
||||||
|
return saveLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qint64 VBestSquare::Square(const QSizeF &size)
|
||||||
|
{
|
||||||
|
return static_cast<qint64>(size.width()*size.height());
|
||||||
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@
|
||||||
class VBestSquare
|
class VBestSquare
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VBestSquare();
|
VBestSquare(const QSizeF &sheetSize, bool saveLength);
|
||||||
|
|
||||||
void NewResult(qint64 square, int i, int j, const QTransform &matrix, bool mirror, BestFrom type);
|
void NewResult(const QSizeF &candidate, int i, int j, const QTransform &matrix, bool mirror, BestFrom type);
|
||||||
void NewResult(const VBestSquare &best);
|
void NewResult(const VBestSquare &best);
|
||||||
|
|
||||||
qint64 BestSquare() const;
|
QSizeF BestSize() const;
|
||||||
int GContourEdge() const;
|
int GContourEdge() const;
|
||||||
int DetailEdge() const;
|
int DetailEdge() const;
|
||||||
QTransform Matrix() const;
|
QTransform Matrix() const;
|
||||||
|
@ -49,15 +49,21 @@ public:
|
||||||
bool Mirror() const;
|
bool Mirror() const;
|
||||||
BestFrom Type() const;
|
BestFrom Type() const;
|
||||||
|
|
||||||
|
bool IsSaveLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// All nedded information about best result
|
// All nedded information about best result
|
||||||
int resI; // Edge of global contour
|
int resI; // Edge of global contour
|
||||||
int resJ; // Edge of detail
|
int resJ; // Edge of detail
|
||||||
QTransform resMatrix; // Matrix for rotation and translation detail
|
QTransform resMatrix; // Matrix for rotation and translation detail
|
||||||
qint64 resSquare; // Best square size (least). For begin set max value.
|
QSizeF bestSize;
|
||||||
|
qreal sheetWidth;
|
||||||
bool valideResult;
|
bool valideResult;
|
||||||
bool resMirror;
|
bool resMirror;
|
||||||
BestFrom type;
|
BestFrom type;
|
||||||
|
bool saveLength;
|
||||||
|
|
||||||
|
static qint64 Square(const QSizeF &size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VBESTSQUARE_H
|
#endif // VBESTSQUARE_H
|
||||||
|
|
|
@ -116,6 +116,12 @@ void VContour::SetWidth(int width)
|
||||||
d->paperWidth = width;
|
d->paperWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QSizeF VContour::GetSize() const
|
||||||
|
{
|
||||||
|
return QSizeF(d->paperWidth, d->paperHeight);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QPointF> VContour::UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const
|
QVector<QPointF> VContour::UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
|
#include <QSizeF>
|
||||||
|
|
||||||
class VContourData;
|
class VContourData;
|
||||||
class QPointF;
|
class QPointF;
|
||||||
|
@ -60,6 +61,8 @@ public:
|
||||||
int GetWidth() const;
|
int GetWidth() const;
|
||||||
void SetWidth(int width);
|
void SetWidth(int width);
|
||||||
|
|
||||||
|
QSizeF GetSize() const;
|
||||||
|
|
||||||
QVector<QPointF> UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const;
|
QVector<QPointF> UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const;
|
||||||
|
|
||||||
int EdgesCount() const;
|
int EdgesCount() const;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
||||||
:QObject(parent), papers(QVector<VLayoutPaper>()), bank(new VBank()), paperHeight(0), paperWidth(0),
|
:QObject(parent), papers(QVector<VLayoutPaper>()), bank(new VBank()), paperHeight(0), paperWidth(0),
|
||||||
stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true), rotationIncrease(180),
|
stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true), rotationIncrease(180),
|
||||||
autoCrop(false)
|
autoCrop(false), saveLength(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -106,6 +106,7 @@ void VLayoutGenerator::Generate()
|
||||||
paper.SetPaperIndex(static_cast<quint32>(papers.count()));
|
paper.SetPaperIndex(static_cast<quint32>(papers.count()));
|
||||||
paper.SetRotate(rotate);
|
paper.SetRotate(rotate);
|
||||||
paper.SetRotationIncrease(rotationIncrease);
|
paper.SetRotationIncrease(rotationIncrease);
|
||||||
|
paper.SetSaveLength(saveLength);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const int index = bank->GetTiket();
|
const int index = bank->GetTiket();
|
||||||
|
@ -189,6 +190,18 @@ void VLayoutGenerator::Abort()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VLayoutGenerator::IsSaveLength() const
|
||||||
|
{
|
||||||
|
return saveLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutGenerator::SetSaveLength(bool value)
|
||||||
|
{
|
||||||
|
saveLength = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VLayoutGenerator::GetAutoCrop() const
|
bool VLayoutGenerator::GetAutoCrop() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
bool GetAutoCrop() const;
|
bool GetAutoCrop() const;
|
||||||
void SetAutoCrop(bool value);
|
void SetAutoCrop(bool value);
|
||||||
|
|
||||||
|
bool IsSaveLength() const;
|
||||||
|
void SetSaveLength(bool value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Start();
|
void Start();
|
||||||
void Arranged(int count);
|
void Arranged(int count);
|
||||||
|
@ -97,6 +100,7 @@ private:
|
||||||
bool rotate;
|
bool rotate;
|
||||||
int rotationIncrease;
|
int rotationIncrease;
|
||||||
bool autoCrop;
|
bool autoCrop;
|
||||||
|
bool saveLength;
|
||||||
|
|
||||||
void CheckDetailsSize();
|
void CheckDetailsSize();
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,6 +147,18 @@ void VLayoutPaper::SetRotationIncrease(int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VLayoutPaper::IsSaveLength() const
|
||||||
|
{
|
||||||
|
return d->saveLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutPaper::SetSaveLength(bool value)
|
||||||
|
{
|
||||||
|
d->saveLength = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutPaper::SetPaperIndex(quint32 index)
|
void VLayoutPaper::SetPaperIndex(quint32 index)
|
||||||
{
|
{
|
||||||
|
@ -181,7 +193,7 @@ int VLayoutPaper::Count() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop)
|
bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, volatile bool &stop)
|
||||||
{
|
{
|
||||||
VBestSquare bestResult;
|
VBestSquare bestResult(d->globalContour.GetSize(), d->saveLength);
|
||||||
QThreadPool *thread_pool = QThreadPool::globalInstance();
|
QThreadPool *thread_pool = QThreadPool::globalInstance();
|
||||||
thread_pool->setExpiryTimeout(1000);
|
thread_pool->setExpiryTimeout(1000);
|
||||||
QVector<VPosition *> threads;
|
QVector<VPosition *> threads;
|
||||||
|
@ -190,7 +202,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->rotate, d->rotationIncrease,
|
||||||
|
d->saveLength);
|
||||||
//Info for debug
|
//Info for debug
|
||||||
#ifdef LAYOUT_DEBUG
|
#ifdef LAYOUT_DEBUG
|
||||||
thread->setPaperIndex(d->paperIndex);
|
thread->setPaperIndex(d->paperIndex);
|
||||||
|
|
|
@ -65,6 +65,9 @@ public:
|
||||||
int GetRotationIncrease() const;
|
int GetRotationIncrease() const;
|
||||||
void SetRotationIncrease(int value);
|
void SetRotationIncrease(int value);
|
||||||
|
|
||||||
|
bool IsSaveLength() const;
|
||||||
|
void SetSaveLength(bool value);
|
||||||
|
|
||||||
void SetPaperIndex(quint32 index);
|
void SetPaperIndex(quint32 index);
|
||||||
|
|
||||||
bool ArrangeDetail(const VLayoutDetail &detail, volatile bool &stop);
|
bool ArrangeDetail(const VLayoutDetail &detail, volatile bool &stop);
|
||||||
|
|
|
@ -46,18 +46,18 @@ class VLayoutPaperData : public QSharedData
|
||||||
public:
|
public:
|
||||||
VLayoutPaperData()
|
VLayoutPaperData()
|
||||||
:details(QVector<VLayoutDetail>()), globalContour(VContour()), paperIndex(0), frame(0), layoutWidth(0),
|
:details(QVector<VLayoutDetail>()), globalContour(VContour()), paperIndex(0), frame(0), layoutWidth(0),
|
||||||
rotate(true), rotationIncrease(180)
|
rotate(true), rotationIncrease(180), saveLength(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VLayoutPaperData(int height, int width)
|
VLayoutPaperData(int height, int width)
|
||||||
:details(QVector<VLayoutDetail>()), globalContour(VContour(height, width)), paperIndex(0), frame(0),
|
:details(QVector<VLayoutDetail>()), globalContour(VContour(height, width)), paperIndex(0), frame(0),
|
||||||
layoutWidth(0), rotate(true), rotationIncrease(180)
|
layoutWidth(0), rotate(true), rotationIncrease(180), saveLength(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VLayoutPaperData(const VLayoutPaperData &paper)
|
VLayoutPaperData(const VLayoutPaperData &paper)
|
||||||
:QSharedData(paper), details(paper.details), globalContour(paper.globalContour), paperIndex(paper.paperIndex),
|
:QSharedData(paper), details(paper.details), globalContour(paper.globalContour), paperIndex(paper.paperIndex),
|
||||||
frame(paper.frame), layoutWidth(paper.layoutWidth), rotate(paper.rotate),
|
frame(paper.frame), layoutWidth(paper.layoutWidth), rotate(paper.rotate),
|
||||||
rotationIncrease(paper.rotationIncrease)
|
rotationIncrease(paper.rotationIncrease), saveLength(paper.saveLength)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~VLayoutPaperData() {}
|
~VLayoutPaperData() {}
|
||||||
|
@ -73,6 +73,7 @@ public:
|
||||||
qreal layoutWidth;
|
qreal layoutWidth;
|
||||||
bool rotate;
|
bool rotate;
|
||||||
int rotationIncrease;
|
int rotationIncrease;
|
||||||
|
bool saveLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
|
|
|
@ -47,9 +47,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop,
|
VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop,
|
||||||
bool rotate, int rotationIncrease)
|
bool rotate, int rotationIncrease, bool saveLength)
|
||||||
:QRunnable(), bestResult(VBestSquare()), gContour(gContour), detail(detail), i(i), j(j), paperIndex(0), frame(0),
|
:QRunnable(), bestResult(VBestSquare(gContour.GetSize(), saveLength)), gContour(gContour), detail(detail), i(i),
|
||||||
detailsCount(0), details(QVector<VLayoutDetail>()), stop(stop), rotate(rotate), rotationIncrease(rotationIncrease)
|
j(j), paperIndex(0), frame(0), detailsCount(0), details(QVector<VLayoutDetail>()), stop(stop), rotate(rotate),
|
||||||
|
rotationIncrease(rotationIncrease)
|
||||||
{
|
{
|
||||||
if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false)
|
if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false)
|
||||||
{
|
{
|
||||||
|
@ -225,9 +226,8 @@ void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutDetail &deta
|
||||||
{
|
{
|
||||||
QVector<QPointF> newGContour = gContour.UniteWithContour(detail, globalI, detJ, type);
|
QVector<QPointF> newGContour = gContour.UniteWithContour(detail, globalI, detJ, type);
|
||||||
newGContour.append(newGContour.first());
|
newGContour.append(newGContour.first());
|
||||||
const QRectF rec = QPolygonF(newGContour).boundingRect();
|
const QSizeF size = QPolygonF(newGContour).boundingRect().size();
|
||||||
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), globalI, detJ, detail.GetMatrix(),
|
bestResult.NewResult(size, globalI, detJ, detail.GetMatrix(), detail.IsMirror(), type);
|
||||||
detail.IsMirror(), type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -47,7 +47,7 @@ class VPosition : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop, bool rotate,
|
VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, volatile bool *stop, bool rotate,
|
||||||
int rotationIncrease);
|
int rotationIncrease, bool saveLength);
|
||||||
virtual ~VPosition(){}
|
virtual ~VPosition(){}
|
||||||
|
|
||||||
quint32 getPaperIndex() const;
|
quint32 getPaperIndex() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user