From 5f4760f06feb5719aad1ab7a5e3cf01781c932a7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 23 Feb 2017 16:49:20 +0200 Subject: [PATCH] Read/write info about pin points. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 18 ++++++ src/libs/ifc/schema/pattern/v0.4.2.xsd | 6 ++ src/libs/vtools/tools/vtoolseamallowance.cpp | 60 ++++++++++++++++++++ src/libs/vtools/tools/vtoolseamallowance.h | 4 ++ 4 files changed, 88 insertions(+) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 15a349c66..b38fe5a81 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -828,6 +828,12 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) qreal dRot = GetParametrDouble(domElement, AttrRotation, "0"); detail.GetPatternPieceData().SetRotation(dRot); + const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR); + detail.GetPatternPieceData().SetTopLeftPin(topLeftPin); + + const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR); + detail.GetPatternPieceData().SetBottomRightPin(bottomRightPin); + QDomNodeList nodeListMCP = domElement.childNodes(); for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) { @@ -860,6 +866,12 @@ void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &deta detail.GetPatternInfo().SetFontSize(iFS); qreal dRot = GetParametrDouble(domElement, AttrRotation, "0"); detail.GetPatternInfo().SetRotation(dRot); + + const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR); + detail.GetPatternInfo().SetTopLeftPin(topLeftPin); + + const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR); + detail.GetPatternInfo().SetBottomRightPin(bottomRightPin); } //--------------------------------------------------------------------------------------------------------------------- @@ -876,6 +888,12 @@ void VPattern::ParsePieceGrainline(const QDomElement &domElement, VPiece &detail detail.GetGrainlineGeometry().SetRotation(qsRot); ArrowType eAT = static_cast(GetParametrUInt(domElement, AttrArrows, "0")); detail.GetGrainlineGeometry().SetArrowType(eAT); + + const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR); + detail.GetGrainlineGeometry().SetTopPin(topPin); + + const quint32 bottomPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR); + detail.GetGrainlineGeometry().SetBottomPin(bottomPin); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/schema/pattern/v0.4.2.xsd b/src/libs/ifc/schema/pattern/v0.4.2.xsd index eb2136ce1..7d9e8030e 100644 --- a/src/libs/ifc/schema/pattern/v0.4.2.xsd +++ b/src/libs/ifc/schema/pattern/v0.4.2.xsd @@ -494,6 +494,8 @@ + + @@ -505,6 +507,8 @@ + + @@ -515,6 +519,8 @@ + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 710329d51..7d70830db 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -75,6 +75,10 @@ const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllow const QString VToolSeamAllowance::AttrHeight = QStringLiteral("height"); const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united"); const QString VToolSeamAllowance::AttrFont = QStringLiteral("fontSize"); +const QString VToolSeamAllowance::AttrTopLeftPin = QStringLiteral("topLeftPin"); +const QString VToolSeamAllowance::AttrBottomRightPin = QStringLiteral("bottomRightPin"); +const QString VToolSeamAllowance::AttrTopPin = QStringLiteral("topPin"); +const QString VToolSeamAllowance::AttrBottomPin = QStringLiteral("bottomPin"); //--------------------------------------------------------------------------------------------------------------------- VToolSeamAllowance::~VToolSeamAllowance() @@ -252,6 +256,24 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement doc->SetAttribute(domData, AttrFont, data.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation()); + if (data.TopLeftPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrTopLeftPin, data.TopLeftPin()); + } + else + { + domData.removeAttribute(AttrTopLeftPin); + } + + if (data.BottomRightPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrBottomRightPin, data.BottomRightPin()); + } + else + { + domData.removeAttribute(AttrBottomRightPin); + } + for (int i = 0; i < data.GetMCPCount(); ++i) { const MaterialCutPlacement mcp = data.GetMCP(i); @@ -280,6 +302,25 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight()); doc->SetAttribute(domData, AttrFont, geom.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation()); + + if (geom.TopLeftPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrTopLeftPin, geom.TopLeftPin()); + } + else + { + domData.removeAttribute(AttrTopLeftPin); + } + + if (geom.BottomRightPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrBottomRightPin, geom.BottomRightPin()); + } + else + { + domData.removeAttribute(AttrBottomRightPin); + } + domElement.appendChild(domData); } @@ -295,6 +336,25 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation()); doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType())); + + if (glGeom.TopPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrTopPin, glGeom.TopPin()); + } + else + { + domData.removeAttribute(AttrTopPin); + } + + if (glGeom.BottomPin() > NULL_ID) + { + doc->SetAttribute(domData, AttrBottomPin, glGeom.BottomPin()); + } + else + { + domData.removeAttribute(AttrBottomPin); + } + domElement.appendChild(domData); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 68f0fdd48..b1dc83a42 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -66,6 +66,10 @@ public: static const QString AttrHeight; static const QString AttrUnited; static const QString AttrFont; + static const QString AttrTopLeftPin; + static const QString AttrBottomRightPin; + static const QString AttrTopPin; + static const QString AttrBottomPin; void Remove(bool ask);