From 52c8e47e60061a153b939991244e1c4f27245e94 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Nov 2022 17:16:50 +0200 Subject: [PATCH] New option "Seam line on drawing". There are two ways to export a sew line to DXF-AAMA: on Draw layer or Sew line layer. The second is not standard, but preferable way for most CAD systems. --- src/app/puzzle/xml/vplayoutfilereader.cpp | 1 + src/app/puzzle/xml/vplayoutfilewriter.cpp | 2 ++ src/app/puzzle/xml/vplayoutliterals.cpp | 1 + src/app/puzzle/xml/vplayoutliterals.h | 1 + .../configpages/preferencespatternpage.cpp | 2 ++ .../configpages/preferencespatternpage.ui | 10 +++++++ src/app/valentina/xml/vpattern.cpp | 3 ++ src/libs/ifc/ifcdef.cpp | 1 + src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema/layout/v0.1.3.xsd | 2 ++ src/libs/ifc/schema/pattern/v0.9.2.xsd | 1 + src/libs/vdxf/vdxfengine.cpp | 4 ++- src/libs/vlayout/vabstractpiece.cpp | 12 ++++++++ src/libs/vlayout/vabstractpiece.h | 3 ++ src/libs/vlayout/vabstractpiece_p.h | 11 +++++++- src/libs/vlayout/vlayoutpiece.cpp | 1 + src/libs/vmisc/vcommonsettings.cpp | 13 +++++++++ src/libs/vmisc/vcommonsettings.h | 3 ++ .../tools/piece/dialogseamallowance.cpp | 10 ++++--- .../dialogs/tools/piece/tabs/tabpaths.ui | 28 +++++++++++++------ src/libs/vtools/tools/vtoolseamallowance.cpp | 1 + 21 files changed, 96 insertions(+), 15 deletions(-) diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 3935a3722..d6e04bcad 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -468,6 +468,7 @@ void VPLayoutFileReader::ReadPiece(const VPPiecePtr &piece) piece->SetMirror(ReadAttributeBool(attribs, ML::AttrMirrored, falseStr)); piece->SetForbidFlipping(ReadAttributeBool(attribs, ML::AttrForbidFlipping, falseStr)); piece->SetForceFlipping(ReadAttributeBool(attribs, ML::AttrForceFlipping, falseStr)); + piece->SetSewLineOnDrawing(ReadAttributeBool(attribs, ML::AttrSewLineOnDrawing, falseStr)); piece->SetMatrix(StringToTransfrom(ReadAttributeEmptyString(attribs, ML::AttrTransform))); const QStringList tags diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index b98144b97..0496f0253 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -259,6 +259,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) [](bool forbid) noexcept {return not forbid;}); SetAttributeOrRemoveIf(ML::AttrForceFlipping, piece->IsForceFlipping(), [](bool force) noexcept {return not force;}); + SetAttributeOrRemoveIf(ML::AttrSewLineOnDrawing, piece->IsSewLineOnDrawing(), + [](bool value) noexcept {return not value;}); SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix())); SetAttributeOrRemoveIf(ML::AttrGradationLabel, piece->GetGradationId(), [](const QString &label) noexcept {return label.isEmpty();}); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index adebd9e8e..03c757dbb 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -80,6 +80,7 @@ const QString AttrID = QStringLiteral("id"); // NOLINT(cert-er const QString AttrMirrored = QStringLiteral("mirrored"); // NOLINT(cert-err58-cpp) const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); // NOLINT(cert-err58-cpp) const QString AttrForceFlipping = QStringLiteral("forceFlipping"); // NOLINT(cert-err58-cpp) +const QString AttrSewLineOnDrawing = QStringLiteral("sewLineOnDrawing"); // NOLINT(cert-err58-cpp) const QString AttrTransform = QStringLiteral("transform"); // NOLINT(cert-err58-cpp) const QString AttrShowSeamline = QStringLiteral("showSeamline"); // NOLINT(cert-err58-cpp) const QString AttrEnabled = QStringLiteral("enabled"); // NOLINT(cert-err58-cpp) diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index 3dd646a45..807e42fb5 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -85,6 +85,7 @@ extern const QString AttrID; extern const QString AttrMirrored; extern const QString AttrForbidFlipping; extern const QString AttrForceFlipping; +extern const QString AttrSewLineOnDrawing; extern const QString AttrTransform; extern const QString AttrShowSeamline; extern const QString AttrEnabled; diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index a36ed1bca..2c4e0768e 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -108,6 +108,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) InitLabelDateTimeFormats(); ui->forbidFlippingCheck->setChecked(settings->GetForbidWorkpieceFlipping()); + ui->checkBoxSewLineOnDrawing->setChecked(settings->GetSewLineOnDrawing()); ui->doublePassmarkCheck->setChecked(settings->IsDoublePassmark()); ui->checkBoxHideMainPath->setChecked(settings->IsHideMainPath()); ui->fontComboBoxLabelFont->setCurrentFont(settings->GetLabelFont()); @@ -162,6 +163,7 @@ auto PreferencesPatternPage::Apply() -> QStringList settings->SetDefaultSeamAllowance(ui->defaultSeamAllowance->value()); settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked()); + settings->SetSewLineOnDrawing(ui->checkBoxSewLineOnDrawing->isChecked()); settings->SetHideMainPath(ui->checkBoxHideMainPath->isChecked()); settings->SetLabelFont(ui->fontComboBoxLabelFont->currentFont()); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui index ec971c310..5ee197810 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.ui @@ -196,6 +196,16 @@ This option will take an affect after restart. + + + + By default export to DXF-AAMA sew line on Draw layer for all new created workpieces + + + Sew line on drawing + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d6102b94b..d9230d993 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -946,6 +946,9 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse initData.detail.SetForceFlipping(GetParametrBool(domElement, AttrForceFlipping, QString().setNum(VAbstractValApplication::VApp() ->ValentinaSettings()->GetForceWorkpieceFlipping()))); + initData.detail.SetSewLineOnDrawing(GetParametrBool(domElement, AttrSewLineOnDrawing, + QString().setNum(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetSewLineOnDrawing()))); initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr)); initData.detail.SetPriority(GetParametrUInt(domElement, VToolSeamAllowance::AttrPiecePriority, QChar('0'))); diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index e09f206e6..0050d8cdf 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -126,6 +126,7 @@ const QString AttrIdObject = QStringLiteral("idObject"); const QString AttrInLayout = QStringLiteral("inLayout"); const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString AttrForceFlipping = QStringLiteral("forceFlipping"); +const QString AttrSewLineOnDrawing = QStringLiteral("sewLineOnDrawing"); const QString AttrRotationAngle = QStringLiteral("rotationAngle"); const QString AttrClosed = QStringLiteral("closed"); const QString AttrShowLabel = QStringLiteral("showLabel"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 80fcfc9d6..65f3be0ad 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -146,6 +146,7 @@ extern const QString AttrIdObject; extern const QString AttrInLayout; extern const QString AttrForbidFlipping; extern const QString AttrForceFlipping; +extern const QString AttrSewLineOnDrawing; extern const QString AttrClosed; extern const QString AttrShowLabel; extern const QString AttrShowLabel1; diff --git a/src/libs/ifc/schema/layout/v0.1.3.xsd b/src/libs/ifc/schema/layout/v0.1.3.xsd index e2e2c8d2b..3fa3471df 100644 --- a/src/libs/ifc/schema/layout/v0.1.3.xsd +++ b/src/libs/ifc/schema/layout/v0.1.3.xsd @@ -220,6 +220,7 @@ + @@ -413,6 +414,7 @@ + diff --git a/src/libs/ifc/schema/pattern/v0.9.2.xsd b/src/libs/ifc/schema/pattern/v0.9.2.xsd index 2e2c0f442..ef82ce847 100644 --- a/src/libs/ifc/schema/pattern/v0.9.2.xsd +++ b/src/libs/ifc/schema/pattern/v0.9.2.xsd @@ -751,6 +751,7 @@ + diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index e0439e409..872e523e5 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -760,7 +760,9 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer &detailBlock if (detail.IsSeamAllowance() && not detail.IsHideMainPath() && not detail.IsSeamAllowanceBuiltIn()) { QVector points = detail.GetMappedContourPoints(); - if (DRW_Entity *e = AAMAPolygon(detail.GetMappedContourPoints(), *layer8, true)) + const UTF8STRING &layer = not detail.IsSewLineOnDrawing() ? *layer14 : *layer8; + + if (DRW_Entity *e = AAMAPolygon(points, layer, true)) { detailBlock->ent.push_back(e); } diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 51187409f..1e33f98c1 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1027,6 +1027,18 @@ void VAbstractPiece::SetHideMainPath(bool value) d->m_hideMainPath = value; } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsSewLineOnDrawing() const +{ + return d->m_onDrawing; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetSewLineOnDrawing(bool value) +{ + d->m_onDrawing = value; +} + //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPiece::GetSAWidth() const -> qreal { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 6b6dd8761..66a82f80b 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -82,6 +82,9 @@ public: auto IsHideMainPath() const -> bool; void SetHideMainPath(bool value); + auto IsSewLineOnDrawing() const -> bool; + void SetSewLineOnDrawing(bool value); + auto GetSAWidth() const -> qreal; void SetSAWidth(qreal value); diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index c5bf1e588..653481fa7 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -72,12 +72,13 @@ public: qreal m_my{0}; // NOLINT (misc-non-private-member-variables-in-classes) uint m_priority{0}; // NOLINT (misc-non-private-member-variables-in-classes) QUuid m_uuid{QUuid::createUuid()}; // NOLINT (misc-non-private-member-variables-in-classes) + bool m_onDrawing{false}; // NOLINT (misc-non-private-member-variables-in-classes) private: Q_DISABLE_ASSIGN_MOVE(VAbstractPieceData) // NOLINT static constexpr quint32 streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData" - static constexpr quint16 classVersion = 3; + static constexpr quint16 classVersion = 4; }; QT_WARNING_POP @@ -105,6 +106,9 @@ inline auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) // Added in classVersion = 3 dataStream << piece.m_uuid; + // Added in classVersion = 4 + dataStream << piece.m_onDrawing; + return dataStream; } @@ -154,6 +158,11 @@ inline auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QD dataStream >> piece.m_uuid; } + if (actualClassVersion >= 4) + { + dataStream >> piece.m_onDrawing; + } + return dataStream; } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index ca52896df..0e78c7a9c 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -640,6 +640,7 @@ auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pat det.SetSAWidth(VAbstractValApplication::VApp()->toPixel(piece.GetSAWidth())); det.SetForbidFlipping(piece.IsForbidFlipping()); det.SetForceFlipping(piece.IsForceFlipping()); + det.SetSewLineOnDrawing(piece.IsSewLineOnDrawing()); det.SetId(id); if (not futureSeamAllowanceValid.result()) diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 72c7dd872..77ab543f9 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -96,6 +96,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing, (QLatin1String("pattern/sewLineOnDrawing"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, (QLatin1String("pattern/defaultSeamAllowance"))) // NOLINT @@ -922,6 +923,18 @@ void VCommonSettings::SetForceWorkpieceFlipping(bool value) } } +//--------------------------------------------------------------------------------------------------------------------- +auto VCommonSettings::GetSewLineOnDrawing() const -> bool +{ + return value(*settingPatternSewLineOnDrawing, false).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::SetSewLineOnDrawing(bool value) +{ + setValue(*settingPatternSewLineOnDrawing, value); +} + //--------------------------------------------------------------------------------------------------------------------- auto VCommonSettings::IsHideMainPath() const -> bool { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 58821d57b..e4410f9e1 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -179,6 +179,9 @@ public: auto GetForceWorkpieceFlipping() const -> bool; void SetForceWorkpieceFlipping(bool value); + auto GetSewLineOnDrawing() const -> bool; + void SetSewLineOnDrawing(bool value); + auto IsHideMainPath() const -> bool; void SetHideMainPath(bool value); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 9104cb8a4..01289bdcc 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -350,6 +350,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping()); uiTabPaths->checkBoxForceFlipping->setChecked(piece.IsForceFlipping()); + uiTabPaths->checkBoxOnDrawing->setChecked(piece.IsSewLineOnDrawing()); uiTabPaths->checkBoxSeams->setChecked(piece.IsSeamAllowance()); uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn()); uiTabPaths->lineEditName->setText(piece.GetName()); @@ -2591,6 +2592,7 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.SetPlaceLabels(GetListInternals(uiTabPlaceLabels->listWidgetPlaceLabels)); piece.SetForbidFlipping(uiTabPaths->checkBoxForbidFlipping->isChecked()); piece.SetForceFlipping(uiTabPaths->checkBoxForceFlipping->isChecked()); + piece.SetSewLineOnDrawing(uiTabPaths->checkBoxOnDrawing->isChecked()); piece.SetSeamAllowance(uiTabPaths->checkBoxSeams->isChecked()); piece.SetSeamAllowanceBuiltIn(uiTabPaths->checkBoxBuiltIn->isChecked()); piece.SetHideMainPath(uiTabPaths->checkBoxHideMainPath->isChecked()); @@ -3045,10 +3047,10 @@ void DialogSeamAllowance::InitPieceTab() } }); - uiTabPaths->checkBoxForbidFlipping->setChecked( - VAbstractApplication::VApp()->Settings()->GetForbidWorkpieceFlipping()); - uiTabPaths->checkBoxForceFlipping->setChecked( - VAbstractApplication::VApp()->Settings()->GetForceWorkpieceFlipping()); + VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); + uiTabPaths->checkBoxForbidFlipping->setChecked(settings->GetForbidWorkpieceFlipping()); + uiTabPaths->checkBoxForceFlipping->setChecked(settings->GetForceWorkpieceFlipping()); + uiTabPaths->checkBoxOnDrawing->setChecked(settings->GetSewLineOnDrawing()); connect(uiTabPaths->lineEditUUID, &QLineEdit::textChanged, this, &DialogSeamAllowance::DetailUUIDChanged); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui index 6997d588f..39848c017 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui @@ -6,8 +6,8 @@ 0 0 - 422 - 624 + 427 + 651 @@ -28,8 +28,8 @@ 0 0 - 394 - 612 + 407 + 631 @@ -83,6 +83,16 @@ + + + + Export to DXF-AAMA sew line on Draw layer + + + On drawing + + + @@ -1127,16 +1137,16 @@ + + VPlainTextEdit + QPlainTextEdit +
vplaintextedit.h
+
VLineEdit QLineEdit
vlineedit.h
- - VPlainTextEdit - QPlainTextEdit -
vplaintextedit.h
-
diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index ad41a1f03..0266cafc4 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -361,6 +361,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl [](bool inLayout) noexcept {return inLayout;}); doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping()); doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping()); + doc->SetAttribute(domElement, AttrSewLineOnDrawing, piece.IsSewLineOnDrawing()); doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowance, piece.IsSeamAllowance(), [](bool seamAllowance) noexcept {return not seamAllowance;}); doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath());