From 12fa4399e86b93b03b309546cc7cf12f636f8764 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 18 Aug 2017 09:02:03 +0300 Subject: [PATCH] Convert piece label to new format. --HG-- branch : feature --- src/libs/ifc/schema/pattern/v0.6.0.xsd | 30 ---------- src/libs/ifc/xml/vpatternconverter.cpp | 78 +++++++++++++++++++++++++- src/libs/ifc/xml/vpatternconverter.h | 3 +- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/libs/ifc/schema/pattern/v0.6.0.xsd b/src/libs/ifc/schema/pattern/v0.6.0.xsd index 995ded109..229a2e61e 100644 --- a/src/libs/ifc/schema/pattern/v0.6.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.6.0.xsd @@ -512,14 +512,6 @@ - - - - - - - - @@ -861,28 +853,6 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index d81bbd54a..a1265d674 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -154,6 +154,11 @@ static const QString strFSIncrement = QStringLiteral("sfIncrement" static const QString strShowDate = QStringLiteral("showDate"); static const QString strShowMeasurements = QStringLiteral("showMeasurements"); static const QString strSize = QStringLiteral("size"); +static const QString strMCP = QStringLiteral("mcp"); +static const QString strLetter = QStringLiteral("letter"); +static const QString strMaterial = QStringLiteral("material"); +static const QString strUserDefined = QStringLiteral("userDef"); +static const QString strPlacement = QStringLiteral("placement"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -801,7 +806,8 @@ void VPatternConverter::ToV0_6_0() "Time to refactor the code."); SetVersion(QStringLiteral("0.6.0")); QDomElement label = AddTagPatternLabelV0_5_1(); - PortLabeltoV0_6_0(label); + PortPatternLabeltoV0_6_0(label); + PortPieceLabelstoV0_6_0(); RemoveUnusedTagsV0_6_0(); Save(); } @@ -2117,7 +2123,7 @@ QDomElement VPatternConverter::AddTagPatternLabelV0_5_1() } //--------------------------------------------------------------------------------------------------------------------- -void VPatternConverter::PortLabeltoV0_6_0(QDomElement &label) +void VPatternConverter::PortPatternLabeltoV0_6_0(QDomElement &label) { // TODO. Delete if minimal supported version is 0.6.0 Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0), @@ -2187,6 +2193,68 @@ void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QSt label.appendChild(tagLine); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::PortPieceLabelstoV0_6_0() +{ + // TODO. Delete if minimal supported version is 0.6.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0), + "Time to refactor the code."); + + const QDomNodeList nodeList = elementsByTagName(strData); + for (int i = 0; i < nodeList.size(); ++i) + { + QDomElement dataTag = nodeList.at(i).toElement(); + try + { + if (not GetParametrString(dataTag, strLetter, "").isEmpty()) + { + AddLabelTemplateLineV0_6_0(dataTag, "%pLetter%", true, false, Qt::AlignHCenter, 6); + } + } + catch(const VExceptionEmptyParameter &) + {} + + AddLabelTemplateLineV0_6_0(dataTag, "%pName%", true, false, Qt::AlignHCenter, 2); + + QDomNodeList nodeListMCP = dataTag.childNodes(); + for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) + { + QDomElement domMCP = nodeListMCP.at(iMCP).toElement(); + + QString line; + + const int material = GetParametrUInt(domMCP, strMaterial, 0); + switch(material) + { + case 0: + line.append("%mFabric%"); + break; + case 1: + line.append("%mLining%"); + break; + case 2: + line.append("%mInterfacing%"); + break; + case 3: + line.append("%mInterlining%"); + break; + case 4: + default: + line.append(GetParametrString(domMCP, strUserDefined, "User material")); + break; + } + + line.append(", %wCut% %pQuantity%"); + if (GetParametrUInt(domMCP, strPlacement, 0) == 1) + { + line.append(" %wOnFold%"); + } + + AddLabelTemplateLineV0_6_0(dataTag, line, false, false, Qt::AlignHCenter, 0); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::RemoveUnusedTagsV0_6_0() { @@ -2198,6 +2266,12 @@ void VPatternConverter::RemoveUnusedTagsV0_6_0() RemoveUniqueTagV0_6_0(strSize); RemoveUniqueTagV0_6_0(strShowDate); RemoveUniqueTagV0_6_0(strShowMeasurements); + + const QDomNodeList nodeList = elementsByTagName(strMCP); + for (int i = 0; i < nodeList.size(); ++i) + { + nodeList.at(i).parentNode().removeChild(nodeList.at(i)); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 8f83e1336..0cc38b39f 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -150,9 +150,10 @@ private: void LabelTagToV0_4_4(const QString &tagName); QDomElement AddTagPatternLabelV0_5_1(); - void PortLabeltoV0_6_0(QDomElement &label); + void PortPatternLabeltoV0_6_0(QDomElement &label); void AddLabelTemplateLineV0_6_0(QDomElement &label, const QString &text, bool bold, bool italic, int alignment, int fontSizeIncrement); + void PortPieceLabelstoV0_6_0(); void RemoveUnusedTagsV0_6_0(); void RemoveUniqueTagV0_6_0(const QString &tag); };