New options: rotatate and rotation increase.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-22 16:11:50 +02:00
parent dd098506dd
commit ef73b351ed
11 changed files with 464 additions and 166 deletions

View File

@ -153,6 +153,37 @@ void DialogLayoutSettings::SetGroup(const Cases &value)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::GetRotate() const
{
return ui->groupBoxRotate->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetRotate(bool state)
{
ui->groupBoxRotate->setChecked(state);
}
//---------------------------------------------------------------------------------------------------------------------
int DialogLayoutSettings::GetIncrease() const
{
return ui->comboBoxIncrease->currentText().toInt();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetIncrease(int increase)
{
int index = ui->comboBoxIncrease->findText(QString::number(increase));
if (index == -1)
{
index = 21;
}
ui->comboBoxIncrease->setCurrentIndex(index);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::TemplateSelected() void DialogLayoutSettings::TemplateSelected()
{ {

View File

@ -61,6 +61,12 @@ public:
Cases GetGroup() const; Cases GetGroup() const;
void SetGroup(const Cases &value); void SetGroup(const Cases &value);
bool GetRotate() const;
void SetRotate(bool state);
int GetIncrease() const;
void SetIncrease(int increase);
public slots: public slots:
void ConvertPaperSize(); void ConvertPaperSize();
void ConvertLayoutSize(); void ConvertLayoutSize();

View File

@ -6,182 +6,344 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>659</width> <width>661</width>
<height>273</height> <height>289</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Creation a layout</string> <string>Creation a layout</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QGroupBox" name="groupBoxPaperSize"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="title"> <item>
<string>Paper size</string> <widget class="QGroupBox" name="groupBoxPaperSize">
</property> <property name="title">
<layout class="QVBoxLayout" name="verticalLayout"> <string>Paper size</string>
<item> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <property name="flat">
<property name="spacing"> <bool>false</bool>
<number>6</number> </property>
</property> <property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizePolicy"> <property name="spacing">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <number>6</number>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text">
<string>Templates:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxTemplates"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QComboBox" name="comboBoxPaperSizeUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>124</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelHeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperHeight">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperWidth">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.990000000005239</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelSizeDescription">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QToolButton" name="toolButtonPortrate"> <widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>...</string> <string>Templates:</string>
</property> </property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/16x16/portrait.png</normaloff>:/icon/16x16/portrait.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonLandscape"> <widget class="QComboBox" name="comboBoxTemplates"/>
<property name="text"> </item>
<string>...</string> </layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QComboBox" name="comboBoxPaperSizeUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="icon"> <property name="minimumSize">
<iconset resource="../../share/resources/icon.qrc"> <size>
<normaloff>:/icon/16x16/landscape.png</normaloff>:/icon/16x16/landscape.png</iconset> <width>124</width>
<height>0</height>
</size>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="labelWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelHeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperHeight">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxPaperWidth">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.990000000005239</double>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelSizeDescription">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButtonPortrate">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/16x16/portrait.png</normaloff>:/icon/16x16/portrait.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonLandscape">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/16x16/landscape.png</normaloff>:/icon/16x16/landscape.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
</item> </widget>
</layout> </item>
</widget> <item>
<widget class="QGroupBox" name="groupBoxRotate">
<property name="title">
<string>Rotate workpiece</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Rotate by</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxIncrease">
<property name="currentIndex">
<number>21</number>
</property>
<item>
<property name="text">
<string notr="true">1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">5</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">6</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">8</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">9</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">10</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">12</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">15</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">18</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">20</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">24</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">30</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">36</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">40</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">45</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">60</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">72</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">90</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">180</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>degree</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxCreationOptions"> <widget class="QGroupBox" name="groupBoxCreationOptions">
@ -349,7 +511,7 @@
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroupPrinciple"/> <buttongroup name="buttonGroupPrinciple"/>
<buttongroup name="buttonGroup"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -285,6 +285,8 @@ void TableWindow::Layout()
lGenerator.SetPaperHeight(layout.GetPaperHeight()); lGenerator.SetPaperHeight(layout.GetPaperHeight());
lGenerator.SetPaperWidth(layout.GetPaperWidth()); lGenerator.SetPaperWidth(layout.GetPaperWidth());
lGenerator.SetShift(layout.GetShift()); lGenerator.SetShift(layout.GetShift());
lGenerator.SetRotate(layout.GetRotate());
lGenerator.SetRotationIncrease(layout.GetIncrease());
DialogLayoutProgress progress(listDetails.count(), this); DialogLayoutProgress progress(listDetails.count(), this);

View File

@ -38,7 +38,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) stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true), rotationIncrease(180)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -101,6 +101,8 @@ void VLayoutGenerator::Generate()
paper.SetShift(shift); paper.SetShift(shift);
paper.SetLayoutWidth(bank->GetLayoutWidth()); paper.SetLayoutWidth(bank->GetLayoutWidth());
paper.SetPaperIndex(papers.count()); paper.SetPaperIndex(papers.count());
paper.SetRotate(rotate);
paper.SetRotationIncrease(rotationIncrease);
do do
{ {
const int index = bank->GetTiket(); const int index = bank->GetTiket();
@ -170,6 +172,35 @@ void VLayoutGenerator::Abort()
state = LayoutErrors::ProcessStoped; state = LayoutErrors::ProcessStoped;
} }
//---------------------------------------------------------------------------------------------------------------------
int VLayoutGenerator::GetRotationIncrease() const
{
return rotationIncrease;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetRotationIncrease(int value)
{
rotationIncrease = value;
if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false)
{
rotationIncrease = 180;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::GetRotate() const
{
return rotate;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetRotate(bool value)
{
rotate = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::CheckDetailsSize() void VLayoutGenerator::CheckDetailsSize()
{ {

View File

@ -66,6 +66,12 @@ public:
QList<QGraphicsItem *> GetItems() const; QList<QGraphicsItem *> GetItems() const;
bool GetRotate() const;
void SetRotate(bool value);
int GetRotationIncrease() const;
void SetRotationIncrease(int value);
signals: signals:
void Start(); void Start();
void Arranged(int count); void Arranged(int count);
@ -84,6 +90,8 @@ private:
bool stopGeneration; bool stopGeneration;
LayoutErrors state; LayoutErrors state;
unsigned int shift; unsigned int shift;
bool rotate;
int rotationIncrease;
void CheckDetailsSize(); void CheckDetailsSize();
}; };

View File

@ -122,6 +122,35 @@ void VLayoutPaper::SetShift(unsigned int shift)
d->globalContour.SetShift(shift); d->globalContour.SetShift(shift);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPaper::GetRotate() const
{
return d->rotate;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetRotate(bool value)
{
d->rotate = value;
}
//---------------------------------------------------------------------------------------------------------------------
int VLayoutPaper::GetRotationIncrease() const
{
return d->rotationIncrease;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetRotationIncrease(int value)
{
d->rotationIncrease = value;
if ((d->rotationIncrease >= 1 && d->rotationIncrease <= 180 && 360 % d->rotationIncrease == 0) == false)
{
d->rotationIncrease = 180;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPaper::SetPaperIndex(quint32 index) void VLayoutPaper::SetPaperIndex(quint32 index)
{ {
@ -164,7 +193,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, 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); VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop, d->rotate, d->rotationIncrease);
//Info for debug //Info for debug
#ifdef LAYOUT_DEBUG #ifdef LAYOUT_DEBUG
thread->setPaperIndex(d->paperIndex); thread->setPaperIndex(d->paperIndex);
@ -177,7 +206,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
threads.append(thread); threads.append(thread);
thread_pool->start(thread); thread_pool->start(thread);
d->frame = d->frame + 3 + 360/180*2; d->frame = d->frame + 3 + 360/d->rotationIncrease*2;
} }
} }

View File

@ -64,6 +64,12 @@ public:
unsigned int GetShift() const; unsigned int GetShift() const;
void SetShift(unsigned int shift); void SetShift(unsigned int shift);
bool GetRotate() const;
void SetRotate(bool value);
int GetRotationIncrease() const;
void SetRotationIncrease(int value);
void SetPaperIndex(quint32 index); void SetPaperIndex(quint32 index);
bool ArrangeDetail(const VLayoutDetail &detail, bool &stop); bool ArrangeDetail(const VLayoutDetail &detail, bool &stop);

View File

@ -45,17 +45,19 @@ 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)
{} {}
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) layoutWidth(0), rotate(true), rotationIncrease(180)
{} {}
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) frame(paper.frame), layoutWidth(paper.layoutWidth), rotate(paper.rotate),
rotationIncrease(paper.rotationIncrease)
{} {}
~VLayoutPaperData() {} ~VLayoutPaperData() {}
@ -69,6 +71,8 @@ public:
quint32 paperIndex; quint32 paperIndex;
quint32 frame; quint32 frame;
qreal layoutWidth; qreal layoutWidth;
bool rotate;
int rotationIncrease;
}; };
#ifdef Q_CC_GNU #ifdef Q_CC_GNU

View File

@ -38,10 +38,16 @@
#include <QCoreApplication> #include <QCoreApplication>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop) VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop, bool rotate,
int rotationIncrease)
:QRunnable(), bestResult(VBestSquare()), gContour(gContour), detail(detail), i(i), j(j), paperIndex(0), frame(0), :QRunnable(), bestResult(VBestSquare()), gContour(gContour), detail(detail), i(i), j(j), paperIndex(0), frame(0),
detailsCount(0), details(QVector<VLayoutDetail>()), stop(stop) detailsCount(0), details(QVector<VLayoutDetail>()), stop(stop), rotate(rotate), rotationIncrease(rotationIncrease)
{} {
if ((rotationIncrease >= 1 && rotationIncrease <= 180 && 360 % rotationIncrease == 0) == false)
{
rotationIncrease = 180;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPosition::run() void VPosition::run()
@ -69,7 +75,17 @@ void VPosition::run()
} }
frame = frame + 3; frame = frame + 3;
Rotate(180); if (rotate)
{
Rotate(rotationIncrease);
}
else
{
if (gContour.GetContour().isEmpty())
{
Rotate(rotationIncrease);
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,8 @@ class QPainterPath;
class VPosition : public QRunnable class VPosition : public QRunnable
{ {
public: public:
VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop); VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop, bool rotate,
int rotationIncrease);
virtual ~VPosition(){} virtual ~VPosition(){}
virtual void run(); virtual void run();
@ -79,6 +80,8 @@ private:
quint32 detailsCount; quint32 detailsCount;
QVector<VLayoutDetail> details; QVector<VLayoutDetail> details;
bool *stop; bool *stop;
bool rotate;
int rotationIncrease;
enum class CrossingType : char enum class CrossingType : char
{ {