Create, save, open and edit simple curve by dialog. Editing by mouse still not

prepared.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-02-26 16:38:42 +02:00
parent 4eca4f97c6
commit a9112a29cb
11 changed files with 632 additions and 61 deletions

View File

@ -1842,7 +1842,8 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
// TODO. Delete if minimal supported version is 0.2.7
void VPattern::ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
@ -1865,10 +1866,10 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &dom
const auto p1 = data->GeometricObject<VPointF>(point1);
const auto p4 = data->GeometricObject<VPointF>(point4);
VSpline spline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
auto spline = new VSpline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
if (duplicate > 0)
{
spline.SetDuplicate(duplicate);
spline->SetDuplicate(duplicate);
}
VToolSpline::Create(id, spline, color, scene, this, data, parse, Source::FromFile);
@ -1881,6 +1882,63 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &dom
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
try
{
quint32 id = 0;
ToolsCommonAttributes(domElement, id);
const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
const QString angle1 = GetParametrString(domElement, AttrAngle1, "0");
QString a1 = angle1;//need for saving fixed formula;
const QString angle2 = GetParametrString(domElement, AttrAngle2, "0");
QString a2 = angle2;//need for saving fixed formula;
const QString length1 = GetParametrString(domElement, AttrLength1, "0");
QString l1 = length1;//need for saving fixed formula;
const QString length2 = GetParametrString(domElement, AttrLength2, "0");
QString l2 = length2;//need for saving fixed formula;
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
VToolSpline::Create(id, point1, point4, a1, a2, l1, l2, kCurve, duplicate, color, scene, this, data, parse,
Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (a1 != angle1 || a2 != angle2 || l1 != length1 || l2 != length2)
{
SetAttribute(domElement, AttrAngle1, a1);
SetAttribute(domElement, AttrAngle2, a2);
SetAttribute(domElement, AttrLength1, l1);
SetAttribute(domElement, AttrLength2, l2);
modified = true;
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
catch (qmu::QmuParserError &e)
{
VExceptionObjectError excep(tr("Error creating or updating simple interactive spline"), domElement);
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
{
@ -2217,32 +2275,37 @@ void VPattern::GarbageCollector()
* @param parse parser file mode.
* @param type type of spline.
*/
void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
void VPattern::ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document &parse, const QString &type)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
QStringList splines = QStringList() << VToolSpline::ToolType /*0*/
<< VToolSplinePath::ToolType /*1*/
<< VNodeSpline::ToolType /*2*/
<< VNodeSplinePath::ToolType; /*3*/
QStringList splines = QStringList() << VToolSpline::OldToolType /*0*/
<< VToolSpline::ToolType /*1*/
<< VToolSplinePath::ToolType /*2*/
<< VNodeSpline::ToolType /*3*/
<< VNodeSplinePath::ToolType; /*4*/
switch (splines.indexOf(type))
{
case 0: //VToolSpline::ToolType
case 0: //VToolSpline::OldToolType
qCDebug(vXML, "VToolSpline.");
ParseOldToolSpline(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7
break;
case 1: //VToolSpline::ToolType
qCDebug(vXML, "VToolSpline.");
ParseToolSpline(scene, domElement, parse);
break;
case 1: //VToolSplinePath::ToolType
case 2: //VToolSplinePath::ToolType
qCDebug(vXML, "VToolSplinePath.");
ParseToolSplinePath(scene, domElement, parse);
break;
case 2: //VNodeSpline::ToolType
case 3: //VNodeSpline::ToolType
qCDebug(vXML, "VNodeSpline.");
ParseNodeSpline(domElement, parse);
break;
case 3: //VNodeSplinePath::ToolType
case 4: //VNodeSplinePath::ToolType
qCDebug(vXML, "VNodeSplinePath.");
ParseNodeSplinePath(domElement, parse);
break;

View File

@ -119,7 +119,7 @@ private:
const Document &parse, const QString &type);
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document &parse);
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
void ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document &parse, const QString& type);
void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document &parse, const QString& type);
@ -167,7 +167,10 @@ private:
const Document &parse);
void ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
void ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
// TODO. Delete if minimal supported version is 0.2.7
void ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
void ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse);
void ParseNodeSpline(const QDomElement &domElement, const Document &parse);
void ParseNodeSplinePath(const QDomElement &domElement, const Document &parse);

View File

@ -89,6 +89,8 @@ const QString AttrRadius = QStringLiteral("radius");
const QString AttrAngle = QStringLiteral("angle");
const QString AttrAngle1 = QStringLiteral("angle1");
const QString AttrAngle2 = QStringLiteral("angle2");
const QString AttrLength1 = QStringLiteral("length1");
const QString AttrLength2 = QStringLiteral("length2");
const QString AttrP1Line = QStringLiteral("p1Line");
const QString AttrP2Line = QStringLiteral("p2Line");
const QString AttrP1Line1 = QStringLiteral("p1Line1");

View File

@ -91,6 +91,8 @@ extern const QString AttrRadius;
extern const QString AttrAngle;
extern const QString AttrAngle1;
extern const QString AttrAngle2;
extern const QString AttrLength1;
extern const QString AttrLength2;
extern const QString AttrP1Line;
extern const QString AttrP2Line;
extern const QString AttrP1Line1;
@ -101,8 +103,8 @@ extern const QString AttrPShoulder;
extern const QString AttrPoint1;
extern const QString AttrPoint2;
extern const QString AttrPoint4;
extern const QString AttrKAsm1;
extern const QString AttrKAsm2;
extern const QString AttrKAsm1;// TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKAsm2;// TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKCurve;
extern const QString AttrDuplicate;
extern const QString AttrPathPoint;

View File

@ -12,6 +12,7 @@
<file>schema/pattern/v0.2.4.xsd</file>
<file>schema/pattern/v0.2.5.xsd</file>
<file>schema/pattern/v0.2.6.xsd</file>
<file>schema/pattern/v0.2.7.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

View File

@ -0,0 +1,437 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="crossType"></xs:attribute>
<xs:attribute name="vCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="hCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="length1" type="xs:string"></xs:attribute>
<xs:attribute name="length2" type="xs:string"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="duplicate" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" 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:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="crossType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.6");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.6.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.7");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.7.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -109,6 +109,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000205):
return QStringLiteral("://schema/pattern/v0.2.5.xsd");
case (0x000206):
return QStringLiteral("://schema/pattern/v0.2.6.xsd");
case (0x000207):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -201,6 +203,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH
}
case (0x000206):
{
ToV0_2_7();
const QString schema = XSDSchema(0x000207);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000207):
break;
default:
break;
@ -315,6 +324,13 @@ void VPatternConverter::ToV0_2_6()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_2_7()
{
SetVersion(QStringLiteral("0.2.7"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -67,6 +67,7 @@ private:
void ToV0_2_4();
void ToV0_2_5();
void ToV0_2_6();
void ToV0_2_7();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -30,10 +30,12 @@
#define VSPLINE_P_H
#include <QSharedData>
#include "vpointf.h"
#include <QLineF>
#include <QtCore/qmath.h>
#include "vpointf.h"
#include "../vmisc/vabstractapplication.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
@ -139,12 +141,12 @@ VSplineData::VSplineData(VPointF p1, VPointF p4, qreal angle1, qreal angle2, qre
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
p1p2.setAngle(angle1);
c1Length = p1p2.length();
c1LengthF = QString().number(c1Length);
c1LengthF = QString().number(qApp->fromPixel(c1Length));
QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y());
p4p3.setAngle(angle2);
c2Length = p4p3.length();
c2LengthF = QString().number(c2Length);
c2LengthF = QString().number(qApp->fromPixel(c2Length));
}
//---------------------------------------------------------------------------------------------------------------------
@ -167,7 +169,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal k
angle1F = QString().number(angle1);
c1Length = p1p2.length();
c1LengthF = QString().number(c1Length);
c1LengthF = QString().number(qApp->fromPixel(c1Length));
QLineF p4p3(p4.toQPointF(), p3);
@ -175,7 +177,7 @@ VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal k
angle2F = QString().number(angle2);
c2Length = p4p3.length();
c2LengthF = QString().number(c2Length);
c2LengthF = QString().number(qApp->fromPixel(c2Length));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,8 @@
# include <QtMath>
#endif
const QString VToolSpline::ToolType = QStringLiteral("simple");
const QString VToolSpline::ToolType = QStringLiteral("simpleInteractive");
const QString VToolSpline::OldToolType = QStringLiteral("simple");
//---------------------------------------------------------------------------------------------------------------------
/**
@ -124,8 +125,8 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
SCASSERT(dialogTool != nullptr);
auto spl = Create(0, dialogTool->GetSpline(), dialogTool->GetColor(), scene, doc, data, Document::FullParse,
Source::FromGui);
auto spl = Create(0, new VSpline(dialogTool->GetSpline()), dialogTool->GetColor(), scene, doc, data,
Document::FullParse, Source::FromGui);
if (spl != nullptr)
{
@ -138,7 +139,7 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param spl spline.
* @param spline spline.
* @param color spline color.
* @param scene pointer to scene.
* @param doc dom document container.
@ -147,11 +148,10 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param typeCreation way we create this tool.
* @return the created tool
*/
VToolSpline* VToolSpline::Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
auto spline = new VSpline(spl);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
@ -185,6 +185,30 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const VSpline &spl, const QS
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
VToolSpline *VToolSpline::Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2,
QString &l1, QString &l2, qreal kCurve, quint32 duplicate, const QString &color,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
qreal calcAngle1 = CheckFormula(_id, a1, data);
qreal calcAngle2 = CheckFormula(_id, a2, data);
qreal calcLength1 = qApp->toPixel(CheckFormula(_id, l1, data));
qreal calcLength2 = qApp->toPixel(CheckFormula(_id, l2, data));
auto p1 = data->GeometricObject<VPointF>(point1);
auto p4 = data->GeometricObject<VPointF>(point4);
auto spline = new VSpline(*p1, *p4, calcAngle1, a1, calcAngle2, a2, calcLength1, l1, calcLength2, l2, kCurve);
if (duplicate > 0)
{
spline->SetDuplicate(duplicate);
}
return VToolSpline::Create(_id, spline, color, scene, doc, data, parse, typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
VSpline VToolSpline::getSpline() const
{
@ -290,14 +314,8 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false);
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
doc->SetAttribute(domElement, AttrAngle1, spl.GetStartAngle());
doc->SetAttribute(domElement, AttrAngle2, spl.GetEndAngle());
doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1());
doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2());
doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve());
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
SetSplineAttributes(domElement, spl);
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
@ -305,29 +323,9 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VAbstractSpline::SaveOptions(tag, obj);
QSharedPointer<VSpline> spl = qSharedPointerDynamicCast<VSpline>(obj);
auto spl = qSharedPointerDynamicCast<VSpline>(obj);
SCASSERT(spl.isNull() == false);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrPoint1, spl->GetP1().id());
doc->SetAttribute(tag, AttrPoint4, spl->GetP4().id());
doc->SetAttribute(tag, AttrAngle1, spl->GetStartAngle());
doc->SetAttribute(tag, AttrAngle2, spl->GetEndAngle());
doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1());
doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2());
doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve());
if (spl->GetDuplicate() > 0)
{
doc->SetAttribute(tag, AttrDuplicate, spl->GetDuplicate());
}
else
{
if (tag.hasAttribute(AttrDuplicate))
{
tag.removeAttribute(AttrDuplicate);
}
}
SetSplineAttributes(tag, *spl);
}
//---------------------------------------------------------------------------------------------------------------------
@ -525,3 +523,42 @@ void VToolSpline::RefreshGeometry()
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &spl)
{
if (domElement.attribute(AttrType) == OldToolType)
{
doc->SetAttribute(domElement, AttrType, ToolType);
}
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
doc->SetAttribute(domElement, AttrAngle1, spl.GetStartAngleFormula());
doc->SetAttribute(domElement, AttrAngle2, spl.GetEndAngleFormula());
doc->SetAttribute(domElement, AttrLength1, spl.GetC1LengthFormula());
doc->SetAttribute(domElement, AttrLength2, spl.GetC2LengthFormula());
doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve());
if (spl.GetDuplicate() > 0)
{
doc->SetAttribute(domElement, AttrDuplicate, spl.GetDuplicate());
}
else
{
if (domElement.hasAttribute(AttrDuplicate))
{
domElement.removeAttribute(AttrDuplicate);
}
}
if (domElement.hasAttribute(AttrKAsm1))
{
domElement.removeAttribute(AttrKAsm1);
}
if (domElement.hasAttribute(AttrKAsm2))
{
domElement.removeAttribute(AttrKAsm2);
}
}

View File

@ -45,10 +45,15 @@ public:
virtual ~VToolSpline() Q_DECL_OVERRIDE;
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
static VToolSpline *Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
static VToolSpline *Create(const quint32 _id, VSpline *spline, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static VToolSpline *Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2, QString &l1,
QString &l2, qreal kCurve, quint32 duplicate, const QString &color,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString OldToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Spline)};
@ -73,8 +78,10 @@ protected:
virtual void SetVisualization() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolSpline)
void RefreshGeometry ();
QPointF oldPosition;
void RefreshGeometry ();
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
};
#endif // VTOOLSPLINE_H