Merge branch 'feature/manual-layout' into 'feature/manual-layout'

Feature/manual layout VPExporter Class

See merge request smart-pattern/valentina!13
This commit is contained in:
Roman Telezhynskyi 2021-05-22 11:15:17 +00:00
commit 224aa23527
12 changed files with 381 additions and 199 deletions

View File

@ -13,6 +13,7 @@ SOURCES += \
$$PWD/vpcarrouselpiecelist.cpp \ $$PWD/vpcarrouselpiecelist.cpp \
$$PWD/vpcommandline.cpp \ $$PWD/vpcommandline.cpp \
$$PWD/vpcommands.cpp \ $$PWD/vpcommands.cpp \
$$PWD/vpexporter.cpp \
$$PWD/vpgraphicspiece.cpp \ $$PWD/vpgraphicspiece.cpp \
$$PWD/vpgraphicssheet.cpp \ $$PWD/vpgraphicssheet.cpp \
$$PWD/vpgraphicstilegrid.cpp \ $$PWD/vpgraphicstilegrid.cpp \
@ -43,6 +44,7 @@ HEADERS += \
$$PWD/vpcarrouselpiecelist.h \ $$PWD/vpcarrouselpiecelist.h \
$$PWD/vpcommandline.h \ $$PWD/vpcommandline.h \
$$PWD/vpcommands.h \ $$PWD/vpcommands.h \
$$PWD/vpexporter.h \
$$PWD/vpgraphicspiece.h \ $$PWD/vpgraphicspiece.h \
$$PWD/vpgraphicssheet.h \ $$PWD/vpgraphicssheet.h \
$$PWD/vpgraphicstilegrid.h \ $$PWD/vpgraphicstilegrid.h \

View File

@ -260,6 +260,24 @@ DEPENDPATH += $$PWD/../../libs/vgeometry
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a
# VObj static library
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vobj/$${DESTDIR}/ -lvobj
INCLUDEPATH += $$PWD/../../libs/vobj
DEPENDPATH += $$PWD/../../libs/vobj
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vobj/$${DESTDIR}/vobj.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vobj/$${DESTDIR}/libvobj.a
# VDxf static library
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vdxf/$${DESTDIR}/ -lvdxf
INCLUDEPATH += $$PWD/../../libs/vdxf
DEPENDPATH += $$PWD/../../libs/vdxf
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vdxf/$${DESTDIR}/vdxf.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vdxf/$${DESTDIR}/libvdxf.a
# QMuParser library # QMuParser library
win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2

View File

@ -0,0 +1,147 @@
#include "vpexporter.h"
#include <QFileDialog>
#include <QMessageBox>
#include "../vwidgets/vmaingraphicsscene.h"
#include "vpsheet.h"
#include "vpmaingraphicsview.h"
#include "../vobj/vobjpaintdevice.h"
#include "../vdxf/vdxfpaintdevice.h"
//---------------------------------------------------------------------------------------------------------------------
VPExporter::VPExporter()
{
}
//---------------------------------------------------------------------------------------------------------------------
VPExporter::~VPExporter()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGraphicsView *mainGraphicsView)
{
QString dir = QDir::homePath();
QString filters(ExportFormatDescription(format));
// is it ok to have a null ptr hier as a parent?
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save as"),
dir + QLatin1String("/") + layout->GetFocusedSheet()->GetName() + ExportFormatSuffix(format),
filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if(not fileName.isEmpty())
{
mainGraphicsView->PrepareForExport();
SetFileName(fileName);
QSizeF size = QSizeF(layout->GetFocusedSheet()->GetSheetSize());
if(layout->GetFocusedSheet()->GetOrientation() == PageOrientation::Landscape)
{
size.transpose();
}
const QRectF rect = QRectF(0, 0, size.width(), size.height());
SetImageRect(rect);
switch(format)
{
case LayoutExportFormats::SVG:
ExportToSVG(mainGraphicsView->scene());
break;
case LayoutExportFormats::PDF:
ExportToPDF(mainGraphicsView->scene());
break;
case LayoutExportFormats::TIF:
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:
// 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;
}
mainGraphicsView->CleanAfterExport();
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<std::pair<QString, LayoutExportFormats> > VPExporter::InitFormats()
{
QVector<std::pair<QString, LayoutExportFormats>> list;
auto InitFormat = [&list](LayoutExportFormats format)
{
list.append(std::make_pair(ExportFormatDescription(format), format));
};
InitFormat(LayoutExportFormats::SVG);
InitFormat(LayoutExportFormats::PDF);
// InitFormat(LayoutExportFormats::PNG);
InitFormat(LayoutExportFormats::TIF);
InitFormat(LayoutExportFormats::OBJ);
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::PDFTiled);
// InitFormat(LayoutExportFormats::NC);
// InitFormat(LayoutExportFormats::RLD);
return list;
}

View File

@ -0,0 +1,32 @@
#ifndef VPEXPORTER_H
#define VPEXPORTER_H
#include <QObject>
#include "vplayout.h"
#include "../vmisc/def.h"
#include "vcommonsettings.h"
#include "../vlayout/vlayoutdef.h"
#include "../vlayout/vlayoutexporter.h"
//#include "../dialogs/dialogsavelayout.h"
class VPMainGraphicsView;
class VPExporter : VLayoutExporter
{
public:
VPExporter();
~VPExporter();
void Export(VPLayout* layout, LayoutExportFormats format, VPMainGraphicsView *mainGraphicsView);
/**
* @brief InitFormats
* @return returns the list of formats, that we can export in puzzle
*/
QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
};
#endif // VPEXPORTER_H

View File

@ -488,6 +488,14 @@ void VPMainWindow::InitPropertyTabCurrentSheet()
ui->comboBoxSheetTemplate->blockSignals(false); ui->comboBoxSheetTemplate->blockSignals(false);
ui->comboBoxSheetTemplate->setCurrentIndex(0); ui->comboBoxSheetTemplate->setCurrentIndex(0);
// ---------------------- export format --------------------------
VPExporter exporter;
for (auto &v : exporter.InitFormats())
{
ui->comboBoxSheetExportFormat->addItem(v.first, QVariant(static_cast<int>(v.second)));
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1604,8 +1612,6 @@ void VPMainWindow::on_checkBoxTilesShowTiles_toggled(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonTilesExport_clicked() void VPMainWindow::on_pushButtonTilesExport_clicked()
{ {
// svg export to do some test for the first test
QString dir = QDir::homePath(); QString dir = QDir::homePath();
QString filters(tr("PDF Files") + QLatin1String("(*.pdf)")); QString filters(tr("PDF Files") + QLatin1String("(*.pdf)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
@ -1674,45 +1680,10 @@ void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonSheetExport_clicked() void VPMainWindow::on_pushButtonSheetExport_clicked()
{ {
// svg export to do some test for the first test LayoutExportFormats format = static_cast<LayoutExportFormats>(ui->comboBoxSheetExportFormat->currentData().toInt());
QString dir = QDir::homePath();
QString filters(tr("SVG Files") + QLatin1String("(*.svg)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
dir + QLatin1String("/") + m_layout->GetFocusedSheet()->GetName() + QLatin1String(".svg"),
filters, nullptr
#ifdef Q_OS_LINUX
, QFileDialog::DontUseNativeDialog
#endif
);
if(not fileName.isEmpty())
{
m_graphicsView->PrepareForExport();
const QSizeF s = m_layout->GetFocusedSheet()->GetSheetSize();
const QRectF r = QRectF(0, 0, s.width(), s.height());
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(QSize(qFloor(s.width()),qFloor(s.height())));
generator.setViewBox(r);
generator.setTitle(m_layout->GetFocusedSheet()->GetName());
generator.setDescription(m_layout->GetDescription().toHtmlEscaped());
generator.setResolution(static_cast<int>(PrintDPI));
QPainter painter;
painter.begin(&generator);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, VPApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
m_graphicsView->GetScene()->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
m_graphicsView->CleanAfterExport();
}
VPExporter exporter;
exporter.Export(m_layout, format, m_graphicsView);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -40,6 +40,7 @@
#include "vppiece.h" #include "vppiece.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
#include "vptilefactory.h" #include "vptilefactory.h"
#include "vpexporter.h"
#include "vpcommandline.h" #include "vpcommandline.h"
#include "../vlayout/vlayoutdef.h" #include "../vlayout/vlayoutdef.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
@ -105,7 +106,7 @@ protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
virtual QStringList RecentFileList() const override; virtual QStringList RecentFileList() const override;
private slots: private slots:
/** /**
* @brief on_actionOpen_triggered When the menu action File > Open is * @brief on_actionOpen_triggered When the menu action File > Open is
* triggered. * triggered.

View File

@ -668,7 +668,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-153</y>
<width>342</width> <width>342</width>
<height>870</height> <height>870</height>
</rect> </rect>
@ -934,7 +934,11 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetGridColWidth"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetGridColWidth">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="labelSheetGridRowHeight"> <widget class="QLabel" name="labelSheetGridRowHeight">
@ -944,7 +948,11 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetGridRowHeight"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetGridRowHeight">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -349,151 +349,6 @@ Draw DialogSaveLayout::Mode() const
return m_mode; 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() DialogSaveLayout::~DialogSaveLayout()
{ {
@ -525,7 +380,7 @@ void DialogSaveLayout::Save()
for (int i=0; i < count; ++i) 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)) if (QFile::exists(name))
{ {
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"), QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
@ -573,7 +428,7 @@ void DialogSaveLayout::PathChanged(const QString &text)
void DialogSaveLayout::ShowExample() void DialogSaveLayout::ShowExample()
{ {
const LayoutExportFormats currentFormat = Format(); 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->checkBoxBinaryDXF->setEnabled(false);
ui->groupBoxPaperFormat->setEnabled(false); ui->groupBoxPaperFormat->setEnabled(false);
@ -822,7 +677,7 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
auto InitFormat = [&list](LayoutExportFormats format) 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); InitFormat(LayoutExportFormats::SVG);

View File

@ -61,9 +61,6 @@ public:
Draw Mode() const; Draw Mode() const;
static QString ExportFormatDescription(LayoutExportFormats format);
static QString ExportFormatSuffix(LayoutExportFormats format);
bool IsTextAsPaths() const; bool IsTextAsPaths() const;
void SetTextAsPaths(bool textAsPaths); void SetTextAsPaths(bool textAsPaths);

View File

@ -514,7 +514,7 @@ void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails)
for (int i = 0; i < detailsOnLayout.size(); ++i) for (int i = 0; i < detailsOnLayout.size(); ++i)
{ {
const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + 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<QGraphicsRectItem *>( QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(
m_layoutSettings->LayoutPapers().at(i)); m_layoutSettings->LayoutPapers().at(i));
@ -827,7 +827,7 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector<VLayoutPiece> listDe
} }
const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + 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()); ExportApparelLayout(listDetails, name, rect.size());
} }
@ -1110,7 +1110,7 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
if (paper != nullptr) if (paper != nullptr)
{ {
const QString name = m_dialogSaveLayout->Path() + '/' + m_dialogSaveLayout->FileName() + 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(); auto *brush = new QBrush();
brush->setColor( QColor( Qt::white ) ); brush->setColor( QColor( Qt::white ) );
QGraphicsScene *scene = scenes.at(i); QGraphicsScene *scene = scenes.at(i);

View File

@ -433,3 +433,149 @@ void VLayoutExporter::PdfToPs(const QStringList &params)
qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2").arg(params.last(), proc.errorString())); 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();
}
}

View File

@ -34,6 +34,8 @@
#include <QString> #include <QString>
#include <QCoreApplication> #include <QCoreApplication>
#include "../vlayout/vlayoutdef.h"
class QGraphicsScene; class QGraphicsScene;
class QGraphicsItem; class QGraphicsItem;
class VLayoutPiece; class VLayoutPiece;
@ -91,6 +93,9 @@ public:
static auto SupportPDFConversion() -> bool; static auto SupportPDFConversion() -> bool;
static QString ExportFormatDescription(LayoutExportFormats format);
static QString ExportFormatSuffix(LayoutExportFormats format);
private: private:
QString m_fileName{}; QString m_fileName{};
QMarginsF m_margins{}; QMarginsF m_margins{};