Convert old tool union to format version 0.4.0.
--HG-- branch : feature
This commit is contained in:
parent
004c83a11f
commit
ac58338fc4
|
@ -362,23 +362,75 @@
|
||||||
<xs:element name="det" minOccurs="2" maxOccurs="2">
|
<xs:element name="det" minOccurs="2" maxOccurs="2">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="node" maxOccurs="unbounded">
|
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
|
<xs:sequence>
|
||||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
|
||||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
<xs:complexType>
|
||||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
<xs:attribute name="type" type="xs:string" use="required"></xs:attribute>
|
||||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||||
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
|
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
|
||||||
|
<xs:attribute name="before" type="xs:double"></xs:attribute>
|
||||||
|
<xs:attribute name="after" type="xs:double"></xs:attribute>
|
||||||
|
<xs:attribute name="angle" type="nodeAngle"></xs:attribute>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="children" minOccurs="0" maxOccurs="1">
|
<xs:element name="csa" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name="start" type="xs:unsignedInt"></xs:attribute>
|
||||||
|
<xs:attribute name="path" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||||
|
<xs:attribute name="end" type="xs:unsignedInt"></xs:attribute>
|
||||||
|
<xs:attribute name="reverse" type="xs:boolean"></xs:attribute>
|
||||||
|
<xs:attribute name="includeAs" type="piecePathIncludeType"></xs:attribute>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name="path" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="children" minOccurs="1" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
|
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="csa" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|
|
@ -130,7 +130,8 @@ const QString strMy = QStringLiteral("my");
|
||||||
const QString strForbidFlipping = QStringLiteral("forbidFlipping");
|
const QString strForbidFlipping = QStringLiteral("forbidFlipping");
|
||||||
const QString strInLayout = QStringLiteral("inLayout");
|
const QString strInLayout = QStringLiteral("inLayout");
|
||||||
const QString strSeamAllowance = QStringLiteral("seamAllowance");
|
const QString strSeamAllowance = QStringLiteral("seamAllowance");
|
||||||
const QString strTypeObject = QStringLiteral("typeObject");
|
const QString strNodeType = QStringLiteral("nodeType");
|
||||||
|
const QString strDet = QStringLiteral("det");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||||
|
@ -590,6 +591,7 @@ void VPatternConverter::ToV0_4_0()
|
||||||
SetVersion(QStringLiteral("0.4.0"));
|
SetVersion(QStringLiteral("0.4.0"));
|
||||||
TagRemoveAttributeTypeObjectInV0_4_0();
|
TagRemoveAttributeTypeObjectInV0_4_0();
|
||||||
TagDetailToV0_4_0();
|
TagDetailToV0_4_0();
|
||||||
|
TagUnionDetailsToV0_4_0();
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1714,9 +1716,9 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0()
|
||||||
QDomElement domElement = domNode.toElement();
|
QDomElement domElement = domNode.toElement();
|
||||||
if (not domElement.isNull())
|
if (not domElement.isNull())
|
||||||
{
|
{
|
||||||
if (domElement.hasAttribute(strTypeObject))
|
if (domElement.hasAttribute(strNodeType))
|
||||||
{
|
{
|
||||||
domElement.removeAttribute(strTypeObject);
|
domElement.removeAttribute(strNodeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
domNode = domNode.nextSibling();
|
domNode = domNode.nextSibling();
|
||||||
|
@ -1810,3 +1812,109 @@ void VPatternConverter::TagDetailToV0_4_0()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QDomElement VPatternConverter::GetUnionDetailNodesV0_4_0(const QDomElement &detail)
|
||||||
|
{
|
||||||
|
QDomElement tagNodes = createElement(strNodes);
|
||||||
|
|
||||||
|
if (not detail.isNull())
|
||||||
|
{
|
||||||
|
const QDomNodeList childList = detail.childNodes();
|
||||||
|
for (qint32 i = 0; i < childList.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement node = childList.at(i).toElement();
|
||||||
|
if (not node.isNull())
|
||||||
|
{
|
||||||
|
QDomElement tagNode = createElement(strNode);
|
||||||
|
|
||||||
|
tagNode.setAttribute(strIdObject, node.attribute(strIdObject, NULL_ID_STR));
|
||||||
|
|
||||||
|
if (node.hasAttribute(strReverse))
|
||||||
|
{
|
||||||
|
tagNode.setAttribute(strReverse, node.attribute(strReverse, "0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
tagNode.setAttribute(strType, node.attribute(strType, ""));
|
||||||
|
|
||||||
|
tagNodes.appendChild(tagNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tagNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QDomElement VPatternConverter::GetUnionChildrenNodesV0_4_0(const QDomElement &detail)
|
||||||
|
{
|
||||||
|
QDomElement tagNodes = createElement(strNodes);
|
||||||
|
|
||||||
|
if (not detail.isNull())
|
||||||
|
{
|
||||||
|
const QDomNodeList childList = detail.childNodes();
|
||||||
|
for (qint32 i = 0; i < childList.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement node = childList.at(i).toElement();
|
||||||
|
if (not node.isNull())
|
||||||
|
{
|
||||||
|
QDomElement tagNode = node.cloneNode().toElement();
|
||||||
|
tagNodes.appendChild(tagNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tagNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPatternConverter::TagUnionDetailsToV0_4_0()
|
||||||
|
{
|
||||||
|
// TODO. Delete if minimal supported version is 0.4.0
|
||||||
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
|
||||||
|
"Time to refactor the code.");
|
||||||
|
|
||||||
|
const QDomNodeList list = elementsByTagName(strTools);
|
||||||
|
for (int i=0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
// Tag 'tools' used only for union details, so no need to check any additional attributes
|
||||||
|
QDomElement toolDOM = list.at(i).toElement();
|
||||||
|
if (not toolDOM.isNull())
|
||||||
|
{
|
||||||
|
const QStringList tags = QStringList() << strDet << strChildren;
|
||||||
|
|
||||||
|
QVector<QDomElement> nodes;
|
||||||
|
QDomElement tagChildrenNodes = createElement(strChildren);
|
||||||
|
|
||||||
|
const QDomNodeList childList = toolDOM.childNodes();
|
||||||
|
for (qint32 i = 0; i < childList.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement element = childList.at(i).toElement();
|
||||||
|
if (not element.isNull())
|
||||||
|
{
|
||||||
|
switch (tags.indexOf(element.tagName()))
|
||||||
|
{
|
||||||
|
case 0://strDet
|
||||||
|
nodes.append(GetUnionDetailNodesV0_4_0(element));
|
||||||
|
break;
|
||||||
|
case 1://strChildren
|
||||||
|
tagChildrenNodes.appendChild(GetUnionChildrenNodesV0_4_0(element));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveAllChildren(toolDOM);
|
||||||
|
|
||||||
|
for (int i = 0; i < nodes.size(); ++i)
|
||||||
|
{
|
||||||
|
QDomElement tagDet = createElement(strDet);
|
||||||
|
tagDet.appendChild(nodes.at(i));
|
||||||
|
toolDOM.appendChild(tagDet);
|
||||||
|
}
|
||||||
|
toolDOM.appendChild(tagChildrenNodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -137,6 +137,9 @@ private:
|
||||||
|
|
||||||
void TagRemoveAttributeTypeObjectInV0_4_0();
|
void TagRemoveAttributeTypeObjectInV0_4_0();
|
||||||
void TagDetailToV0_4_0();
|
void TagDetailToV0_4_0();
|
||||||
|
void TagUnionDetailsToV0_4_0();
|
||||||
|
QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail);
|
||||||
|
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user