New option "Unite papers".
--HG-- branch : develop
This commit is contained in:
parent
aa3cc5de3a
commit
5ebcd1caba
|
@ -87,6 +87,7 @@ const QString VSettings::SettingLayoutRotate = QStringLitera
|
|||
const QString VSettings::SettingLayoutRotationIncrease = QStringLiteral("layout/rotationIncrease");
|
||||
const QString VSettings::SettingLayoutAutoCrop = QStringLiteral("layout/autoCrop");
|
||||
const QString VSettings::SettingLayoutSaveLength = QStringLiteral("layout/saveLength");
|
||||
const QString VSettings::SettingLayoutUnitePages = QStringLiteral("layout/unitePages");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
|
||||
|
@ -700,6 +701,18 @@ void VSettings::SetLayoutSaveLength(bool value)
|
|||
setValue(SettingLayoutSaveLength, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSettings::GetLayoutUnitePages() const
|
||||
{
|
||||
return value(SettingLayoutUnitePages, false).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSettings::SetLayoutUnitePages(bool value)
|
||||
{
|
||||
setValue(SettingLayoutUnitePages, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VSettings::StandardTablesPath()
|
||||
{
|
||||
|
|
|
@ -166,6 +166,9 @@ public:
|
|||
bool GetLayoutSaveLength() const;
|
||||
void SetLayoutSaveLength(bool value);
|
||||
|
||||
bool GetLayoutUnitePages() const;
|
||||
void SetLayoutUnitePages(bool value);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VSettings)
|
||||
static const QString SettingConfigurationOsSeparator;
|
||||
|
@ -213,6 +216,7 @@ private:
|
|||
static const QString SettingLayoutRotationIncrease;
|
||||
static const QString SettingLayoutAutoCrop;
|
||||
static const QString SettingLayoutSaveLength;
|
||||
static const QString SettingLayoutUnitePages;
|
||||
};
|
||||
|
||||
#endif // VSETTINGS_H
|
||||
|
|
|
@ -225,6 +225,18 @@ void DialogLayoutSettings::SetSaveLength(bool save)
|
|||
ui->checkBoxSaveLength->setChecked(save);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogLayoutSettings::IsUnitePages() const
|
||||
{
|
||||
return ui->checkBoxUnitePages->isChecked();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutSettings::SetUnitePages(bool save)
|
||||
{
|
||||
ui->checkBoxUnitePages->setChecked(save);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutSettings::TemplateSelected()
|
||||
{
|
||||
|
@ -319,6 +331,7 @@ void DialogLayoutSettings::DialogAccepted()
|
|||
generator->SetRotationIncrease(GetIncrease());
|
||||
generator->SetAutoCrop(GetAutoCrop());
|
||||
generator->SetSaveLength(IsSaveLength());
|
||||
generator->SetUnitePages(IsUnitePages());
|
||||
|
||||
WriteSettings();
|
||||
accepted();
|
||||
|
@ -415,85 +428,73 @@ QSizeF DialogLayoutSettings::Template()
|
|||
switch (temp)
|
||||
{
|
||||
case PaperSizeTemplate::A0:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(false);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(1189, Unit::Mm, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::A1:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(false);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::A2:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(false);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::A3:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(false);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::A4:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(false);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(210, Unit::Mm, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Letter:
|
||||
SetAutoCrop(false);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(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);
|
||||
SetSaveLength(false);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(11, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(17, Unit::Inch, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Roll24in:
|
||||
SetAutoCrop(true);
|
||||
SetSaveLength(true);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(24, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Roll30in:
|
||||
SetAutoCrop(true);
|
||||
SetSaveLength(true);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(30, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Roll36in:
|
||||
SetAutoCrop(true);
|
||||
SetSaveLength(true);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(36, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Roll42in:
|
||||
SetAutoCrop(true);
|
||||
SetSaveLength(true);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(42, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||
return QSizeF(width, height);
|
||||
case PaperSizeTemplate::Roll44in:
|
||||
SetAutoCrop(true);
|
||||
SetSaveLength(true);
|
||||
SetAdditionalOptions(true);
|
||||
|
||||
width = VAbstractMeasurements::UnitConvertor(44, Unit::Inch, paperUnit);
|
||||
height = VAbstractMeasurements::UnitConvertor(QIMAGE_MAX, Unit::Px, paperUnit);
|
||||
|
@ -620,6 +621,7 @@ void DialogLayoutSettings::ReadSettings()
|
|||
SetIncrease(qApp->getSettings()->GetLayoutRotationIncrease());
|
||||
SetAutoCrop(qApp->getSettings()->GetLayoutAutoCrop());
|
||||
SetSaveLength(qApp->getSettings()->GetLayoutSaveLength());
|
||||
SetUnitePages(qApp->getSettings()->GetLayoutUnitePages());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -634,6 +636,7 @@ void DialogLayoutSettings::WriteSettings() const
|
|||
qApp->getSettings()->SetLayoutRotationIncrease(GetIncrease());
|
||||
qApp->getSettings()->SetLayoutAutoCrop(GetAutoCrop());
|
||||
qApp->getSettings()->SetLayoutSaveLength(IsSaveLength());
|
||||
qApp->getSettings()->SetLayoutUnitePages(IsUnitePages());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -649,3 +652,11 @@ void DialogLayoutSettings::SheetSize(const QSizeF &size)
|
|||
CorrectPaperDecimals();
|
||||
PaperSizeChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogLayoutSettings::SetAdditionalOptions(bool value)
|
||||
{
|
||||
SetAutoCrop(value);
|
||||
SetSaveLength(value);
|
||||
SetUnitePages(value);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,9 @@ public:
|
|||
bool IsSaveLength() const;
|
||||
void SetSaveLength(bool save);
|
||||
|
||||
bool IsUnitePages() const;
|
||||
void SetUnitePages(bool save);
|
||||
|
||||
public slots:
|
||||
void ConvertPaperSize();
|
||||
void ConvertLayoutSize();
|
||||
|
@ -113,6 +116,7 @@ private:
|
|||
void WriteSettings() const;
|
||||
|
||||
void SheetSize(const QSizeF &size);
|
||||
void SetAdditionalOptions(bool value);
|
||||
};
|
||||
|
||||
#endif // DIALOGLAYOUTSETTINGS_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>661</width>
|
||||
<height>317</height>
|
||||
<height>345</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -205,6 +205,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxUnitePages">
|
||||
<property name="text">
|
||||
<string>Unite pages (if possible)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -104,6 +104,10 @@ void MainWindowsNoGUI::ToolLayoutSettings(bool checked)
|
|||
CleanLayout();
|
||||
papers = lGenerator.GetPapersItems();// Blank sheets
|
||||
details = lGenerator.GetAllDetails();// All details
|
||||
if (lGenerator.IsUnitePages())
|
||||
{
|
||||
UnitePages();
|
||||
}
|
||||
CreateShadows();
|
||||
CreateScenes();
|
||||
PrepareSceneList();
|
||||
|
@ -870,3 +874,90 @@ int MainWindowsNoGUI::ContinueIfLayoutStale()
|
|||
msgBox.exec();
|
||||
return msgBox.result();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindowsNoGUI::UnitePages()
|
||||
{
|
||||
if (papers.size() < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QGraphicsItem *> nPapers;
|
||||
QList<QList<QGraphicsItem *> > nDetails;
|
||||
qreal length = 0;
|
||||
int j = 0; // papers count
|
||||
|
||||
for (int i = 0; i < papers.size(); ++i)
|
||||
{
|
||||
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
|
||||
SCASSERT(paper != nullptr)
|
||||
if (length + paper->rect().height() <= QIMAGE_MAX)
|
||||
{
|
||||
UniteDetails(j, nDetails, length, i);
|
||||
length += paper->rect().height();
|
||||
UnitePapers(j, nPapers, paper->rect().width(), length);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 0; // Strat new paper
|
||||
++j;// New paper
|
||||
UniteDetails(j, nDetails, length, i);
|
||||
length += paper->rect().height();
|
||||
UnitePapers(j, nPapers, paper->rect().width(), length);
|
||||
}
|
||||
}
|
||||
|
||||
qDeleteAll (papers);
|
||||
papers.clear();
|
||||
papers = nPapers;
|
||||
|
||||
details.clear();
|
||||
details = nDetails;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QList<QGraphicsItem *> MainWindowsNoGUI::MoveDetails(qreal length, const QList<QGraphicsItem *> &details)
|
||||
{
|
||||
if (qFuzzyCompare(length+1, 0+1))
|
||||
{
|
||||
return details;
|
||||
}
|
||||
|
||||
for (int i = 0; i < details.size(); ++i)
|
||||
{
|
||||
details.at(i)->moveBy(0, length);
|
||||
}
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindowsNoGUI::UnitePapers(int j, QList<QGraphicsItem *> &nPapers, qreal width, qreal length)
|
||||
{
|
||||
if ((j == 0 && nPapers.isEmpty()) || j >= nPapers.size())
|
||||
{//First or new paper in list
|
||||
QGraphicsRectItem *paper = new QGraphicsRectItem(0, 0, width, length);
|
||||
paper->setPen(QPen(Qt::black, 1));
|
||||
paper->setBrush(QBrush(Qt::white));
|
||||
nPapers.insert(j, paper);
|
||||
}
|
||||
else
|
||||
{// Avoid memory leak
|
||||
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(nPapers.at(j));
|
||||
paper->setRect(0, 0, width, length);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindowsNoGUI::UniteDetails(int j, QList<QList<QGraphicsItem *> > &nDetails, qreal length, int i)
|
||||
{
|
||||
if ((j == 0 && nDetails.isEmpty()) || j >= nDetails.size())
|
||||
{//First or new details in paper
|
||||
nDetails.insert(j, MoveDetails(length, details.at(i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
nDetails[j].append(MoveDetails(length, details.at(i)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,11 @@ private:
|
|||
QString FileName() const;
|
||||
|
||||
int ContinueIfLayoutStale();
|
||||
|
||||
void UnitePages();
|
||||
QList<QGraphicsItem *> MoveDetails(qreal length, const QList<QGraphicsItem *> &details);
|
||||
void UnitePapers(int j, QList<QGraphicsItem *> &nPapers, qreal width, qreal length);
|
||||
void UniteDetails(int j, QList<QList<QGraphicsItem *> > &nDetails, qreal length, int i);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOWSNOGUI_H
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
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),
|
||||
autoCrop(false), saveLength(false)
|
||||
autoCrop(false), saveLength(false), unitePages(false)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -190,6 +190,18 @@ void VLayoutGenerator::Abort()
|
|||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutGenerator::IsUnitePages() const
|
||||
{
|
||||
return unitePages;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutGenerator::SetUnitePages(bool value)
|
||||
{
|
||||
unitePages = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutGenerator::IsSaveLength() const
|
||||
{
|
||||
|
|
|
@ -79,6 +79,9 @@ public:
|
|||
bool IsSaveLength() const;
|
||||
void SetSaveLength(bool value);
|
||||
|
||||
bool IsUnitePages() const;
|
||||
void SetUnitePages(bool value);
|
||||
|
||||
signals:
|
||||
void Start();
|
||||
void Arranged(int count);
|
||||
|
@ -101,6 +104,7 @@ private:
|
|||
int rotationIncrease;
|
||||
bool autoCrop;
|
||||
bool saveLength;
|
||||
bool unitePages;
|
||||
|
||||
void CheckDetailsSize();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user