Merge with feature.

Added export to DXF-AAMA. ref #391.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-07-20 12:04:57 +03:00
commit 92da4adc88
26 changed files with 1008 additions and 251 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,"
.RE
.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."
.RE
.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,"
.RE
.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."
.RE
.IP "--bdxf"

View File

@ -331,9 +331,9 @@ QString DialogSaveLayout::ExportFormatDescription(LayoutExportFormats format)
case LayoutExportFormats::DXF_AC1027_Flat:
return QString("AutoCAD DXF 2013 %1 %2").arg(dxfFlatFilesStr, dxfSuffix);
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:
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:
return QString("AutoCAD DXF R13 AAMA %1 %2").arg(filesStr, dxfSuffix);
case LayoutExportFormats::DXF_AC1014_AAMA:
@ -648,17 +648,16 @@ QVector<std::pair<QString, LayoutExportFormats> > DialogSaveLayout::InitFormats(
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);
// 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_AC1009_ASTM);
// InitFormat(LayoutExportFormats::DXF_AC1012_ASTM);

View File

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

View File

@ -60,6 +60,30 @@
# define PDFTOPS "pdftops"
#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)
: VAbstractMainWindow(parent),
@ -72,6 +96,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
shadows(),
scenes(),
details(),
detailsOnLayout(),
undoAction(nullptr),
redoAction(nullptr),
actionDockWidgetToolOptions(nullptr),
@ -148,7 +173,8 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
case LayoutErrors::NoError:
CleanLayout();
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);
scenes = CreateScenes(papers, shadows, details);
PrepareSceneList();
@ -201,217 +227,256 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog)
{
if (dialog.Mode() == Draw::Layout)
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)
{
ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
if (dialog.Mode() == Draw::Layout)
{
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
{
ExportDetailsAsApparelLayout(dialog, listDetails);
}
}
else
{
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list;
for (int i=0; i < listDetails.count(); ++i)
if (dialog.Mode() == Draw::Layout)
{
QGraphicsItem *item = listDetails.at(i).GetItem(dialog.IsTextAsPaths());
item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy());
list.append(item);
ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
}
for (int i=0; i < list.size(); ++i)
else
{
scene->addItem(list.at(i));
ExportDetailsAsFlatLayout(dialog, listDetails);
}
QList<QGraphicsItem *> papers;// Blank sheets
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();
QGraphicsRectItem *paper = new QGraphicsRectItem(rect);
paper->setPen(QPen(Qt::black, 1));
paper->setBrush(QBrush(Qt::white));
papers.append(paper);
QList<QList<QGraphicsItem *> > details;// All details
details.append(list);
QList<QGraphicsItem *> shadows = CreateShadows(papers);
QList<QGraphicsScene *> scenes = CreateScenes(papers, shadows, details);
const bool ignorePrinterFields = false;
const qreal margin = ToPixel(1, Unit::Cm);
ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields,
QMarginsF(margin, margin, margin, margin));
qDeleteAll(scenes);//Scene will clear all other items
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::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 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 = false;
QDir dir(path);
dir.setPath(path);
if (not dir.exists(path))
bool usedNotExistedDir = CreateLayoutPath(path);
if (not usedNotExistedDir)
{
usedNotExistedDir = dir.mkpath(".");
if (not usedNotExistedDir)
{
qCritical() << tr("Can't create a path");
return;
}
qCritical() << tr("Can't create a path");
return;
}
qApp->ValentinaSettings()->SetPathLayout(path);
const QString mask = dialog.FileName();
const LayoutExportFormats format = dialog.Format();
if (format == LayoutExportFormats::PDFTiled && dialog.Mode() == Draw::Layout)
{
const QString name = path + QLatin1String("/") + mask + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(format);
const QString name = path + QLatin1String("/") + dialog.FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.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)
{
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_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:
Q_UNREACHABLE(); // For now not supported
break;
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);
DxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1009_Flat:
paper->setVisible(false);
DxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1012_Flat:
paper->setVisible(false);
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;
default:
qDebug() << "Can't recognize file suffix." << 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;
}
}
ExportScene(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
}
if (usedNotExistedDir)
RemoveLayoutPath(path, usedNotExistedDir);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog,
const QVector<VLayoutPiece> &listDetails)
{
if (listDetails.isEmpty())
{
QDir directory(dir);
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));
}
QList<QGraphicsItem *> papers;// Blank sheets
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();
QGraphicsRectItem *paper = new QGraphicsRectItem(rect);
paper->setPen(QPen(Qt::black, 1));
paper->setBrush(QBrush(Qt::white));
papers.append(paper);
QList<QList<QGraphicsItem *> > details;// All details
details.append(list);
QList<QGraphicsItem *> shadows = CreateShadows(papers);
QList<QGraphicsScene *> scenes = CreateScenes(papers, shadows, details);
const bool ignorePrinterFields = false;
const qreal margin = ToPixel(1, Unit::Cm);
ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields,
QMarginsF(margin, margin, margin, margin));
qDeleteAll(scenes);//Scene will clear all other items
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &details,
const QString &name, const QSize &size) const
{
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();
switch (format)
{
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:
Q_UNREACHABLE(); // For now not supported
break;
case LayoutExportFormats::DXF_AC1006_AAMA:
AAMADxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1009_AAMA:
AAMADxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1012_AAMA:
AAMADxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1014_AAMA:
AAMADxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1015_AAMA:
AAMADxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1018_AAMA:
AAMADxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1021_AAMA:
AAMADxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1024_AAMA:
AAMADxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1027_AAMA:
AAMADxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), size, details);
break;
default:
qDebug() << "Can't recognize file type." << Q_FUNC_INFO;
break;
}
RemoveLayoutPath(path, usedNotExistedDir);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsApparelLayout(const DialogSaveLayout &dialog,
QVector<VLayoutPiece> listDetails)
{
if (listDetails.isEmpty())
{
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_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
{
PrepareTextForDXF(endStringPlaceholder, details);
@ -980,6 +1045,37 @@ void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, QG
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
//---------------------------------------------------------------------------------------------------------------------
@ -1345,6 +1441,109 @@ bool MainWindowsNoGUI::IsPagesFit(const QSizeF &printPaper) const
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
{

View File

@ -75,6 +75,8 @@ protected:
QList<QGraphicsScene *> scenes;
QList<QList<QGraphicsItem *> > details;
QVector<QVector<VLayoutPiece> > detailsOnLayout;
QAction *undoAction;
QAction *redoAction;
QAction *actionDockWidgetToolOptions;
@ -92,12 +94,6 @@ protected:
static QVector<VLayoutPiece> PrepareDetailsForLayout(const QHash<quint32, VPiece> &details);
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();
virtual void CleanLayout()=0;
@ -134,8 +130,10 @@ private:
const QMarginsF &margins)const;
void PdfToPs(const QStringList &params)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;
void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size,
const QVector<VLayoutPiece> &details) const;
void PreparePaper(int index) const;
void RestorePaper(int index) const;
@ -154,6 +152,27 @@ private:
bool isPagesUniform() 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

View File

@ -25,8 +25,6 @@ dx_iface::dx_iface(const std::string &file, DRW::Version v, VarMeasurement varMe
version(v)
{
InitHeader(varMeasurement, varInsunits);
InitLTypes();
InitLayers();
InitTextstyles();
InitAppId();
}
@ -192,7 +190,7 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits
}
}
void dx_iface::InitLTypes()
void dx_iface::AddQtLTypes()
{
DRW_LType ltype;
ltype.name = "DOT";
@ -237,21 +235,60 @@ void dx_iface::InitLTypes()
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);
// Optitex doesn't like this 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::AddAAMAHeaderData()
{
cData.headerC.addStr("$CLAYER", "1", 8);
}
void dx_iface::AddDefLayers()
{
DRW_Layer defLayer;
defLayer.name = "0";
defLayer.color = DRW::black; // default color
defLayer.lWeight = DRW_LW_Conv::width03; // default width
defLayer.lineType = "CONTINUOUS"; // default line style
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()
@ -309,6 +346,11 @@ UTF8STRING dx_iface::AddFont(const QFont &f)
return ts.name;
}
void dx_iface::AddBlock(dx_ifaceBlock *block)
{
cData.blocks.push_back(block);
}
std::string dx_iface::LocaleToISO()
{
QMap <std::string, std::string> locMap;

View File

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

View File

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

View File

@ -762,7 +762,7 @@ public:
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),
endwidth(0),
bulge(b),

View File

@ -156,15 +156,13 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){
case DRW::AC1018: //acad 2004
varStr = "AC1018";
break;
/* case DRW::AC1021: //acad 2007
varStr = "AC1021";
break;*/
case DRW::AC1024: //acad 2010
varStr = "AC1024";
break;
case DRW::AC1027: //acad 2013
varStr = "AC1027";
break;
case DRW::AC1021: //acad 2007
default: //acad 2007 default version
varStr = "AC1021";
break;

View File

@ -422,15 +422,15 @@ bool dxfRW::writeDimstyle(DRW_Dimstyle *ent){
} else
writer->writeUtf8Caps(2, ent->name);
writer->writeInt16(70, ent->flags);
if ( version == DRW::AC1009 || !(ent->dimpost.empty()) )
if ( version <= DRW::AC1009 || !(ent->dimpost.empty()) )
writer->writeUtf8String(3, ent->dimpost);
if ( version == DRW::AC1009 || !(ent->dimapost.empty()) )
if ( version <= DRW::AC1009 || !(ent->dimapost.empty()) )
writer->writeUtf8String(4, ent->dimapost);
if ( version == DRW::AC1009 || !(ent->dimblk.empty()) )
if ( version <= DRW::AC1009 || !(ent->dimblk.empty()) )
writer->writeUtf8String(5, ent->dimblk);
if ( version == DRW::AC1009 || !(ent->dimblk1.empty()) )
if ( version <= DRW::AC1009 || !(ent->dimblk1.empty()) )
writer->writeUtf8String(6, ent->dimblk1);
if ( version == DRW::AC1009 || !(ent->dimblk2.empty()) )
if ( version <= DRW::AC1009 || !(ent->dimblk2.empty()) )
writer->writeUtf8String(7, ent->dimblk2);
writer->writeDouble(40, ent->dimscale);
writer->writeDouble(41, ent->dimasz);
@ -1343,7 +1343,7 @@ bool dxfRW::writeBlock(DRW_Block *bk){
}
writer->writeString(100, "AcDbEntity");
}
writer->writeString(8, "0");
writer->writeString(8, bk->layer);
if (version > DRW::AC1009) {
writer->writeString(100, "AcDbBlockEnd");
}
@ -1358,7 +1358,7 @@ bool dxfRW::writeBlock(DRW_Block *bk){
}
writer->writeString(100, "AcDbEntity");
}
writer->writeString(8, "0");
writer->writeString(8, bk->layer);
if (version > DRW::AC1009) {
writer->writeString(100, "AcDbBlockBegin");
writer->writeUtf8String(2, bk->name);
@ -1478,7 +1478,7 @@ bool dxfRW::writeTables() {
writer->writeInt16(70, 1); //end table def
wlayer0 =false;
iface->writeLayers();
if (!wlayer0) {
if (!wlayer0 && version > DRW::AC1009) {
DRW_Layer lay0;
lay0.name = "0";
writeLayer(&lay0);

View File

@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
**
** @file vdxfengine.cpp
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
@ -49,6 +49,9 @@
#include "../vmisc/diagnostic.h"
#include "../vmisc/vmath.h"
#include "dxiface.h"
#include "../vlayout/vlayoutpiece.h"
static const qreal AAMATextHeight = 2.5;
//---------------------------------------------------------------------------------------------------------------------
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
@ -93,6 +96,13 @@ VDxfEngine::~VDxfEngine()
bool VDxfEngine::begin(QPaintDevice *pdev)
{
Q_UNUSED(pdev)
if (isActive())
{
qWarning("VDxfEngine::begin(), the engine was alredy activated");
return false;
}
if (size.isValid() == false)
{
qWarning()<<"VDxfEngine::begin(), size is not valid";
@ -100,6 +110,8 @@ bool VDxfEngine::begin(QPaintDevice *pdev)
}
input = QSharedPointer<dx_iface>(new dx_iface(fileName.toStdString(), m_version, varMeasurement, varInsunits));
input->AddQtLTypes();
input->AddDefLayers();
return true;
}
@ -571,7 +583,272 @@ double VDxfEngine::FromPixel(double pix, const VarInsunits &unit) const
case VarInsunits::Inches:
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
//---------------------------------------------------------------------------------------------------------------------
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->AddAAMAHeaderData();
if (m_version > DRW::AC1009)
{
input->AddDefLayers();
}
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();
QString blockName = detail.GetName();
if (m_version <= DRW::AC1009)
{
blockName.replace(' ', '_');
}
detailBlock->name = blockName.toStdString();
detailBlock->layer = "1";
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 = blockName.toStdString();
insert->basePoint = DRW_Coord(FromPixel(detail.GetMx(), varInsunits),
FromPixel(- detail.GetMy(), varInsunits), 0);
insert->layer = "1";
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), "1"));
}
}
//---------------------------------------------------------------------------------------------------------------------
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 dx_iface;
class DRW_Text;
class VLayoutPiece;
class DRW_Entity;
class dx_ifaceBlock;
class VDxfEngine : public QPaintEngine
{
friend class VDxfPaintDevice;
public:
VDxfEngine();
virtual ~VDxfEngine();
@ -102,6 +106,23 @@ private:
DRW_Text *textBuffer;
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

View File

@ -162,6 +162,15 @@ void VDxfPaintDevice::setInsunits(const VarInsunits &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
{

View File

@ -39,6 +39,7 @@
#include "libdxfrw/drw_base.h"
class VDxfEngine;
class VLayoutPiece;
class VDxfPaintDevice : public QPaintDevice
{
@ -65,6 +66,8 @@ public:
void setMeasurement(const VarMeasurement &var);
void setInsunits(const VarInsunits &var);
bool ExportToAAMA(const QVector<VLayoutPiece> &details) const;
protected:
virtual int metric(PaintDeviceMetric metric) const Q_DECL_OVERRIDE;
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;
for (int i=0; i < papers.count(); ++i)
@ -226,6 +226,17 @@ QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetails() const
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()
{

View File

@ -83,7 +83,9 @@ public:
LayoutErrors State() 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;
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));
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;
@ -336,6 +336,20 @@ QPointF RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
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();
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();
@ -460,8 +474,27 @@ QVector<QPointF> VLayoutPiece::GetLayoutAllowancePoints() const
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data, const QFont &font,
const VContainer *pattern)
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)
{
QPointF ptPos;
qreal labelWidth = 0;
@ -501,6 +534,25 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
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,
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));
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::GetGrainline() const
{
return Map(d->grainlinePoints);
}
//---------------------------------------------------------------------------------------------------------------------
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
{
@ -1059,7 +1133,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
QPainterPath path;
QVector<QPointF> gPoints = Map(d->grainlinePoints);
QVector<QPointF> gPoints = GetGrainline();
path.moveTo(gPoints.at(0));
for (int i = 1; i < gPoints.count(); ++i)
{

View File

@ -85,15 +85,21 @@ public:
QVector<QLineF> GetPassmarks() const;
void SetPassmarks(const QVector<QLineF> &passmarks);
QVector<QVector<QPointF>> InternalPathsForCut(bool cut) const;
QVector<VLayoutPiecePath> GetInternalPaths() const;
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,
qreal dSize, qreal dHeight, const VContainer *pattern);
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
QVector<QPointF> GetGrainline() const;
QTransform GetMatrix() const;
void SetMatrix(const QTransform &matrix);

View File

@ -39,8 +39,8 @@ VLayoutPiecePath::VLayoutPiecePath()
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(const QVector<QPointF> &points, Qt::PenStyle penStyle)
: d(new VLayoutPiecePathData(points, penStyle))
VLayoutPiecePath::VLayoutPiecePath(const QVector<QPointF> &points, bool cut, Qt::PenStyle penStyle)
: d(new VLayoutPiecePathData(points, cut, penStyle))
{
}
@ -101,3 +101,15 @@ void VLayoutPiecePath::SetPenStyle(const Qt::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:
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);
virtual ~VLayoutPiecePath();
@ -60,6 +60,9 @@ public:
Qt::PenStyle PenStyle() const;
void SetPenStyle(const Qt::PenStyle &penStyle);
bool IsCutPath() const;
void SetCutPath(bool cut);
private:
QSharedDataPointer<VLayoutPiecePathData> d;
};

View File

@ -44,18 +44,21 @@ class VLayoutPiecePathData : public QSharedData
public:
VLayoutPiecePathData()
: m_points(),
m_penStyle(Qt::SolidLine)
m_penStyle(Qt::SolidLine),
m_cut(false)
{}
VLayoutPiecePathData(const QVector<QPointF> points, Qt::PenStyle penStyle)
VLayoutPiecePathData(const QVector<QPointF> points, bool cut, Qt::PenStyle penStyle)
: m_points(points),
m_penStyle(penStyle)
m_penStyle(penStyle),
m_cut(cut)
{}
VLayoutPiecePathData(const VLayoutPiecePathData &path)
: QSharedData(path),
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;
@ -66,6 +69,8 @@ public:
/** @brief m_penStyle path pen style. */
Qt::PenStyle m_penStyle;
bool m_cut;
private:
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;
}
//---------------------------------------------------------------------------------------------------------------------
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
{

View File

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

View File

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