From d09de4155b41a25ebdad9a820bfcb1fa8cd56cb7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 20 Jul 2017 17:38:56 +0300 Subject: [PATCH] Added new option for Internal path. ref #391. This option is nedded for AAMA to determine a cut contour. --HG-- branch : develop --- src/app/valentina/xml/vpattern.cpp | 2 + src/libs/ifc/ifcdef.cpp | 1 + src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.5.1.xsd | 930 ++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 22 +- src/libs/ifc/xml/vpatternconverter.h | 3 +- .../dialogs/tools/piece/dialogpiecepath.cpp | 17 + .../dialogs/tools/piece/dialogpiecepath.h | 3 + .../dialogs/tools/piece/dialogpiecepath.ui | 48 +- .../tools/nodeDetails/vtoolpiecepath.cpp | 5 + 11 files changed, 1010 insertions(+), 23 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.5.1.xsd diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 0b34cd0e1..ffe9a8197 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3249,6 +3249,7 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme const PiecePathType type = static_cast(GetParametrUInt(domElement, AttrType, defType)); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); const QString penType = GetParametrString(domElement, AttrTypeLine, TypeLineLine); + const bool cut = GetParametrBool(domElement, AttrCut, falseStr); VPiecePath path; const QDomElement element = domElement.firstChildElement(VAbstractPattern::TagNodes); @@ -3260,6 +3261,7 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme path.SetType(type); path.SetName(name); path.SetPenType(LineStyleToPenStyle(penType)); + path.SetCutPath(cut); VToolPiecePath::Create(id, path, 0, scene, this, data, parse, Source::FromFile, "", idTool); } diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 81e2dbf5a..0a4376cf9 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -63,6 +63,7 @@ const QString AttrDartP3 = QStringLiteral("dartP3"); const QString AttrX = QStringLiteral("x"); const QString AttrY = QStringLiteral("y"); const QString AttrTypeLine = QStringLiteral("typeLine"); +const QString AttrCut = QStringLiteral("cut"); const QString AttrLength = QStringLiteral("length"); const QString AttrBasePoint = QStringLiteral("basePoint"); const QString AttrFirstPoint = QStringLiteral("firstPoint"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 404857ba1..c077fc8c6 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -81,6 +81,7 @@ extern const QString AttrDartP3; extern const QString AttrX; extern const QString AttrY; extern const QString AttrTypeLine; +extern const QString AttrCut; extern const QString AttrLength; extern const QString AttrBasePoint; extern const QString AttrFirstPoint; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index cce5e8f34..b585907db 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -33,6 +33,7 @@ schema/pattern/v0.4.7.xsd schema/pattern/v0.4.8.xsd schema/pattern/v0.5.0.xsd + schema/pattern/v0.5.1.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.5.1.xsd b/src/libs/ifc/schema/pattern/v0.5.1.xsd new file mode 100644 index 000000000..383ed1097 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.5.1.xsd @@ -0,0 +1,930 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 4779e9194..25bbe6e8c 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.5.0"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.5.0.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.5.1"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.5.1.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -213,6 +213,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000408): return QStringLiteral("://schema/pattern/v0.4.8.xsd"); case (0x000500): + return QStringLiteral("://schema/pattern/v0.5.0.xsd"); + case (0x000501): return CurrentSchema; default: InvalidVersion(ver); @@ -355,6 +357,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000500), m_convertedFileName); V_FALLTHROUGH case (0x000500): + ToV0_5_1(); + ValidateXML(XSDSchema(0x000501), m_convertedFileName); + V_FALLTHROUGH + case (0x000501): break; default: InvalidVersion(m_ver); @@ -373,7 +379,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 5, 0), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 5, 1), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -752,6 +758,16 @@ void VPatternConverter::ToV0_5_0() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_5_1() +{ + // TODO. Delete if minimal supported version is 0.5.1 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 5, 1), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.5.1")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 2e22f99b9..449f75c18 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 5, 0); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 5, 1); protected: virtual int MinVer() const Q_DECL_OVERRIDE; @@ -104,6 +104,7 @@ private: void ToV0_4_7(); void ToV0_4_8(); void ToV0_5_0(); + void ToV0_5_1(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index 1f6861c16..ca494c1b2 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -712,6 +712,7 @@ void DialogPiecePath::InitPathTab() [this]() { ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath); + ui->checkBoxCut->setEnabled(GetType() == PiecePathType::InternalPath); ValidObjects(PathIsValid()); }); @@ -792,6 +793,7 @@ void DialogPiecePath::InitPathTypes() ui->comboBoxType->addItem(tr("Custom seam allowance"), static_cast(PiecePathType::CustomSeamAllowance)); ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath); + ui->checkBoxCut->setEnabled(GetType() == PiecePathType::InternalPath); } //--------------------------------------------------------------------------------------------------------------------- @@ -903,6 +905,7 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path) SCASSERT(visPath != nullptr); visPath->SetPath(path); SetPenType(path.GetPenType()); + SetCutPath(path.IsCutPath()); ValidObjects(PathIsValid()); @@ -925,6 +928,7 @@ void DialogPiecePath::SetType(PiecePathType type) } ui->comboBoxPenType->setEnabled(type == PiecePathType::InternalPath); + ui->checkBoxCut->setEnabled(type == PiecePathType::InternalPath); } //--------------------------------------------------------------------------------------------------------------------- @@ -940,6 +944,18 @@ void DialogPiecePath::SetPenType(const Qt::PenStyle &type) vis->setLineStyle(type); } +//--------------------------------------------------------------------------------------------------------------------- +bool DialogPiecePath::IsCutPath() const +{ + return ui->checkBoxCut->isChecked(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPiecePath::SetCutPath(bool value) +{ + ui->checkBoxCut->setChecked(value); +} + //--------------------------------------------------------------------------------------------------------------------- QListWidgetItem *DialogPiecePath::GetItemById(quint32 id) { @@ -1105,6 +1121,7 @@ VPiecePath DialogPiecePath::CreatePath() const path.SetType(GetType()); path.SetName(ui->lineEditName->text()); path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine); + path.SetCutPath(GetType() == PiecePathType::InternalPath ? IsCutPath() : false); return path; } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h index 893aaa80f..2e3d6b5ae 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h @@ -126,6 +126,9 @@ private: Qt::PenStyle GetPenType() const; void SetPenType(const Qt::PenStyle &type); + bool IsCutPath() const; + void SetCutPath(bool value); + QListWidgetItem *GetItemById(quint32 id); quint32 GetLastId() const; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui index cd09bea58..7873925d7 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui @@ -14,7 +14,7 @@ Piece path tool - + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png @@ -60,16 +60,6 @@ - - - - Piece: - - - - - - @@ -93,6 +83,16 @@ + + + + Piece: + + + + + + @@ -102,6 +102,16 @@ + + + + The path is a cut contour + + + Cut on fabric + + + @@ -202,7 +212,7 @@ ... - + :/icon/24x24/fx.png:/icon/24x24/fx.png @@ -219,7 +229,7 @@ - :/icon/24x24/equal.png + :/icon/24x24/equal.png @@ -438,7 +448,7 @@ ... - + :/icon/24x24/fx.png:/icon/24x24/fx.png @@ -455,7 +465,7 @@ - :/icon/24x24/equal.png + :/icon/24x24/equal.png @@ -637,7 +647,7 @@ ... - + :/icon/24x24/fx.png:/icon/24x24/fx.png @@ -654,7 +664,7 @@ - :/icon/24x24/equal.png + :/icon/24x24/equal.png @@ -975,7 +985,7 @@ - + @@ -1012,7 +1022,7 @@ - + diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index ba4703b07..69c378016 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -184,6 +184,11 @@ void VToolPiecePath::AddAttributes(VAbstractPattern *doc, QDomElement &domElemen doc->SetAttribute(domElement, AttrName, path.GetName()); doc->SetAttribute(domElement, AttrType, static_cast(path.GetType())); doc->SetAttribute(domElement, AttrTypeLine, PenStyleToLineStyle(path.GetPenType())); + + if (path.GetType() == PiecePathType::InternalPath) + { + doc->SetAttribute(domElement, AttrCut, path.IsCutPath()); + } } //---------------------------------------------------------------------------------------------------------------------