diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 050573c7f..600549224 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1167,12 +1167,14 @@ void MainWindow::ClosedDialogPin(int result) void MainWindow::ClosedDialogInsertNode(int result) { SCASSERT(dialogTool != nullptr); -// if (result == QDialog::Accepted) -// { -// VToolInsertTool::Create(dialogTool, doc, pattern); -// } + if (result == QDialog::Accepted) + { + DialogInsertNode *dTool = qobject_cast(dialogTool); + SCASSERT(dTool != nullptr); + VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), pattern, doc); + } ArrowTool(); -// doc->LiteParseTree(Document::LiteParse); + doc->LiteParseTree(Document::LiteParse); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 36ee8e5e6..617a40a45 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -28,6 +28,7 @@ schema/pattern/v0.4.2.xsd schema/pattern/v0.4.3.xsd schema/pattern/v0.4.4.xsd + schema/pattern/v0.4.5.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.4.5.xsd b/src/libs/ifc/schema/pattern/v0.4.5.xsd new file mode 100644 index 000000000..2813487dc --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.4.5.xsd @@ -0,0 +1,876 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 706aac902..9f41ae600 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -107,6 +107,7 @@ const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber" const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse"); +const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded"); const QString VAbstractPattern::AttrSABefore = QStringLiteral("before"); const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after"); const QString VAbstractPattern::AttrStart = QStringLiteral("start"); @@ -665,6 +666,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) { const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR); const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0"); + const bool excluded = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeExcluded, "0"); const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance); const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, @@ -705,6 +707,7 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement) node.SetFormulaSABefore(saBefore); node.SetFormulaSAAfter(saAfter); node.SetAngleType(angle); + node.SetExcluded(excluded); return node; } diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index bdc11de53..0eb281daf 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -217,6 +217,7 @@ public: static const QString AttrPlacement; static const QString AttrArrows; static const QString AttrNodeReverse; + static const QString AttrNodeExcluded; static const QString AttrSABefore; static const QString AttrSAAfter; static const QString AttrStart; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index aafd32345..19f4443e3 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -207,6 +207,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000403): return QStringLiteral("://schema/pattern/v0.4.3.xsd"); case (0x000404): + return QStringLiteral("://schema/pattern/v0.4.4.xsd"); + case (0x000405): return CurrentSchema; default: InvalidVersion(ver); @@ -329,6 +331,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000404), m_convertedFileName); V_FALLTHROUGH case (0x000404): + ToV0_4_5(); + ValidateXML(XSDSchema(0x000405), m_convertedFileName); + V_FALLTHROUGH + case (0x000405): break; default: InvalidVersion(m_ver); @@ -347,7 +353,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, 4, 4), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 5), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -676,6 +682,16 @@ void VPatternConverter::ToV0_4_4() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_4_5() +{ + // TODO. Delete if minimal supported version is 0.4.5 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 5), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.4.5")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 70df5445e..1eb0a7b0b 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 5); #endif protected: @@ -105,6 +105,7 @@ private: void ToV0_4_2(); void ToV0_4_3(); void ToV0_4_4(); + void ToV0_4_5(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 2d74cd4a5..b83daa1df 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -235,3 +235,15 @@ QDataStream& operator>>(QDataStream& in, VPieceNode& p) in >> p.d->m_reverse; return in; } + +//--------------------------------------------------------------------------------------------------------------------- +bool VPieceNode::IsExcluded() const +{ + return d->m_excluded; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceNode::SetExcluded(bool exclude) +{ + d->m_excluded = exclude; +} diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index a350164a4..d16616493 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -59,6 +59,9 @@ public: bool GetReverse() const; void SetReverse(bool reverse); + bool IsExcluded() const; + void SetExcluded(bool exclude); + qreal GetSABefore(const VContainer *data) const; qreal GetSABefore(const VContainer *data, Unit unit) const; diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 6defef952..0c6fb68ed 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -43,6 +43,7 @@ public: : m_id(NULL_ID), m_typeTool(Tool::NodePoint), m_reverse(false), + m_excluded(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), @@ -54,6 +55,7 @@ public: : m_id(id), m_typeTool(typeTool), m_reverse(reverse), + m_excluded(false), m_saBefore(-1), m_saAfter(-1), m_formulaWidthBefore(currentSeamAllowance), @@ -71,6 +73,7 @@ public: m_id(node.m_id), m_typeTool(node.m_typeTool), m_reverse(node.m_reverse), + m_excluded(node.m_excluded), m_saBefore(node.m_saBefore), m_saAfter(node.m_saAfter), m_formulaWidthBefore(node.m_formulaWidthBefore), @@ -89,6 +92,10 @@ public: /** @brief reverse true if need reverse points list for node. */ bool m_reverse; + /** @brief m_excluded true if item excluded from main path. Excluded item is not visible and also will not has + * affect on main path. Also include to exist path items automatically setted excluded. */ + bool m_excluded; + qreal m_saBefore; qreal m_saAfter; diff --git a/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp b/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp index ef35bcd92..c3eadd59c 100644 --- a/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp +++ b/src/libs/vtools/dialogs/tools/dialoginsertnode.cpp @@ -150,6 +150,7 @@ void DialogInsertNode::ChosenObject(quint32 id, const SceneObject &type) return; } + node.SetExcluded(true); SetNode(node); prepare = true; diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 5d8e62684..28da1944f 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -624,6 +624,16 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa } } + const bool excluded = node.IsExcluded(); + if (excluded) + { + doc->SetAttribute(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded()); + } + else + { // For backward compatebility. + nod.removeAttribute(VAbstractPattern::AttrNodeExcluded); + } + switch (type) { case (Tool::NodeArc): diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index dece7bca2..e005b1976 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -166,6 +166,34 @@ void VToolSeamAllowance::Remove(bool ask) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc) +{ + SCASSERT(data != nullptr); + + if (pieceId > NULL_ID) + { + VPiece oldDet; + try + { + oldDet = data->GetPiece(pieceId); + } + catch (const VExceptionBadId &) + { + return; + } + + VPiece newDet = oldDet; + + newDet.GetPath().Append(node); + + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, pieceId); + qApp->getUndoStack()->push(saveCommand);// First push then make a connect + data->UpdatePiece(pieceId, newDet);// Update piece because first save will not call lite update + connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 08d70bf99..023e1fdec 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -74,6 +74,8 @@ public: void Remove(bool ask); + static void InsertNode(const VPieceNode &node, quint32 pieceId, VContainer *data, VAbstractPattern *doc); + static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece); static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, const CustomSARecord &record); static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 1e9442ac3..3e35e9776 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -624,7 +624,11 @@ void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &new qDebug()<<"May be wrong tool type!!! Ignoring."<