From 302a1fbc2bdc8ae38d4af2d1f5b0b26cb0cf8fca Mon Sep 17 00:00:00 2001 From: Ronan Date: Sat, 22 May 2021 11:52:24 +0200 Subject: [PATCH] Move ExportFormatSuffix and Description to VLayoutExporter --- src/app/puzzle/vpexporter.cpp | 237 ++++-------------- src/app/puzzle/vpexporter.h | 17 +- .../valentina/dialogs/dialogsavelayout.cpp | 151 +---------- src/app/valentina/dialogs/dialogsavelayout.h | 3 - src/app/valentina/mainwindowsnogui.cpp | 6 +- src/libs/vlayout/vlayoutexporter.cpp | 146 +++++++++++ src/libs/vlayout/vlayoutexporter.h | 5 + 7 files changed, 213 insertions(+), 352 deletions(-) diff --git a/src/app/puzzle/vpexporter.cpp b/src/app/puzzle/vpexporter.cpp index af02f71eb..60c72d366 100644 --- a/src/app/puzzle/vpexporter.cpp +++ b/src/app/puzzle/vpexporter.cpp @@ -1,10 +1,13 @@ #include "vpexporter.h" #include +#include #include "../vwidgets/vmaingraphicsscene.h" #include "vpsheet.h" #include "vpmaingraphicsview.h" +#include "../vobj/vobjpaintdevice.h" +#include "../vdxf/vdxfpaintdevice.h" //--------------------------------------------------------------------------------------------------------------------- @@ -63,8 +66,24 @@ void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGrap ExportToTIF(mainGraphicsView->scene()); break; + case LayoutExportFormats::OBJ: + ExportToOBJ(mainGraphicsView->scene()); + break; + + case LayoutExportFormats::PS: + ExportToPS(mainGraphicsView->scene()); + break; + + case LayoutExportFormats::EPS: + ExportToEPS(mainGraphicsView->scene()); + break; + default: - // do nothing + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText(QString("TODO VPExporter, Handling for format %1 is still missing.").arg(ExportFormatDescription(format))); + int ret = msgBox.exec(); + Q_UNUSED(ret); break; } @@ -72,159 +91,6 @@ void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGrap } } - -// FIXME Bad copy paste from DialogSaveLayout, because I didn't know how to call this function from here -// to be removed as soon as I know how to call the central function from valentina -//--------------------------------------------------------------------------------------------------------------------- -QString VPExporter::ExportFormatDescription(LayoutExportFormats format) -{ - const QString dxfSuffix = QStringLiteral("(*.dxf)"); - const QString dxfFlatFilesStr = tr("(flat) files"); - const QString filesStr = tr("files"); - - switch(format) - { - case LayoutExportFormats::SVG: - return QStringLiteral("Svg %1 (*.svg)").arg(filesStr); - case LayoutExportFormats::PDF: - return QStringLiteral("PDF %1 (*.pdf)").arg(filesStr); - case LayoutExportFormats::PNG: - return tr("Image files") + QStringLiteral(" (*.png)"); - case LayoutExportFormats::OBJ: - return QStringLiteral("Wavefront OBJ (*.obj)"); - case LayoutExportFormats::PS: - return QStringLiteral("PS %1 (*.ps)").arg(filesStr); - case LayoutExportFormats::EPS: - return QStringLiteral("EPS %1 (*.eps)").arg(filesStr); - case LayoutExportFormats::DXF_AC1006_Flat: - return QStringLiteral("AutoCAD DXF R10 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_Flat: - return QStringLiteral("AutoCAD DXF R11/12 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_Flat: - return QStringLiteral("AutoCAD DXF R13 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_Flat: - return QStringLiteral("AutoCAD DXF R14 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_Flat: - return QStringLiteral("AutoCAD DXF 2000 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_Flat: - return QStringLiteral("AutoCAD DXF 2004 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_Flat: - return QStringLiteral("AutoCAD DXF 2007 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_Flat: - return QStringLiteral("AutoCAD DXF 2010 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_Flat: - return QStringLiteral("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1006_AAMA: - return QStringLiteral("AutoCAD DXF R10 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_AAMA: - return QStringLiteral("AutoCAD DXF R11/12 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_AAMA: - return QStringLiteral("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_AAMA: - return QStringLiteral("AutoCAD DXF R14 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_AAMA: - return QStringLiteral("AutoCAD DXF 2000 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_AAMA: - return QStringLiteral("AutoCAD DXF 2004 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_AAMA: - return QStringLiteral("AutoCAD DXF 2007 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_AAMA: - return QStringLiteral("AutoCAD DXF 2010 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_AAMA: - return QStringLiteral("AutoCAD DXF 2013 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1006_ASTM: - return QStringLiteral("AutoCAD DXF R10 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_ASTM: - return QStringLiteral("AutoCAD DXF R11/12 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_ASTM: - return QStringLiteral("AutoCAD DXF R13 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_ASTM: - return QStringLiteral("AutoCAD DXF R14 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_ASTM: - return QStringLiteral("AutoCAD DXF 2000 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_ASTM: - return QStringLiteral("AutoCAD DXF 2004 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_ASTM: - return QStringLiteral("AutoCAD DXF 2007 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_ASTM: - return QStringLiteral("AutoCAD DXF 2010 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_ASTM: - return QStringLiteral("AutoCAD DXF 2013 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::PDFTiled: - return QStringLiteral("PDF %1 %2 (*.pdf)").arg(tr("tiled"), filesStr); - case LayoutExportFormats::NC: - return QStringLiteral("%1 %2 (*.nc)").arg(tr("Numerical control"), filesStr); - case LayoutExportFormats::RLD: - return QStringLiteral("%1 %2 (*.rld)").arg(tr("Raw Layout Data"), filesStr); - case LayoutExportFormats::TIF: - return QStringLiteral("TIFF %1 (*.tif)").arg(filesStr); - default: - return QString(); - } -} - -// FIXME Bad copy paste from DialogSaveLayout, because I didn't know how to call this function from here -// to be removed as soon as I know how to call the central function from valentina -//--------------------------------------------------------------------------------------------------------------------- -QString VPExporter::ExportFormatSuffix(LayoutExportFormats format) -{ - switch(format) - { - case LayoutExportFormats::SVG: - return QStringLiteral(".svg"); - case LayoutExportFormats::PDF: - case LayoutExportFormats::PDFTiled: - return QStringLiteral(".pdf"); - case LayoutExportFormats::PNG: - return QStringLiteral(".png"); - case LayoutExportFormats::OBJ: - return QStringLiteral(".obj"); - case LayoutExportFormats::PS: - return QStringLiteral(".ps"); - case LayoutExportFormats::EPS: - return QStringLiteral(".eps"); - case LayoutExportFormats::DXF_AC1006_Flat: - case LayoutExportFormats::DXF_AC1009_Flat: - case LayoutExportFormats::DXF_AC1012_Flat: - case LayoutExportFormats::DXF_AC1014_Flat: - case LayoutExportFormats::DXF_AC1015_Flat: - case LayoutExportFormats::DXF_AC1018_Flat: - case LayoutExportFormats::DXF_AC1021_Flat: - case LayoutExportFormats::DXF_AC1024_Flat: - case LayoutExportFormats::DXF_AC1027_Flat: - case LayoutExportFormats::DXF_AC1006_AAMA: - case LayoutExportFormats::DXF_AC1009_AAMA: - case LayoutExportFormats::DXF_AC1012_AAMA: - case LayoutExportFormats::DXF_AC1014_AAMA: - case LayoutExportFormats::DXF_AC1015_AAMA: - case LayoutExportFormats::DXF_AC1018_AAMA: - case LayoutExportFormats::DXF_AC1021_AAMA: - case LayoutExportFormats::DXF_AC1024_AAMA: - case LayoutExportFormats::DXF_AC1027_AAMA: - case LayoutExportFormats::DXF_AC1006_ASTM: - case LayoutExportFormats::DXF_AC1009_ASTM: - case LayoutExportFormats::DXF_AC1012_ASTM: - case LayoutExportFormats::DXF_AC1014_ASTM: - case LayoutExportFormats::DXF_AC1015_ASTM: - case LayoutExportFormats::DXF_AC1018_ASTM: - case LayoutExportFormats::DXF_AC1021_ASTM: - case LayoutExportFormats::DXF_AC1024_ASTM: - case LayoutExportFormats::DXF_AC1027_ASTM: - return QStringLiteral(".dxf"); - case LayoutExportFormats::NC: - return QStringLiteral(".nc"); - case LayoutExportFormats::RLD: - return QStringLiteral(".rld"); - case LayoutExportFormats::TIF: - return QStringLiteral(".tif"); - default: - return QString(); - } -} - - -// FIXME Bad copy paste from DialogSaveLayout, because I didn't know how to call this function from here -// to be removed as soon as I know how to call the central function from valentina //--------------------------------------------------------------------------------------------------------------------- QVector > VPExporter::InitFormats() { @@ -238,43 +104,44 @@ QVector > VPExporter::InitFormats() InitFormat(LayoutExportFormats::SVG); InitFormat(LayoutExportFormats::PDF); // InitFormat(LayoutExportFormats::PNG); + InitFormat(LayoutExportFormats::TIF); -// InitFormat(LayoutExportFormats::OBJ); + InitFormat(LayoutExportFormats::OBJ); -// InitFormat(LayoutExportFormats::PS); -// InitFormat(LayoutExportFormats::EPS); + InitFormat(LayoutExportFormats::PS); + InitFormat(LayoutExportFormats::EPS); + + InitFormat(LayoutExportFormats::DXF_AC1006_Flat); +/* InitFormat(LayoutExportFormats::DXF_AC1009_Flat); + InitFormat(LayoutExportFormats::DXF_AC1012_Flat); + InitFormat(LayoutExportFormats::DXF_AC1014_Flat); + InitFormat(LayoutExportFormats::DXF_AC1015_Flat); + InitFormat(LayoutExportFormats::DXF_AC1018_Flat); + InitFormat(LayoutExportFormats::DXF_AC1021_Flat); + InitFormat(LayoutExportFormats::DXF_AC1024_Flat); + InitFormat(LayoutExportFormats::DXF_AC1027_Flat); + InitFormat(LayoutExportFormats::DXF_AC1006_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1009_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1012_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1014_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1015_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1018_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1021_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1024_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1027_AAMA); + InitFormat(LayoutExportFormats::DXF_AC1006_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1009_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1012_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1014_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1015_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1018_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1021_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1024_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);*/ -// InitFormat(LayoutExportFormats::DXF_AC1006_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1009_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1012_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1014_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1015_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1018_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1021_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1024_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1027_Flat); -// InitFormat(LayoutExportFormats::DXF_AC1006_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1009_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1012_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1014_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1015_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1018_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1021_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1024_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1027_AAMA); -// InitFormat(LayoutExportFormats::DXF_AC1006_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1009_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1012_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1014_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1015_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1018_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1021_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1024_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1027_ASTM); // InitFormat(LayoutExportFormats::PDFTiled); // InitFormat(LayoutExportFormats::NC); // InitFormat(LayoutExportFormats::RLD); - InitFormat(LayoutExportFormats::TIF); return list; } diff --git a/src/app/puzzle/vpexporter.h b/src/app/puzzle/vpexporter.h index bbd9076eb..6e87a2aa7 100644 --- a/src/app/puzzle/vpexporter.h +++ b/src/app/puzzle/vpexporter.h @@ -21,21 +21,12 @@ public: void Export(VPLayout* layout, LayoutExportFormats format, VPMainGraphicsView *mainGraphicsView); - - // FIXME Bad copy paste from DialogSaveLayout, because I didn't know how to call this function from here - // to be removed as soon as I know how to call the central function from valentina + /** + * @brief InitFormats + * @return returns the list of formats, that we can export in puzzle + */ QVector > InitFormats(); -private: - - - - // FIXME Bad copy paste from DialogSaveLayout, because I didn't know how to call this function from here - // to be removed as soon as I know how to call the central function from valentina - static QString ExportFormatDescription(LayoutExportFormats format); - static QString ExportFormatSuffix(LayoutExportFormats format); - - }; #endif // VPEXPORTER_H diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index d4e472e72..61f2ec1c2 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -349,151 +349,6 @@ Draw DialogSaveLayout::Mode() const return m_mode; } -//--------------------------------------------------------------------------------------------------------------------- -QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format) -{ - const QString dxfSuffix = QStringLiteral("(*.dxf)"); - const QString dxfFlatFilesStr = tr("(flat) files"); - const QString filesStr = tr("files"); - - switch(format) - { - case LayoutExportFormats::SVG: - return QStringLiteral("Svg %1 (*.svg)").arg(filesStr); - case LayoutExportFormats::PDF: - return QStringLiteral("PDF %1 (*.pdf)").arg(filesStr); - case LayoutExportFormats::PNG: - return tr("Image files") + QStringLiteral(" (*.png)"); - case LayoutExportFormats::OBJ: - return QStringLiteral("Wavefront OBJ (*.obj)"); - case LayoutExportFormats::PS: - return QStringLiteral("PS %1 (*.ps)").arg(filesStr); - case LayoutExportFormats::EPS: - return QStringLiteral("EPS %1 (*.eps)").arg(filesStr); - case LayoutExportFormats::DXF_AC1006_Flat: - return QStringLiteral("AutoCAD DXF R10 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_Flat: - return QStringLiteral("AutoCAD DXF R11/12 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_Flat: - return QStringLiteral("AutoCAD DXF R13 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_Flat: - return QStringLiteral("AutoCAD DXF R14 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_Flat: - return QStringLiteral("AutoCAD DXF 2000 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_Flat: - return QStringLiteral("AutoCAD DXF 2004 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_Flat: - return QStringLiteral("AutoCAD DXF 2007 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_Flat: - return QStringLiteral("AutoCAD DXF 2010 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_Flat: - return QStringLiteral("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1006_AAMA: - return QStringLiteral("AutoCAD DXF R10 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_AAMA: - return QStringLiteral("AutoCAD DXF R11/12 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_AAMA: - return QStringLiteral("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_AAMA: - return QStringLiteral("AutoCAD DXF R14 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_AAMA: - return QStringLiteral("AutoCAD DXF 2000 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_AAMA: - return QStringLiteral("AutoCAD DXF 2004 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_AAMA: - return QStringLiteral("AutoCAD DXF 2007 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_AAMA: - return QStringLiteral("AutoCAD DXF 2010 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_AAMA: - return QStringLiteral("AutoCAD DXF 2013 AAMA %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1006_ASTM: - return QStringLiteral("AutoCAD DXF R10 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1009_ASTM: - return QStringLiteral("AutoCAD DXF R11/12 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1012_ASTM: - return QStringLiteral("AutoCAD DXF R13 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1014_ASTM: - return QStringLiteral("AutoCAD DXF R14 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1015_ASTM: - return QStringLiteral("AutoCAD DXF 2000 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1018_ASTM: - return QStringLiteral("AutoCAD DXF 2004 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1021_ASTM: - return QStringLiteral("AutoCAD DXF 2007 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1024_ASTM: - return QStringLiteral("AutoCAD DXF 2010 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::DXF_AC1027_ASTM: - return QStringLiteral("AutoCAD DXF 2013 ASTM %1 %2").arg(filesStr, dxfSuffix); - case LayoutExportFormats::PDFTiled: - return QStringLiteral("PDF %1 %2 (*.pdf)").arg(tr("tiled"), filesStr); - case LayoutExportFormats::NC: - return QStringLiteral("%1 %2 (*.nc)").arg(tr("Numerical control"), filesStr); - case LayoutExportFormats::RLD: - return QStringLiteral("%1 %2 (*.rld)").arg(tr("Raw Layout Data"), filesStr); - case LayoutExportFormats::TIF: - return QStringLiteral("TIFF %1 (*.tif)").arg(filesStr); - default: - return QString(); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -QString DialogSaveLayout::ExportFormatSuffix(LayoutExportFormats format) -{ - switch(format) - { - case LayoutExportFormats::SVG: - return QStringLiteral(".svg"); - case LayoutExportFormats::PDF: - case LayoutExportFormats::PDFTiled: - return QStringLiteral(".pdf"); - case LayoutExportFormats::PNG: - return QStringLiteral(".png"); - case LayoutExportFormats::OBJ: - return QStringLiteral(".obj"); - case LayoutExportFormats::PS: - return QStringLiteral(".ps"); - case LayoutExportFormats::EPS: - return QStringLiteral(".eps"); - case LayoutExportFormats::DXF_AC1006_Flat: - case LayoutExportFormats::DXF_AC1009_Flat: - case LayoutExportFormats::DXF_AC1012_Flat: - case LayoutExportFormats::DXF_AC1014_Flat: - case LayoutExportFormats::DXF_AC1015_Flat: - case LayoutExportFormats::DXF_AC1018_Flat: - case LayoutExportFormats::DXF_AC1021_Flat: - case LayoutExportFormats::DXF_AC1024_Flat: - case LayoutExportFormats::DXF_AC1027_Flat: - case LayoutExportFormats::DXF_AC1006_AAMA: - case LayoutExportFormats::DXF_AC1009_AAMA: - case LayoutExportFormats::DXF_AC1012_AAMA: - case LayoutExportFormats::DXF_AC1014_AAMA: - case LayoutExportFormats::DXF_AC1015_AAMA: - case LayoutExportFormats::DXF_AC1018_AAMA: - case LayoutExportFormats::DXF_AC1021_AAMA: - case LayoutExportFormats::DXF_AC1024_AAMA: - case LayoutExportFormats::DXF_AC1027_AAMA: - case LayoutExportFormats::DXF_AC1006_ASTM: - case LayoutExportFormats::DXF_AC1009_ASTM: - case LayoutExportFormats::DXF_AC1012_ASTM: - case LayoutExportFormats::DXF_AC1014_ASTM: - case LayoutExportFormats::DXF_AC1015_ASTM: - case LayoutExportFormats::DXF_AC1018_ASTM: - case LayoutExportFormats::DXF_AC1021_ASTM: - case LayoutExportFormats::DXF_AC1024_ASTM: - case LayoutExportFormats::DXF_AC1027_ASTM: - return QStringLiteral(".dxf"); - case LayoutExportFormats::NC: - return QStringLiteral(".nc"); - case LayoutExportFormats::RLD: - return QStringLiteral(".rld"); - case LayoutExportFormats::TIF: - return QStringLiteral(".tif"); - default: - return QString(); - } -} - //--------------------------------------------------------------------------------------------------------------------- DialogSaveLayout::~DialogSaveLayout() { @@ -525,7 +380,7 @@ void DialogSaveLayout::Save() for (int i=0; i < count; ++i) { - const QString name = Path()+'/'+FileName()+QString::number(i+1)+ExportFormatSuffix(Format()); + const QString name = Path()+'/'+FileName()+QString::number(i+1)+VLayoutExporter::ExportFormatSuffix(Format()); if (QFile::exists(name)) { QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"), @@ -573,7 +428,7 @@ void DialogSaveLayout::PathChanged(const QString &text) void DialogSaveLayout::ShowExample() { const LayoutExportFormats currentFormat = Format(); - ui->labelExample->setText(tr("Example:") + FileName() + QLatin1Char('1') + ExportFormatSuffix(currentFormat)); + ui->labelExample->setText(tr("Example:") + FileName() + QLatin1Char('1') + VLayoutExporter::ExportFormatSuffix(currentFormat)); ui->checkBoxBinaryDXF->setEnabled(false); ui->groupBoxPaperFormat->setEnabled(false); @@ -822,7 +677,7 @@ QVector > DialogSaveLayout::InitFormats( auto InitFormat = [&list](LayoutExportFormats format) { - list.append(std::make_pair(ExportFormatDescription(format), format)); + list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format)); }; InitFormat(LayoutExportFormats::SVG); diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index 4eaafc775..9c4950f17 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -61,9 +61,6 @@ public: Draw Mode() const; - static QString ExportFormatDescription(LayoutExportFormats format); - static QString ExportFormatSuffix(LayoutExportFormats format); - bool IsTextAsPaths() const; void SetTextAsPaths(bool textAsPaths); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index be4b57485..ef3794c3e 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -514,7 +514,7 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails) for (int i = 0; i < detailsOnLayout.size(); ++i) { const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + - QString::number(i+1) + DialogSaveLayout::ExportFormatSuffix(m_dialogSaveLayout->Format()); + QString::number(i+1) + VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format()); QGraphicsRectItem *paper = qgraphicsitem_cast( m_layoutSettings->LayoutPapers().at(i)); @@ -827,7 +827,7 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector listDe } const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + - QString::number(1) + DialogSaveLayout::ExportFormatSuffix(m_dialogSaveLayout->Format()); + QString::number(1) + VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format()); ExportApparelLayout(listDetails, name, rect.size()); } @@ -1110,7 +1110,7 @@ void MainWindowsNoGUI::ExportScene(const QList &scenes, if (paper != nullptr) { const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + - QString::number(i+1) + DialogSaveLayout::ExportFormatSuffix(m_dialogSaveLayout->Format()); + QString::number(i+1) + VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format()); auto *brush = new QBrush(); brush->setColor( QColor( Qt::white ) ); QGraphicsScene *scene = scenes.at(i); diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index 4d9248f60..ca99c2aff 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -433,3 +433,149 @@ void VLayoutExporter::PdfToPs(const QStringList ¶ms) qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString())); } } + + +//--------------------------------------------------------------------------------------------------------------------- +QString VLayoutExporter::ExportFormatDescription(LayoutExportFormats format) +{ + const QString dxfSuffix = QStringLiteral("(*.dxf)"); + const QString dxfFlatFilesStr = tr("(flat) files"); + const QString filesStr = tr("files"); + + switch(format) + { + case LayoutExportFormats::SVG: + return QStringLiteral("Svg %1 (*.svg)").arg(filesStr); + case LayoutExportFormats::PDF: + return QStringLiteral("PDF %1 (*.pdf)").arg(filesStr); + case LayoutExportFormats::PNG: + return tr("Image files") + QStringLiteral(" (*.png)"); + case LayoutExportFormats::OBJ: + return QStringLiteral("Wavefront OBJ (*.obj)"); + case LayoutExportFormats::PS: + return QStringLiteral("PS %1 (*.ps)").arg(filesStr); + case LayoutExportFormats::EPS: + return QStringLiteral("EPS %1 (*.eps)").arg(filesStr); + case LayoutExportFormats::DXF_AC1006_Flat: + return QStringLiteral("AutoCAD DXF R10 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1009_Flat: + return QStringLiteral("AutoCAD DXF R11/12 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1012_Flat: + return QStringLiteral("AutoCAD DXF R13 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1014_Flat: + return QStringLiteral("AutoCAD DXF R14 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1015_Flat: + return QStringLiteral("AutoCAD DXF 2000 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1018_Flat: + return QStringLiteral("AutoCAD DXF 2004 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1021_Flat: + return QStringLiteral("AutoCAD DXF 2007 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1024_Flat: + return QStringLiteral("AutoCAD DXF 2010 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1027_Flat: + return QStringLiteral("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1006_AAMA: + return QStringLiteral("AutoCAD DXF R10 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1009_AAMA: + return QStringLiteral("AutoCAD DXF R11/12 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1012_AAMA: + return QStringLiteral("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1014_AAMA: + return QStringLiteral("AutoCAD DXF R14 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1015_AAMA: + return QStringLiteral("AutoCAD DXF 2000 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1018_AAMA: + return QStringLiteral("AutoCAD DXF 2004 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1021_AAMA: + return QStringLiteral("AutoCAD DXF 2007 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1024_AAMA: + return QStringLiteral("AutoCAD DXF 2010 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1027_AAMA: + return QStringLiteral("AutoCAD DXF 2013 AAMA %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1006_ASTM: + return QStringLiteral("AutoCAD DXF R10 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1009_ASTM: + return QStringLiteral("AutoCAD DXF R11/12 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1012_ASTM: + return QStringLiteral("AutoCAD DXF R13 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1014_ASTM: + return QStringLiteral("AutoCAD DXF R14 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1015_ASTM: + return QStringLiteral("AutoCAD DXF 2000 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1018_ASTM: + return QStringLiteral("AutoCAD DXF 2004 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1021_ASTM: + return QStringLiteral("AutoCAD DXF 2007 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1024_ASTM: + return QStringLiteral("AutoCAD DXF 2010 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::DXF_AC1027_ASTM: + return QStringLiteral("AutoCAD DXF 2013 ASTM %1 %2").arg(filesStr, dxfSuffix); + case LayoutExportFormats::PDFTiled: + return QStringLiteral("PDF %1 %2 (*.pdf)").arg(tr("tiled"), filesStr); + case LayoutExportFormats::NC: + return QStringLiteral("%1 %2 (*.nc)").arg(tr("Numerical control"), filesStr); + case LayoutExportFormats::RLD: + return QStringLiteral("%1 %2 (*.rld)").arg(tr("Raw Layout Data"), filesStr); + case LayoutExportFormats::TIF: + return QStringLiteral("TIFF %1 (*.tif)").arg(filesStr); + default: + return QString(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VLayoutExporter::ExportFormatSuffix(LayoutExportFormats format) +{ + switch(format) + { + case LayoutExportFormats::SVG: + return QStringLiteral(".svg"); + case LayoutExportFormats::PDF: + case LayoutExportFormats::PDFTiled: + return QStringLiteral(".pdf"); + case LayoutExportFormats::PNG: + return QStringLiteral(".png"); + case LayoutExportFormats::OBJ: + return QStringLiteral(".obj"); + case LayoutExportFormats::PS: + return QStringLiteral(".ps"); + case LayoutExportFormats::EPS: + return QStringLiteral(".eps"); + case LayoutExportFormats::DXF_AC1006_Flat: + case LayoutExportFormats::DXF_AC1009_Flat: + case LayoutExportFormats::DXF_AC1012_Flat: + case LayoutExportFormats::DXF_AC1014_Flat: + case LayoutExportFormats::DXF_AC1015_Flat: + case LayoutExportFormats::DXF_AC1018_Flat: + case LayoutExportFormats::DXF_AC1021_Flat: + case LayoutExportFormats::DXF_AC1024_Flat: + case LayoutExportFormats::DXF_AC1027_Flat: + case LayoutExportFormats::DXF_AC1006_AAMA: + case LayoutExportFormats::DXF_AC1009_AAMA: + case LayoutExportFormats::DXF_AC1012_AAMA: + case LayoutExportFormats::DXF_AC1014_AAMA: + case LayoutExportFormats::DXF_AC1015_AAMA: + case LayoutExportFormats::DXF_AC1018_AAMA: + case LayoutExportFormats::DXF_AC1021_AAMA: + case LayoutExportFormats::DXF_AC1024_AAMA: + case LayoutExportFormats::DXF_AC1027_AAMA: + case LayoutExportFormats::DXF_AC1006_ASTM: + case LayoutExportFormats::DXF_AC1009_ASTM: + case LayoutExportFormats::DXF_AC1012_ASTM: + case LayoutExportFormats::DXF_AC1014_ASTM: + case LayoutExportFormats::DXF_AC1015_ASTM: + case LayoutExportFormats::DXF_AC1018_ASTM: + case LayoutExportFormats::DXF_AC1021_ASTM: + case LayoutExportFormats::DXF_AC1024_ASTM: + case LayoutExportFormats::DXF_AC1027_ASTM: + return QStringLiteral(".dxf"); + case LayoutExportFormats::NC: + return QStringLiteral(".nc"); + case LayoutExportFormats::RLD: + return QStringLiteral(".rld"); + case LayoutExportFormats::TIF: + return QStringLiteral(".tif"); + default: + return QString(); + } +} diff --git a/src/libs/vlayout/vlayoutexporter.h b/src/libs/vlayout/vlayoutexporter.h index 5952cae93..439f56b95 100644 --- a/src/libs/vlayout/vlayoutexporter.h +++ b/src/libs/vlayout/vlayoutexporter.h @@ -34,6 +34,8 @@ #include #include +#include "../vlayout/vlayoutdef.h" + class QGraphicsScene; class QGraphicsItem; class VLayoutPiece; @@ -91,6 +93,9 @@ public: static auto SupportPDFConversion() -> bool; + static QString ExportFormatDescription(LayoutExportFormats format); + static QString ExportFormatSuffix(LayoutExportFormats format); + private: QString m_fileName{}; QMarginsF m_margins{};