Export to DXF-AAMA.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-07-16 21:10:48 +03:00
parent bcd61305c3
commit 54eadfdb3c
24 changed files with 979 additions and 240 deletions

View File

@ -71,6 +71,33 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14," .BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14,"
.RE .RE
.RS .RS
.BR "*" " AutoCAD DXF R10 AAMA files (*.dxf) = 15,"
.RE
.RS
.BR "*" " AutoCAD DXF R11/12 AAMA files (*.dxf) = 16,"
.RE
.RS
.BR "*" " AutoCAD DXF R13 AAMA files (*.dxf) = 17,"
.RE
.RS
.BR "*" " AutoCAD DXF R14 AAMA files (*.dxf) = 18,"
.RE
.RS
.BR "*" " AutoCAD DXF 2000 AAMA files (*.dxf) = 19,"
.RE
.RS
.BR "*" " AutoCAD DXF 2004 AAMA files (*.dxf) = 20,"
.RE
.RS
.BR "*" " AutoCAD DXF 2007 AAMA files (*.dxf) = 21,"
.RE
.RS
.BR "*" " AutoCAD DXF 2010 AAMA files (*.dxf) = 22,"
.RE
.RS
.BR "*" " AutoCAD DXF 2013 AAMA files (*.dxf) = 23,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33." .BR "*" " PDF tiled files (*.pdf) = 33."
.RE .RE
.IP "--bdxf" .IP "--bdxf"

View File

@ -71,6 +71,33 @@ The path to output destination folder. By default the directory at which the app
.BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14," .BR "*" " AutoCAD DXF 2013 (flat) files (*.dxf) = 14,"
.RE .RE
.RS .RS
.BR "*" " AutoCAD DXF R10 AAMA files (*.dxf) = 15,"
.RE
.RS
.BR "*" " AutoCAD DXF R11/12 AAMA files (*.dxf) = 16,"
.RE
.RS
.BR "*" " AutoCAD DXF R13 AAMA files (*.dxf) = 17,"
.RE
.RS
.BR "*" " AutoCAD DXF R14 AAMA files (*.dxf) = 18,"
.RE
.RS
.BR "*" " AutoCAD DXF 2000 AAMA files (*.dxf) = 19,"
.RE
.RS
.BR "*" " AutoCAD DXF 2004 AAMA files (*.dxf) = 20,"
.RE
.RS
.BR "*" " AutoCAD DXF 2007 AAMA files (*.dxf) = 21,"
.RE
.RS
.BR "*" " AutoCAD DXF 2010 AAMA files (*.dxf) = 22,"
.RE
.RS
.BR "*" " AutoCAD DXF 2013 AAMA files (*.dxf) = 23,"
.RE
.RS
.BR "*" " PDF tiled files (*.pdf) = 33." .BR "*" " PDF tiled files (*.pdf) = 33."
.RE .RE
.IP "--bdxf" .IP "--bdxf"

View File

@ -331,9 +331,9 @@ QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format)
case LayoutExportFormats::DXF_AC1027_Flat: case LayoutExportFormats::DXF_AC1027_Flat:
return QString("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix); return QString("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1006_AAMA: case LayoutExportFormats::DXF_AC1006_AAMA:
return QString("AutoCAD DXF R10 AAMA %1 %2").arg(dxfFlatFilesStr, dxfSuffix); return QString("AutoCAD DXF R10 AAMA %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1009_AAMA: case LayoutExportFormats::DXF_AC1009_AAMA:
return QString("AutoCAD DXF R11/12 AAMA %1 %2").arg(dxfFlatFilesStr, dxfSuffix); return QString("AutoCAD DXF R11/12 AAMA %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1012_AAMA: case LayoutExportFormats::DXF_AC1012_AAMA:
return QString("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix); return QString("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1014_AAMA: case LayoutExportFormats::DXF_AC1014_AAMA:
@ -648,17 +648,16 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
InitFormat(LayoutExportFormats::DXF_AC1021_Flat); InitFormat(LayoutExportFormats::DXF_AC1021_Flat);
InitFormat(LayoutExportFormats::DXF_AC1024_Flat); InitFormat(LayoutExportFormats::DXF_AC1024_Flat);
InitFormat(LayoutExportFormats::DXF_AC1027_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);
// We will support them anyway // We will support them anyway
// 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_AC1006_ASTM);
// InitFormat(LayoutExportFormats::DXF_AC1009_ASTM); // InitFormat(LayoutExportFormats::DXF_AC1009_ASTM);
// InitFormat(LayoutExportFormats::DXF_AC1012_ASTM); // InitFormat(LayoutExportFormats::DXF_AC1012_ASTM);

View File

@ -4399,7 +4399,7 @@ void MainWindow::ExportLayoutAs()
return; return;
} }
ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins); ExportData(QVector<VLayoutPiece>(), dialog);
} }
catch (const VException &e) catch (const VException &e)
{ {

View File

@ -60,6 +60,30 @@
# define PDFTOPS "pdftops" # define PDFTOPS "pdftops"
#endif #endif
namespace
{
bool CreateLayoutPath(const QString &path)
{
bool usedNotExistedDir = true;
QDir dir(path);
dir.setPath(path);
if (not dir.exists(path))
{
usedNotExistedDir = dir.mkpath(".");
}
return usedNotExistedDir;
}
void RemoveLayoutPath(const QString &path, bool usedNotExistedDir)
{
if (usedNotExistedDir)
{
QDir dir(path);
dir.rmpath(".");
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
: VAbstractMainWindow(parent), : VAbstractMainWindow(parent),
@ -72,6 +96,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
shadows(), shadows(),
scenes(), scenes(),
details(), details(),
detailsOnLayout(),
undoAction(nullptr), undoAction(nullptr),
redoAction(nullptr), redoAction(nullptr),
actionDockWidgetToolOptions(nullptr), actionDockWidgetToolOptions(nullptr),
@ -148,7 +173,8 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
case LayoutErrors::NoError: case LayoutErrors::NoError:
CleanLayout(); CleanLayout();
papers = lGenerator.GetPapersItems();// Blank sheets papers = lGenerator.GetPapersItems();// Blank sheets
details = lGenerator.GetAllDetails();// All details details = lGenerator.GetAllDetailsItems();// All details items
detailsOnLayout = lGenerator.GetAllDetails();// All details items
shadows = CreateShadows(papers); shadows = CreateShadows(papers);
scenes = CreateScenes(papers, shadows, details); scenes = CreateScenes(papers, shadows, details);
PrepareSceneList(); PrepareSceneList();
@ -200,13 +226,90 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog) void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog)
{
const LayoutExportFormats format = dialog.Format();
if (format == LayoutExportFormats::DXF_AC1006_AAMA ||
format == LayoutExportFormats::DXF_AC1009_AAMA ||
format == LayoutExportFormats::DXF_AC1012_AAMA ||
format == LayoutExportFormats::DXF_AC1014_AAMA ||
format == LayoutExportFormats::DXF_AC1015_AAMA ||
format == LayoutExportFormats::DXF_AC1018_AAMA ||
format == LayoutExportFormats::DXF_AC1021_AAMA ||
format == LayoutExportFormats::DXF_AC1024_AAMA ||
format == LayoutExportFormats::DXF_AC1027_AAMA)
{ {
if (dialog.Mode() == Draw::Layout) if (dialog.Mode() == Draw::Layout)
{ {
ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins); for (int i = 0; i < detailsOnLayout.size(); ++i)
{
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
SCASSERT(paper != nullptr)
ExportApparelLayout(dialog, detailsOnLayout.at(i), name, paper->rect().size().toSize());
}
} }
else else
{ {
ExportDetailsAsApparelLayout(dialog, listDetails);
}
}
else
{
if (dialog.Mode() == Draw::Layout)
{
ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
}
else
{
ExportDetailsAsFlatLayout(dialog, listDetails);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportFlatLayout(const DialogSaveLayout &dialog, const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details, bool ignorePrinterFields,
const QMarginsF &margins)
{
const QString path = dialog.Path();
bool usedNotExistedDir = CreateLayoutPath(path);
if (not usedNotExistedDir)
{
qCritical() << tr("Can't create a path");
return;
}
qApp->ValentinaSettings()->SetPathLayout(path);
const LayoutExportFormats format = dialog.Format();
if (format == LayoutExportFormats::PDFTiled && dialog.Mode() == Draw::Layout)
{
const QString name = path + QLatin1String("/") + dialog.FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
PdfTiledFile(name);
}
else
{
ExportScene(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
}
RemoveLayoutPath(path, usedNotExistedDir);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog,
const QVector<VLayoutPiece> &listDetails)
{
if (listDetails.isEmpty())
{
return;
}
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene()); QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
@ -251,70 +354,29 @@ void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, cons
const bool ignorePrinterFields = false; const bool ignorePrinterFields = false;
const qreal margin = ToPixel(1, Unit::Cm); const qreal margin = ToPixel(1, Unit::Cm);
ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields,
QMarginsF(margin, margin, margin, margin)); QMarginsF(margin, margin, margin, margin));
qDeleteAll(scenes);//Scene will clear all other items qDeleteAll(scenes);//Scene will clear all other items
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog, const QList<QGraphicsScene *> &scenes, void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &details,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &shadows, const QString &name, const QSize &size) const
const QList<QList<QGraphicsItem *> > &details, bool ignorePrinterFields,
const QMarginsF &margins)
{ {
const QString path = dialog.Path(); const QString path = dialog.Path();
bool usedNotExistedDir = false; bool usedNotExistedDir = CreateLayoutPath(path);
QDir dir(path);
dir.setPath(path);
if (not dir.exists(path))
{
usedNotExistedDir = dir.mkpath(".");
if (not usedNotExistedDir) if (not usedNotExistedDir)
{ {
qCritical() << tr("Can't create a path"); qCritical() << tr("Can't create a path");
return; return;
} }
}
qApp->ValentinaSettings()->SetPathLayout(path);
const QString mask = dialog.FileName();
const LayoutExportFormats format = dialog.Format();
if (format == LayoutExportFormats::PDFTiled && dialog.Mode() == Draw::Layout) qApp->ValentinaSettings()->SetPathLayout(path);
{ const LayoutExportFormats format = dialog.Format();
const QString name = path + QLatin1String("/") + mask + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(format);
PdfTiledFile(name);
}
else
{
for (int i=0; i < scenes.size(); ++i)
{
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
const QString name = path + QLatin1String("/") + mask+QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(format);
QBrush *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));
switch (format) switch (format)
{ {
case LayoutExportFormats::PDFTiled: // Handled separately
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_AC1006_ASTM:
case LayoutExportFormats::DXF_AC1009_ASTM: case LayoutExportFormats::DXF_AC1009_ASTM:
case LayoutExportFormats::DXF_AC1012_ASTM: case LayoutExportFormats::DXF_AC1012_ASTM:
@ -326,92 +388,95 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog, const QList<
case LayoutExportFormats::DXF_AC1027_ASTM: case LayoutExportFormats::DXF_AC1027_ASTM:
Q_UNREACHABLE(); // For now not supported Q_UNREACHABLE(); // For now not supported
break; break;
case LayoutExportFormats::SVG: case LayoutExportFormats::DXF_AC1006_AAMA:
paper->setVisible(false); AAMADxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), size, details);
SvgFile(name, paper, scene);
paper->setVisible(true);
break; break;
case LayoutExportFormats::PDF: case LayoutExportFormats::DXF_AC1009_AAMA:
PdfFile(name, paper, scene, ignorePrinterFields, margins); AAMADxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), size, details);
break; break;
case LayoutExportFormats::PNG: case LayoutExportFormats::DXF_AC1012_AAMA:
PngFile(name, paper, scene); AAMADxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), size, details);
break; break;
case LayoutExportFormats::OBJ: case LayoutExportFormats::DXF_AC1014_AAMA:
paper->setVisible(false); AAMADxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), size, details);
ObjFile(name, paper, scene);
paper->setVisible(true);
break; break;
case LayoutExportFormats::PS: case LayoutExportFormats::DXF_AC1015_AAMA:
PsFile(name, paper, scene, ignorePrinterFields, margins); AAMADxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), size, details);
break; break;
case LayoutExportFormats::EPS: case LayoutExportFormats::DXF_AC1018_AAMA:
EpsFile(name, paper, scene, ignorePrinterFields, margins); AAMADxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), size, details);
break; break;
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1021_AAMA:
paper->setVisible(false); AAMADxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), size, details);
DxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break; break;
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1024_AAMA:
paper->setVisible(false); AAMADxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), size, details);
DxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break; break;
case LayoutExportFormats::DXF_AC1012_Flat: case LayoutExportFormats::DXF_AC1027_AAMA:
paper->setVisible(false); AAMADxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), size, details);
DxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1014_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1015_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1018_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1021_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1024_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1027_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break; break;
default: default:
qDebug() << "Can't recognize file suffix." << Q_FUNC_INFO; qDebug() << "Can't recognize file type." << Q_FUNC_INFO;
break; break;
} }
paper->setPen(QPen(Qt::black, 1));
brush->setColor( QColor( Qt::gray ) ); RemoveLayoutPath(path, usedNotExistedDir);
brush->setStyle( Qt::SolidPattern );
scenes[i]->setBackgroundBrush( *brush );
shadows[i]->setVisible(true);
delete brush;
}
}
} }
if (usedNotExistedDir) //---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsApparelLayout(const DialogSaveLayout &dialog,
QVector<VLayoutPiece> listDetails)
{ {
QDir directory(dir); if (listDetails.isEmpty())
directory.rmpath("."); {
return;
} }
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list;
for (int i=0; i < listDetails.count(); ++i)
{
QGraphicsItem *item = listDetails.at(i).GetItem(dialog.IsTextAsPaths());
item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy());
list.append(item);
}
for (int i=0; i < list.size(); ++i)
{
scene->addItem(list.at(i));
}
QRect rect = scene->itemsBoundingRect().toRect();
const int mx = rect.x();
const int my = rect.y();
QTransform matrix;
matrix = matrix.translate(-mx, -my);
for (int i=0; i < list.size(); ++i)
{
list.at(i)->setTransform(matrix);
}
rect = scene->itemsBoundingRect().toRect();
for (int i=0; i < listDetails.count(); ++i)
{
QTransform moveMatrix;
matrix = matrix.translate(listDetails.at(i).GetMx(), listDetails.at(i).GetMy());
matrix = matrix.translate(-mx, -my);
moveMatrix *= listDetails.at(i).GetMatrix();
listDetails[i].SetMatrix(moveMatrix);
listDetails[i].SetMx(listDetails.at(i).GetMx()-mx);
listDetails[i].SetMy(listDetails.at(i).GetMy()-my);
}
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
ExportApparelLayout(dialog, listDetails, name, rect.size());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -943,7 +1008,7 @@ void MainWindowsNoGUI::ObjFile(const QString &name, QGraphicsRectItem *paper, QG
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default") QT_WARNING_DISABLE_GCC("-Wswitch-default")
void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, void MainWindowsNoGUI::FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper,
QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const
{ {
PrepareTextForDXF(endStringPlaceholder, details); PrepareTextForDXF(endStringPlaceholder, details);
@ -980,6 +1045,37 @@ void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, QG
RestoreTextAfterDXF(endStringPlaceholder, details); RestoreTextAfterDXF(endStringPlaceholder, details);
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::AAMADxfFile(const QString &name, int version, bool binary, const QSize &size,
const QVector<VLayoutPiece> &details) const
{
VDxfPaintDevice generator;
generator.setFileName(name);
generator.setSize(size);
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(version));
generator.SetBinaryFormat(binary);
switch (*pattern->GetPatternUnit())
{
case Unit::Cm:
generator.setInsunits(VarInsunits::Centimeters);
break;
case Unit::Mm:
generator.setInsunits(VarInsunits::Millimeters);
break;
case Unit::Inch:
generator.setInsunits(VarInsunits::Inches);
break;
case Unit::Px:
case Unit::LAST_UNIT_DO_NOT_USE:
Q_UNREACHABLE();
break;
}
generator.ExportToAAMA(details);
}
QT_WARNING_POP QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1345,6 +1441,109 @@ bool MainWindowsNoGUI::IsPagesFit(const QSizeF &printPaper) const
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details, bool ignorePrinterFields,
const QMarginsF &margins) const
{
for (int i=0; i < scenes.size(); ++i)
{
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
QBrush *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));
switch (dialog.Format())
{
case LayoutExportFormats::SVG:
paper->setVisible(false);
SvgFile(name, paper, scene);
paper->setVisible(true);
break;
case LayoutExportFormats::PDF:
PdfFile(name, paper, scene, ignorePrinterFields, margins);
break;
case LayoutExportFormats::PNG:
PngFile(name, paper, scene);
break;
case LayoutExportFormats::OBJ:
paper->setVisible(false);
ObjFile(name, paper, scene);
paper->setVisible(true);
break;
case LayoutExportFormats::PS:
PsFile(name, paper, scene, ignorePrinterFields, margins);
break;
case LayoutExportFormats::EPS:
EpsFile(name, paper, scene, ignorePrinterFields, margins);
break;
case LayoutExportFormats::DXF_AC1006_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1009_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1012_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1014_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1015_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1018_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1021_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1024_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1027_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
default:
qDebug() << "Can't recognize file type." << Q_FUNC_INFO;
break;
}
paper->setPen(QPen(Qt::black, 1));
brush->setColor( QColor( Qt::gray ) );
brush->setStyle( Qt::SolidPattern );
scenes[i]->setBackgroundBrush( *brush );
shadows[i]->setVisible(true);
delete brush;
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString MainWindowsNoGUI::FileName() const QString MainWindowsNoGUI::FileName() const
{ {

View File

@ -75,6 +75,8 @@ protected:
QList<QGraphicsScene *> scenes; QList<QGraphicsScene *> scenes;
QList<QList<QGraphicsItem *> > details; QList<QList<QGraphicsItem *> > details;
QVector<QVector<VLayoutPiece> > detailsOnLayout;
QAction *undoAction; QAction *undoAction;
QAction *redoAction; QAction *redoAction;
QAction *actionDockWidgetToolOptions; QAction *actionDockWidgetToolOptions;
@ -92,12 +94,6 @@ protected:
static QVector<VLayoutPiece> PrepareDetailsForLayout(const QHash<quint32, VPiece> &details); static QVector<VLayoutPiece> PrepareDetailsForLayout(const QHash<quint32, VPiece> &details);
void ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog); void ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog);
void ExportLayout(const DialogSaveLayout &dialog,
const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details,
bool ignorePrinterFields, const QMarginsF &margins);
void InitTempLayoutScene(); void InitTempLayoutScene();
virtual void CleanLayout()=0; virtual void CleanLayout()=0;
@ -134,8 +130,10 @@ private:
const QMarginsF &margins)const; const QMarginsF &margins)const;
void PdfToPs(const QStringList &params)const; void PdfToPs(const QStringList &params)const;
void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const; void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const;
void DxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene, void FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene,
const QList<QList<QGraphicsItem *> > &details)const; const QList<QList<QGraphicsItem *> > &details)const;
void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size,
const QVector<VLayoutPiece> &details) const;
void PreparePaper(int index) const; void PreparePaper(int index) const;
void RestorePaper(int index) const; void RestorePaper(int index) const;
@ -154,6 +152,27 @@ private:
bool isPagesUniform() const; bool isPagesUniform() const;
bool IsPagesFit(const QSizeF &printPaper) const; bool IsPagesFit(const QSizeF &printPaper) const;
void ExportScene(const DialogSaveLayout &dialog,
const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details,
bool ignorePrinterFields, const QMarginsF &margins) const;
void ExportApparelLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) const;
void ExportDetailsAsApparelLayout(const DialogSaveLayout &dialog, QVector<VLayoutPiece> listDetails);
void ExportFlatLayout(const DialogSaveLayout &dialog,
const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details,
bool ignorePrinterFields, const QMarginsF &margins);
void ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &listDetails);
}; };
#endif // MAINWINDOWSNOGUI_H #endif // MAINWINDOWSNOGUI_H

View File

@ -25,8 +25,7 @@ dx_iface::dx_iface(const std::string &file, DRW::Version v, VarMeasurement varMe
version(v) version(v)
{ {
InitHeader(varMeasurement, varInsunits); InitHeader(varMeasurement, varInsunits);
InitLTypes(); InitDefLayers();
InitLayers();
InitTextstyles(); InitTextstyles();
InitAppId(); InitAppId();
} }
@ -192,7 +191,7 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits
} }
} }
void dx_iface::InitLTypes() void dx_iface::AddQtLTypes()
{ {
DRW_LType ltype; DRW_LType ltype;
ltype.name = "DOT"; ltype.name = "DOT";
@ -237,21 +236,54 @@ void dx_iface::InitLTypes()
cData.lineTypes.push_back(ltype); cData.lineTypes.push_back(ltype);
} }
void dx_iface::InitLayers() void dx_iface::AddAAMALayers()
{
DRW_Layer layer;
layer.name = "1";// CUT, OUTLINE
layer.color = DRW::black;
cData.layers.push_back(layer);
layer.name = "8";// DRAW, INK
layer.color = DRW::black;
cData.layers.push_back(layer);
layer.name = "7";// GRAINLINE
layer.color = DRW::black;
cData.layers.push_back(layer);
// layer.name = "6";// MIRROR LINES
// layer.color = DRW::black;
// cData.layers.push_back(layer);
layer.name = "11";// INTCUT
layer.color = DRW::black;
cData.layers.push_back(layer);
// layer.name = "13";// DRILL
// layer.color = DRW::black;
// cData.layers.push_back(layer);
layer.name = "4";// NOTCH
layer.color = DRW::black;
cData.layers.push_back(layer);
layer.name = "19";// TEXT
layer.color = DRW::black;
cData.layers.push_back(layer);
// layer.name = "26";// REF
// layer.color = DRW::black;
// cData.layers.push_back(layer);
}
void dx_iface::InitDefLayers()
{ {
DRW_Layer defLayer; DRW_Layer defLayer;
defLayer.name = "0"; defLayer.name = "0";
defLayer.color = DRW::black; // default color defLayer.color = DRW::black; // default color
defLayer.lWeight = DRW_LW_Conv::width03; // default width defLayer.lWeight = DRW_LW_Conv::width03; // default width
defLayer.lineType = "CONTINUOUS"; // default line style
cData.layers.push_back(defLayer); cData.layers.push_back(defLayer);
// DRW_Layer mLayer;
// mLayer.name = "mainlayer";
// mLayer.color = DRW::black; // default color
// mLayer.lWeight = 100; // default width
// mLayer.lineType = "CONTINUOUS"; // default line style
// cData.lineTypes.push_back(mLayer);
} }
void dx_iface::InitTextstyles() void dx_iface::InitTextstyles()
@ -309,6 +341,11 @@ UTF8STRING dx_iface::AddFont(const QFont &f)
return ts.name; return ts.name;
} }
void dx_iface::AddBlock(dx_ifaceBlock *block)
{
cData.blocks.push_back(block);
}
std::string dx_iface::LocaleToISO() std::string dx_iface::LocaleToISO()
{ {
QMap <std::string, std::string> locMap; QMap <std::string, std::string> locMap;

View File

@ -118,6 +118,10 @@ public:
void AddEntity(DRW_Entity* e); void AddEntity(DRW_Entity* e);
UTF8STRING AddFont(const QFont &f); UTF8STRING AddFont(const QFont &f);
void AddBlock(dx_ifaceBlock* block);
void AddQtLTypes();
void AddAAMALayers();
private: private:
Q_DISABLE_COPY(dx_iface) Q_DISABLE_COPY(dx_iface)
@ -126,8 +130,7 @@ private:
DRW::Version version; DRW::Version version;
void InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits); void InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits);
void InitLTypes(); void InitDefLayers();
void InitLayers();
void InitTextstyles(); void InitTextstyles();
void InitAppId(); void InitAppId();

View File

@ -272,7 +272,7 @@ public:
{ {
// eType = DRW::LWPOLYLINE; // eType = DRW::LWPOLYLINE;
} }
DRW_Vertex2D(double sx, double sy, double b) DRW_Vertex2D(double sx, double sy, double b = 0.0)
: x(sx), : x(sx),
y(sy), y(sy),
stawidth(0), stawidth(0),

View File

@ -762,7 +762,7 @@ public:
eType = DRW::VERTEX; eType = DRW::VERTEX;
} }
DRW_Vertex(double sx, double sy, double sz, double b) DRW_Vertex(double sx, double sy, double sz = 0.0, double b = 0.0)
: stawidth(0), : stawidth(0),
endwidth(0), endwidth(0),
bulge(b), bulge(b),

View File

@ -49,6 +49,9 @@
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "dxiface.h" #include "dxiface.h"
#include "../vlayout/vlayoutpiece.h"
static const qreal AAMATextHeight = 2.5;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
@ -93,6 +96,13 @@ VDxfEngine::~VDxfEngine()
bool VDxfEngine::begin(QPaintDevice *pdev) bool VDxfEngine::begin(QPaintDevice *pdev)
{ {
Q_UNUSED(pdev) Q_UNUSED(pdev)
if (isActive())
{
qWarning("VDxfEngine::begin(), the engine was alredy activated");
return false;
}
if (size.isValid() == false) if (size.isValid() == false)
{ {
qWarning()<<"VDxfEngine::begin(), size is not valid"; qWarning()<<"VDxfEngine::begin(), size is not valid";
@ -100,6 +110,7 @@ bool VDxfEngine::begin(QPaintDevice *pdev)
} }
input = QSharedPointer<dx_iface>(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits)); input = QSharedPointer<dx_iface>(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits));
input->AddQtLTypes();
return true; return true;
} }
@ -571,7 +582,259 @@ double VDxfEngine::FromPixel(double pix, const VarInsunits &unit) const
case VarInsunits::Inches: case VarInsunits::Inches:
return pix / resolution; return pix / resolution;
} }
return 0; return pix;
}
//---------------------------------------------------------------------------------------------------------------------
double VDxfEngine::ToPixel(double val, const VarInsunits &unit) const
{
switch (unit)
{
case VarInsunits::Millimeters:
return (val / 25.4) * resolution;
case VarInsunits::Centimeters:
return ((val * 10.0) / 25.4) * resolution;
case VarInsunits::Inches:
return val * resolution;
}
return val;
} }
QT_WARNING_POP QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
{
if (size.isValid() == false)
{
qWarning()<<"VDxfEngine::begin(), size is not valid";
return false;
}
input = QSharedPointer<dx_iface>(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits));
input->AddAAMALayers();
ExportAAMAGlobalText(input, details);
for(int i = 0; i < details.size(); ++i)
{
const VLayoutPiece &detail = details.at(i);
dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
detailBlock->name = detail.GetName().toStdString();
ExportAAMAOutline(detailBlock, detail);
ExportAAMADraw(detailBlock, detail);
ExportAAMAIntcut(detailBlock, detail);
ExportAAMANotch(detailBlock, detail);
ExportAAMAGrainline(detailBlock, detail);
ExportAAMAText(detailBlock, detail);
input->AddBlock(detailBlock);
DRW_Insert *insert = new DRW_Insert();
insert->name = detail.GetName().toStdString();
insert->basePoint = DRW_Coord(FromPixel(detail.GetMx(), varInsunits),
FromPixel(- detail.GetMy(), varInsunits), 0);
insert->layer = "0";
input->AddEntity(insert);
}
return input->fileExport(m_binary);
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
QVector<QPointF> outline;
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
{
outline = detail.GetSeamAllowancePoints();
}
else
{
outline = detail.GetContourPoints();
}
DRW_Entity *e = AAMAPolygon(outline, "1", true);
if (e)
{
detailBlock->ent.push_back(e);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
if (not detail.IsHideMainPath())
{
QVector<QPointF> poly = detail.GetContourPoints();
DRW_Entity *e = AAMAPolygon(poly, "8", true);
if (e)
{
detailBlock->ent.push_back(e);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
QVector<QVector<QPointF>> drawIntCut = detail.InternalPathsForCut(false);
for(int j = 0; j < drawIntCut.size(); ++j)
{
DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "8", false);
if (e)
{
detailBlock->ent.push_back(e);
}
}
drawIntCut = detail.InternalPathsForCut(true);
for(int j = 0; j < drawIntCut.size(); ++j)
{
DRW_Entity *e = AAMAPolygon(drawIntCut.at(j), "11", false);
if (e)
{
detailBlock->ent.push_back(e);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
if (detail.IsSeamAllowance())
{
QVector<QLineF> passmarks = detail.GetPassmarks();
for(int i = 0; i < passmarks.size(); ++i)
{
DRW_Entity *e = AAMALine(passmarks.at(i), "4");
if (e)
{
detailBlock->ent.push_back(e);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
const QVector<QPointF> grainline = detail.GetGrainline();
if (grainline.count() > 1)
{
DRW_Entity *e = AAMALine(QLineF(grainline.last(), grainline.first()), "7");
if (e)
{
detailBlock->ent.push_back(e);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
{
const QStringList list = detail.GetPieceText();
const QPointF startPos = detail.GetPieceTextPosition();
for (int i = 0; i < list.size(); ++i)
{
QPointF pos(startPos.x(), startPos.y() - ToPixel(AAMATextHeight, varInsunits)*(list.size() - i-1));
detailBlock->ent.push_back(AAMAText(pos, list.at(i), "19"));
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details)
{
for(int i = 0; i < details.size(); ++i)
{
const QStringList strings = details.at(i).GetPatternText();
if (not strings.isEmpty())
{
for (int j = 0; j < strings.size(); ++j)
{
QPointF pos(0, getSize().height() - ToPixel(AAMATextHeight, varInsunits)*(strings.size() - j-1));
input->AddEntity(AAMAText(pos, strings.at(j), "1"));
}
return;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
DRW_Entity *VDxfEngine::AAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed)
{
if (polygon.isEmpty())
{
return nullptr;
}
if (m_version > DRW::AC1009)
{ // Use lwpolyline
return CreateAAMAPolygon<DRW_LWPolyline, DRW_Vertex2D>(polygon, layer, forceClosed);
}
else
{ // Use polyline
return CreateAAMAPolygon<DRW_Polyline, DRW_Vertex>(polygon, layer, forceClosed);
}
}
//---------------------------------------------------------------------------------------------------------------------
DRW_Entity *VDxfEngine::AAMALine(const QLineF &line, const QString &layer)
{
DRW_Line *lineEnt = new DRW_Line();
lineEnt->basePoint = DRW_Coord(FromPixel(line.p1().x(), varInsunits),
FromPixel(getSize().height() - line.p1().y(), varInsunits), 0);
lineEnt->secPoint = DRW_Coord(FromPixel(line.p2().x(), varInsunits),
FromPixel(getSize().height() - line.p2().y(), varInsunits), 0);
lineEnt->layer = layer.toStdString();
return lineEnt;
}
//---------------------------------------------------------------------------------------------------------------------
DRW_Entity *VDxfEngine::AAMAText(const QPointF &pos, const QString &text, const QString &layer)
{
DRW_Text *textLine = new DRW_Text();
textLine->basePoint = DRW_Coord(FromPixel(pos.x(), varInsunits),
FromPixel(getSize().height() - pos.y(), varInsunits), 0);
textLine->secPoint = DRW_Coord(FromPixel(pos.x(), varInsunits),
FromPixel(getSize().height() - pos.y(), varInsunits), 0);
textLine->height = AAMATextHeight;
textLine->layer = layer.toStdString();
textLine->text = text.toStdString();
return textLine;
}
//---------------------------------------------------------------------------------------------------------------------
template<class P, class V>
P *VDxfEngine::CreateAAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed)
{
P *poly = new P();
poly->layer = layer.toStdString();
if (forceClosed)
{
poly->flags |= 0x1; // closed
}
else
{
if (polygon.size() > 1 && polygon.first() == polygon.last())
{
poly->flags |= 0x1; // closed
}
}
for (int i=0; i < polygon.count(); ++i)
{
poly->addVertex(V(FromPixel(polygon.at(i).x(), varInsunits),
FromPixel(getSize().height() - polygon.at(i).y(), varInsunits)));
}
return poly;
}

View File

@ -46,9 +46,13 @@
class QTextStream; class QTextStream;
class dx_iface; class dx_iface;
class DRW_Text; class DRW_Text;
class VLayoutPiece;
class DRW_Entity;
class dx_ifaceBlock;
class VDxfEngine : public QPaintEngine class VDxfEngine : public QPaintEngine
{ {
friend class VDxfPaintDevice;
public: public:
VDxfEngine(); VDxfEngine();
virtual ~VDxfEngine(); virtual ~VDxfEngine();
@ -102,6 +106,23 @@ private:
DRW_Text *textBuffer; DRW_Text *textBuffer;
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const; Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
Q_REQUIRED_RESULT double ToPixel(double val, const VarInsunits &unit) const;
bool ExportToAAMA(const QVector<VLayoutPiece> &details);
void ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
void ExportAAMAGlobalText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details);
Q_REQUIRED_RESULT DRW_Entity *AAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
Q_REQUIRED_RESULT DRW_Entity *AAMALine(const QLineF &line, const QString &layer);
Q_REQUIRED_RESULT DRW_Entity *AAMAText(const QPointF &pos, const QString &text, const QString &layer);
template<class P, class V>
Q_REQUIRED_RESULT P *CreateAAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
}; };
#endif // VDXFENGINE_H #endif // VDXFENGINE_H

View File

@ -162,6 +162,15 @@ void VDxfPaintDevice::setInsunits(const VarInsunits &var)
engine->setInsunits(var); engine->setInsunits(var);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VDxfPaintDevice::ExportToAAMA(const QVector<VLayoutPiece> &details) const
{
engine->setActive(true);
const bool res = engine->ExportToAAMA(details);
engine->setActive(false);
return res;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
{ {

View File

@ -39,6 +39,7 @@
#include "libdxfrw/drw_base.h" #include "libdxfrw/drw_base.h"
class VDxfEngine; class VDxfEngine;
class VLayoutPiece;
class VDxfPaintDevice : public QPaintDevice class VDxfPaintDevice : public QPaintDevice
{ {
@ -65,6 +66,8 @@ public:
void setMeasurement(const VarMeasurement &var); void setMeasurement(const VarMeasurement &var);
void setInsunits(const VarInsunits &var); void setInsunits(const VarInsunits &var);
bool ExportToAAMA(const QVector<VLayoutPiece> &details) const;
protected: protected:
virtual int metric(PaintDeviceMetric metric) const Q_DECL_OVERRIDE; virtual int metric(PaintDeviceMetric metric) const Q_DECL_OVERRIDE;
private: private:

View File

@ -216,7 +216,7 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetails() const QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetailsItems() const
{ {
QList<QList<QGraphicsItem *> > list; QList<QList<QGraphicsItem *> > list;
for (int i=0; i < papers.count(); ++i) for (int i=0; i < papers.count(); ++i)
@ -226,6 +226,17 @@ QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetails() const
return list; return list;
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QVector<VLayoutPiece> > VLayoutGenerator::GetAllDetails() const
{
QVector<QVector<VLayoutPiece> > list;
for (int i=0; i < papers.count(); ++i)
{
list.append(papers.at(i).GetDetails());
}
return list;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::Abort() void VLayoutGenerator::Abort()
{ {

View File

@ -83,7 +83,9 @@ public:
LayoutErrors State() const; LayoutErrors State() const;
Q_REQUIRED_RESULT QList<QGraphicsItem *> GetPapersItems() const; Q_REQUIRED_RESULT QList<QGraphicsItem *> GetPapersItems() const;
Q_REQUIRED_RESULT QList<QList<QGraphicsItem *>> GetAllDetails() const; Q_REQUIRED_RESULT QList<QList<QGraphicsItem *>> GetAllDetailsItems() const;
QVector<QVector<VLayoutPiece>> GetAllDetails() const;
bool GetRotate() const; bool GetRotate() const;
void SetRotate(bool value); void SetRotate(bool value);

View File

@ -68,7 +68,7 @@ QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VConta
const VPiecePath path = pattern->GetPiecePath(pathsId.at(i)); const VPiecePath path = pattern->GetPiecePath(pathsId.at(i));
if (path.GetType() == PiecePathType::InternalPath) if (path.GetType() == PiecePathType::InternalPath)
{ {
paths.append(VLayoutPiecePath(path.PathPoints(pattern), path.GetPenType())); paths.append(VLayoutPiecePath(path.PathPoints(pattern), path.IsCutPath(), path.GetPenType()));
} }
} }
return paths; return paths;
@ -336,6 +336,20 @@ QPointF RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
return ptDest + ptCenter; return ptDest + ptCenter;
} }
//---------------------------------------------------------------------------------------------------------------------
QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm)
{
QStringList text;
if (labelShape.count() > 2)
{
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
{
text.append(tm.GetSourceLine(i).m_qsText);
}
}
return text;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -389,7 +403,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
const VPieceLabelData& data = piece.GetPatternPieceData(); const VPieceLabelData& data = piece.GetPatternPieceData();
if (data.IsVisible() == true) if (data.IsVisible() == true)
{ {
det.SetDetail(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern); det.SetPieceText(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern);
} }
const VPatternLabelData& geom = piece.GetPatternInfo(); const VPatternLabelData& geom = piece.GetPatternInfo();
@ -460,7 +474,26 @@ QVector<QPointF> VLayoutPiece::GetLayoutAllowancePoints() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data, const QFont &font, QPointF VLayoutPiece::GetPieceTextPosition() const
{
if (d->detailLabel.count() > 2)
{
return d->matrix.map(d->detailLabel.first());
}
else
{
return QPointF();
}
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VLayoutPiece::GetPieceText() const
{
return PieceLabelText(d->detailLabel, d->m_tmDetail);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPieceText(const QString& qsName, const VPieceLabelData& data, const QFont &font,
const VContainer *pattern) const VContainer *pattern)
{ {
QPointF ptPos; QPointF ptPos;
@ -501,6 +534,25 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
d->m_tmDetail.FitFontSize(labelWidth, labelHeight); d->m_tmDetail.FitFontSize(labelWidth, labelHeight);
} }
//---------------------------------------------------------------------------------------------------------------------
QPointF VLayoutPiece::GetPatternTextPosition() const
{
if (d->patternInfo.count() > 2)
{
return d->matrix.map(d->patternInfo.first());
}
else
{
return QPointF();
}
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VLayoutPiece::GetPatternText() const
{
return PieceLabelText(d->patternInfo, d->m_tmPattern);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font, void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font,
qreal dSize, qreal dHeight, const VContainer *pattern) qreal dSize, qreal dHeight, const VContainer *pattern)
@ -586,6 +638,12 @@ void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pa
d->grainlinePoints = CorrectPosition(item->boundingRect(), RoundPoints(v)); d->grainlinePoints = CorrectPosition(item->boundingRect(), RoundPoints(v));
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::GetGrainline() const
{
return Map(d->grainlinePoints);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QTransform VLayoutPiece::GetMatrix() const QTransform VLayoutPiece::GetMatrix() const
{ {
@ -806,6 +864,22 @@ void VLayoutPiece::SetPassmarks(const QVector<QLineF> &passmarks)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QVector<QPointF> > VLayoutPiece::InternalPathsForCut(bool cut) const
{
QVector<QVector<QPointF> > paths;
for (int i=0;i < d->m_internalPaths.count(); ++i)
{
if (d->m_internalPaths.at(i).IsCutPath() == cut)
{
paths.append(Map(d->m_internalPaths.at(i).Points()));
}
}
return paths;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<VLayoutPiecePath> VLayoutPiece::GetInternalPaths() const QVector<VLayoutPiecePath> VLayoutPiece::GetInternalPaths() const
{ {
@ -1059,7 +1133,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
QPainterPath path; QPainterPath path;
QVector<QPointF> gPoints = Map(d->grainlinePoints); QVector<QPointF> gPoints = GetGrainline();
path.moveTo(gPoints.at(0)); path.moveTo(gPoints.at(0));
for (int i = 1; i < gPoints.count(); ++i) for (int i = 1; i < gPoints.count(); ++i)
{ {

View File

@ -85,15 +85,21 @@ public:
QVector<QLineF> GetPassmarks() const; QVector<QLineF> GetPassmarks() const;
void SetPassmarks(const QVector<QLineF> &passmarks); void SetPassmarks(const QVector<QLineF> &passmarks);
QVector<QVector<QPointF>> InternalPathsForCut(bool cut) const;
QVector<VLayoutPiecePath> GetInternalPaths() const; QVector<VLayoutPiecePath> GetInternalPaths() const;
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths); void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
void SetDetail(const QString &qsName, const VPieceLabelData& data, const QFont& font, const VContainer *pattern); QPointF GetPieceTextPosition() const;
QStringList GetPieceText() const;
void SetPieceText(const QString &qsName, const VPieceLabelData& data, const QFont& font, const VContainer *pattern);
QPointF GetPatternTextPosition() const;
QStringList GetPatternText() const;
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont& font, void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont& font,
qreal dSize, qreal dHeight, const VContainer *pattern); qreal dSize, qreal dHeight, const VContainer *pattern);
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern); void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
QVector<QPointF> GetGrainline() const;
QTransform GetMatrix() const; QTransform GetMatrix() const;
void SetMatrix(const QTransform &matrix); void SetMatrix(const QTransform &matrix);

View File

@ -39,8 +39,8 @@ VLayoutPiecePath::VLayoutPiecePath()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(const QVector<QPointF> &points, Qt::PenStyle penStyle) VLayoutPiecePath::VLayoutPiecePath(const QVector<QPointF> &points, bool cut, Qt::PenStyle penStyle)
: d(new VLayoutPiecePathData(points, penStyle)) : d(new VLayoutPiecePathData(points, cut, penStyle))
{ {
} }
@ -101,3 +101,15 @@ void VLayoutPiecePath::SetPenStyle(const Qt::PenStyle &penStyle)
{ {
d->m_penStyle = penStyle; d->m_penStyle = penStyle;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPiecePath::IsCutPath() const
{
return d->m_cut;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiecePath::SetCutPath(bool cut)
{
d->m_cut = cut;
}

View File

@ -39,7 +39,7 @@ class VLayoutPiecePath
{ {
public: public:
VLayoutPiecePath(); VLayoutPiecePath();
VLayoutPiecePath(const QVector<QPointF> &points, Qt::PenStyle penStyle = Qt::SolidLine); VLayoutPiecePath(const QVector<QPointF> &points, bool cut, Qt::PenStyle penStyle = Qt::SolidLine);
VLayoutPiecePath(const VLayoutPiecePath &path); VLayoutPiecePath(const VLayoutPiecePath &path);
virtual ~VLayoutPiecePath(); virtual ~VLayoutPiecePath();
@ -60,6 +60,9 @@ public:
Qt::PenStyle PenStyle() const; Qt::PenStyle PenStyle() const;
void SetPenStyle(const Qt::PenStyle &penStyle); void SetPenStyle(const Qt::PenStyle &penStyle);
bool IsCutPath() const;
void SetCutPath(bool cut);
private: private:
QSharedDataPointer<VLayoutPiecePathData> d; QSharedDataPointer<VLayoutPiecePathData> d;
}; };

View File

@ -44,18 +44,21 @@ class VLayoutPiecePathData : public QSharedData
public: public:
VLayoutPiecePathData() VLayoutPiecePathData()
: m_points(), : m_points(),
m_penStyle(Qt::SolidLine) m_penStyle(Qt::SolidLine),
m_cut(true)
{} {}
VLayoutPiecePathData(const QVector<QPointF> points, Qt::PenStyle penStyle) VLayoutPiecePathData(const QVector<QPointF> points, bool cut, Qt::PenStyle penStyle)
: m_points(points), : m_points(points),
m_penStyle(penStyle) m_penStyle(penStyle),
m_cut(cut)
{} {}
VLayoutPiecePathData(const VLayoutPiecePathData &path) VLayoutPiecePathData(const VLayoutPiecePathData &path)
: QSharedData(path), : QSharedData(path),
m_points(path.m_points), m_points(path.m_points),
m_penStyle(path.m_penStyle) m_penStyle(path.m_penStyle),
m_cut(path.m_cut)
{} {}
~VLayoutPiecePathData() Q_DECL_EQ_DEFAULT; ~VLayoutPiecePathData() Q_DECL_EQ_DEFAULT;
@ -66,6 +69,8 @@ public:
/** @brief m_penStyle path pen style. */ /** @brief m_penStyle path pen style. */
Qt::PenStyle m_penStyle; Qt::PenStyle m_penStyle;
bool m_cut;
private: private:
VLayoutPiecePathData &operator=(const VLayoutPiecePathData &) Q_DECL_EQ_DELETE; VLayoutPiecePathData &operator=(const VLayoutPiecePathData &) Q_DECL_EQ_DELETE;
}; };

View File

@ -237,6 +237,18 @@ void VPiecePath::SetPenType(const Qt::PenStyle &type)
d->m_penType = type; d->m_penType = type;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPiecePath::IsCutPath() const
{
return d->m_cut;
}
//---------------------------------------------------------------------------------------------------------------------
void VPiecePath::SetCutPath(bool cut)
{
d->m_cut = cut;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const
{ {

View File

@ -78,6 +78,9 @@ public:
Qt::PenStyle GetPenType() const; Qt::PenStyle GetPenType() const;
void SetPenType(const Qt::PenStyle &type); void SetPenType(const Qt::PenStyle &type);
bool IsCutPath() const;
void SetCutPath(bool cut);
QVector<QPointF> PathPoints(const VContainer *data) const; QVector<QPointF> PathPoints(const VContainer *data) const;
QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const; QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const;
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const; QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const;

View File

@ -46,14 +46,16 @@ public:
: m_nodes(), : m_nodes(),
m_type(PiecePathType::Unknown), m_type(PiecePathType::Unknown),
m_name(), m_name(),
m_penType(Qt::SolidLine) m_penType(Qt::SolidLine),
m_cut(true)
{} {}
explicit VPiecePathData(PiecePathType type) explicit VPiecePathData(PiecePathType type)
: m_nodes(), : m_nodes(),
m_type(type), m_type(type),
m_name(), m_name(),
m_penType(Qt::SolidLine) m_penType(Qt::SolidLine),
m_cut(true)
{} {}
VPiecePathData(const VPiecePathData &path) VPiecePathData(const VPiecePathData &path)
@ -61,7 +63,8 @@ public:
m_nodes(path.m_nodes), m_nodes(path.m_nodes),
m_type(path.m_type), m_type(path.m_type),
m_name(path.m_name), m_name(path.m_name),
m_penType(path.m_penType) m_penType(path.m_penType),
m_cut(path.m_cut)
{} {}
~VPiecePathData(); ~VPiecePathData();
@ -70,6 +73,7 @@ public:
PiecePathType m_type; PiecePathType m_type;
QString m_name; QString m_name;
Qt::PenStyle m_penType; Qt::PenStyle m_penType;
bool m_cut;
private: private:
VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE; VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE;