diff --git a/ChangeLog.txt b/ChangeLog.txt index ef50c5285..4ea913b1d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -42,6 +42,7 @@ - Call Piece Options and Delete Piece from the piece list context menu. - Change default values for grainline length and pattern label size to 10 cm. - Tool Point at distance and angle now allows negative length. +- Export pattern to DXF-ASTM. # Version 0.6.2 (unreleased) - [#903] Bug in tool Cut Spline path. diff --git a/dist/debian/valentina.1 b/dist/debian/valentina.1 index 18664147b..9eeca66a4 100644 --- a/dist/debian/valentina.1 +++ b/dist/debian/valentina.1 @@ -102,6 +102,33 @@ The path to output destination folder. By default the directory at which the app .BR "*" " AutoCAD DXF 2013 AAMA files (*.dxf) = 23," .RE .RS +.BR "*" " AutoCAD DXF R10 ASTM файли (*.dxf) = 24," +.RE +.RS +.BR "*" " AutoCAD DXF R11/12 ASTM файли (*.dxf) = 25," +.RE +.RS +.BR "*" " AutoCAD DXF R13 ASTM файли (*.dxf) = 26," +.RE +.RS +.BR "*" " AutoCAD DXF R14 ASTM файли (*.dxf) = 27," +.RE +.RS +.BR "*" " AutoCAD DXF 2000 ASTM файли (*.dxf) = 28," +.RE +.RS +.BR "*" " AutoCAD DXF 2004 ASTM файли (*.dxf) = 29," +.RE +.RS +.BR "*" " AutoCAD DXF 2007 ASTM файли (*.dxf) = 30," +.RE +.RS +.BR "*" " AutoCAD DXF 2010 ASTM файли (*.dxf) = 31," +.RE +.RS +.BR "*" " AutoCAD DXF 2013 ASTM файли (*.dxf) = 32," +.RE +.RS .BR "*" " PDF tiled files (*.pdf) = 33." .RE .IP "--bdxf" diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index fc095b21d..f04ce78de 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -810,16 +810,15 @@ QVector > DialogSaveLayout::InitFormats( InitFormat(LayoutExportFormats::DXF_AC1021_AAMA); InitFormat(LayoutExportFormats::DXF_AC1024_AAMA); InitFormat(LayoutExportFormats::DXF_AC1027_AAMA); - // We will support them anyway -// InitFormat(LayoutExportFormats::DXF_AC1006_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1009_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1012_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1014_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1015_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1018_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1021_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1024_ASTM); -// InitFormat(LayoutExportFormats::DXF_AC1027_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1006_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1009_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1012_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1014_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1015_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1018_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1021_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1024_ASTM); + InitFormat(LayoutExportFormats::DXF_AC1027_ASTM); InitFormat(LayoutExportFormats::PDFTiled); // InitFormat(LayoutExportFormats::NC); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 14459be31..580005944 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -510,7 +510,16 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails) format == LayoutExportFormats::DXF_AC1018_AAMA || format == LayoutExportFormats::DXF_AC1021_AAMA || format == LayoutExportFormats::DXF_AC1024_AAMA || - format == LayoutExportFormats::DXF_AC1027_AAMA) + format == LayoutExportFormats::DXF_AC1027_AAMA || + format == LayoutExportFormats::DXF_AC1006_ASTM || + format == LayoutExportFormats::DXF_AC1009_ASTM || + format == LayoutExportFormats::DXF_AC1012_ASTM || + format == LayoutExportFormats::DXF_AC1014_ASTM || + format == LayoutExportFormats::DXF_AC1015_ASTM || + format == LayoutExportFormats::DXF_AC1018_ASTM || + format == LayoutExportFormats::DXF_AC1021_ASTM || + format == LayoutExportFormats::DXF_AC1024_ASTM || + format == LayoutExportFormats::DXF_AC1027_ASTM) { if (m_dialogSaveLayout->Mode() == Draw::Layout) { @@ -665,15 +674,31 @@ void MainWindowsNoGUI::ExportApparelLayout(const QVector &details, switch (format) { case LayoutExportFormats::DXF_AC1006_ASTM: + ASTMDxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1009_ASTM: + ASTMDxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1012_ASTM: + ASTMDxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1014_ASTM: + ASTMDxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1015_ASTM: + ASTMDxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1018_ASTM: + ASTMDxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1021_ASTM: + ASTMDxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1024_ASTM: + ASTMDxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); + break; case LayoutExportFormats::DXF_AC1027_ASTM: - Q_UNREACHABLE(); // For now not supported + ASTMDxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); break; case LayoutExportFormats::DXF_AC1006_AAMA: AAMADxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details); @@ -1424,6 +1449,20 @@ void MainWindowsNoGUI::AAMADxfFile(const QString &name, int version, bool binary generator.ExportToAAMA(details); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::ASTMDxfFile(const QString &name, int version, bool binary, const QSize &size, + const QVector &details) const +{ + VDxfPaintDevice generator; + generator.setFileName(name); + generator.setSize(size); + generator.setResolution(PrintDPI); + generator.SetVersion(static_cast(version)); + generator.SetBinaryFormat(binary); + generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 + generator.ExportToASTM(details); +} + QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 7e9e289dd..1137d725b 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -182,6 +182,8 @@ private: const QList > &details)const; void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size, const QVector &details) const; + void ASTMDxfFile(const QString &name, int version, bool binary, const QSize &size, + const QVector &details) const; void PreparePaper(int index) const; void RestorePaper(int index) const; diff --git a/src/libs/vdxf/dxiface.cpp b/src/libs/vdxf/dxiface.cpp index fb7b743ef..88372d63f 100644 --- a/src/libs/vdxf/dxiface.cpp +++ b/src/libs/vdxf/dxiface.cpp @@ -43,9 +43,12 @@ bool dx_iface::fileExport(bool binary) void dx_iface::writeEntity(DRW_Entity* e){ switch (e->eType) { - case DRW::POINT: + case DRW::POINT: dxfW->writePoint(static_cast(e)); break; + case DRW::ASTMNOTCH: + dxfW->writeASTMNotch(static_cast(e)); + break; case DRW::LINE: dxfW->writeLine(static_cast(e)); break; @@ -283,6 +286,107 @@ void dx_iface::AddAAMAHeaderData() cData.headerC.addStr("$CLAYER", "1", 8); // Current layer name } +void dx_iface::AddASTMLayers() +{ + DRW_Layer layer; + + layer.name = '1';// piece boundary + layer.color = DRW::black; + cData.layers.push_back(layer); + + // Do not support +// layer.name = '2';// turn points +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + // Do not support +// layer.name = '3';// curve points +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + layer.name = '4';// V-notch and slit notch + layer.color = DRW::black; + cData.layers.push_back(layer); + + // Do not support +// layer.name = '5';// grade reference and alternate grade reference line(s) +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + // Do not support +// layer.name = '6';// mirror line +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + layer.name = '7';// grainline + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = '8';// internal line(s) + layer.color = DRW::black; + cData.layers.push_back(layer); + + // Do not support +// layer.name = '9';// stripe reference line(s) +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + // Do not support +// layer.name = '10';// plaid reference line(s) +// layer.color = DRW::black; +// cData.layers.push_back(layer); + + layer.name = "11";// internal cutout(s) + layer.color = DRW::black; + cData.layers.push_back(layer); + + // Layer 12 intentionally left blank by the standard + + layer.name = "13";// drill holes + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "14";// sew line(s) + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "15";// annotation text + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "80";// T-notch + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "81";// castle notch + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "82";// check notch + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "83";// U-notch + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "84";// piece boundary quality validation curves + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "85";// internal lines quality validation curves + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "86";// internal cutouts quality validation curves + layer.color = DRW::black; + cData.layers.push_back(layer); + + layer.name = "87";// sew lines quality validation curves + layer.color = DRW::black; + cData.layers.push_back(layer); +} + void dx_iface::AddDefLayers() { DRW_Layer defLayer; diff --git a/src/libs/vdxf/dxiface.h b/src/libs/vdxf/dxiface.h index 15adc34f3..78c9b11d2 100644 --- a/src/libs/vdxf/dxiface.h +++ b/src/libs/vdxf/dxiface.h @@ -124,6 +124,7 @@ public: void AddDefLayers(); void AddAAMALayers(); void AddAAMAHeaderData(); + void AddASTMLayers(); private: Q_DISABLE_COPY(dx_iface) diff --git a/src/libs/vdxf/libdxfrw/drw_entities.cpp b/src/libs/vdxf/libdxfrw/drw_entities.cpp index 8f2c8a677..1450a07dc 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.cpp +++ b/src/libs/vdxf/libdxfrw/drw_entities.cpp @@ -224,6 +224,18 @@ void DRW_Point::parseCode(int code, dxfReader *reader){ } } +void DRW_ASTMNotch::parseCode(int code, dxfReader *reader) +{ + switch (code) { + case 50: + angle = reader->getDouble(); + break; + default: + DRW_Point::parseCode(code, reader); + break; + } +} + void DRW_Line::parseCode(int code, dxfReader *reader){ switch (code) { case 11: diff --git a/src/libs/vdxf/libdxfrw/drw_entities.h b/src/libs/vdxf/libdxfrw/drw_entities.h index 1b4719a94..667007d2a 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.h +++ b/src/libs/vdxf/libdxfrw/drw_entities.h @@ -80,6 +80,7 @@ namespace DRW { VIEWPORT, // WIPEOUT, //WIPEOUTVARIABLE XLINE, + ASTMNOTCH, // ASTM NOTCH UNKNOWN }; @@ -251,6 +252,22 @@ public: // the UCS in effect when the point was drawn }; + +class DRW_ASTMNotch : public DRW_Point { + SETENTFRIENDS +public: + DRW_ASTMNotch() + { + eType = DRW::ASTMNOTCH; + } + +protected: + void parseCode(int code, dxfReader *reader); + +public: + double angle{0}; /*!< angle, code 50 */ +}; + //! Class to handle line entity /*! * Class to handle line entity diff --git a/src/libs/vdxf/libdxfrw/drw_interface.h b/src/libs/vdxf/libdxfrw/drw_interface.h index b0de89012..d18cb5afd 100644 --- a/src/libs/vdxf/libdxfrw/drw_interface.h +++ b/src/libs/vdxf/libdxfrw/drw_interface.h @@ -62,6 +62,9 @@ public: /** Called for every point */ virtual void addPoint(const DRW_Point &) { } + /** Called for every ASTM notch */ + virtual void addASTMNotch(const DRW_ASTMNotch &) { } + /** Called for every line */ virtual void addLine(const DRW_Line &) { } diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index 3f775a573..e807179a4 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -553,6 +553,15 @@ bool dxfRW::writePoint(DRW_Point *ent) { return true; } +bool dxfRW::writeASTMNotch(DRW_ASTMNotch *ent) +{ + writePoint(ent); + writer->writeDouble(50, ent->angle); + writer->writeDouble(39, ent->thickness); // Defined, but not used in point + + return true; +} + bool dxfRW::writeLine(DRW_Line *ent) { writer->writeString(0, "LINE"); writeEntity(ent); @@ -2360,6 +2369,28 @@ bool dxfRW::processPoint() { return true; } +bool dxfRW::processASTMNotch() +{ + DRW_DBG("dxfRW::processASTMNotch\n"); + int code; + DRW_ASTMNotch notch; + while (reader->readRec(&code)) { + DRW_DBG(code); DRW_DBG("\n"); + switch (code) { + case 0: { + nextentity = reader->getString(); + DRW_DBG(nextentity); DRW_DBG("\n"); + iface->addASTMNotch(notch); + return true; //found new entity or ENDSEC, terminate + } + default: + notch.parseCode(code, reader); + break; + } + } + return true; +} + bool dxfRW::processLine() { DRW_DBG("dxfRW::processLine\n"); int code; diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.h b/src/libs/vdxf/libdxfrw/libdxfrw.h index 6e3e17679..234f14b4a 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.h +++ b/src/libs/vdxf/libdxfrw/libdxfrw.h @@ -47,6 +47,7 @@ public: bool writeVport(DRW_Vport *ent); bool writeAppId(DRW_AppId *ent); bool writePoint(DRW_Point *ent); + bool writeASTMNotch(DRW_ASTMNotch *ent); bool writeLine(DRW_Line *ent); bool writeRay(DRW_Ray *ent); bool writeXline(DRW_Xline *ent); @@ -90,6 +91,7 @@ private: bool processAppId(); bool processPoint(); + bool processASTMNotch(); bool processLine(); bool processRay(); bool processXline(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index af8f5546b..bec63c1c8 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -55,6 +55,23 @@ static const qreal AAMATextHeight = 2.5; +namespace +{ +QVector PieceOutline(const VLayoutPiece &detail) +{ + QVector outline; + if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn()) + { + outline = detail.GetMappedSeamAllowancePoints(); + } + else + { + outline = detail.GetMappedContourPoints(); + } + return outline; +} +} + //--------------------------------------------------------------------------------------------------------------------- static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() { @@ -623,7 +640,7 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) } input->AddAAMALayers(); - ExportAAMAGlobalText(input, details); + ExportStyleSystemText(input, details); for(auto &detail : details) { @@ -643,7 +660,7 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) ExportAAMAIntcut(detailBlock, detail); ExportAAMANotch(detailBlock, detail); ExportAAMAGrainline(detailBlock, detail); - ExportAAMAText(detailBlock, detail); + ExportPieceText(detailBlock, detail); ExportAAMADrill(detailBlock, detail); input->AddBlock(detailBlock); @@ -661,17 +678,7 @@ bool VDxfEngine::ExportToAAMA(const QVector &details) //--------------------------------------------------------------------------------------------------------------------- void VDxfEngine::ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) { - QVector outline; - if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn()) - { - outline = detail.GetMappedSeamAllowancePoints(); - } - else - { - outline = detail.GetMappedContourPoints(); - } - - DRW_Entity *e = AAMAPolygon(outline, QChar('1'), true); + DRW_Entity *e = AAMAPolygon(PieceOutline(detail), QChar('1'), true); if (e) { detailBlock->ent.push_back(e); @@ -761,7 +768,7 @@ void VDxfEngine::ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPi } //--------------------------------------------------------------------------------------------------------------------- -void VDxfEngine::ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +void VDxfEngine::ExportPieceText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) { const QStringList list = detail.GetPieceText(); const QPointF startPos = detail.GetPieceTextPosition(); @@ -774,7 +781,7 @@ void VDxfEngine::ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece & } //--------------------------------------------------------------------------------------------------------------------- -void VDxfEngine::ExportAAMAGlobalText(const QSharedPointer &input, const QVector &details) +void VDxfEngine::ExportStyleSystemText(const QSharedPointer &input, const QVector &details) { for(auto &detail : details) { @@ -812,6 +819,261 @@ void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece } } +//--------------------------------------------------------------------------------------------------------------------- +bool VDxfEngine::ExportToASTM(const QVector &details) +{ + if (size.isValid() == false) + { + qWarning()<<"VDxfEngine::begin(), size is not valid"; + return false; + } + + input = QSharedPointer(new dx_iface(getFileNameForLocale(), m_version, varMeasurement, + varInsunits)); + + input->AddAAMAHeaderData(); + if (m_version > DRW::AC1009) + { + input->AddDefLayers(); + } + input->AddASTMLayers(); + + ExportStyleSystemText(input, details); + + for(auto &detail : details) + { + dx_ifaceBlock *detailBlock = new dx_ifaceBlock(); + + QString blockName = detail.GetName(); + if (m_version <= DRW::AC1009) + { + blockName.replace(' ', '_'); + } + + detailBlock->name = blockName.toStdString(); + detailBlock->layer = '1'; + + ExportASTMPieceBoundary(detailBlock, detail); + ExportASTMSewLine(detailBlock, detail); + ExportASTMInternalLine(detailBlock, detail); + ExportASTMInternalCutout(detailBlock, detail); + ExportASTMNotch(detailBlock, detail); + ExportAAMAGrainline(detailBlock, detail); + ExportPieceText(detailBlock, detail); + ExportASTMDrill(detailBlock, detail); + ExportASTMAnnotationText(detailBlock, detail); + + input->AddBlock(detailBlock); + + DRW_Insert *insert = new DRW_Insert(); + insert->name = blockName.toStdString(); + insert->layer = '1'; + + input->AddEntity(insert); + } + + return input->fileExport(m_binary); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMPieceBoundary(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + QVector pieceBoundary = PieceOutline(detail); + + // Piece boundary + DRW_Entity *e = AAMAPolygon(PieceOutline(detail), QChar('1'), true); + if (e) + { + detailBlock->ent.push_back(e); + } + + // Piece boundary quality validation curves + DRW_Entity *q = AAMAPolygon(PieceOutline(detail), "84", true); + if (q) + { + detailBlock->ent.push_back(q); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMSewLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + if (not detail.IsHideMainPath() && not detail.IsSeamAllowanceBuiltIn()) + { + QVector sewLine = detail.GetMappedContourPoints(); + + // Sew lines + if (DRW_Entity *e = AAMAPolygon(sewLine, "14", true)) + { + detailBlock->ent.push_back(e); + } + + // Sew lines quality validation curves + if (DRW_Entity *e = AAMAPolygon(sewLine, "87", true)) + { + detailBlock->ent.push_back(e); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMInternalLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + const QVector> drawIntCut = detail.InternalPathsForCut(false); + for(auto &intCut : drawIntCut) + { + // Internal line + if (DRW_Entity *e = AAMAPolygon(intCut, QChar('8'), false)) + { + detailBlock->ent.push_back(e); + } + + // Internal lines quality validation curves + if (DRW_Entity *e = AAMAPolygon(intCut, "85", false)) + { + detailBlock->ent.push_back(e); + } + } + + const QVector labels = detail.GetPlaceLabels(); + for(auto &label : labels) + { + if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button + && label.type != PlaceLabelType::Circle) + { + for(auto &p : qAsConst(label.shape)) + { + // Internal line (placelabel) + if (DRW_Entity *e = AAMAPolygon(p, QChar('8'), false)) + { + detailBlock->ent.push_back(e); + } + + // Internal lines quality validation curves + if (DRW_Entity *e = AAMAPolygon(p, "85", false)) + { + detailBlock->ent.push_back(e); + } + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMInternalCutout(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + QVector> drawIntCut = detail.InternalPathsForCut(true); + for(auto &intCut : drawIntCut) + { + // Internal cutout + if (DRW_Entity *e = AAMAPolygon(intCut, "11", false)) + { + detailBlock->ent.push_back(e); + } + + // Internal cutouts quality validation curves + if (DRW_Entity *e = AAMAPolygon(intCut, "86", false)) + { + detailBlock->ent.push_back(e); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMAnnotationText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + QString name = detail.GetName(); + QPointF textPos = detail.VLayoutPiece::DetailBoundingRect().center(); + + QPointF pos(textPos.x(), textPos.y() - ToPixel(AAMATextHeight, varInsunits)); + detailBlock->ent.push_back(AAMAText(pos, name, "15")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMDrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + const QVector labels = detail.GetPlaceLabels(); + + for(auto &label : labels) + { + if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button + || label.type == PlaceLabelType::Circle) + { + const QPointF center = detail.GetMatrix().map(label.center); + DRW_Point *point = new DRW_Point(); + point->basePoint = DRW_Coord(FromPixel(center.x(), varInsunits), + FromPixel(getSize().height() - center.y(), varInsunits), 0); + point->layer = "13"; + + detailBlock->ent.push_back(point); + + // TODO. Investigate drill category +// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, varInsunits)); +// detailBlock->ent.push_back(AAMAText(pos, category, "13")); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::ExportASTMNotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail) +{ + if (detail.IsSeamAllowance()) + { + const QVector passmarks = detail.GetPassmarks(); + for(auto &passmark : passmarks) + { + DRW_ASTMNotch *notch = new DRW_ASTMNotch(); + const QPointF center = passmark.baseLine.p1(); + + notch->basePoint = DRW_Coord(FromPixel(center.x(), varInsunits), + FromPixel(getSize().height() - center.y(), varInsunits), + FromPixel(passmark.baseLine.length(), varInsunits)); + + notch->angle = passmark.baseLine.angle(); + + if (passmark.type == PassmarkLineType::OneLine || passmark.type == PassmarkLineType::TwoLines + || passmark.type == PassmarkLineType::ThreeLines) + { // Slit notch + notch->layer = "4"; + } + else if (passmark.type == PassmarkLineType::VMark || passmark.type == PassmarkLineType::VMark2) + { + QLineF boundaryLine = QLineF(passmark.lines.first().p2(), passmark.lines.last().p2()); + notch->thickness = FromPixel(boundaryLine.length(), varInsunits); // width + + notch->layer = "4"; + } + else if (passmark.type == PassmarkLineType::TMark) + { + qreal width = FromPixel(passmark.lines.last().length(), varInsunits); + notch->thickness = FromPixel(width, varInsunits); + + notch->layer = "80"; + } + else if (passmark.type == PassmarkLineType::BoxMark) + { + QPointF start = passmark.lines.first().p1(); + QPointF end = passmark.lines.last().p2(); + + notch->layer = "81"; + + notch->thickness = FromPixel(QLineF(start, end).length(), varInsunits); + } + else if (passmark.type == PassmarkLineType::UMark) + { + QPointF start = passmark.lines.first().p1(); + QPointF end = passmark.lines.last().p2(); + + notch->thickness = FromPixel(QLineF(start, end).length(), varInsunits); + + notch->layer = "83"; + } + + detailBlock->ent.push_back(notch); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- DRW_Entity *VDxfEngine::AAMAPolygon(const QVector &polygon, const QString &layer, bool forceClosed) { diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 0c8c261e3..945f965de 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -114,10 +114,19 @@ private: 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 &input, const QVector &details); + void ExportPieceText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportStyleSystemText(const QSharedPointer &input, const QVector &details); void ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + bool ExportToASTM(const QVector &details); + void ExportASTMPieceBoundary(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMSewLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMInternalLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMInternalCutout(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMAnnotationText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMDrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + void ExportASTMNotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail); + Q_REQUIRED_RESULT DRW_Entity *AAMAPolygon(const QVector &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); diff --git a/src/libs/vdxf/vdxfpaintdevice.cpp b/src/libs/vdxf/vdxfpaintdevice.cpp index a45414e96..d425e98e5 100644 --- a/src/libs/vdxf/vdxfpaintdevice.cpp +++ b/src/libs/vdxf/vdxfpaintdevice.cpp @@ -171,7 +171,16 @@ bool VDxfPaintDevice::ExportToAAMA(const QVector &details) const return res; } - //--------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- +bool VDxfPaintDevice::ExportToASTM(const QVector &details) const +{ + engine->setActive(true); + const bool res = engine->ExportToASTM(details); + engine->setActive(false); + return res; +} + +//--------------------------------------------------------------------------------------------------------------------- int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const { switch (metric) diff --git a/src/libs/vdxf/vdxfpaintdevice.h b/src/libs/vdxf/vdxfpaintdevice.h index e6fac0510..1488da069 100644 --- a/src/libs/vdxf/vdxfpaintdevice.h +++ b/src/libs/vdxf/vdxfpaintdevice.h @@ -67,6 +67,7 @@ public: void setInsunits(const VarInsunits &var); bool ExportToAAMA(const QVector &details) const; + bool ExportToASTM(const QVector &details) const; protected: virtual int metric(PaintDeviceMetric metric) const override; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 1f8dfa8a1..a0d959641 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -544,6 +544,7 @@ QVector VLayoutPiece::Map(QVectormatrix.map(passmarks.at(i).baseLine); } return passmarks;