diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 55b1490c5..79685bb4b 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -31,6 +31,7 @@ #include "../core/vapplication.h" #include "../vmisc/vsettings.h" #include "../ifc/exception/vexception.h" +#include "../vlayout/vlayoutexporter.h" #include #include @@ -788,35 +789,12 @@ bool DialogSaveLayout::SupportPSTest() { if (!tested) { - havePdf = TestPdf(); + havePdf = VLayoutExporter::SupportPDFConversion(); tested = true; } return havePdf; } -//--------------------------------------------------------------------------------------------------------------------- -bool DialogSaveLayout::TestPdf() -{ - bool res = false; - - QProcess proc; -#if defined(Q_OS_WIN) || defined(Q_OS_OSX) - // Seek pdftops in app bundle or near valentin.exe - proc.start(qApp->applicationDirPath() + QLatin1String("/")+ PDFTOPS, QStringList()); -#else - proc.start(PDFTOPS, QStringList()); // Seek pdftops in standard path -#endif - if (proc.waitForStarted(15000) && (proc.waitForFinished(15000) || proc.state() == QProcess::NotRunning)) - { - res = true; - } - else - { - qDebug()< > DialogSaveLayout::InitFormats() { diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index 8f6d480f7..ac724be5d 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -33,14 +33,6 @@ #include "vabstractlayoutdialog.h" #include "../vlayout/vlayoutdef.h" -#ifndef PDFTOPS -#ifdef Q_OS_WIN -# define PDFTOPS QStringLiteral("pdftops.exe") -#else -# define PDFTOPS QStringLiteral("pdftops") -#endif -#endif - namespace Ui { class DialogSaveLAyout; @@ -115,7 +107,6 @@ private: static bool havePdf; static bool tested; static bool SupportPSTest(); - static bool TestPdf(); static QVector > InitFormats(); void RemoveFormatFromList(LayoutExportFormats format); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 6218ace49..1aab3c703 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -43,6 +43,7 @@ #include "dialogs/dialogsavelayout.h" #include "dialogs/dialoglayoutscale.h" #include "../vlayout/vposter.h" +#include "../vlayout/vlayoutexporter.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vpatterndb/floatItemData/vpatternlabeldata.h" #include "../vpatterndb/floatItemData/vgrainlinedata.h" @@ -82,14 +83,6 @@ Q_LOGGING_CATEGORY(vMainNoGUIWindow, "v.mainnoguiwindow") QT_WARNING_POP -#ifndef PDFTOPS -#ifdef Q_OS_WIN -# define PDFTOPS QStringLiteral("pdftops.exe") -#else -# define PDFTOPS QStringLiteral("pdftops") -#endif -#endif - namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -684,61 +677,86 @@ void MainWindowsNoGUI::ExportApparelLayout(const QVector &details, qApp->ValentinaSettings()->SetPathLayout(path); const LayoutExportFormats format = m_dialogSaveLayout->Format(); + VLayoutExporter exporter; + exporter.SetFileName(name); + exporter.SetImageRect(QRectF(0, 0, size.width(), size.height())); + exporter.SetXScale(m_dialogSaveLayout->GetXScale()); + exporter.SetYScale(m_dialogSaveLayout->GetYScale()); + exporter.SetBinaryDxfFormat(m_dialogSaveLayout->IsBinaryDXFFormat()); + switch (format) { case LayoutExportFormats::DXF_AC1006_ASTM: - ASTMDxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1006); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1009_ASTM: - ASTMDxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1009); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1012_ASTM: - ASTMDxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1012); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1014_ASTM: - ASTMDxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1014); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1015_ASTM: - ASTMDxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1015); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1018_ASTM: - ASTMDxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1018); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1021_ASTM: - ASTMDxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1021); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1024_ASTM: - ASTMDxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1024); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1027_ASTM: - ASTMDxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1027); + exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AC1006_AAMA: - AAMADxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1006); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1009_AAMA: - AAMADxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1009); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1012_AAMA: - AAMADxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1012); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1014_AAMA: - AAMADxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1014); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1015_AAMA: - AAMADxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1015); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1018_AAMA: - AAMADxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1018); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1021_AAMA: - AAMADxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1021); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1024_AAMA: - AAMADxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1024); + exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::DXF_AC1027_AAMA: - AAMADxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + exporter.SetDxfVersion(DRW::AC1027); + exporter.ExportToAAMADXF(details); break; default: qDebug() << "Can't recognize file type." << Q_FUNC_INFO; @@ -1217,111 +1235,6 @@ QList MainWindowsNoGUI::CreateScenes(const QListrect(); - QSvgGenerator generator; - generator.setFileName(name); - generator.setSize(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right()), - qFloor(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom()))); - generator.setViewBox(QRectF(0, 0, r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right(), - r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom())); - generator.setTitle(tr("Pattern")); - generator.setDescription(doc->GetDescription().toHtmlEscaped()); - generator.setResolution(static_cast(PrintDPI)); - QPainter painter; - painter.begin(&generator); - painter.translate(margins.left(), margins.top()); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); - painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale()); - scene->render(&painter, r, r, Qt::IgnoreAspectRatio); - painter.end(); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PngFile save layout to png file. - * @param name name layout file. - */ -void MainWindowsNoGUI::PngFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, - const QMarginsF &margins) const -{ - const QRectF r = paper->rect(); - // Create the image with the exact size of the shrunk scene - QImage image(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right()), - qFloor(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom())), - QImage::Format_ARGB32); - image.fill(Qt::white); - QPainter painter(&image); - painter.translate(margins.left(), margins.top()); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); - painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale()); - scene->render(&painter, r, r, Qt::IgnoreAspectRatio); - image.save(name); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PdfFile save layout to pdf file. - * @param name name layout file. - */ -void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, - bool ignorePrinterFields, const QMarginsF &margins) const -{ - QPrinter printer; - printer.setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+ - QCoreApplication::applicationVersion()); - printer.setOutputFormat(QPrinter::PdfFormat); - printer.setOutputFileName(name); - printer.setDocName(FileName()); - const QRectF r = paper->rect(); - printer.setResolution(static_cast(PrintDPI)); - printer.setOrientation(QPrinter::Portrait); - printer.setFullPage(ignorePrinterFields); - - qreal width = FromPixel(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right(), Unit::Mm); - qreal height = FromPixel(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom(), Unit::Mm); - - if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter))) - { - qWarning() << tr("Cannot set printer page size"); - } - - const qreal left = FromPixel(margins.left(), Unit::Mm); - const qreal top = FromPixel(margins.top(), Unit::Mm); - const qreal right = FromPixel(margins.right(), Unit::Mm); - const qreal bottom = FromPixel(margins.bottom(), Unit::Mm); - - if (not printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter)) - { - qWarning() << tr("Cannot set printer margins"); - } - - QPainter painter; - if (not painter.begin( &printer )) - { // failed to open file - qCritical("%s", qUtf8Printable(tr("Can't open printer %1").arg(name))); - return; - } - painter.setFont( QFont( QStringLiteral("Arial"), 8, QFont::Normal ) ); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush ( QBrush ( Qt::NoBrush ) ); - painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale()); - scene->render(&painter, r, r, Qt::IgnoreAspectRatio); - painter.end(); -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::PdfTiledFile(const QString &name) { @@ -1351,154 +1264,6 @@ void MainWindowsNoGUI::PdfTiledFile(const QString &name) PrintPages(&printer); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief EpsFile save layout to eps file. - * @param name name layout file. - */ -void MainWindowsNoGUI::EpsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, - bool ignorePrinterFields, const QMarginsF &margins) const -{ - QTemporaryFile tmp; - if (tmp.open()) - { - PdfFile(tmp.fileName(), paper, scene, ignorePrinterFields, margins); - QStringList params = QStringList() << QStringLiteral("-eps") << tmp.fileName() << name; - PdfToPs(params); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PsFile save layout to ps file. - * @param name name layout file. - */ -void MainWindowsNoGUI::PsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool - ignorePrinterFields, const QMarginsF &margins) const -{ - QTemporaryFile tmp; - if (tmp.open()) - { - PdfFile(tmp.fileName(), paper, scene, ignorePrinterFields, margins); - QStringList params = QStringList() << tmp.fileName() << name; - PdfToPs(params); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format. - * @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when - * need create eps file. - */ -void MainWindowsNoGUI::PdfToPs(const QStringList ¶ms) const -{ -#ifndef QT_NO_CURSOR - QGuiApplication::setOverrideCursor(Qt::WaitCursor); -#endif - QProcess proc; -#if defined(Q_OS_MAC) - // Fix issue #594. Broken export on Mac. - proc.setWorkingDirectory(qApp->applicationDirPath()); - proc.start(QLatin1String("./") + PDFTOPS, params); -#else - proc.start(PDFTOPS, params); -#endif - if (proc.waitForStarted(15000)) - { - proc.waitForFinished(15000); - } -#ifndef QT_NO_CURSOR - QGuiApplication::restoreOverrideCursor(); -#endif - - QFile f(params.last()); - if (f.exists() == false) - { - const QString msg = tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString()); - QMessageBox msgBox(QMessageBox::Critical, tr("Critical error!"), msg, QMessageBox::Ok | QMessageBox::Default); - msgBox.exec(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene) const -{ - VObjPaintDevice generator; - generator.setFileName(name); - generator.setSize(paper->rect().size().toSize()); - generator.setResolution(static_cast(PrintDPI)); - QPainter painter; - painter.begin(&generator); - scene->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio); - painter.end(); -} - -//--------------------------------------------------------------------------------------------------------------------- -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wswitch-default") - -void MainWindowsNoGUI::FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, - QGraphicsScene *scene, const QList > &details) const -{ - PrepareTextForDXF(endStringPlaceholder, details); - VDxfPaintDevice generator; - generator.setFileName(name); - - const QRectF r = paper->rect(); - generator.setSize(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale()), - qFloor(r.height() * m_dialogSaveLayout->GetYScale()))); - - generator.setResolution(PrintDPI); - generator.SetVersion(static_cast(version)); - generator.SetBinaryFormat(binary); - generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 - - QPainter painter; - if (painter.begin(&generator)) - { - painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale()); - scene->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio); - painter.end(); - } - RestoreTextAfterDXF(endStringPlaceholder, details); -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::AAMADxfFile(const QString &name, int version, bool binary, const QSize &size, - const QVector &details) const -{ - VDxfPaintDevice generator; - generator.setFileName(name); - generator.setSize(QSize(qCeil(size.width() * m_dialogSaveLayout->GetXScale()), - qCeil(size.height() * m_dialogSaveLayout->GetYScale()))); - generator.setResolution(PrintDPI); - generator.SetVersion(static_cast(version)); - generator.SetBinaryFormat(binary); - generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 - generator.SetXScale(m_dialogSaveLayout->GetXScale()); - generator.SetYScale(m_dialogSaveLayout->GetYScale()); - generator.ExportToAAMA(details); -} - -//--------------------------------------------------------------------------------------------------------------------- -void MainWindowsNoGUI::ASTMDxfFile(const QString &name, int version, bool binary, const QSize &size, - const QVector &details) const -{ - VDxfPaintDevice generator; - generator.setFileName(name); - generator.setSize(size); - generator.setResolution(PrintDPI); - generator.SetVersion(static_cast(version)); - generator.SetBinaryFormat(binary); - generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 - generator.SetXScale(m_dialogSaveLayout->GetXScale()); - generator.SetYScale(m_dialogSaveLayout->GetYScale()); - generator.ExportToASTM(details); -} - -QT_WARNING_POP - //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::PreparePaper(int index) const { @@ -1548,70 +1313,6 @@ void MainWindowsNoGUI::RestorePaper(int index) const } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf. - * - * Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special - * placholder. This method append it. - * - * @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string. - */ -void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder, - const QList > &details) const -{ - for (auto &paperItems : details) - { - for (auto item : paperItems) - { - QList pieceChildren = item->childItems(); - for (auto child : pieceChildren) - { - if (child->type() == QGraphicsSimpleTextItem::Type) - { - if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(child)) - { - textItem->setText(textItem->text() + placeholder); - } - } - } - } - } -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief MainWindowsNoGUI::RestoreTextAfterDXF restore QGraphicsSimpleTextItem items after export to flat dxf. - * - * Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special - * placholder. This method remove it. - * - * @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string. - */ -void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder, - const QList > &details) const -{ - for (auto &paperItems : details) - { - for (auto item : paperItems) - { - QList pieceChildren = item->childItems(); - for (auto child : pieceChildren) - { - if (child->type() == QGraphicsSimpleTextItem::Type) - { - if(QGraphicsSimpleTextItem *textItem = qgraphicsitem_cast(child)) - { - QString text = textItem->text(); - text.replace(placeholder, QString()); - textItem->setText(text); - } - } - } - } - } -} - //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::PrintPreview() { @@ -1951,87 +1652,119 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, const QList > &details, bool ignorePrinterFields, const QMarginsF &margins) const { + VLayoutExporter exporter; + exporter.SetMargins(margins); + exporter.SetXScale(m_dialogSaveLayout->GetXScale()); + exporter.SetYScale(m_dialogSaveLayout->GetYScale()); + exporter.SetTitle(tr("Pattern")); + exporter.SetDescription(doc->GetDescription().toHtmlEscaped()); + exporter.SetIgnorePrinterMargins(ignorePrinterFields); + exporter.SetBinaryDxfFormat(m_dialogSaveLayout->IsBinaryDXFFormat()); + for (int i=0; i < scenes.size(); ++i) { - QGraphicsRectItem *paper = qgraphicsitem_cast(papers.at(i)); - if (paper) + auto *paper = qgraphicsitem_cast(papers.at(i)); + if (paper != nullptr) { const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + QString::number(i+1) + DialogSaveLayout::ExportFormatSuffix(m_dialogSaveLayout->Format()); - QBrush *brush = new QBrush(); + auto *brush = new QBrush(); brush->setColor( QColor( Qt::white ) ); QGraphicsScene *scene = scenes.at(i); scene->setBackgroundBrush( *brush ); shadows[i]->setVisible(false); - paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), 0.1, Qt::NoPen)); + const qreal thinPen = 0.1; + paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), thinPen, Qt::NoPen)); + + exporter.SetFileName(name); + exporter.SetImageRect(paper->rect()); switch (m_dialogSaveLayout->Format()) { case LayoutExportFormats::SVG: paper->setVisible(false); - SvgFile(name, paper, scene, margins); + exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + exporter.ExportToSVG(scene); paper->setVisible(true); break; case LayoutExportFormats::PDF: - PdfFile(name, paper, scene, ignorePrinterFields, margins); + exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + exporter.ExportToPDF(scene); break; case LayoutExportFormats::PNG: - PngFile(name, paper, scene, margins); + exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + exporter.ExportToPNG(scene); break; case LayoutExportFormats::OBJ: paper->setVisible(false); - ObjFile(name, paper, scene); + exporter.ExportToOBJ(scene); paper->setVisible(true); break; case LayoutExportFormats::PS: - PsFile(name, paper, scene, ignorePrinterFields, margins); + exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + exporter.ExportToPS(scene); break; case LayoutExportFormats::EPS: - EpsFile(name, paper, scene, ignorePrinterFields, margins); + exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + exporter.ExportToEPS(scene); break; case LayoutExportFormats::DXF_AC1006_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1006); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1009_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1009); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1012_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1012); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1014_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1014); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1015_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1015); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1018_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1018); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1021_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1021); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1024_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1024); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1027_Flat: paper->setVisible(false); - FlatDxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details); + exporter.SetDxfVersion(DRW::AC1027); + exporter.ExportToFlatDXF(scene, details); paper->setVisible(true); break; default: diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 409398df6..a2342a125 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -169,30 +169,11 @@ private: const QList &shadows, const QList > &details); - void SvgFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, const QMarginsF &margins)const; - void PngFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, const QMarginsF &margins)const; - void PdfFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields, - const QMarginsF &margins)const; void PdfTiledFile(const QString &name); - void EpsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields, - const QMarginsF &margins)const; - void PsFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignorePrinterFields, - const QMarginsF &margins)const; - void PdfToPs(const QStringList ¶ms)const; - void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const; - void FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene, - const QList > &details)const; - void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size, - const QVector &details) const; - void ASTMDxfFile(const QString &name, int version, bool binary, const QSize &size, - const QVector &details) const; void PreparePaper(int index) const; void RestorePaper(int index) const; - void PrepareTextForDXF(const QString &placeholder, const QList > &details) const; - void RestoreTextAfterDXF(const QString &placeholder, const QList > &details) const; - void PrintPreview(); void LayoutPrint(); diff --git a/src/libs/vlayout/vlayout.pri b/src/libs/vlayout/vlayout.pri index fe16ecc40..e9bca6559 100644 --- a/src/libs/vlayout/vlayout.pri +++ b/src/libs/vlayout/vlayout.pri @@ -4,6 +4,7 @@ HEADERS += \ $$PWD/stable.h \ $$PWD/testpath.h \ + $$PWD/vlayoutexporter.h \ $$PWD/vlayoutgenerator.h \ $$PWD/vlayoutdef.h \ $$PWD/vlayoutpaper.h \ @@ -28,6 +29,7 @@ HEADERS += \ SOURCES += \ $$PWD/testpath.cpp \ + $$PWD/vlayoutexporter.cpp \ $$PWD/vlayoutgenerator.cpp \ $$PWD/vlayoutpaper.cpp \ $$PWD/vbank.cpp \ diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp new file mode 100644 index 000000000..c085dc5bb --- /dev/null +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -0,0 +1,368 @@ +/************************************************************************ + ** + ** @file vlayoutexporter.cpp + ** @author Roman Telezhynskyi + ** @date 19 12, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2020 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#include "vlayoutexporter.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../vmisc/vmath.h" +#include "../vmisc/defglobal.h" +#include "../vmisc/def.h" +#include "../vobj/vobjpaintdevice.h" +#include "../vdxf/vdxfpaintdevice.h" + +namespace +{ +#ifdef Q_OS_WIN +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) +#else +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) +#endif + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf. + * + * Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special + * placholder. This method append it. + * + * @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string. + */ +void PrepareTextForDXF(const QString &placeholder, const QList > &details) +{ + for (const auto &paperItems : details) + { + for (auto *item : paperItems) + { + QList pieceChildren = item->childItems(); + for (auto *child : qAsConst(pieceChildren)) + { + if (child->type() == QGraphicsSimpleTextItem::Type) + { + if(auto *textItem = qgraphicsitem_cast(child)) + { + textItem->setText(textItem->text() + placeholder); + } + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RestoreTextAfterDXF restore QGraphicsSimpleTextItem items after export to flat dxf. + * + * Because QPaintEngine::drawTextItem doesn't pass whole string per time we mark end of each string by adding special + * placholder. This method remove it. + * + * @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string. + */ +void RestoreTextAfterDXF(const QString &placeholder, const QList > &details) +{ + for (const auto &paperItems : details) + { + for (auto *item : paperItems) + { + QList pieceChildren = item->childItems(); + for (auto *child : qAsConst(pieceChildren)) + { + if (child->type() == QGraphicsSimpleTextItem::Type) + { + if(auto *textItem = qgraphicsitem_cast(child)) + { + QString text = textItem->text(); + text.replace(placeholder, QString()); + textItem->setText(text); + } + } + } + } + } +} +} // namespace + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToSVG(QGraphicsScene *scene) const +{ + QSvgGenerator generator; + generator.setFileName(m_fileName); + + QSize drawingSize; + drawingSize.setWidth(qFloor(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right())); + drawingSize.setHeight(qFloor(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom())); + generator.setSize(drawingSize); + + QRectF viewBoxRect; + viewBoxRect.setWidth(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right()); + viewBoxRect.setHeight(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom()); + generator.setViewBox(viewBoxRect); + + generator.setTitle(m_title); + generator.setDescription(m_description); + generator.setResolution(static_cast(PrintDPI)); + + QPainter painter; + painter.begin(&generator); + painter.translate(m_margins.left(), m_margins.top()); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(m_pen); + painter.setBrush(QBrush(Qt::NoBrush)); + painter.scale(m_xScale, m_yScale); + scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); + painter.end(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToPNG(QGraphicsScene *scene) const +{ + // Create the image with the exact size of the shrunk scene + QSize drawingSize; + drawingSize.setWidth(qFloor(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right())); + drawingSize.setHeight(qFloor(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom())); + + QImage image(drawingSize, QImage::Format_ARGB32); + image.fill(Qt::white); + + QPainter painter(&image); + painter.translate(m_margins.left(), m_margins.top()); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(m_pen); + painter.setBrush(QBrush(Qt::NoBrush)); + painter.scale(m_xScale, m_yScale); + + scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); + image.save(m_fileName); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToPDF(QGraphicsScene *scene) const +{ + QPrinter printer; + printer.setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) + + QCoreApplication::applicationVersion()); + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setOutputFileName(m_fileName); + printer.setDocName(QFileInfo(m_fileName).fileName()); + printer.setResolution(static_cast(PrintDPI)); + printer.setOrientation(QPrinter::Portrait); + printer.setFullPage(m_ignorePrinterMargins); + + qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm); + qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm); + + if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter))) + { + qWarning() << tr("Cannot set printer page size"); + } + + const qreal left = FromPixel(m_margins.left(), Unit::Mm); + const qreal top = FromPixel(m_margins.top(), Unit::Mm); + const qreal right = FromPixel(m_margins.right(), Unit::Mm); + const qreal bottom = FromPixel(m_margins.bottom(), Unit::Mm); + + if (not printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter)) + { + qWarning() << tr("Cannot set printer margins"); + } + + QPainter painter; + if (not painter.begin(&printer)) + { // failed to open file + qCritical() << qUtf8Printable(tr("Can't open file '%1'").arg(m_fileName)); + return; + } + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(m_pen); + painter.setBrush(QBrush(Qt::NoBrush)); + painter.scale(m_xScale, m_yScale); + scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); + painter.end(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToOBJ(QGraphicsScene *scene) const +{ + VObjPaintDevice generator; + generator.setFileName(m_fileName); + generator.setSize(m_imageRect.size().toSize()); + generator.setResolution(static_cast(PrintDPI)); + + QPainter painter; + painter.begin(&generator); + scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); + painter.end(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToPS(QGraphicsScene *scene) const +{ + QTemporaryFile tmp; + if (tmp.open()) + { + ExportToPDF(scene); + PdfToPs(QStringList{tmp.fileName(), m_fileName}); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToEPS(QGraphicsScene *scene) const +{ + QTemporaryFile tmp; + if (tmp.open()) + { + ExportToPDF(scene); + PdfToPs(QStringList{QStringLiteral("-eps"), tmp.fileName(), m_fileName}); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList > &details) const +{ + PrepareTextForDXF(endStringPlaceholder, details); + + VDxfPaintDevice generator; + generator.setFileName(m_fileName); + generator.setSize(QSize(qFloor(m_imageRect.width() * m_xScale), qFloor(m_imageRect.height() * m_yScale))); + generator.setResolution(PrintDPI); + generator.SetVersion(static_cast(m_dxfVersion)); + generator.SetBinaryFormat(m_binaryDxfFormat); + generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 + + QPainter painter; + if (painter.begin(&generator)) + { + painter.scale(m_xScale, m_yScale); + scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); + painter.end(); + } + + RestoreTextAfterDXF(endStringPlaceholder, details); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToAAMADXF(const QVector &details) const +{ + VDxfPaintDevice generator; + generator.setFileName(m_fileName); + generator.setSize(QSize(qCeil(m_imageRect.width() * m_xScale), qCeil(m_imageRect.height() * m_yScale))); + generator.setResolution(PrintDPI); + generator.SetVersion(static_cast(m_dxfVersion)); + generator.SetBinaryFormat(m_binaryDxfFormat); + generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 + generator.SetXScale(m_xScale); + generator.SetYScale(m_yScale); + generator.ExportToAAMA(details); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::ExportToASTMDXF(const QVector &details) const +{ + VDxfPaintDevice generator; + generator.setFileName(m_fileName); + generator.setSize(QSize(qCeil(m_imageRect.width() * m_xScale), qCeil(m_imageRect.height() * m_yScale))); + generator.setResolution(PrintDPI); + generator.SetVersion(static_cast(m_dxfVersion)); + generator.SetBinaryFormat(m_binaryDxfFormat); + generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 + generator.SetXScale(m_xScale); + generator.SetYScale(m_yScale); + generator.ExportToASTM(details); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VLayoutExporter::SupportPDFConversion() -> bool +{ + bool res = false; + + QProcess proc; +#if defined(Q_OS_WIN) || defined(Q_OS_OSX) + // Seek pdftops in app bundle or near valentina.exe + proc.start(qApp->applicationDirPath() + QLatin1String("/")+ *PDFTOPS, QStringList()); +#else + proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path +#endif + + const int timeout = 15000; + if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning)) + { + res = true; + } + else + { + qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString(); + } + return res; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format. + * @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when + * need create eps file. + */ +void VLayoutExporter::PdfToPs(const QStringList ¶ms) +{ +#ifndef QT_NO_CURSOR + QGuiApplication::setOverrideCursor(Qt::WaitCursor); +#endif + + QProcess proc; +#if defined(Q_OS_MAC) + // Fix issue #594. Broken export on Mac. + proc.setWorkingDirectory(qApp->applicationDirPath()); + proc.start(QLatin1String("./") + *PDFTOPS, params); +#else + proc.start(*PDFTOPS, params); +#endif + + const int timeout = 15000; + if (proc.waitForStarted(timeout)) + { + proc.waitForFinished(timeout); + } + +#ifndef QT_NO_CURSOR + QGuiApplication::restoreOverrideCursor(); +#endif + + QFile f(params.last()); + if (not f.exists()) + { + qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString())); + } +} diff --git a/src/libs/vlayout/vlayoutexporter.h b/src/libs/vlayout/vlayoutexporter.h new file mode 100644 index 000000000..182e216dd --- /dev/null +++ b/src/libs/vlayout/vlayoutexporter.h @@ -0,0 +1,240 @@ +/************************************************************************ + ** + ** @file vlayoutexporter.h + ** @author Roman Telezhynskyi + ** @date 19 12, 2020 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2020 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef VLAYOUTEXPORTER_H +#define VLAYOUTEXPORTER_H + +#include +#include +#include +#include +#include + +class QGraphicsScene; +class QGraphicsItem; +class VLayoutPiece; + +class VLayoutExporter +{ + Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) +public: + VLayoutExporter() = default; + + auto FileName() const -> QString; + void SetFileName(const QString &fileName); + + auto Margins() const -> QMarginsF; + void SetMargins(const QMarginsF &margins); + + auto ImageRect() const -> QRectF; + void SetImageRect(const QRectF &imageRect); + + auto XScale() const -> qreal; + void SetXScale(qreal xScale); + + auto YScale() const -> qreal; + void SetYScale(qreal yScale); + + auto Title() const -> QString; + void SetTitle(const QString &title); + + auto Description() const -> QString; + void SetDescription(const QString &description); + + auto Pen() const -> QPen; + void SetPen(const QPen &pen); + + auto IgnorePrinterMargins() const -> bool; + void SetIgnorePrinterMargins(bool ignorePrinterMargins); + + auto BinaryDxfFormat() const -> bool; + void SetBinaryDxfFormat(bool binaryFormat); + + auto DxfVersion() const -> int; + void SetDxfVersion(int dxfVersion); + + void ExportToSVG(QGraphicsScene *scene) const; + void ExportToPNG(QGraphicsScene *scene) const; + void ExportToPDF(QGraphicsScene *scene) const; + void ExportToOBJ(QGraphicsScene *scene) const; + void ExportToPS(QGraphicsScene *scene) const; + void ExportToEPS(QGraphicsScene *scene) const; + void ExportToFlatDXF(QGraphicsScene *scene, const QList > &details) const; + void ExportToAAMADXF(const QVector &details) const; + void ExportToASTMDXF(const QVector &details) const; + + static auto SupportPDFConversion() -> bool; + +private: + QString m_fileName{}; + QMarginsF m_margins{}; + QRectF m_imageRect{}; + qreal m_xScale{1.0}; + qreal m_yScale{1.0}; + QString m_title{}; + QString m_description{}; + QPen m_pen{}; + bool m_ignorePrinterMargins{false}; + bool m_binaryDxfFormat{false}; + int m_dxfVersion{0}; + + static void PdfToPs(const QStringList ¶ms); +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::FileName() const -> QString +{ + return m_fileName; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetFileName(const QString &fileName) +{ + m_fileName = fileName; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::Margins() const -> QMarginsF +{ + return m_margins; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetMargins(const QMarginsF &margins) +{ + m_margins = margins; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::ImageRect() const -> QRectF +{ + return m_imageRect; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetImageRect(const QRectF &imageRect) +{ + m_imageRect = imageRect; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::XScale() const -> qreal +{ + return m_xScale; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetXScale(qreal xScale) +{ + m_xScale = xScale; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::YScale() const -> qreal +{ + return m_yScale; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetYScale(qreal yScale) +{ + m_yScale = yScale; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::Title() const -> QString +{ + return m_title; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetTitle(const QString &title) +{ + m_title = title; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::Description() const -> QString +{ + return m_description; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetDescription(const QString &description) +{ + m_description = description; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::Pen() const -> QPen +{ + return m_pen; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetPen(const QPen &pen) +{ + m_pen = pen; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::IgnorePrinterMargins() const -> bool +{ + return m_ignorePrinterMargins; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetIgnorePrinterMargins(bool ignorePrinterMargins) +{ + m_ignorePrinterMargins = ignorePrinterMargins; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::BinaryDxfFormat() const -> bool +{ + return m_binaryDxfFormat; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetBinaryDxfFormat(bool binaryFormat) +{ + m_binaryDxfFormat = binaryFormat; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VLayoutExporter::DxfVersion() const -> int +{ + return m_dxfVersion; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VLayoutExporter::SetDxfVersion(int dxfVersion) +{ + m_dxfVersion = dxfVersion; +} + +#endif // VLAYOUTEXPORTER_H