From ae78373f888f3077796c36b5c550b3b14b1bdad9 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 18 Aug 2017 07:59:47 +0300 Subject: [PATCH] Read/write piece label. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 3 +++ src/libs/ifc/schema/pattern/v0.6.0.xsd | 11 +++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 2 ++ src/libs/ifc/xml/vabstractpattern.h | 2 ++ src/libs/ifc/xml/vdomdocument.h | 6 +++--- src/libs/vtools/tools/vtoolseamallowance.cpp | 6 +++++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index a2f20c1d8..de50bb0b6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -903,6 +903,8 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) Q_UNUSED(e) ppData.SetLetter(""); } + ppData.SetQuantity(static_cast(GetParametrUInt(domElement, AttrQuantity, "1"))); + ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr)); ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0"))); ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1")); ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1")); @@ -911,6 +913,7 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR)); ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR)); ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR)); + ppData.SetLabelTemplate(GetLabelTemplate(domElement)); QDomNodeList nodeListMCP = domElement.childNodes(); for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) diff --git a/src/libs/ifc/schema/pattern/v0.6.0.xsd b/src/libs/ifc/schema/pattern/v0.6.0.xsd index b14d3be51..995ded109 100644 --- a/src/libs/ifc/schema/pattern/v0.6.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.6.0.xsd @@ -503,6 +503,15 @@ + + + + + + + + + @@ -514,6 +523,7 @@ + @@ -522,6 +532,7 @@ + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 77602144c..472feab06 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -98,6 +98,8 @@ const QString VAbstractPattern::AttrObject = QStringLiteral("object") const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); const QString VAbstractPattern::AttrType = QStringLiteral("type"); const QString VAbstractPattern::AttrLetter = QStringLiteral("letter"); +const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity"); +const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold"); const QString VAbstractPattern::AttrMaterial = QStringLiteral("material"); const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index e5d78660f..f5d166e0d 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -220,6 +220,8 @@ public: static const QString AttrTool; static const QString AttrType; static const QString AttrLetter; + static const QString AttrQuantity; + static const QString AttrOnFold; static const QString AttrMaterial; static const QString AttrUserDefined; static const QString AttrCutNumber; diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 38c0afada..16c6437a9 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -129,6 +129,9 @@ public: static bool SafeCopy(const QString &source, const QString &destination, QString &error); + QVector GetLabelTemplate(const QDomElement &element) const; + void SetLabelTemplate(QDomElement &element, const QVector &lines); + protected: bool setTagText(const QString &tag, const QString &text); bool setTagText(const QDomElement &domElement, const QString &text); @@ -137,9 +140,6 @@ protected: void TestUniqueId() const; void CollectId(const QDomElement &node, QVector &vector)const; - QVector GetLabelTemplate(const QDomElement &element) const; - void SetLabelTemplate(QDomElement &element, const QVector &lines); - private: Q_DISABLE_COPY(VDomDocument) /** @brief Map used for finding element by id. */ diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 1a4d7e02f..26d85bdf0 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -302,7 +302,9 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPieceLabelData& data = piece.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); - doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible() == true? trueStr : falseStr); + doc->SetAttribute(domData, VAbstractPattern::AttrQuantity, data.GetQuantity()); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible()); + doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold()); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, VAbstractPattern::AttrWidth, data.GetLabelWidth()); @@ -337,6 +339,8 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement domData.removeAttribute(AttrBottomRightPin); } + doc->SetLabelTemplate(domData, data.GetLabelTemplate()); + for (int i = 0; i < data.GetMCPCount(); ++i) { const MaterialCutPlacement mcp = data.GetMCP(i);