From 6ebd9e70335a874071c20516f4101a4ed308911c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 16 Mar 2024 15:32:23 +0200 Subject: [PATCH] Improve compatibility with Richpeace CAD. --- ChangeLog.txt | 1 + dist/OBS_debian/debian.valentina.1 | 14 ++ dist/debian/valentina.1 | 14 ++ .../puzzle/dialogs/dialogsavemanuallayout.cpp | 62 ++++++++ .../puzzle/dialogs/dialogsavemanuallayout.h | 6 + .../puzzle/dialogs/dialogsavemanuallayout.ui | 20 ++- src/app/puzzle/vpmainwindow.cpp | 5 + src/app/puzzle/vpsettings.cpp | 13 ++ src/app/puzzle/vpsettings.h | 3 + src/app/valentina/core/vcmdexport.cpp | 16 ++ src/app/valentina/core/vcmdexport.h | 2 + .../valentina/dialogs/dialogsavelayout.cpp | 79 ++++++++- src/app/valentina/dialogs/dialogsavelayout.h | 8 + src/app/valentina/dialogs/dialogsavelayout.ui | 16 +- src/app/valentina/mainwindow.cpp | 4 + src/app/valentina/mainwindowsnogui.cpp | 2 + src/libs/vdxf/dxfdef.h | 9 ++ src/libs/vdxf/dxiface.cpp | 21 ++- src/libs/vdxf/libdxfrw/libdxfrw.cpp | 14 ++ src/libs/vdxf/vdxfengine.cpp | 150 +++++++++++++++++- src/libs/vdxf/vdxfengine.h | 7 + src/libs/vdxf/vdxfpaintdevice.cpp | 18 +++ src/libs/vdxf/vdxfpaintdevice.h | 3 + src/libs/vlayout/vlayoutexporter.cpp | 14 ++ src/libs/vlayout/vlayoutexporter.h | 5 + src/libs/vmisc/commandoptions.cpp | 2 + src/libs/vmisc/commandoptions.h | 1 + src/libs/vmisc/vvalentinasettings.cpp | 17 +- src/libs/vmisc/vvalentinasettings.h | 3 + 29 files changed, 502 insertions(+), 27 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 90b8b122d..a5cd6ebc5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -65,6 +65,7 @@ - Minimal Qt version increased to Qt 5.15. Minimal C++ standard to C++17. - Updated Windows installer. - Automatic crash reports. +- Improve compatibility with Richpeace CAD. # Valentina 0.7.52 September 12, 2022 - Fix crash when default locale is ru. diff --git a/dist/OBS_debian/debian.valentina.1 b/dist/OBS_debian/debian.valentina.1 index a8c31c902..5b63f98c9 100644 --- a/dist/OBS_debian/debian.valentina.1 +++ b/dist/OBS_debian/debian.valentina.1 @@ -97,6 +97,20 @@ The path to output destination folder. By default the directory at which the app .RE .IP "--bdxf" .RB "Export dxf in binary form." +.IP "--dxfApparelComp " +.RB "Number corresponding to compatibility mode for DXF AAMA/ASTM format (default = 0, " "export mode" "): +.RS +.BR "*" " By standard = 0," +.RE +.RS +.BR "*" " Richpeace CAD V8 = 1," +.RE +.RS +.BR "*" " Richpeace CAD V9 = 2," +.RE +.RS +.BR "*" " Richpeace CAD V10 = 3." +.RE .IP "--noGrainline" .RB "Show/hide grainline when export layout." .IP "--text2paths" diff --git a/dist/debian/valentina.1 b/dist/debian/valentina.1 index a8c31c902..5b63f98c9 100755 --- a/dist/debian/valentina.1 +++ b/dist/debian/valentina.1 @@ -97,6 +97,20 @@ The path to output destination folder. By default the directory at which the app .RE .IP "--bdxf" .RB "Export dxf in binary form." +.IP "--dxfApparelComp " +.RB "Number corresponding to compatibility mode for DXF AAMA/ASTM format (default = 0, " "export mode" "): +.RS +.BR "*" " By standard = 0," +.RE +.RS +.BR "*" " Richpeace CAD V8 = 1," +.RE +.RS +.BR "*" " Richpeace CAD V9 = 2," +.RE +.RS +.BR "*" " Richpeace CAD V10 = 3." +.RE .IP "--noGrainline" .RB "Show/hide grainline when export layout." .IP "--text2paths" diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 7cf878110..1d9e2aa59 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -111,6 +111,8 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo // RemoveFormatFromList(LayoutExportFormats::NC); // No support for now + InitDxfCompatibility(); + connect(bOk, &QPushButton::clicked, this, &DialogSaveManualLayout::Save); connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveManualLayout::ShowExample); connect(ui->comboBoxFormat, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -224,6 +226,45 @@ auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool } } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogSaveManualLayout::DxfCompatibility() const -> DXFApparelCompatibility +{ + switch (Format()) + { + case LayoutExportFormats::DXF_AAMA: + case LayoutExportFormats::DXF_ASTM: + return static_cast(ui->comboBoxDxfCompatibility->currentData().toInt()); + default: + return DXFApparelCompatibility::STANDARD; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSaveManualLayout::SetDxfCompatibility(DXFApparelCompatibility type) +{ + switch (Format()) + { + case LayoutExportFormats::DXF_AAMA: + case LayoutExportFormats::DXF_ASTM: + { + if (static_cast(type) < 0 || type >= DXFApparelCompatibility::COUNT) + { + break; + } + + const int i = ui->comboBoxDxfCompatibility->findData(static_cast(type)); + if (i < 0) + { + break; + } + ui->comboBoxDxfCompatibility->setCurrentIndex(i); + break; + } + default: + break; + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSaveManualLayout::SetShowGrainline(bool show) { @@ -491,6 +532,8 @@ void DialogSaveManualLayout::ShowExample() ui->checkBoxExportUnified->setVisible(false); ui->checkBoxTilesScheme->setVisible(false); ui->checkBoxShowGrainline->setVisible(false); + ui->labelDxfCompatibility->setVisible(false); + ui->comboBoxDxfCompatibility->setVisible(false); const bool editableTextAsPaths = !settings->GetSingleLineFonts() && !settings->GetSingleStrokeOutlineFont(); @@ -499,6 +542,8 @@ void DialogSaveManualLayout::ShowExample() case LayoutExportFormats::DXF_AAMA: case LayoutExportFormats::DXF_ASTM: ui->checkBoxBinaryDXF->setVisible(true); + ui->labelDxfCompatibility->setVisible(true); + ui->comboBoxDxfCompatibility->setVisible(true); break; case LayoutExportFormats::PDFTiled: ui->checkBoxTextAsPaths->setVisible(editableTextAsPaths); @@ -616,6 +661,8 @@ void DialogSaveManualLayout::ReadSettings() qDebug() << qUtf8Printable(e.ErrorMessage()); } SetShowGrainline(settings->GetShowGrainline()); + + SetDxfCompatibility(static_cast(settings->GetDxfCompatibility())); } //--------------------------------------------------------------------------------------------------------------------- @@ -629,4 +676,19 @@ void DialogSaveManualLayout::WriteSettings() const VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); settings->SetLayoutExportFormat(static_cast(Format())); settings->SetShowGrainline(IsShowGrainline()); + + settings->SetDxfCompatibility(static_cast(DxfCompatibility())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSaveManualLayout::InitDxfCompatibility() +{ + ui->comboBoxDxfCompatibility->addItem(tr("By standard"), + QVariant(static_cast(DXFApparelCompatibility::STANDARD))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V8"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV08))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V9"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV09))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V10"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV10))); } diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.h b/src/app/puzzle/dialogs/dialogsavemanuallayout.h index 851331b50..fa4f71c4c 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.h +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.h @@ -30,6 +30,7 @@ #include +#include "../vdxf/dxfdef.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/vlayoutdef.h" #include "../vmisc/defglobal.h" @@ -57,6 +58,9 @@ public: void SetBinaryDXFFormat(bool binary); auto IsBinaryDXFFormat() const -> bool; + auto DxfCompatibility() const -> DXFApparelCompatibility; + void SetDxfCompatibility(DXFApparelCompatibility type); + void SetShowGrainline(bool show); auto IsShowGrainline() const -> bool; @@ -95,6 +99,8 @@ private: void ReadSettings(); void WriteSettings() const; + + void InitDxfCompatibility(); }; #endif // DIALOGSAVEMANUALLAYOUT_H diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.ui b/src/app/puzzle/dialogs/dialogsavemanuallayout.ui index 9c8bccdfd..9fbae807d 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.ui +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.ui @@ -6,8 +6,8 @@ 0 0 - 390 - 283 + 464 + 287 @@ -111,7 +111,7 @@ Options - + @@ -178,6 +178,20 @@ + + + + + + Compatibility: + + + + + + + + diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 1fae79464..acfe0ccd2 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -313,6 +313,7 @@ struct VPExportData QString fileName{}; qreal xScale{1.}; qreal yScale{1.}; + DXFApparelCompatibility dxfCompatibility{DXFApparelCompatibility::STANDARD}; bool isBinaryDXF{false}; bool textAsPaths{false}; bool exportUnified{true}; @@ -2323,10 +2324,12 @@ void VPMainWindow::ExportApparelLayout(const VPExportData &data, const QVector qint8 +{ + return CastToLayoutExportFormat(qvariant_cast(value(*settingDxfCompatibility, 0))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPSettings::SetDxfCompatibility(qint8 type) +{ + setValue(*settingDxfCompatibility, type); +} + //--------------------------------------------------------------------------------------------------------------------- auto VPSettings::GetLayoutLineWidth() const -> int { diff --git a/src/app/puzzle/vpsettings.h b/src/app/puzzle/vpsettings.h index 39edda649..5f8bcfb39 100644 --- a/src/app/puzzle/vpsettings.h +++ b/src/app/puzzle/vpsettings.h @@ -105,6 +105,9 @@ public: auto GetLayoutExportFormat() const -> qint8; void SetLayoutExportFormat(qint8 format); + auto GetDxfCompatibility() const -> qint8; + void SetDxfCompatibility(qint8 type); + auto GetLayoutLineWidth() const -> int; void SetLayoutLineWidth(int width); diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index cae36c469..836ee8653 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -322,6 +322,17 @@ auto VCommandLine::OptExportType() const -> int return r; } +//--------------------------------------------------------------------------------------------------------------------- +int VCommandLine::DXFApparelCompatibilityType() const +{ + int r = 0; + if (IsOptionSet(LONG_OPTION_DXF_APPAREL_COMP)) + { + r = OptionValue(LONG_OPTION_DXF_APPAREL_COMP).toInt(); + } + return r; +} + //--------------------------------------------------------------------------------------------------------------------- auto VCommandLine::IsBinaryDXF() const -> bool { @@ -631,6 +642,11 @@ void VCommandLine::InitCommandLineOptions() translate("VCommandLine", "Format number"), QChar('0')}, {LONG_OPTION_BINARYDXF, translate("VCommandLine", "Export dxf in binary form.")}, + {LONG_OPTION_DXF_APPAREL_COMP, + translate("VCommandLine", + "Number corresponding to compatibility mode for DXF AAMA/ASTM format (default = 0, export mode):") + + DialogSaveLayout::MakeHelpDxfApparelCompatibilityList(), + translate("VCommandLine", "Mode number"), QChar('0')}, {LONG_OPTION_NOGRAINLINE, translate("VCommandLine", "Show/hide grainline when export layout.")}, {LONG_OPTION_TEXT2PATHS, translate("VCommandLine", "Export text as paths.")}, {LONG_OPTION_EXPORTONLYDETAILS, diff --git a/src/app/valentina/core/vcmdexport.h b/src/app/valentina/core/vcmdexport.h index 386c0793b..a4b4f68ef 100644 --- a/src/app/valentina/core/vcmdexport.h +++ b/src/app/valentina/core/vcmdexport.h @@ -82,6 +82,8 @@ public: //@brief returns export type set, defaults 0 - svg auto OptExportType() const -> int; + auto DXFApparelCompatibilityType() const -> int; + auto IsBinaryDXF() const -> bool; auto IsNoGrainline() const -> bool; auto IsTextAsPaths() const -> bool; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 4b17b5542..35d7c65ea 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -124,6 +124,8 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName RemoveFormatFromList(LayoutExportFormats::RLD); } + InitDxfCompatibility(); + connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save); connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample); connect(ui->comboBoxFormat, QOverload::of(&QComboBox::currentIndexChanged), this, @@ -226,6 +228,45 @@ auto DialogSaveLayout::IsBinaryDXFFormat() const -> bool } } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogSaveLayout::DxfCompatibility() const -> DXFApparelCompatibility +{ + switch (Format()) + { + case LayoutExportFormats::DXF_AAMA: + case LayoutExportFormats::DXF_ASTM: + return static_cast(ui->comboBoxDxfCompatibility->currentData().toInt()); + default: + return DXFApparelCompatibility::STANDARD; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSaveLayout::SetDxfCompatibility(DXFApparelCompatibility type) +{ + switch (Format()) + { + case LayoutExportFormats::DXF_AAMA: + case LayoutExportFormats::DXF_ASTM: + { + if (static_cast(type) < 0 || type >= DXFApparelCompatibility::COUNT) + { + break; + } + + const int i = ui->comboBoxDxfCompatibility->findData(static_cast(type)); + if (i < 0) + { + break; + } + ui->comboBoxDxfCompatibility->setCurrentIndex(i); + break; + } + default: + break; + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSaveLayout::SetShowGrainline(bool show) { @@ -293,8 +334,7 @@ auto DialogSaveLayout::MakeHelpFormatList() -> QString const auto formats = InitFormats(); for (int i = 0; i < formats.size(); ++i) { - out += QStringLiteral("\t* ") + formats.at(i).first + QStringLiteral(" = ") + - QString::number(static_cast(formats.at(i).second)); + out += "\t* "_L1 + formats.at(i).first + " = "_L1 + QString::number(static_cast(formats.at(i).second)); if (i < formats.size() - 1) { @@ -308,6 +348,20 @@ auto DialogSaveLayout::MakeHelpFormatList() -> QString return out; } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogSaveLayout::MakeHelpDxfApparelCompatibilityList() -> QString +{ + QString out("\n"_L1); + out += QStringLiteral("\t* %1 = %2,\n") + .arg(tr("By standard")) + .arg(static_cast(DXFApparelCompatibility::STANDARD)); + out += QStringLiteral("\t* Richpeace CAD V8 = %1,\n").arg(static_cast(DXFApparelCompatibility::RPCADV08)); + out += QStringLiteral("\t* Richpeace CAD V9 = %1,\n").arg(static_cast(DXFApparelCompatibility::RPCADV09)); + out += QStringLiteral("\t* Richpeace CAD V10 = %1.\n").arg(static_cast(DXFApparelCompatibility::RPCADV10)); + + return out; +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSaveLayout::SetDestinationPath(const QString &cmdDestinationPath) { @@ -437,6 +491,8 @@ void DialogSaveLayout::ShowExample() ui->checkBoxTextAsPaths->setEnabled(true); ui->checkBoxShowGrainline->setVisible(false); ui->checkBoxTogetherWithNotches->setVisible(false); + ui->labelDxfCompatibility->setVisible(false); + ui->comboBoxDxfCompatibility->setVisible(false); VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); @@ -446,6 +502,8 @@ void DialogSaveLayout::ShowExample() case LayoutExportFormats::DXF_ASTM: ui->checkBoxBinaryDXF->setVisible(true); ui->checkBoxTogetherWithNotches->setVisible(m_mode != Draw::Layout); + ui->labelDxfCompatibility->setVisible(true); + ui->comboBoxDxfCompatibility->setVisible(true); break; case LayoutExportFormats::PDFTiled: ui->groupBoxPaperFormat->setEnabled(true); @@ -808,6 +866,8 @@ void DialogSaveLayout::ReadSettings() } SetShowGrainline(settings->GetShowGrainline()); } + + SetDxfCompatibility(static_cast(settings->GetDxfCompatibility())); } //--------------------------------------------------------------------------------------------------------------------- @@ -856,4 +916,19 @@ void DialogSaveLayout::WriteSettings() const settings->SetLayoutExportFormat(static_cast(Format())); settings->SetShowGrainline(IsShowGrainline()); } + + settings->SetDxfCompatibility(static_cast(DxfCompatibility())); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSaveLayout::InitDxfCompatibility() +{ + ui->comboBoxDxfCompatibility->addItem(tr("By standard"), + QVariant(static_cast(DXFApparelCompatibility::STANDARD))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V8"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV08))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V9"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV09))); + ui->comboBoxDxfCompatibility->addItem("Richpeace CAD V10"_L1, + QVariant(static_cast(DXFApparelCompatibility::RPCADV10))); } diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index c02a1d3e4..9d855a6d2 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -29,6 +29,7 @@ #ifndef DIALOGSAVELAYOUT_H #define DIALOGSAVELAYOUT_H +#include "../vdxf/dxfdef.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/vlayoutdef.h" #include "../vmisc/def.h" @@ -56,10 +57,15 @@ public: void SetBinaryDXFFormat(bool binary); auto IsBinaryDXFFormat() const -> bool; + auto DxfCompatibility() const -> DXFApparelCompatibility; + void SetDxfCompatibility(DXFApparelCompatibility type); + void SetShowGrainline(bool show); auto IsShowGrainline() const -> bool; static auto MakeHelpFormatList() -> QString; + static auto MakeHelpDxfApparelCompatibilityList() -> QString; + void SetDestinationPath(const QString &cmdDestinationPath); auto Mode() const -> Draw; @@ -117,6 +123,8 @@ private: void ReadSettings(); void WriteSettings() const; + + void InitDxfCompatibility(); }; #endif // DIALOGSAVELAYOUT_H diff --git a/src/app/valentina/dialogs/dialogsavelayout.ui b/src/app/valentina/dialogs/dialogsavelayout.ui index 795adfeb1..4ca4dfb5b 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.ui +++ b/src/app/valentina/dialogs/dialogsavelayout.ui @@ -7,7 +7,7 @@ 0 0 544 - 439 + 472 @@ -149,6 +149,20 @@ + + + + + + Compatibility: + + + + + + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a752b72c0..e43ac7a2e 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -7227,6 +7227,8 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SelectFormat(static_cast(expParams->OptExportType())); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); + m_dialogSaveLayout->SetDxfCompatibility( + static_cast(expParams->DXFApparelCompatibilityType())); m_dialogSaveLayout->SetShowGrainline(!expParams->IsNoGrainline()); m_dialogSaveLayout->SetTextAsPaths(expParams->IsTextAsPaths()); m_dialogSaveLayout->SetXScale(expParams->ExportXScale()); @@ -7266,6 +7268,8 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SelectFormat(static_cast(expParams->OptExportType())); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); + m_dialogSaveLayout->SetDxfCompatibility( + static_cast(expParams->DXFApparelCompatibilityType())); m_dialogSaveLayout->SetShowGrainline(!expParams->IsNoGrainline()); m_dialogSaveLayout->SetXScale(expParams->ExportXScale()); m_dialogSaveLayout->SetYScale(expParams->ExportYScale()); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index d50cc5242..7085b958d 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -680,10 +680,12 @@ void MainWindowsNoGUI::ExportApparelLayout(const QVector &details, { case LayoutExportFormats::DXF_ASTM: exporter.SetDxfVersion(DRW::AC1009); + exporter.SetDxfApparelCompatibility(m_dialogSaveLayout->DxfCompatibility()); exporter.ExportToASTMDXF(details); break; case LayoutExportFormats::DXF_AAMA: exporter.SetDxfVersion(DRW::AC1009); + exporter.SetDxfApparelCompatibility(m_dialogSaveLayout->DxfCompatibility()); exporter.ExportToAAMADXF(details); break; case LayoutExportFormats::RLD: diff --git a/src/libs/vdxf/dxfdef.h b/src/libs/vdxf/dxfdef.h index b24c092cb..6cecccd04 100644 --- a/src/libs/vdxf/dxfdef.h +++ b/src/libs/vdxf/dxfdef.h @@ -51,6 +51,15 @@ enum class VarInsunits : quint8 Centimeters = 5 }; +enum class DXFApparelCompatibility : qint8 +{ + STANDARD = 0, // According to specification AAMA/ASTM + RPCADV08 = 1, // Richpeace CAD V8 + RPCADV09 = 2, // Richpeace CAD V9 + RPCADV10 = 3, // Richpeace CAD V10 + COUNT /*Use only for validation*/ +}; + // Helps mark end of string. See VDxfEngine::drawTextItem for more details extern const QString endStringPlaceholder; diff --git a/src/libs/vdxf/dxiface.cpp b/src/libs/vdxf/dxiface.cpp index 171e1d223..689428cc3 100644 --- a/src/libs/vdxf/dxiface.cpp +++ b/src/libs/vdxf/dxiface.cpp @@ -346,15 +346,13 @@ void dx_iface::AddASTMLayers() 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); + 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 = '3'; // curve points + layer.color = DRW::black; + cData.layers.push_back(layer); layer.name = '4'; // V-notch and slit notch layer.color = DRW::black; @@ -365,10 +363,9 @@ void dx_iface::AddASTMLayers() // 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 = '6'; // mirror line + layer.color = DRW::black; + cData.layers.push_back(layer); layer.name = '7'; // grainline layer.color = DRW::black; diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index fbbe8b4fe..65b042663 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -223,8 +223,12 @@ auto dxfRW::writeEntity(DRW_Entity *ent) -> bool { writer->writeString(100, "AcDbEntity"); } + if (ent->space == 1) + { writer->writeInt16(67, 1); + } + if (version > DRW::AC1009) { writer->writeUtf8String(8, ent->layer); @@ -1062,7 +1066,9 @@ auto dxfRW::writePolyline(DRW_Polyline *ent) -> bool } } else + { writer->writeInt16(66, 1); + } writer->writeDouble(10, 0.0); writer->writeDouble(20, 0.0); writer->writeDouble(30, ent->basePoint.z); @@ -1514,7 +1520,9 @@ auto dxfRW::writeInsert(DRW_Insert *ent) -> bool writer->writeUtf8String(2, ent->name); } else + { writer->writeUtf8Caps(2, ent->name); + } writer->writeDouble(10, ent->basePoint.x); writer->writeDouble(20, ent->basePoint.y); writer->writeDouble(30, ent->basePoint.z); @@ -1751,7 +1759,9 @@ auto dxfRW::writeBlock(DRW_Block *bk) -> bool writer->writeUtf8String(2, bk->name); } else + { writer->writeUtf8Caps(2, bk->name); + } writer->writeInt16(70, bk->flags); writer->writeDouble(10, bk->basePoint.x); writer->writeDouble(20, bk->basePoint.y); @@ -1760,9 +1770,13 @@ auto dxfRW::writeBlock(DRW_Block *bk) -> bool writer->writeDouble(30, bk->basePoint.z); } if (version > DRW::AC1009) + { writer->writeUtf8String(3, bk->name); + } else + { writer->writeUtf8Caps(3, bk->name); + } writer->writeString(1, ""); return true; diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index b6087f6c8..d13799480 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -28,6 +28,7 @@ #include "vdxfengine.h" +#include #include #include #include @@ -36,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +72,14 @@ using namespace Qt::Literals::StringLiterals; +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vDxf, "v.undo") // NOLINT + +QT_WARNING_POP + namespace { const qreal AAMATextHeight = 2.5; @@ -214,13 +224,13 @@ auto VDxfEngine::begin(QPaintDevice *pdev) -> bool if (isActive()) { - qWarning("VDxfEngine::begin(), the engine was alredy activated"); + qCWarning(vDxf) << qUtf8Printable("VDxfEngine::begin(), the engine was alredy activated"_L1); return false; } if (not m_size.isValid()) { - qWarning() << "VDxfEngine::begin(), size is not valid"; + qCWarning(vDxf) << qUtf8Printable("VDxfEngine::begin(), size is not valid"_L1); return false; } @@ -735,6 +745,18 @@ auto VDxfEngine::IsBoundaryTogetherWithNotches() const -> bool return m_togetherWithNotches; } +//--------------------------------------------------------------------------------------------------------------------- +auto VDxfEngine::DxfApparelCompatibility() const -> DXFApparelCompatibility +{ + return m_compatibilityMode; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::SetDxfApparelCompatibility(DXFApparelCompatibility mode) +{ + m_compatibilityMode = mode; +} + //--------------------------------------------------------------------------------------------------------------------- auto VDxfEngine::ErrorString() const -> QString { @@ -778,7 +800,7 @@ auto VDxfEngine::ExportToAAMA(const QVector &details) -> bool { if (not m_size.isValid()) { - qWarning() << "VDxfEngine::begin(), size is not valid"; + qCWarning(vDxf) << qUtf8Printable("VDxfEngine::ExportToAAMA(), size is not valid"_L1); return false; } @@ -1111,9 +1133,24 @@ void VDxfEngine::ExportPieceText(const QSharedPointer &detailBloc QVector const labelShape = detail.GetPieceLabelRect(); if (labelShape.count() != 4) { + if (m_compatibilityMode == DXFApparelCompatibility::STANDARD) + { + qCWarning(vDxf) << qUtf8Printable( + QApplication::translate("VDxfEngine", "Piece '%1'. Piece System Text is missing.") + .arg(detail.GetName())); + } return; } + if (m_compatibilityMode == DXFApparelCompatibility::RPCADV08) + { + CheckLabelCompatibilityRPCADV08(detail); + } + else if (m_compatibilityMode == DXFApparelCompatibility::RPCADV09) + { + CheckLabelCompatibilityRPCADV09(detail); + } + const qreal scale = qMin(detail.GetXScale(), detail.GetYScale()); const qreal dW = QLineF(labelShape.at(0), labelShape.at(1)).length(); const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length(); @@ -1251,6 +1288,13 @@ void VDxfEngine::ExportStyleSystemText(const QSharedPointer &input, co return; } } + + if (m_compatibilityMode == DXFApparelCompatibility::STANDARD) + { + // According to ASTM standard Style System Text is mandatory. + // Some applications may refuse file without Style System Text. + qCWarning(vDxf) << qUtf8Printable(QApplication::translate("VDxfEngine", "Style System Text is missing.")); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1315,7 +1359,7 @@ auto VDxfEngine::ExportToASTM(const QVector &details) -> bool { if (not m_size.isValid()) { - qWarning() << "VDxfEngine::begin(), size is not valid"; + qCWarning(vDxf) << qUtf8Printable("VDxfEngine::ExportToASTM(), size is not valid"_L1); return false; } @@ -1786,7 +1830,18 @@ auto VDxfEngine::ExportASTMNotch(const VLayoutPassmark &passmark) -> DRW_ASTMNot notch->angle = passmark.baseLine.angle(); - switch (passmark.type) + PassmarkLineType type = passmark.type; + if (m_compatibilityMode == DXFApparelCompatibility::RPCADV08 || + m_compatibilityMode == DXFApparelCompatibility::RPCADV09 || + m_compatibilityMode == DXFApparelCompatibility::RPCADV10) + { + if (type == PassmarkLineType::ExternalVMark || type == PassmarkLineType::InternalVMark) + { + type = PassmarkLineType::CheckMark; + } + } + + switch (type) { case PassmarkLineType::OneLine: case PassmarkLineType::TwoLines: @@ -1876,7 +1931,7 @@ auto VDxfEngine::ExportASTMNotchDataDependecy(const VLayoutPassmark &passmark, c attdef->height = 3.0; attdef->text = "Link:" + notchLayer; attdef->name = "Dependency"; - attdef->flags = 2; // this is a constant attribute + attdef->flags |= 0x2; // this is a constant attribute attdef->horizontalAdjustment = 3; // aligned (if vertical alignment = 0) return attdef; @@ -2135,6 +2190,77 @@ void VDxfEngine::ASTMDrawFoldLineTwoArrows(const QVector> &poin } } +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::CheckLabelCompatibilityRPCADV09(const VLayoutPiece &detail) +{ + // According to ASTM standard Piece System Text is mandatory. + // Richpeace CAD V9. At least 'Piece Name:' or 'Size:' identifiers must be present. + const QStringList strings = detail.GetPieceText(); + bool pieceNameFound = false; + bool sizeFound = false; + + for (const QString &line : strings) + { + if (line.startsWith("Piece Name:"_L1)) + { + pieceNameFound = true; + } + else if (line.startsWith("Size:"_L1)) + { + sizeFound = true; + } + + // Break the loop early if both conditions are met + if (pieceNameFound || sizeFound) + { + break; + } + } + + if (!pieceNameFound && !sizeFound) + { + qCWarning(vDxf) << qUtf8Printable( + QApplication::translate("VDxfEngine", "Piece '%1'. 'Piece Name:' or 'Size:' identifier is missing.") + .arg(detail.GetName())); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfEngine::CheckLabelCompatibilityRPCADV08(const VLayoutPiece &detail) +{ + // According to ASTM standard Piece System Text is mandatory. + // Richpeace CAD V8. If present 'Piece Name:' identifier, 'Size:' identifier must also be present. + const QStringList strings = detail.GetPieceText(); + bool pieceNameFound = false; + bool sizeFound = false; + + for (const QString &line : strings) + { + if (line.startsWith("Piece Name:"_L1)) + { + pieceNameFound = true; + } + else if (line.startsWith("Size:"_L1)) + { + sizeFound = true; + } + + // Break the loop early if both conditions are met + if (pieceNameFound && sizeFound) + { + break; + } + } + + if (pieceNameFound && !sizeFound) + { + qCWarning(vDxf) << qUtf8Printable( + QApplication::translate("VDxfEngine", + "Piece '%1'. 'Piece Name:' identifier requires 'Size:' identifier to be present.") + .arg(detail.GetName())); + } +} + //--------------------------------------------------------------------------------------------------------------------- template auto VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const UTF8STRING &layer, bool forceClosed) -> P * @@ -2156,7 +2282,17 @@ auto VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const UTF8STRING & for (const auto &p : polygon) { - poly->addVertex(V(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits))); + V vertex(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits)); + + if constexpr (std::is_same_v) + { + if (p.CurvePoint()) + { + vertex.flags |= 0x1; + } + } + + poly->addVertex(vertex); } return poly; diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 4566ea899..5a39d55cd 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -117,6 +117,9 @@ public: void SetBoundaryTogetherWithNotches(bool value); auto IsBoundaryTogetherWithNotches() const -> bool; + auto DxfApparelCompatibility() const -> DXFApparelCompatibility; + void SetDxfApparelCompatibility(DXFApparelCompatibility mode); + auto ErrorString() const -> QString; private: @@ -135,6 +138,7 @@ private: qreal m_xscale{1}; qreal m_yscale{1}; bool m_togetherWithNotches{false}; + DXFApparelCompatibility m_compatibilityMode{DXFApparelCompatibility::STANDARD}; Q_REQUIRED_RESULT auto FromPixel(double pix, const VarInsunits &unit) const -> double; Q_REQUIRED_RESULT auto ToPixel(double val, const VarInsunits &unit) const -> double; @@ -200,6 +204,9 @@ private: void ASTMDrawFoldLineTwoArrows(const QVector> &points, const QSharedPointer &detailBlock); + + static void CheckLabelCompatibilityRPCADV09(const VLayoutPiece &detail); + static void CheckLabelCompatibilityRPCADV08(const VLayoutPiece &detail); }; #endif // VDXFENGINE_H diff --git a/src/libs/vdxf/vdxfpaintdevice.cpp b/src/libs/vdxf/vdxfpaintdevice.cpp index 812d5bc2b..256e4cbc2 100644 --- a/src/libs/vdxf/vdxfpaintdevice.cpp +++ b/src/libs/vdxf/vdxfpaintdevice.cpp @@ -214,6 +214,24 @@ auto VDxfPaintDevice::IsBoundaryTogetherWithNotches() const -> bool return m_engine->IsBoundaryTogetherWithNotches(); } +//--------------------------------------------------------------------------------------------------------------------- +auto VDxfPaintDevice::DxfApparelCompatibility() const -> DXFApparelCompatibility +{ + return m_engine->DxfApparelCompatibility(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDxfPaintDevice::SetDxfApparelCompatibility(DXFApparelCompatibility mode) +{ + if (m_engine->isActive()) + { + qWarning("VDxfPaintDevice::SetDxfApparelCompatibility(), cannot set compatibility mode while Dxf is being " + "generated"); + return; + } + m_engine->SetDxfApparelCompatibility(mode); +} + //--------------------------------------------------------------------------------------------------------------------- auto VDxfPaintDevice::ExportToAAMA(const QVector &details) const -> bool { diff --git a/src/libs/vdxf/vdxfpaintdevice.h b/src/libs/vdxf/vdxfpaintdevice.h index 0579b07db..c1e545b90 100644 --- a/src/libs/vdxf/vdxfpaintdevice.h +++ b/src/libs/vdxf/vdxfpaintdevice.h @@ -75,6 +75,9 @@ public: void SetBoundaryTogetherWithNotches(bool value); auto IsBoundaryTogetherWithNotches() const -> bool; + auto DxfApparelCompatibility() const -> DXFApparelCompatibility; + void SetDxfApparelCompatibility(DXFApparelCompatibility mode); + auto ExportToAAMA(const QVector &details) const -> bool; auto ExportToASTM(const QVector &details) const -> bool; diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index ffe857421..1a16f40ad 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -128,6 +128,18 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QList DXFApparelCompatibility +{ + return m_dxfCompatibility; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutExporter::SetDxfApparelCompatibility(DXFApparelCompatibility mode) +{ + m_dxfCompatibility = mode; +} + //--------------------------------------------------------------------------------------------------------------------- auto VLayoutExporter::IsShowGrainline() const -> bool { @@ -325,6 +337,7 @@ void VLayoutExporter::ExportToAAMADXF(const QVector &details) cons generator.SetXScale(m_xScale); generator.SetYScale(m_yScale); generator.SetBoundaryTogetherWithNotches(m_togetherWithNotches); + generator.SetDxfApparelCompatibility(m_dxfCompatibility); if (not generator.ExportToAAMA(details)) { qCritical() << tr("Can't create an AAMA dxf file.") << generator.ErrorString(); @@ -344,6 +357,7 @@ void VLayoutExporter::ExportToASTMDXF(const QVector &details) cons generator.SetXScale(m_xScale); generator.SetYScale(m_yScale); generator.SetBoundaryTogetherWithNotches(m_togetherWithNotches); + generator.SetDxfApparelCompatibility(m_dxfCompatibility); if (not generator.ExportToASTM(details)) { qCritical() << tr("Can't create an ASTM dxf file.") << generator.ErrorString(); diff --git a/src/libs/vlayout/vlayoutexporter.h b/src/libs/vlayout/vlayoutexporter.h index de1ba71d9..4e4e0bdf5 100644 --- a/src/libs/vlayout/vlayoutexporter.h +++ b/src/libs/vlayout/vlayoutexporter.h @@ -34,6 +34,7 @@ #include #include +#include "../vdxf/dxfdef.h" #include "../vlayout/vlayoutdef.h" class QGraphicsScene; @@ -77,6 +78,9 @@ public: auto BinaryDxfFormat() const -> bool; void SetBinaryDxfFormat(bool binaryFormat); + auto DxfApparelCompatibility() const -> DXFApparelCompatibility; + void SetDxfApparelCompatibility(DXFApparelCompatibility mode); + auto IsShowGrainline() const -> bool; void SetShowGrainline(bool show); @@ -138,6 +142,7 @@ private: bool m_singleStrokeOutlineFont{false}; int m_penWidth{1}; bool m_togetherWithNotches{false}; + DXFApparelCompatibility m_dxfCompatibility{DXFApparelCompatibility::STANDARD}; void ExportToPDF(QGraphicsScene *scene, const QList &details, const QString &filename) const; }; diff --git a/src/libs/vmisc/commandoptions.cpp b/src/libs/vmisc/commandoptions.cpp index 9cd3af847..50f411b3e 100644 --- a/src/libs/vmisc/commandoptions.cpp +++ b/src/libs/vmisc/commandoptions.cpp @@ -46,6 +46,7 @@ const QString SINGLE_OPTION_PAGETEMPLATE = QStringLiteral("p"); const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); +const QString LONG_OPTION_DXF_APPAREL_COMP = QStringLiteral("dxfApparelComp"); const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); const QString LONG_OPTION_NOGRAINLINE = QStringLiteral("noGrainline"); // NOLINT const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); @@ -152,6 +153,7 @@ auto AllKeys() -> QStringList SINGLE_OPTION_PAGETEMPLATE, LONG_OPTION_EXP2FORMAT, SINGLE_OPTION_EXP2FORMAT, + LONG_OPTION_DXF_APPAREL_COMP, LONG_OPTION_BINARYDXF, LONG_OPTION_NOGRAINLINE, LONG_OPTION_TEXT2PATHS, diff --git a/src/libs/vmisc/commandoptions.h b/src/libs/vmisc/commandoptions.h index 295a12a60..eafa634a5 100644 --- a/src/libs/vmisc/commandoptions.h +++ b/src/libs/vmisc/commandoptions.h @@ -46,6 +46,7 @@ extern const QString SINGLE_OPTION_PAGETEMPLATE; extern const QString LONG_OPTION_EXP2FORMAT; extern const QString SINGLE_OPTION_EXP2FORMAT; +extern const QString LONG_OPTION_DXF_APPAREL_COMP; extern const QString LONG_OPTION_BINARYDXF; extern const QString LONG_OPTION_NOGRAINLINE; extern const QString LONG_OPTION_TEXT2PATHS; diff --git a/src/libs/vmisc/vvalentinasettings.cpp b/src/libs/vmisc/vvalentinasettings.cpp index 89525e860..575edc38a 100644 --- a/src/libs/vmisc/vvalentinasettings.cpp +++ b/src/libs/vmisc/vvalentinasettings.cpp @@ -107,8 +107,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, ("layout/textAsPath Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, ("layout/time"_L1)) // NOLINT // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, ("layout/efficiencyCoefficient"_L1)) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, ("layout/exportFormat"_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, ("detail/exportFormat"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, ("layout/exportFormat"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, ("detail/exportFormat"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDxfCompatibility, ("layout/dxfCompatibility"_L1)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, ("tiledPDF/paperHeight"_L1)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, ("tiledPDF/paperWidth"_L1)) // NOLINT @@ -774,6 +775,18 @@ void VValentinaSettings::SetDetailExportFormat(qint8 format) setValue(*settingDetailExportFormat, format); } +//--------------------------------------------------------------------------------------------------------------------- +auto VValentinaSettings::GetDxfCompatibility() const -> qint8 +{ + return CastToLayoutExportFormat(qvariant_cast(value(*settingDxfCompatibility, 0))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VValentinaSettings::SetDxfCompatibility(qint8 type) +{ + setValue(*settingDxfCompatibility, type); +} + //--------------------------------------------------------------------------------------------------------------------- auto VValentinaSettings::GetHistorySearchHistory() const -> QStringList { diff --git a/src/libs/vmisc/vvalentinasettings.h b/src/libs/vmisc/vvalentinasettings.h index b7f697eeb..a0ad1b055 100644 --- a/src/libs/vmisc/vvalentinasettings.h +++ b/src/libs/vmisc/vvalentinasettings.h @@ -182,6 +182,9 @@ public: auto GetDetailExportFormat() const -> qint8; void SetDetailExportFormat(qint8 format); + auto GetDxfCompatibility() const -> qint8; + void SetDxfCompatibility(qint8 type); + auto GetHistorySearchHistory() const -> QStringList; void SetHistorySearchHistory(const QStringList &history);