Resolved issue #290. Add paper type 'Roll - 36" & 'Roll - 44" to 'Create Layout'

paper size.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-02 19:21:47 +03:00
parent 350cc90ced
commit 5766523733
11 changed files with 167 additions and 35 deletions

View File

@ -32,6 +32,7 @@
#include "../../libs/ifc/xml/vdomdocument.h"
#include "../../core/vsettings.h"
#include "../../xml/vabstractmeasurements.h"
#include "../../libs/vlayout/vlayoutgenerator.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
# include "../../../utils/vmath.h"
@ -40,11 +41,13 @@
#endif
enum class PaperSizeTemplate : char { A0, A1, A2, A3, A4, Letter, Legal };
enum class PaperSizeTemplate : char { A0, A1, A2, A3, A4, Letter, Legal, Roll24in, Roll30in, Roll36in, Roll42in,
Roll44in};
//---------------------------------------------------------------------------------------------------------------------
DialogLayoutSettings::DialogLayoutSettings(QWidget *parent)
: QDialog(parent), ui(new Ui::DialogLayoutSettings), oldPaperUnit(Unit::Mm), oldLayoutUnit(Unit::Mm)
DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent)
: QDialog(parent), ui(new Ui::DialogLayoutSettings), oldPaperUnit(Unit::Mm), oldLayoutUnit(Unit::Mm),
generator(generator)
{
ui->setupUi(this);
@ -68,6 +71,9 @@ DialogLayoutSettings::DialogLayoutSettings(QWidget *parent)
connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogLayoutSettings::Swap);
connect(ui->comboBoxLayoutUnit, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &DialogLayoutSettings::ConvertLayoutSize);
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogLayoutSettings::DialogAccepted);
}
//---------------------------------------------------------------------------------------------------------------------
@ -196,6 +202,18 @@ void DialogLayoutSettings::SetIncrease(int increase)
ui->comboBoxIncrease->setCurrentIndex(index);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::GetAutoCrop() const
{
return ui->checkBoxAutoCrop->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetAutoCrop(bool autoCrop)
{
ui->checkBoxAutoCrop->setChecked(autoCrop);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::TemplateSelected()
{
@ -272,6 +290,22 @@ void DialogLayoutSettings::Swap(bool checked)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::DialogAccepted()
{
SCASSERT(generator != nullptr)
generator->SetLayoutWidth(GetLayoutWidth());
generator->SetCaseType(GetGroup());
generator->SetPaperHeight(GetPaperHeight());
generator->SetPaperWidth(GetPaperWidth());
generator->SetShift(GetShift());
generator->SetRotate(GetRotate());
generator->SetRotationIncrease(GetIncrease());
generator->SetAutoCrop(GetAutoCrop());
accepted();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::InitPaperUnits()
{
@ -311,16 +345,27 @@ void DialogLayoutSettings::InitLayoutUnits()
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::InitTemplates()
{
const QIcon ico("://icon/16x16/template.png");
const QIcon icoPaper("://icon/16x16/template.png");
const QIcon icoRoll("://icon/16x16/roll.png");
const QString pdi = QString("(%1ppi)").arg(VApplication::PrintDPI);
ui->comboBoxTemplates->addItem(ico, "A0 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A0)));
ui->comboBoxTemplates->addItem(ico, "A1 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A1)));
ui->comboBoxTemplates->addItem(ico, "A2 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A2)));
ui->comboBoxTemplates->addItem(ico, "A3 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A3)));
ui->comboBoxTemplates->addItem(ico, "A4 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A4)));
ui->comboBoxTemplates->addItem(ico, "Letter "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Letter)));
ui->comboBoxTemplates->addItem(ico, "Legal "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Legal)));
ui->comboBoxTemplates->addItem(icoPaper, "A0 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A0)));
ui->comboBoxTemplates->addItem(icoPaper, "A1 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A1)));
ui->comboBoxTemplates->addItem(icoPaper, "A2 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A2)));
ui->comboBoxTemplates->addItem(icoPaper, "A3 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A3)));
ui->comboBoxTemplates->addItem(icoPaper, "A4 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A4)));
ui->comboBoxTemplates->addItem(icoPaper, tr("Letter ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Letter)));
ui->comboBoxTemplates->addItem(icoPaper, tr("Legal ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Legal)));
ui->comboBoxTemplates->addItem(icoRoll,
tr("Roll 24in ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Roll24in)));
ui->comboBoxTemplates->addItem(icoRoll,
tr("Roll 30in ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Roll30in)));
ui->comboBoxTemplates->addItem(icoRoll,
tr("Roll 36in ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Roll36in)));
ui->comboBoxTemplates->addItem(icoRoll,
tr("Roll 42in ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Roll42in)));
ui->comboBoxTemplates->addItem(icoRoll,
tr("Roll 44in ")+pdi, QVariant(static_cast<char>(PaperSizeTemplate::Roll44in)));
TemplateSelected();
}
@ -343,33 +388,65 @@ QSizeF DialogLayoutSettings::Template()
switch (temp)
{
case PaperSizeTemplate::A0:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
height = VAbstractMeasurements::UnitConvertor(1189, Unit::Mm, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::A1:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
height = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::A2:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
height = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::A3:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
height = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::A4:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(210, Unit::Mm, paperUnit);
height = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Letter:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(8.5, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Legal:
SetAutoCrop(false);
width = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(17, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Roll24in:
SetAutoCrop(true);
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(120, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Roll30in:
SetAutoCrop(true);
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(120, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Roll36in:
SetAutoCrop(true);
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(120, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Roll42in:
SetAutoCrop(true);
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(120, Unit::Inch, paperUnit);
return QSizeF(width, height);
case PaperSizeTemplate::Roll44in:
SetAutoCrop(true);
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
height = VAbstractMeasurements::UnitConvertor(120, Unit::Inch, paperUnit);
return QSizeF(width, height);
default:
break;
}

View File

@ -39,11 +39,13 @@ namespace Ui
class DialogLayoutSettings;
}
class VLayoutGenerator;
class DialogLayoutSettings : public QDialog
{
Q_OBJECT
public:
explicit DialogLayoutSettings(QWidget *parent = 0);
DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent = 0);
~DialogLayoutSettings();
int GetPaperHeight() const;
@ -67,6 +69,9 @@ public:
int GetIncrease() const;
void SetIncrease(int increase);
bool GetAutoCrop() const;
void SetAutoCrop(bool crop);
public slots:
void ConvertPaperSize();
void ConvertLayoutSize();
@ -75,11 +80,14 @@ public slots:
void PaperSizeChanged();
void Swap(bool checked);
void DialogAccepted();
private:
Q_DISABLE_COPY(DialogLayoutSettings)
Ui::DialogLayoutSettings *ui;
Unit oldPaperUnit;
Unit oldLayoutUnit;
VLayoutGenerator *generator;
void InitPaperUnits();
void InitLayoutUnits();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>661</width>
<height>289</height>
<height>317</height>
</rect>
</property>
<property name="windowTitle">
@ -195,6 +195,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxAutoCrop">
<property name="text">
<string>Auto crop unused length</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -522,7 +529,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroupPrinciple"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroupPrinciple"/>
</buttongroups>
</ui>

View File

@ -58,5 +58,6 @@
<file>icon/32x32/pdf.png</file>
<file>icon/24x24/fx.png</file>
<file>icon/16x16/fx.png</file>
<file>icon/16x16/roll.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View File

@ -413,22 +413,15 @@ void TableWindow::PrintToPdf()
//---------------------------------------------------------------------------------------------------------------------
void TableWindow::Layout()
{
DialogLayoutSettings layout(this);
VLayoutGenerator lGenerator(this);
lGenerator.SetDetails(listDetails);
DialogLayoutSettings layout(&lGenerator, this);
if (layout.exec() == QDialog::Rejected)
{
return;
}
VLayoutGenerator lGenerator(this);
lGenerator.SetDetails(listDetails);
lGenerator.SetLayoutWidth(layout.GetLayoutWidth());
lGenerator.SetCaseType(layout.GetGroup());
lGenerator.SetPaperHeight(layout.GetPaperHeight());
lGenerator.SetPaperWidth(layout.GetPaperWidth());
lGenerator.SetShift(layout.GetShift());
lGenerator.SetRotate(layout.GetRotate());
lGenerator.SetRotationIncrease(layout.GetIncrease());
DialogLayoutProgress progress(listDetails.count(), this);
connect(&lGenerator, &VLayoutGenerator::Start, &progress, &DialogLayoutProgress::Start);
@ -732,7 +725,7 @@ void TableWindow::PrepareSceneList()
ui->listWidget->addItem(item);
}
if (scenes.isEmpty() == false)
if (not scenes.isEmpty())
{
ui->listWidget->setCurrentRow(0);
EnableActions(true);
@ -757,7 +750,7 @@ QIcon TableWindow::ScenePreview(int i) const
Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter);
image.scaled(101, 146, Qt::KeepAspectRatio);
painter.end();
}
else
{

View File

@ -117,8 +117,8 @@
</property>
<property name="iconSize">
<size>
<width>200</width>
<height>200</height>
<width>180</width>
<height>180</height>
</size>
</property>
<property name="movement">
@ -130,6 +130,12 @@
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>3</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>

View File

@ -38,7 +38,8 @@
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::VLayoutGenerator(QObject *parent)
: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)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -161,7 +162,7 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
QList<QGraphicsItem *> list;
for (int i=0; i < papers.count(); ++i)
{
list.append(papers.at(i).GetPaperItem());
list.append(papers.at(i).GetPaperItem(autoCrop));
}
return list;
}
@ -184,6 +185,18 @@ void VLayoutGenerator::Abort()
state = LayoutErrors::ProcessStoped;
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::GetAutoCrop() const
{
return autoCrop;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetAutoCrop(bool value)
{
autoCrop = value;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
int VLayoutGenerator::GetRotationIncrease() const

View File

@ -73,6 +73,9 @@ public:
int GetRotationIncrease() const;
void SetRotationIncrease(int value);
bool GetAutoCrop() const;
void SetAutoCrop(bool value);
signals:
void Start();
void Arranged(int count);
@ -93,6 +96,7 @@ private:
unsigned int shift;
bool rotate;
int rotationIncrease;
bool autoCrop;
void CheckDetailsSize();
};

View File

@ -35,6 +35,7 @@
#include <QCoreApplication>
#include <QThreadPool>
#include <QPen>
#include <QGraphicsScene>
//---------------------------------------------------------------------------------------------------------------------
VLayoutPaper::VLayoutPaper()
@ -259,10 +260,32 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutDetail
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsRectItem *VLayoutPaper::GetPaperItem() const
QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const
{
QGraphicsRectItem *paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(),
d->globalContour.GetHeight()));
QGraphicsRectItem *paper;
if (autoCrop)
{
QGraphicsScene *scene = new QGraphicsScene();
QList<QGraphicsItem *> list = GetDetails();
for (int i=0; i < list.size(); ++i)
{
scene->addItem(list.at(i));
}
const int height = scene->itemsBoundingRect().toRect().height() + static_cast<int>(d->layoutWidth)*2;
delete scene;
if (d->globalContour.GetHeight() > height)
{
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), height));
}
else
{
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
}
}
else
{
paper = new QGraphicsRectItem(QRectF(0, 0, d->globalContour.GetWidth(), d->globalContour.GetHeight()));
}
paper->setPen(QPen(Qt::black, 1));
paper->setBrush(QBrush(Qt::white));
return paper;

View File

@ -69,7 +69,7 @@ public:
bool ArrangeDetail(const VLayoutDetail &detail, bool &stop);
int Count() const;
QGraphicsRectItem *GetPaperItem() const;
QGraphicsRectItem *GetPaperItem(bool autoCrop) const;
QList<QGraphicsItem *> GetDetails() const;
private: