Convert piece label to new format.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-18 09:02:03 +03:00
parent ae78373f88
commit 12fa4399e8
3 changed files with 78 additions and 33 deletions

View File

@ -512,14 +512,6 @@
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="mcp" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cutNumber" type="xs:unsignedInt"/>
<xs:attribute name="userDef" type="xs:string"/>
<xs:attribute name="material" type="materialType"/>
<xs:attribute name="placement" type="placementType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="letter" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/>
@ -861,28 +853,6 @@
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="materialType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--Fabric-->
<xs:enumeration value="1"/>
<!--Lining-->
<xs:enumeration value="2"/>
<!--Interfacing-->
<xs:enumeration value="3"/>
<!--Interlining-->
<xs:enumeration value="4"/>
<!--UserDefined-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="placementType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--No placement-->
<xs:enumeration value="1"/>
<!--Cut on Fold-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="arrowType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>

View File

@ -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));
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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);
};