From a8a3487996c718325a941a89f15a7af90eab421e Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Sat, 17 Dec 2016 03:53:47 +0200 Subject: [PATCH] Added new schema v0.3.9. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 91 +++- src/app/valentina/xml/vpattern.h | 4 + src/libs/ifc/ifcdef.cpp | 3 + src/libs/ifc/ifcdef.h | 3 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.3.9.xsd | 655 +++++++++++++++++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 1 + src/libs/ifc/xml/vabstractpattern.h | 1 + src/libs/ifc/xml/vpatternconverter.cpp | 4 +- 9 files changed, 759 insertions(+), 4 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.3.9.xsd diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 624f5ff2e..b5a7efbc6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -558,7 +558,8 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const { scene = sceneDetail; } - const QStringList tags = QStringList() << TagPoint << TagLine << TagSpline << TagArc << TagTools << TagOperation; + const QStringList tags = QStringList() << TagPoint << TagLine << TagSpline << TagArc << TagTools << TagOperation + << TagElArc; const QDomNodeList nodeList = node.childNodes(); const qint32 num = nodeList.size(); for (qint32 i = 0; i < num; ++i) @@ -592,6 +593,10 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const qCDebug(vXML, "Tag operation."); ParseOperationElement(scene, domElement, parse, domElement.attribute(AttrType, "")); break; + case 6: // TagElArc + qCDebug(vXML, "Tag elliptical arc."); + ParseEllipticalArcElement(scene, domElement, parse, domElement.attribute(AttrType, "")); + break; default: VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName())); throw e; @@ -2438,6 +2443,58 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + + try + { + quint32 id = 0; + + ToolsCommonAttributes(domElement, id); + const quint32 center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); + const QString radius1 = GetParametrString(domElement, AttrRadius1, "10"); + const QString radius2 = GetParametrString(domElement, AttrRadius2, "10"); + QString r1 = radius1;//need for saving fixed formula; + QString r2 = radius2;//need for saving fixed formula; + const QString f1 = GetParametrString(domElement, AttrAngle1, "180"); + QString f1Fix = f1;//need for saving fixed formula; + const QString f2 = GetParametrString(domElement, AttrAngle2, "270"); + QString f2Fix = f2;//need for saving fixed formula; + const QString frotation = GetParametrString(domElement, AttrRotationAngle, "0"); + QString frotationFix = frotation;//need for saving fixed formula; + const QString color = GetParametrString(domElement, AttrColor, ColorBlack); + + VToolEllipticalArc::Create(id, center, r1, r2, f1Fix, f2Fix, frotationFix, color, scene, this, data, parse, + Source::FromFile); + //Rewrite attribute formula. Need for situation when we have wrong formula. + if (r1 != radius1 || r2 != radius2 || f1Fix != f1 || f2Fix != f2 || frotationFix != frotation) + { + SetAttribute(domElement, AttrRadius1, r1); + SetAttribute(domElement, AttrRadius2, r2); + SetAttribute(domElement, AttrAngle1, f1Fix); + SetAttribute(domElement, AttrAngle2, f2Fix); + SetAttribute(domElement, AttrRotationAngle, frotationFix); + modified = true; + haveLiteChange(); + } + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + catch (qmu::QmuParserError &e) + { + VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + throw excep; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse) { @@ -2865,6 +2922,34 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen } } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseEllipticalArcElement parse elliptical arc tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ +void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, + const QString &type) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of elliptical arc is empty"); + + QStringList arcs = QStringList() << VToolEllipticalArc::ToolType; /*0*/ + + switch (arcs.indexOf(type)) + { + case 0: //VToolArc::ToolType + ParseToolEllipticalArc(scene, domElement, parse); + break; + default: + VException e(tr("Unknown elliptical arc type '%1'.").arg(type)); + throw e; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ParseToolsElement parse tools tag. @@ -3442,7 +3527,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QRectF VPattern::ActiveDrawBoundingRect() const { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used."); QRectF rec; @@ -3563,6 +3648,8 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::Move: rec = ToolBoundingRect(rec, tool.getId()); break; + case Tool::EllipticalArc: + rec = ToolBoundingRect(rec, tool.getId()); //These tools are not accesseble in Draw mode, but still 'history' contains them. case Tool::Detail: case Tool::UnionDetails: diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index b21f86751..dd8c68496 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -125,6 +125,8 @@ private: const Document &parse, const QString& type); void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString& type); + void ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, + const QString &type); void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, const Document &parse, const QString& type); void ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, @@ -193,6 +195,8 @@ private: void ParseNodeArc(const QDomElement &domElement, const Document &parse); void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); + void ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); + void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 450dede6e..0e4fa1022 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -90,6 +90,8 @@ const QString AttrSecondPoint = QStringLiteral("secondPoint"); const QString AttrThirdPoint = QStringLiteral("thirdPoint"); const QString AttrCenter = QStringLiteral("center"); const QString AttrRadius = QStringLiteral("radius"); +const QString AttrRadius1 = QStringLiteral("radius1"); +const QString AttrRadius2 = QStringLiteral("radius2"); const QString AttrAngle = QStringLiteral("angle"); const QString AttrAngle1 = QStringLiteral("angle1"); const QString AttrAngle2 = QStringLiteral("angle2"); @@ -136,6 +138,7 @@ const QString AttrArc = QStringLiteral("arc"); const QString AttrSuffix = QStringLiteral("suffix"); const QString AttrIdObject = QStringLiteral("idObject"); const QString AttrInLayout = QStringLiteral("inLayout"); +const QString AttrRotationAngle = QStringLiteral("rotationAngle"); const QString TypeLineNone = QStringLiteral("none"); const QString TypeLineLine = QStringLiteral("hair"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index d3594f201..dfc86eb6b 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -91,9 +91,12 @@ extern const QString AttrSecondPoint; extern const QString AttrThirdPoint; extern const QString AttrCenter; extern const QString AttrRadius; +extern const QString AttrRadius1; +extern const QString AttrRadius2; extern const QString AttrAngle; extern const QString AttrAngle1; extern const QString AttrAngle2; +extern const QString AttrRotationAngle; extern const QString AttrLength1; extern const QString AttrLength2; extern const QString AttrP1Line; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 33ca3fdf5..770590cbb 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -32,5 +32,6 @@ schema/individual_measurements/v0.3.1.xsd schema/individual_measurements/v0.3.2.xsd schema/individual_measurements/v0.3.3.xsd + schema/pattern/v0.3.9.xsd diff --git a/src/libs/ifc/schema/pattern/v0.3.9.xsd b/src/libs/ifc/schema/pattern/v0.3.9.xsd new file mode 100644 index 000000000..e78d7b6f3 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.3.9.xsd @@ -0,0 +1,655 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 05076bd9f..20a153bc0 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -72,6 +72,7 @@ const QString VAbstractPattern::TagPoint = QStringLiteral("point"); const QString VAbstractPattern::TagLine = QStringLiteral("line"); const QString VAbstractPattern::TagSpline = QStringLiteral("spline"); const QString VAbstractPattern::TagArc = QStringLiteral("arc"); +const QString VAbstractPattern::TagElArc = QStringLiteral("elArc"); const QString VAbstractPattern::TagTools = QStringLiteral("tools"); const QString VAbstractPattern::TagOperation = QStringLiteral("operation"); const QString VAbstractPattern::TagGradation = QStringLiteral("gradation"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index d5036b3f0..086ed7445 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -177,6 +177,7 @@ public: static const QString TagLine; static const QString TagSpline; static const QString TagArc; + static const QString TagElArc; static const QString TagTools; static const QString TagOperation; static const QString TagGradation; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index deff9a092..96ea1b8ea 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.8"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.8.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.9"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.9.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!