Resolved issue #716. Command line option to create *tiled* export.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-07-08 20:18:47 +03:00
parent e56e59dec1
commit c074318d65
9 changed files with 185 additions and 201 deletions

View File

@ -9,6 +9,7 @@
- [#712] Default seam allowance setting.
- [#630] Improve export: upgrade to DXF r14 format.
- [#669] Improve export: export labels as text in DXF.
- [#716] Command line option to create *tiled* export.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -68,7 +68,10 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2010 (flat) files (*.dxf) = 13,"
.RE
.RS
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14."
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33."
.RE
.IP "--bdxf"
.RB "Export dxf in binary form."

View File

@ -68,7 +68,10 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2010 (flat) files (*.dxf) = 13,"
.RE
.RS
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14."
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33."
.RE
.IP "--bdxf"
.RB "Export dxf in binary form."

View File

@ -87,6 +87,13 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
{
ui->comboBoxFormat->addItem(v.first, QVariant(static_cast<int>(v.second)));
}
#ifdef V_NO_ASSERT // Temporarily unavailable
const int index = ui->comboBoxFormat->findData(LayoutExportFormats::OBJ);
if (index != -1)
{
ui->comboBoxFormat->removeItem(index);
}
#endif
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample);
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
@ -176,6 +183,7 @@ void DialogSaveLayout::SetBinaryDXFFormat(bool binary)
break;
case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
case LayoutExportFormats::PNG:
case LayoutExportFormats::OBJ:
case LayoutExportFormats::PS:
@ -221,6 +229,7 @@ bool DialogSaveLayout::IsBinaryDXFFormat() const
return ui->checkBoxBinaryDXF->isChecked();
case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
case LayoutExportFormats::PNG:
case LayoutExportFormats::OBJ:
case LayoutExportFormats::PS:
@ -344,6 +353,8 @@ QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format)
return QString("AutoCAD DXF 2010 ASTM %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1027_ASTM:
return QString("AutoCAD DXF 2013 ASTM %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::PDFTiled:
return QString("PDF tiled %1 (*.pdf)").arg(filesStr);
default:
return QString();
}
@ -357,6 +368,7 @@ QString DialogSaveLayout::ExportFromatSuffix(LayoutExportFormats format)
case LayoutExportFormats::SVG:
return ".svg";
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
return ".pdf";
case LayoutExportFormats::PNG:
return ".png";
@ -511,6 +523,7 @@ void DialogSaveLayout::ShowExample()
break;
case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
case LayoutExportFormats::PNG:
case LayoutExportFormats::OBJ:
case LayoutExportFormats::PS:
@ -588,9 +601,7 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
InitFormat(LayoutExportFormats::SVG);
InitFormat(LayoutExportFormats::PDF);
InitFormat(LayoutExportFormats::PNG);
#ifndef V_NO_ASSERT // Temporarily unavailable
InitFormat(LayoutExportFormats::OBJ);
#endif
if (SupportPSTest())
{
InitFormat(LayoutExportFormats::PS);
@ -625,6 +636,7 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
// InitFormat(LayoutExportFormats::DXF_AC1021_ASTM);
// InitFormat(LayoutExportFormats::DXF_AC1024_ASTM);
// InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);
InitFormat(LayoutExportFormats::PDFTiled);
return list;
}

View File

@ -77,6 +77,7 @@ enum class LayoutExportFormats : char
DXF_AC1021_ASTM = 30, /* ACAD 2007. */
DXF_AC1024_ASTM = 31, /* ACAD 2010. */
DXF_AC1027_ASTM = 32, /* ACAD 2013. */
PDFTiled = 33,
COUNT /*Use only for validation*/
};

View File

@ -3343,7 +3343,6 @@ void MainWindow::SetLayoutModeActions()
ui->actionExportAs->setEnabled(enabled);
ui->actionPrintPreview->setEnabled(enabled);
ui->actionPrintPreviewTiled->setEnabled(enabled);
ui->actionSaveAsTiledPDF->setEnabled(enabled);
ui->actionPrint->setEnabled(enabled);
ui->actionPrintTiled->setEnabled(enabled);
}
@ -4013,7 +4012,6 @@ void MainWindow::CreateActions()
connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs);
connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin);
connect(ui->actionPrintPreviewTiled, &QAction::triggered, this, &MainWindow::PrintPreviewTiled);
connect(ui->actionSaveAsTiledPDF, &QAction::triggered, this, &MainWindow::SaveAsTiledPDF);
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::PrintOrigin);
connect(ui->actionPrintTiled, &QAction::triggered, this, &MainWindow::PrintTiled);

View File

@ -54,7 +54,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-32</y>
<y>0</y>
<width>127</width>
<height>358</height>
</rect>
@ -401,7 +401,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>127</width>
<width>140</width>
<height>110</height>
</rect>
</property>
@ -510,7 +510,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>127</width>
<width>140</width>
<height>248</height>
</rect>
</property>
@ -772,7 +772,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>127</width>
<width>140</width>
<height>248</height>
</rect>
</property>
@ -1121,7 +1121,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>326</height>
<height>328</height>
</rect>
</property>
<attribute name="icon">
@ -1512,7 +1512,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>326</height>
<height>328</height>
</rect>
</property>
<attribute name="icon">
@ -1626,7 +1626,6 @@
<addaction name="actionPrintPreview"/>
<addaction name="actionPrint"/>
<addaction name="separator"/>
<addaction name="actionSaveAsTiledPDF"/>
<addaction name="actionPrintPreviewTiled"/>
<addaction name="actionPrintTiled"/>
<addaction name="separator"/>
@ -2420,24 +2419,6 @@
<enum>QAction::NoRole</enum>
</property>
</action>
<action name="actionSaveAsTiledPDF">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/pdf.png</normaloff>:/icon/32x32/pdf.png</iconset>
</property>
<property name="text">
<string>Save as tiled PDF</string>
</property>
<property name="toolTip">
<string>Split and save a layout into smaller pages</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="actionPrint">
<property name="enabled">
<bool>false</bool>
@ -2674,8 +2655,8 @@
</customwidget>
</customwidgets>
<resources>
<include location="share/resources/toolicon.qrc"/>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
<include location="share/resources/toolicon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -202,13 +202,15 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
{
const QString path = dialog.Path();
bool usedNotExistedDir = false;
QDir dir(path);
dir.setPath(path);
if (not dir.exists(path))
{
if (not dir.mkpath(path))
usedNotExistedDir = dir.mkpath(".");
if (not usedNotExistedDir)
{
qCritical() << tr("Can't create path");
qCritical() << tr("Can't create a path");
return;
}
}
@ -216,6 +218,14 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
const QString mask = dialog.FileName();
const LayoutExportFormats format = dialog.Format();
if (format == LayoutExportFormats::PDFTiled)
{
const QString name = path + QLatin1String("/") + mask + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(format);
PdfTiledFile(name);
}
else
{
for (int i=0; i < scenes.size(); ++i)
{
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
@ -231,6 +241,7 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
switch (format)
{
case LayoutExportFormats::PDFTiled: // Handled separately
case LayoutExportFormats::DXF_AC1006_AAMA:
case LayoutExportFormats::DXF_AC1009_AAMA:
case LayoutExportFormats::DXF_AC1012_AAMA:
@ -331,11 +342,11 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog)
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::SaveAsTiledPDF()
if (usedNotExistedDir)
{
isTiled = true;
SaveLayoutAs();
QDir directory(dir);
directory.rmpath(".");
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -749,6 +760,33 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::PdfTiledFile(const QString &name)
{
isTiled = true;
if (isLayoutStale)
{
if (ContinueIfLayoutStale() == QMessageBox::No)
{
return;
}
}
QPrinter printer;
SetPrinterSettings(&printer, PrintType::PrintPDF);
printer.setPageSize(QPrinter::A4);// Want to be sure that page size is correct.
// Call IsPagesFit after setting a printer settings and check if pages is not bigger than printer's paper size
if (not isTiled && not IsPagesFit(printer.paperRect().size()))
{
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
}
printer.setOutputFileName(name);
printer.setResolution(static_cast<int>(PrintDPI));
PrintPages( &printer );
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief EpsFile save layout to eps file.
@ -974,58 +1012,6 @@ void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder) const
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::SaveLayoutAs()
{
if (isLayoutStale)
{
if (ContinueIfLayoutStale() == QMessageBox::No)
{
return;
}
}
QPrinter printer;
SetPrinterSettings(&printer, PrintType::PrintPDF);
printer.setPageSize(QPrinter::A4);// Want to be sure that page size is correct.
// Call IsPagesFit after setting a printer settings and check if pages is not bigger than printer's paper size
if (not isTiled && not IsPagesFit(printer.paperRect().size()))
{
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
}
const QString dir = qApp->ValentinaSettings()->GetPathLayout();
bool usedNotExistedDir = false;
QDir directory(dir);
if (not directory.exists())
{
usedNotExistedDir = directory.mkpath(".");
}
QString fileName = QFileDialog::getSaveFileName(this, tr("Print to pdf"),
dir + QLatin1String("/") + FileName() + QLatin1String(".pdf"),
tr("PDF file (*.pdf)"), nullptr, QFileDialog::DontUseNativeDialog);
if (not fileName.isEmpty())
{
QFileInfo f( fileName );
if(f.suffix().isEmpty())
{
fileName.append(".pdf");
}
qApp->ValentinaSettings()->SetPathLayout(f.absolutePath());
printer.setOutputFileName(fileName);
printer.setResolution(static_cast<int>(PrintDPI));
PrintPages( &printer );
}
if (usedNotExistedDir)
{
QDir directory(dir);
directory.rmpath(".");
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::PrintPreview()
{

View File

@ -50,7 +50,6 @@ public:
public slots:
void ToolLayoutSettings(bool checked);
void SaveAsTiledPDF();
void PrintPreviewOrigin();
void PrintPreviewTiled();
void PrintOrigin();
@ -117,6 +116,7 @@ private:
void SvgFile(const QString &name, int i)const;
void PngFile(const QString &name, int i)const;
void PdfFile(const QString &name, int i)const;
void PdfTiledFile(const QString &name);
void EpsFile(const QString &name, int i)const;
void PsFile(const QString &name, int i)const;
void PdfToPs(const QStringList &params)const;
@ -129,7 +129,6 @@ private:
void PrepareTextForDXF(const QString &placeholder) const;
void RestoreTextAfterDXF(const QString &placeholder) const;
void SaveLayoutAs();
void PrintPreview();
void LayoutPrint();