Merge with feature.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-03-14 13:55:45 +02:00
commit 69c949be45
23 changed files with 3916 additions and 524 deletions

View File

@ -804,35 +804,26 @@ void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail, q
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) const
{
detail.GetPatternPieceData().SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
VPieceLabelData &ppData = detail.GetPatternPieceData();
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
try
{
QString qsLetter = GetParametrString(domElement, AttrLetter, "");
detail.GetPatternPieceData().SetLetter(qsLetter);
ppData.SetLetter(qsLetter);
}
catch(const VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
detail.GetPatternPieceData().SetLetter("");
ppData.SetLetter("");
}
QPointF ptPos;
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
detail.GetPatternPieceData().SetPos(ptPos);
qreal dLW = GetParametrDouble(domElement, AttrWidth, "0");
detail.GetPatternPieceData().SetLabelWidth(dLW);
qreal dLH = GetParametrDouble(domElement, VToolSeamAllowance::AttrHeight, "0");
detail.GetPatternPieceData().SetLabelHeight(dLH);
int iFS = static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"));
detail.GetPatternPieceData().SetFontSize(iFS);
qreal dRot = GetParametrDouble(domElement, AttrRotation, "0");
detail.GetPatternPieceData().SetRotation(dRot);
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
detail.GetPatternPieceData().SetTopLeftPin(topLeftPin);
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
detail.GetPatternPieceData().SetBottomRightPin(bottomRightPin);
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
ppData.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
ppData.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
QDomNodeList nodeListMCP = domElement.childNodes();
for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP)
@ -846,54 +837,37 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
}
mcp.m_iCutNumber = static_cast<int>(GetParametrUInt(domMCP, AttrCutNumber, 0));
mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0));
detail.GetPatternPieceData().Append(mcp);
ppData.Append(mcp);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &detail) const
{
detail.GetPatternInfo().SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
QPointF ptPos;
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
detail.GetPatternInfo().SetPos(ptPos);
qreal dLW = GetParametrDouble(domElement, AttrWidth, "0");
detail.GetPatternInfo().SetLabelWidth(dLW);
qreal dLH = GetParametrDouble(domElement, VToolSeamAllowance::AttrHeight, "0");
detail.GetPatternInfo().SetLabelHeight(dLH);
int iFS = static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"));
detail.GetPatternInfo().SetFontSize(iFS);
qreal dRot = GetParametrDouble(domElement, AttrRotation, "0");
detail.GetPatternInfo().SetRotation(dRot);
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
detail.GetPatternInfo().SetTopLeftPin(topLeftPin);
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
detail.GetPatternInfo().SetBottomRightPin(bottomRightPin);
VPatternLabelData &patternInfo = detail.GetPatternInfo();
patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
patternInfo.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
patternInfo.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
patternInfo.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
patternInfo.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParsePieceGrainline(const QDomElement &domElement, VPiece &detail) const
{
detail.GetGrainlineGeometry().SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
QPointF ptPos;
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
detail.GetGrainlineGeometry().SetPos(ptPos);
QString qsLength = GetParametrString(domElement, AttrLength, "0");
detail.GetGrainlineGeometry().SetLength(qsLength);
QString qsRot = GetParametrString(domElement, AttrRotation, "90");
detail.GetGrainlineGeometry().SetRotation(qsRot);
ArrowType eAT = static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0"));
detail.GetGrainlineGeometry().SetArrowType(eAT);
const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR);
detail.GetGrainlineGeometry().SetTopPin(topPin);
const quint32 bottomPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR);
detail.GetGrainlineGeometry().SetBottomPin(bottomPin);
VGrainlineData &gGeometry = detail.GetGrainlineGeometry();
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
gGeometry.SetLength(GetParametrString(domElement, AttrLength, "1"));
gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, "90"));
gGeometry.SetArrowType(static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0")));
gGeometry.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
gGeometry.SetTopPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR));
gGeometry.SetBottomPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
<file>schema/pattern/v0.4.1.xsd</file>
<file>schema/pattern/v0.4.2.xsd</file>
<file>schema/pattern/v0.4.3.xsd</file>
<file>schema/pattern/v0.4.4.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,874 @@
<?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 name="unit" type="units"/>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="extension" type="imageExtension"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<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 name="h50" type="xs:boolean"/>
<xs:attribute name="h56" type="xs:boolean"/>
<xs:attribute name="h62" type="xs:boolean"/>
<xs:attribute name="h68" type="xs:boolean"/>
<xs:attribute name="h74" type="xs:boolean"/>
<xs:attribute name="h80" type="xs:boolean"/>
<xs:attribute name="h86" type="xs:boolean"/>
<xs:attribute name="h92" type="xs:boolean"/>
<xs:attribute name="h98" type="xs:boolean"/>
<xs:attribute name="h104" type="xs:boolean"/>
<xs:attribute name="h110" type="xs:boolean"/>
<xs:attribute name="h116" type="xs:boolean"/>
<xs:attribute name="h122" type="xs:boolean"/>
<xs:attribute name="h128" type="xs:boolean"/>
<xs:attribute name="h134" type="xs:boolean"/>
<xs:attribute name="h140" type="xs:boolean"/>
<xs:attribute name="h146" type="xs:boolean"/>
<xs:attribute name="h152" type="xs:boolean"/>
<xs:attribute name="h158" type="xs:boolean"/>
<xs:attribute name="h164" type="xs:boolean"/>
<xs:attribute name="h170" type="xs:boolean"/>
<xs:attribute name="h176" type="xs:boolean"/>
<xs:attribute name="h182" type="xs:boolean"/>
<xs:attribute name="h188" type="xs:boolean"/>
<xs:attribute name="h194" type="xs:boolean"/>
<xs:attribute name="h200" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"/>
<xs:attribute name="s22" type="xs:boolean"/>
<xs:attribute name="s24" type="xs:boolean"/>
<xs:attribute name="s26" type="xs:boolean"/>
<xs:attribute name="s28" type="xs:boolean"/>
<xs:attribute name="s30" type="xs:boolean"/>
<xs:attribute name="s32" type="xs:boolean"/>
<xs:attribute name="s34" type="xs:boolean"/>
<xs:attribute name="s36" type="xs:boolean"/>
<xs:attribute name="s38" type="xs:boolean"/>
<xs:attribute name="s40" type="xs:boolean"/>
<xs:attribute name="s42" type="xs:boolean"/>
<xs:attribute name="s44" type="xs:boolean"/>
<xs:attribute name="s46" type="xs:boolean"/>
<xs:attribute name="s48" type="xs:boolean"/>
<xs:attribute name="s50" type="xs:boolean"/>
<xs:attribute name="s52" type="xs:boolean"/>
<xs:attribute name="s54" type="xs:boolean"/>
<xs:attribute name="s56" type="xs:boolean"/>
<xs:attribute name="s58" type="xs:boolean"/>
<xs:attribute name="s60" type="xs:boolean"/>
<xs:attribute name="s62" type="xs:boolean"/>
<xs:attribute name="s64" type="xs:boolean"/>
<xs:attribute name="s66" type="xs:boolean"/>
<xs:attribute name="s68" type="xs:boolean"/>
<xs:attribute name="s70" type="xs:boolean"/>
<xs:attribute name="s72" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"/>
<xs:attribute name="defHeight" type="baseHeight"/>
<xs:attribute name="defSize" type="baseSize"/>
</xs:complexType>
</xs:element>
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<xs:element name="showMeasurements" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<xs:element name="measurements" type="xs:string"/>
<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 name="name" type="shortName" use="required"/>
<xs:attribute name="formula" type="xs:string" use="required"/>
</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 name="x" type="xs:double"/>
<xs:attribute name="y" type="xs:double"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="name" type="shortName"/>
<xs:attribute name="firstPoint" type="xs:unsignedInt"/>
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"/>
<xs:attribute name="basePoint" type="xs:unsignedInt"/>
<xs:attribute name="pShoulder" type="xs:unsignedInt"/>
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="typeLine" type="xs:string"/>
<xs:attribute name="splinePath" type="xs:unsignedInt"/>
<xs:attribute name="spline" type="xs:unsignedInt"/>
<xs:attribute name="p1Line1" type="xs:unsignedInt"/>
<xs:attribute name="p1Line2" type="xs:unsignedInt"/>
<xs:attribute name="p2Line1" type="xs:unsignedInt"/>
<xs:attribute name="p2Line2" type="xs:unsignedInt"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="radius" type="xs:string"/>
<xs:attribute name="axisP1" type="xs:unsignedInt"/>
<xs:attribute name="axisP2" type="xs:unsignedInt"/>
<xs:attribute name="arc" type="xs:unsignedInt"/>
<xs:attribute name="elArc" type="xs:unsignedInt"/>
<xs:attribute name="curve" type="xs:unsignedInt"/>
<xs:attribute name="curve1" type="xs:unsignedInt"/>
<xs:attribute name="curve2" type="xs:unsignedInt"/>
<xs:attribute name="lineColor" type="colors"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="firstArc" type="xs:unsignedInt"/>
<xs:attribute name="secondArc" type="xs:unsignedInt"/>
<xs:attribute name="crossPoint" type="crossType"/>
<xs:attribute name="vCrossPoint" type="crossType"/>
<xs:attribute name="hCrossPoint" type="crossType"/>
<xs:attribute name="c1Center" type="xs:unsignedInt"/>
<xs:attribute name="c2Center" type="xs:unsignedInt"/>
<xs:attribute name="c1Radius" type="xs:string"/>
<xs:attribute name="c2Radius" type="xs:string"/>
<xs:attribute name="cRadius" type="xs:string"/>
<xs:attribute name="tangent" type="xs:unsignedInt"/>
<xs:attribute name="cCenter" type="xs:unsignedInt"/>
<xs:attribute name="name1" type="shortName"/>
<xs:attribute name="mx1" type="xs:double"/>
<xs:attribute name="my1" type="xs:double"/>
<xs:attribute name="name2" type="shortName"/>
<xs:attribute name="mx2" type="xs:double"/>
<xs:attribute name="my2" type="xs:double"/>
<xs:attribute name="point1" type="xs:unsignedInt"/>
<xs:attribute name="point2" type="xs:unsignedInt"/>
<xs:attribute name="dartP1" type="xs:unsignedInt"/>
<xs:attribute name="dartP2" type="xs:unsignedInt"/>
<xs:attribute name="dartP3" type="xs:unsignedInt"/>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"/>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"/>
</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 name="firstPoint" type="xs:unsignedInt"/>
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
<xs:attribute name="typeLine" type="xs:string"/>
<xs:attribute name="lineColor" type="colors"/>
</xs:complexType>
</xs:element>
<xs:element name="operation" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="source" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="destination" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="suffix" type="xs:string"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
<xs:attribute name="axisType" type="axisType"/>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="radius" type="xs:string"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="length" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="rotationAngle" type="xs:string"/>
<xs:attribute name="radius1" type="xs:string"/>
<xs:attribute name="radius2" type="xs:string"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="length" type="xs:string"/>
</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 name="pSpline" type="xs:unsignedInt"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="length1" type="xs:string"/>
<xs:attribute name="length2" type="xs:string"/>
<xs:attribute name="kAsm1" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="kCurve" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="kAsm1" type="xs:double"/>
<xs:attribute name="kAsm2" type="xs:double"/>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="length1" type="xs:string"/>
<xs:attribute name="length2" type="xs:string"/>
<xs:attribute name="point1" type="xs:unsignedInt"/>
<xs:attribute name="point2" type="xs:unsignedInt"/>
<xs:attribute name="point3" type="xs:unsignedInt"/>
<xs:attribute name="point4" type="xs:unsignedInt"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="duplicate" type="xs:unsignedInt"/>
</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 name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</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 name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</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 name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="path" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="before" type="xs:double"/>
<xs:attribute name="after" type="xs:double"/>
<xs:attribute name="angle" type="nodeAngle"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="type" type="piecePathType"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="typeLine" type="xs:string"/>
</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="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<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 name="path" type="xs:unsignedInt" use="required"/>
<xs:attribute name="end" type="xs:unsignedInt"/>
<xs:attribute name="reverse" type="xs:boolean"/>
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
</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:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
</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="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
</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="0" maxOccurs="unbounded"/>
</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="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="indexD1" type="xs:unsignedInt"/>
<xs:attribute name="indexD2" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</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="data" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<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"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="height" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="height" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="grainline" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="arrows" type="arrowType"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topPin" type="xs:unsignedInt"/>
<xs:attribute name="bottomPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<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 name="path" type="xs:unsignedInt" use="required"/>
<xs:attribute name="end" type="xs:unsignedInt"/>
<xs:attribute name="reverse" type="xs:boolean"/>
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
</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:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="version" type="pieceVersion"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="inLayout" type="xs:boolean"/>
<xs:attribute name="forbidFlipping" type="xs:boolean"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="seamAllowance" type="xs:boolean"/>
<xs:attribute name="united" type="xs:boolean"/>
<xs:attribute name="closed" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groups" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="object" type="xs:unsignedInt"/>
<xs:attribute name="tool" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^\p{Nd}\p{Zs}*/&amp;|!&lt;&gt;^\-()+=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^\-()+=?:;\&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="imageExtension">
<xs:restriction base="xs:string">
<xs:enumeration value="PNG"/>
<xs:enumeration value="JPG"/>
<xs:enumeration value="BMP"/>
</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:enumeration value="lightsalmon"/>
<xs:enumeration value="goldenrod"/>
<xs:enumeration value="orange"/>
<xs:enumeration value="deeppink"/>
<xs:enumeration value="violet"/>
<xs:enumeration value="darkviolet"/>
<xs:enumeration value="mediumseagreen"/>
<xs:enumeration value="lime"/>
<xs:enumeration value="deepskyblue"/>
<xs:enumeration value="cornflowerblue"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="50"/>
<xs:enumeration value="56"/>
<xs:enumeration value="62"/>
<xs:enumeration value="68"/>
<xs:enumeration value="74"/>
<xs:enumeration value="80"/>
<xs:enumeration value="86"/>
<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="200"/>
<xs:enumeration value="500"/>
<xs:enumeration value="560"/>
<xs:enumeration value="620"/>
<xs:enumeration value="680"/>
<xs:enumeration value="740"/>
<xs:enumeration value="800"/>
<xs:enumeration value="860"/>
<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:enumeration value="2000"/>
</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="58"/>
<xs:enumeration value="60"/>
<xs:enumeration value="62"/>
<xs:enumeration value="64"/>
<xs:enumeration value="66"/>
<xs:enumeration value="68"/>
<xs:enumeration value="70"/>
<xs:enumeration value="72"/>
<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:enumeration value="580"/>
<xs:enumeration value="600"/>
<xs:enumeration value="620"/>
<xs:enumeration value="640"/>
<xs:enumeration value="660"/>
<xs:enumeration value="680"/>
<xs:enumeration value="700"/>
<xs:enumeration value="720"/>
</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:simpleType name="axisType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<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"/>
<!--Both-->
<xs:enumeration value="1"/>
<!--Front-->
<xs:enumeration value="2"/>
<!--Rear-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="pieceVersion">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<!--Old version-->
<xs:enumeration value="2"/>
<!--New version-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="nodeAngle">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--by length-->
<xs:enumeration value="1"/>
<!--by points intersections-->
<xs:enumeration value="2"/>
<!--by second edge symmetry-->
<xs:enumeration value="3"/>
<!--by first edge symmetry-->
<xs:enumeration value="4"/>
<!--by first edge right angle-->
<xs:enumeration value="5"/>
<!--by first edge right angle-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="piecePathType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<!--custom seam allowance-->
<xs:enumeration value="2"/>
<!--internal path-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="piecePathIncludeType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--as main path-->
<xs:enumeration value="1"/>
<!--as custom seam allowance-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -58,8 +58,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.3.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.4.4");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.4.4.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -119,6 +119,7 @@ static const QString strDetail = QStringLiteral("detail");
static const QString strSupplement = QStringLiteral("supplement");
static const QString strClosed = QStringLiteral("closed");
static const QString strWidth = QStringLiteral("width");
static const QString strHeight = QStringLiteral("height");
static const QString strNode = QStringLiteral("node");
static const QString strNodes = QStringLiteral("nodes");
static const QString strData = QStringLiteral("data");
@ -204,6 +205,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000402):
return QStringLiteral("://schema/pattern/v0.4.2.xsd");
case (0x000403):
return QStringLiteral("://schema/pattern/v0.4.3.xsd");
case (0x000404):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -321,6 +324,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000403), m_convertedFileName);
V_FALLTHROUGH
case (0x000403):
ToV0_4_4();
ValidateXML(XSDSchema(0x000404), m_convertedFileName);
V_FALLTHROUGH
case (0x000404):
break;
default:
InvalidVersion(m_ver);
@ -339,7 +346,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 3),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 4),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -655,6 +662,19 @@ void VPatternConverter::ToV0_4_3()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_4_4()
{
// TODO. Delete if minimal supported version is 0.4.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 4),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.4"));
LabelTagToV0_4_4(strData);
LabelTagToV0_4_4(strPatternInfo);
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
@ -1927,6 +1947,58 @@ QDomElement VPatternConverter::GetUnionChildrenNodesV0_4_0(const QDomElement &de
return tagNodes;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
{
// TODO. Delete if minimal supported version is 0.4.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 4),
"Time to refactor the code.");
Unit unit = Unit::Cm;
const QStringList units = QStringList() << "mm" << "cm" << "inch";
switch (units.indexOf(UniqueTagText(strUnit)))
{
case 0:// mm
unit = Unit::Mm;
break;
case 1:// cm
unit = Unit::Cm;
break;
case 2:// in
unit = Unit::Inch;
break;
default:
break;
}
auto ConvertData = [unit](QDomElement &dom, const QString &attribute)
{
if (dom.hasAttribute(attribute))
{
QString valStr = dom.attribute(attribute, "1");
bool ok = false;
qreal val = valStr.toDouble(&ok);
if (not ok)
{
val = 1;
}
dom.setAttribute(attribute, QString().setNum(FromPixel(val, unit)));
}
};
const QDomNodeList list = elementsByTagName(tagName);
for (int i=0; i < list.size(); ++i)
{
QDomElement dom = list.at(i).toElement();
if (not dom.isNull())
{
ConvertData(dom, strWidth);
ConvertData(dom, strHeight);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnionDetailsToV0_4_0()
{

View File

@ -55,10 +55,10 @@ public:
// GCC 4.6 doesn't allow constexpr and const together
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 3);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4);
#else
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 3);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 4, 4);
#endif
protected:
@ -104,6 +104,7 @@ private:
void ToV0_4_1();
void ToV0_4_2();
void ToV0_4_3();
void ToV0_4_4();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
@ -145,6 +146,8 @@ private:
void TagUnionDetailsToV0_4_0();
QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail);
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
void LabelTagToV0_4_4(const QString &tagName);
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -75,11 +75,22 @@ QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VConta
}
//---------------------------------------------------------------------------------------------------------------------
void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &labelWidth,
qreal &labelHeight, QPointF &pos)
bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &rotationAngle,
qreal &labelWidth, qreal &labelHeight, QPointF &pos)
{
SCASSERT(pattern != nullptr)
try
{
Calculator cal1;
rotationAngle = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetRotation());
}
catch(qmu::QmuParserError &e)
{
Q_UNUSED(e);
return false;
}
const quint32 topLeftPin = labelData.TopLeftPin();
const quint32 bottomRightPin = labelData.BottomRightPin();
@ -96,7 +107,7 @@ void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
pos = labelRect.topLeft();
return;
return true;
}
catch(const VExceptionBadId &)
{
@ -104,9 +115,43 @@ void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
}
}
labelWidth = labelData.GetLabelWidth();
labelHeight = labelData.GetLabelHeight();
pos = labelData.GetPos();
try
{
Calculator cal1;
labelWidth = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetLabelWidth());
Calculator cal2;
labelHeight = cal2.EvalFormula(pattern->PlainVariables(), labelData.GetLabelHeight());
}
catch(qmu::QmuParserError &e)
{
Q_UNUSED(e);
return false;
}
const quint32 centerPin = labelData.CenterPin();
if (centerPin != NULL_ID)
{
try
{
const auto centerPinPoint = pattern->GeometricObject<VPointF>(centerPin);
const qreal lWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
const qreal lHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
pos = *centerPinPoint - QRectF(0, 0, lWidth, lHeight).center();
}
catch(const VExceptionBadId &)
{
pos = labelData.GetPos();
}
}
else
{
pos = labelData.GetPos();
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
@ -161,7 +206,32 @@ bool FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern
return false;
}
pos = geom.GetPos();
const quint32 centerPin = geom.CenterPin();
if (centerPin != NULL_ID)
{
try
{
const auto centerPinPoint = pattern->GeometricObject<VPointF>(centerPin);
const qreal cLength = ToPixel(length, *pattern->GetPatternUnit());
QLineF grainline(centerPinPoint->x(), centerPinPoint->y(),
centerPinPoint->x() + cLength / 2.0, centerPinPoint->y());
grainline.setAngle(rotationAngle);
grainline = QLineF(grainline.p2(), grainline.p1());
grainline.setLength(cLength);
pos = grainline.p2();
}
catch(const VExceptionBadId &)
{
pos = geom.GetPos();
}
}
else
{
pos = geom.GetPos();
}
return true;
}
@ -401,7 +471,14 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
QPointF ptPos;
qreal labelWidth = 0;
qreal labelHeight = 0;
FindLabelGeometry(data, pattern, labelWidth, labelHeight, ptPos);
qreal labelAngle = 0;
if (not FindLabelGeometry(data, pattern, labelAngle, labelWidth, labelHeight, ptPos))
{
return;
}
labelWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
labelHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
QVector<QPointF> v;
v << ptPos
@ -409,7 +486,7 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
const qreal dAng = qDegreesToRadians(data.GetRotation());
const qreal dAng = qDegreesToRadians(labelAngle);
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
for (int i = 0; i < v.count(); ++i)
{
@ -435,7 +512,14 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
QPointF ptPos;
qreal labelWidth = 0;
qreal labelHeight = 0;
FindLabelGeometry(geom, pattern, labelWidth, labelHeight, ptPos);
qreal labelAngle = 0;
if (not FindLabelGeometry(geom, pattern, labelAngle, labelWidth, labelHeight, ptPos))
{
return;
}
labelWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
labelHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
QVector<QPointF> v;
v << ptPos
@ -443,7 +527,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
const qreal dAng = qDegreesToRadians(geom.GetRotation());
const qreal dAng = qDegreesToRadians(labelAngle);
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
for (int i = 0; i < v.count(); ++i)
{

View File

@ -95,6 +95,18 @@ void VGrainlineData::SetArrowType(ArrowType eAT)
d->m_eArrowType = eAT;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VGrainlineData::CenterPin() const
{
return d->m_centerPin;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetCenterPin(quint32 centerPin)
{
d->m_centerPin = centerPin;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VGrainlineData::TopPin() const
{

View File

@ -59,6 +59,9 @@ public:
ArrowType GetArrowType() const;
void SetArrowType(ArrowType eAT);
quint32 CenterPin() const;
void SetCenterPin(quint32 centerPin);
quint32 TopPin() const;
void SetTopPin(quint32 topPin);

View File

@ -46,6 +46,7 @@ public:
: m_qsLength(),
m_dRotation(),
m_eArrowType(ArrowType::atBoth),
m_centerPin(NULL_ID),
m_topPin(NULL_ID),
m_bottomPin(NULL_ID)
{}
@ -55,6 +56,7 @@ public:
m_qsLength(data.m_qsLength),
m_dRotation(data.m_dRotation),
m_eArrowType(data.m_eArrowType),
m_centerPin(data.m_centerPin),
m_topPin(data.m_topPin),
m_bottomPin(data.m_bottomPin)
{}
@ -67,6 +69,8 @@ public:
QString m_dRotation;
/** @brief m_eArrowType type of arrow on the grainline */
ArrowType m_eArrowType;
/** @brief m_centerPin center pin id */
quint32 m_centerPin;
/** @brief m_topPin top pin id */
quint32 m_topPin;
/** @brief m_bottomPin bottom pin id */

View File

@ -59,25 +59,25 @@ VPatternLabelData::~VPatternLabelData()
{}
//---------------------------------------------------------------------------------------------------------------------
qreal VPatternLabelData::GetLabelWidth() const
QString VPatternLabelData::GetLabelWidth() const
{
return d->m_dLabelWidth;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetLabelWidth(qreal dLabelW)
void VPatternLabelData::SetLabelWidth(const QString &dLabelW)
{
d->m_dLabelWidth = dLabelW;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPatternLabelData::GetLabelHeight() const
QString VPatternLabelData::GetLabelHeight() const
{
return d->m_dLabelHeight;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetLabelHeight(qreal dLabelH)
void VPatternLabelData::SetLabelHeight(const QString &dLabelH)
{
d->m_dLabelHeight = dLabelH;
}
@ -95,15 +95,27 @@ void VPatternLabelData::SetFontSize(int iSize)
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPatternLabelData::GetRotation() const
QString VPatternLabelData::GetRotation() const
{
return d->m_dRotation;
return d->m_dLabelAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetRotation(qreal dRot)
void VPatternLabelData::SetRotation(const QString &dRot)
{
d->m_dRotation = dRot;
d->m_dLabelAngle = dRot;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VPatternLabelData::CenterPin() const
{
return d->m_centerPin;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetCenterPin(const quint32 &centerPin)
{
d->m_centerPin = centerPin;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -47,17 +47,20 @@ public:
virtual ~VPatternLabelData();
// methods, which set up label parameters
qreal GetLabelWidth() const;
void SetLabelWidth(qreal dLabelW);
QString GetLabelWidth() const;
void SetLabelWidth(const QString &dLabelW);
qreal GetLabelHeight() const;
void SetLabelHeight(qreal dLabelH);
QString GetLabelHeight() const;
void SetLabelHeight(const QString &dLabelH);
int GetFontSize() const;
void SetFontSize(int iSize);
qreal GetRotation() const;
void SetRotation(qreal dRot);
QString GetRotation() const;
void SetRotation(const QString &dRot);
quint32 CenterPin() const;
void SetCenterPin(const quint32 &centerPin);
quint32 TopLeftPin() const;
void SetTopLeftPin(const quint32 &topLeftPin);

View File

@ -42,10 +42,11 @@ class VPatternLabelDataPrivate : public QSharedData
{
public:
VPatternLabelDataPrivate()
: m_dLabelWidth(0),
m_dLabelHeight(0),
: m_dLabelWidth(),
m_dLabelHeight(),
m_dLabelAngle(),
m_iFontSize(0),
m_dRotation(0),
m_centerPin(NULL_ID),
m_topLeftPin(NULL_ID),
m_bottomRightPin(NULL_ID)
{}
@ -54,22 +55,25 @@ public:
: QSharedData(data),
m_dLabelWidth(data.m_dLabelWidth),
m_dLabelHeight(data.m_dLabelHeight),
m_dLabelAngle(data.m_dLabelAngle),
m_iFontSize(data.m_iFontSize),
m_dRotation(data.m_dRotation),
m_centerPin(data.m_centerPin),
m_topLeftPin(data.m_topLeftPin),
m_bottomRightPin(data.m_bottomRightPin)
{}
~VPatternLabelDataPrivate();
/** @brief m_dLabelWidth label width */
qreal m_dLabelWidth;
/** @brief m_dLabelHeight label height */
qreal m_dLabelHeight;
/** @brief m_dLabelWidth formula to calculate the width of label */
QString m_dLabelWidth;
/** @brief m_dLabelHeight formula to calculate the height of label */
QString m_dLabelHeight;
/** @brief m_dLabelAngle formula to calculate the rotation angle of label */
QString m_dLabelAngle;
/** @brief m_iFontSize label text base font size */
int m_iFontSize;
/** @brief m_dRotation label rotation */
qreal m_dRotation;
/** @brief m_centerPin center pin id */
quint32 m_centerPin;
/** @brief m_topLeftPin top left corner pin id */
quint32 m_topLeftPin;
/** @brief m_bottomRightPin bottom right corner pin id */

File diff suppressed because it is too large Load Diff

View File

@ -94,14 +94,34 @@ private slots:
void PathDialogClosed(int result);
void TabChanged(int index);
void UpdateValues();
void UpdateGrainlineValues();
void UpdateDetailLabelValues();
void UpdatePatternLabelValues();
void SetAddMode();
void SetEditMode();
void EnableGrainlineRotation();
void EditFormula();
void DeployRotation();
void DeployLength();
void ResetWarning();
void EditGrainlineFormula();
void EditDLFormula();
void EditPLFormula();
void DeployGrainlineRotation();
void DeployGrainlineLength();
void DeployDLWidth();
void DeployDLHeight();
void DeployDLAngle();
void DeployPLWidth();
void DeployPLHeight();
void DeployPLAngle();
void ResetGrainlineWarning();
void ResetLabelsWarning();
void EnabledGrainline();
void EnabledDetailLabel();
void EnabledPatternLabel();
void EvalWidth();
void EvalWidthBefore();
@ -132,6 +152,10 @@ private:
bool flagDPin;
bool flagPPin;
bool flagGFormulas;
bool flagDLAngle;
bool flagDLFormulas;
bool flagPLAngle;
bool flagPLFormulas;
bool m_bAddMode;
qreal m_mx;
qreal m_my;
@ -149,6 +173,12 @@ private:
VGrainlineData m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
int m_DLWidthBaseHeight;
int m_DLHeightBaseHeight;
int m_DLAngleBaseHeight;
int m_PLWidthBaseHeight;
int m_PLHeightBaseHeight;
int m_PLAngleBaseHeight;
int m_formulaBaseWidth;
int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter;
@ -190,6 +220,7 @@ private:
void InitSAIncludeType();
void InitInternalPathsTab();
void InitPatternPieceDataTab();
void InitLabelsTab();
void InitGrainlineTab();
void InitPinsTab();
void InitAllPinComboboxes();
@ -198,8 +229,17 @@ private:
template <typename T>
QVector<T> GetPieceInternals(const QListWidget *list) const;
void SetGrainlineAngle(const VGrainlineData &data);
void SetGrainlineLength(const VGrainlineData &data);
void SetGrainlineAngle(QString angleFormula);
void SetGrainlineLength(QString lengthFormula);
void SetDLWidth(QString widthFormula);
void SetDLHeight(QString heightFormula);
void SetDLAngle(QString angleFormula);
void SetPLWidth(QString widthFormula);
void SetPLHeight(QString heightFormula);
void SetPLAngle(QString angleFormula);
};
#endif // DIALOGSEAMALLOWANCE_H

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@
#include <QMenu>
#include <QMessageBox>
// Current version of seam allowance tag nned for backward compatibility
// Current version of seam allowance tag need for backward compatibility
const quint8 VToolSeamAllowance::pieceVersion = 2;
const QString VToolSeamAllowance::TagCSA = QStringLiteral("csa");
@ -78,6 +78,7 @@ const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united");
const QString VToolSeamAllowance::AttrFont = QStringLiteral("fontSize");
const QString VToolSeamAllowance::AttrTopLeftPin = QStringLiteral("topLeftPin");
const QString VToolSeamAllowance::AttrBottomRightPin = QStringLiteral("bottomRightPin");
const QString VToolSeamAllowance::AttrCenterPin = QStringLiteral("centerPin");
const QString VToolSeamAllowance::AttrTopPin = QStringLiteral("topPin");
const QString VToolSeamAllowance::AttrBottomPin = QStringLiteral("bottomPin");
@ -257,6 +258,15 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
doc->SetAttribute(domData, AttrFont, data.GetFontSize());
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
if (data.CenterPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrCenterPin, data.CenterPin());
}
else
{
domData.removeAttribute(AttrCenterPin);
}
if (data.TopLeftPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrTopLeftPin, data.TopLeftPin());
@ -304,6 +314,15 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
doc->SetAttribute(domData, AttrFont, geom.GetFontSize());
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation());
if (geom.CenterPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrCenterPin, geom.CenterPin());
}
else
{
domData.removeAttribute(AttrCenterPin);
}
if (geom.TopLeftPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrTopLeftPin, geom.TopLeftPin());
@ -338,6 +357,15 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
if (glGeom.CenterPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrCenterPin, glGeom.CenterPin());
}
else
{
domData.removeAttribute(AttrCenterPin);
}
if (glGeom.TopPin() > NULL_ID)
{
doc->SetAttribute(domData, AttrTopPin, glGeom.TopPin());
@ -485,7 +513,14 @@ void VToolSeamAllowance::UpdateLabel()
QPointF pos;
qreal labelWidth = 0;
qreal labelHeight = 0;
const VTextGraphicsItem::MoveType type = FindLabelGeometry(labelData, labelWidth, labelHeight, pos);
qreal labelAngle = 0;
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(labelData, labelAngle, labelWidth, labelHeight,
pos);
if (type & VGrainlineItem::Error)
{
m_dataLabel->hide();
return;
}
m_dataLabel->SetMoveType(type);
QFont fnt = qApp->font();
@ -494,7 +529,8 @@ void VToolSeamAllowance::UpdateLabel()
iFS < MIN_FONT_SIZE ? fnt.setPixelSize(MIN_FONT_SIZE) : fnt.setPixelSize(iFS);
}
m_dataLabel->SetFont(fnt);
m_dataLabel->SetSize(labelWidth, labelHeight);
m_dataLabel->SetSize(ToPixel(labelWidth, *VDataTool::data.GetPatternUnit()),
ToPixel(labelHeight, *VDataTool::data.GetPatternUnit()));
m_dataLabel->UpdateData(detail.GetName(), labelData);
QRectF rectBB;
@ -503,14 +539,14 @@ void VToolSeamAllowance::UpdateLabel()
rectBB.setHeight(m_dataLabel->boundingRect().height());
qreal dX;
qreal dY;
if (m_dataLabel->IsContained(rectBB, labelData.GetRotation(), dX, dY) == false)
if (m_dataLabel->IsContained(rectBB, labelAngle, dX, dY) == false)
{
pos.setX(pos.x() + dX);
pos.setY(pos.y() + dY);
}
m_dataLabel->setPos(pos);
m_dataLabel->setRotation(labelData.GetRotation());
m_dataLabel->setRotation(-labelAngle);
m_dataLabel->Update();
m_dataLabel->show();
}
@ -534,7 +570,13 @@ void VToolSeamAllowance::UpdatePatternInfo()
QPointF pos;
qreal labelWidth = 0;
qreal labelHeight = 0;
const VTextGraphicsItem::MoveType type = FindLabelGeometry(geom, labelWidth, labelHeight, pos);
qreal labelAngle = 0;
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(geom, labelAngle, labelWidth, labelHeight, pos);
if (type & VGrainlineItem::Error)
{
m_dataLabel->hide();
return;
}
m_patternInfo->SetMoveType(type);
QFont fnt = qApp->font();
@ -545,7 +587,8 @@ void VToolSeamAllowance::UpdatePatternInfo()
}
fnt.setPixelSize(iFS);
m_patternInfo->SetFont(fnt);
m_patternInfo->SetSize(labelWidth, labelHeight);
m_patternInfo->SetSize(ToPixel(labelWidth, *VDataTool::data.GetPatternUnit()),
ToPixel(labelHeight, *VDataTool::data.GetPatternUnit()));
m_patternInfo->UpdateData(doc, getData()->size(), getData()->height());
QRectF rectBB;
@ -554,14 +597,14 @@ void VToolSeamAllowance::UpdatePatternInfo()
rectBB.setHeight(m_patternInfo->boundingRect().height());
qreal dX;
qreal dY;
if (m_patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false)
if (m_patternInfo->IsContained(rectBB, labelAngle, dX, dY) == false)
{
pos.setX(pos.x() + dX);
pos.setY(pos.y() + dY);
}
m_patternInfo->setPos(pos);
m_patternInfo->setRotation(geom.GetRotation());
m_patternInfo->setRotation(labelAngle);
m_patternInfo->Update();
m_patternInfo->GetTextLines() > 0 ? m_patternInfo->show() : m_patternInfo->hide();
}
@ -586,8 +629,8 @@ void VToolSeamAllowance::UpdateGrainline()
qreal dRotation = 0;
qreal dLength = 0;
const VGrainlineItem::MoveType type = FindGrainlineGeometry(geom, dLength, dRotation, pos);
if (type == VGrainlineItem::Error)
const VGrainlineItem::MoveTypes type = FindGrainlineGeometry(geom, dLength, dRotation, pos);
if (type & VGrainlineItem::Error)
{
m_grainLine->hide();
return;
@ -613,10 +656,6 @@ void VToolSeamAllowance::SaveMoveDetail(const QPointF& ptPos)
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternPieceData().SetPos(ptPos);
newDet.GetPatternPieceData().SetLabelWidth(m_dataLabel->boundingRect().width());
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
newDet.GetPatternPieceData().SetFontSize(m_dataLabel->GetFontSize());
newDet.GetPatternPieceData().SetRotation(m_dataLabel->rotation());
SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, id);
moveCommand->setText(tr("move pattern piece label"));
@ -632,10 +671,13 @@ void VToolSeamAllowance::SaveResizeDetail(qreal dLabelW, int iFontSize)
{
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternPieceData().SetLabelWidth(dLabelW);
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
dLabelW = FromPixel(dLabelW, *VDataTool::data.GetPatternUnit());
newDet.GetPatternPieceData().SetLabelWidth(QString().setNum(dLabelW));
const qreal height = FromPixel(m_dataLabel->boundingRect().height(), *VDataTool::data.GetPatternUnit());
newDet.GetPatternPieceData().SetLabelHeight(QString().setNum(height));
newDet.GetPatternPieceData().SetFontSize(iFontSize);
newDet.GetPatternPieceData().SetRotation(m_dataLabel->rotation());
SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, id);
resizeCommand->setText(tr("resize pattern piece label"));
connect(resizeCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
@ -651,10 +693,12 @@ void VToolSeamAllowance::SaveRotationDetail(qreal dRot)
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternPieceData().SetPos(m_dataLabel->pos());
newDet.GetPatternPieceData().SetLabelWidth(m_dataLabel->boundingRect().width());
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
newDet.GetPatternPieceData().SetFontSize(m_dataLabel->GetFontSize());
newDet.GetPatternPieceData().SetRotation(dRot);
// Tranform angle to anticlockwise
QLineF line(0, 0, 100, 0);
line.setAngle(-dRot);
newDet.GetPatternPieceData().SetRotation(QString().setNum(line.angle()));
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
rotateCommand->setText(tr("rotate pattern piece label"));
@ -672,10 +716,6 @@ void VToolSeamAllowance::SaveMovePattern(const QPointF &ptPos)
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternInfo().SetPos(ptPos);
newDet.GetPatternInfo().SetLabelWidth(m_patternInfo->boundingRect().width());
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
newDet.GetPatternInfo().SetFontSize(m_patternInfo->GetFontSize());
newDet.GetPatternInfo().SetRotation(m_patternInfo->rotation());
SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, id);
moveCommand->setText(tr("move pattern info label"));
@ -691,10 +731,13 @@ void VToolSeamAllowance::SaveResizePattern(qreal dLabelW, int iFontSize)
{
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternInfo().SetLabelWidth(dLabelW);
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
dLabelW = FromPixel(dLabelW, *VDataTool::data.GetPatternUnit());
newDet.GetPatternInfo().SetLabelWidth(QString().setNum(dLabelW));
qreal height = FromPixel(m_patternInfo->boundingRect().height(), *VDataTool::data.GetPatternUnit());
newDet.GetPatternInfo().SetLabelHeight(QString().setNum(height));
newDet.GetPatternInfo().SetFontSize(iFontSize);
newDet.GetPatternInfo().SetRotation(m_patternInfo->rotation());
SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, id);
resizeCommand->setText(tr("resize pattern info label"));
connect(resizeCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
@ -706,11 +749,14 @@ void VToolSeamAllowance::SaveRotationPattern(qreal dRot)
{
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
newDet.GetPatternInfo().SetPos(m_patternInfo->pos());
newDet.GetPatternInfo().SetLabelWidth(m_patternInfo->boundingRect().width());
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
newDet.GetPatternInfo().SetFontSize(m_patternInfo->GetFontSize());
newDet.GetPatternInfo().SetRotation(dRot);
// Tranform angle to anticlockwise
QLineF line(0, 0, 100, 0);
line.setAngle(-dRot);
newDet.GetPatternInfo().SetRotation(QString().setNum(line.angle()));
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
rotateCommand->setText(tr("rotate pattern info label"));
@ -740,6 +786,7 @@ void VToolSeamAllowance::SaveResizeGrainline(qreal dLength)
VPiece newDet = oldDet;
dLength = FromPixel(dLength, *VDataTool::data.GetPatternUnit());
newDet.GetGrainlineGeometry().SetPos(m_grainLine->pos());
newDet.GetGrainlineGeometry().SetLength(QString().setNum(dLength));
SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, id);
resizeCommand->setText(tr("resize grainline"));
@ -753,8 +800,7 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos)
VPiece oldDet = VAbstractTool::data.GetPiece(id);
VPiece newDet = oldDet;
dRot = qRadiansToDegrees(dRot);
newDet.GetGrainlineGeometry().SetRotation(QString().setNum(dRot));
newDet.GetGrainlineGeometry().SetRotation(QString().setNum(qRadiansToDegrees(dRot)));
newDet.GetGrainlineGeometry().SetPos(ptPos);
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
rotateCommand->setText(tr("rotate grainline"));
@ -1157,9 +1203,27 @@ void VToolSeamAllowance::SaveDialogChange()
}
//---------------------------------------------------------------------------------------------------------------------
VPieceItem::MoveType VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &labelWidth,
qreal &labelHeight, QPointF &pos)
VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &rotationAngle,
qreal &labelWidth, qreal &labelHeight, QPointF &pos)
{
VPieceItem::MoveTypes restrictions = VPieceItem::AllModifications;
try
{
if (not qmu::QmuTokenParser::IsSingle(labelData.GetRotation()))
{
restrictions &= ~ VPieceItem::IsRotatable;
}
Calculator cal1;
rotationAngle = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetRotation());
}
catch(qmu::QmuParserError &e)
{
Q_UNUSED(e);
return VPieceItem::Error;
}
const quint32 topLeftPin = labelData.TopLeftPin();
const quint32 bottomRightPin = labelData.BottomRightPin();
@ -1171,12 +1235,15 @@ VPieceItem::MoveType VToolSeamAllowance::FindLabelGeometry(const VPatternLabelDa
const auto bottomRightPinPoint = VAbstractTool::data.GeometricObject<VPointF>(bottomRightPin);
const QRectF labelRect = QRectF(*topLeftPinPoint, *bottomRightPinPoint);
labelWidth = qAbs(labelRect.width());
labelHeight = qAbs(labelRect.height());
labelWidth = FromPixel(qAbs(labelRect.width()), *VDataTool::data.GetPatternUnit());
labelHeight = FromPixel(qAbs(labelRect.height()), *VDataTool::data.GetPatternUnit());
pos = labelRect.topLeft();
return VTextGraphicsItem::OnlyRotatable;
restrictions &= ~ VPieceItem::IsMovable;
restrictions &= ~ VPieceItem::IsResizable;
return restrictions;
}
catch(const VExceptionBadId &)
{
@ -1184,14 +1251,57 @@ VPieceItem::MoveType VToolSeamAllowance::FindLabelGeometry(const VPatternLabelDa
}
}
labelWidth = labelData.GetLabelWidth();
labelHeight = labelData.GetLabelHeight();
pos = labelData.GetPos();
return VTextGraphicsItem::AllModifications;
try
{
const bool widthIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelWidth());
Calculator cal1;
labelWidth = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelWidth());
const bool heightIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelHeight());
Calculator cal2;
labelHeight = cal2.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelHeight());
if (not widthIsSingle || not heightIsSingle)
{
restrictions &= ~ VPieceItem::IsResizable;
}
}
catch(qmu::QmuParserError &e)
{
Q_UNUSED(e);
return VPieceItem::Error;
}
const quint32 centerPin = labelData.CenterPin();
if (centerPin != NULL_ID)
{
try
{
const auto centerPinPoint = VAbstractTool::data.GeometricObject<VPointF>(centerPin);
const qreal lWidth = ToPixel(labelWidth, *VDataTool::data.GetPatternUnit());
const qreal lHeight = ToPixel(labelHeight, *VDataTool::data.GetPatternUnit());
pos = *centerPinPoint - QRectF(0, 0, lWidth, lHeight).center();
restrictions &= ~ VPieceItem::IsMovable;
}
catch(const VExceptionBadId &)
{
pos = labelData.GetPos();
}
}
else
{
pos = labelData.GetPos();
}
return restrictions;
}
//---------------------------------------------------------------------------------------------------------------------
VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineData& geom, qreal &length,
VPieceItem::MoveTypes VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineData& geom, qreal &length,
qreal &rotationAngle, QPointF &pos)
{
const quint32 topPin = geom.TopPin();
@ -1223,16 +1333,21 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD
}
}
bool isResizable = false;
bool isRotatable = false;
VPieceItem::MoveTypes restrictions = VPieceItem::AllModifications;
try
{
isRotatable = qmu::QmuTokenParser::IsSingle(geom.GetRotation());
if (not qmu::QmuTokenParser::IsSingle(geom.GetRotation()))
{
restrictions &= ~ VPieceItem::IsRotatable;
}
Calculator cal1;
rotationAngle = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), geom.GetRotation());
isResizable = qmu::QmuTokenParser::IsSingle(geom.GetLength());
if (not qmu::QmuTokenParser::IsSingle(geom.GetLength()))
{
restrictions &= ~ VPieceItem::IsResizable;
}
Calculator cal2;
length = cal2.EvalFormula(VAbstractTool::data.PlainVariables(), geom.GetLength());
@ -1243,25 +1358,35 @@ VPieceItem::MoveType VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineD
return VPieceItem::Error;
}
pos = geom.GetPos();
if (isResizable && isRotatable)
const quint32 centerPin = geom.CenterPin();
if (centerPin != NULL_ID)
{
return VPieceItem::AllModifications;
try
{
const auto centerPinPoint = VAbstractTool::data.GeometricObject<VPointF>(centerPin);
const qreal cLength = ToPixel(length, *VDataTool::data.GetPatternUnit());
QLineF grainline(centerPinPoint->x(), centerPinPoint->y(),
centerPinPoint->x() + cLength / 2.0, centerPinPoint->y());
grainline.setAngle(rotationAngle);
grainline = QLineF(grainline.p2(), grainline.p1());
grainline.setLength(cLength);
pos = grainline.p2();
restrictions &= ~ VPieceItem::IsMovable;
}
catch(const VExceptionBadId &)
{
pos = geom.GetPos();
}
}
else
{
if (isResizable)
{
return VPieceItem::OnlyResizable;
}
if (isRotatable)
{
return VPieceItem::OnlyRotatable;
}
pos = geom.GetPos();
}
return VPieceItem::OnlyMovable;
return restrictions;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -68,6 +68,7 @@ public:
static const QString AttrFont;
static const QString AttrTopLeftPin;
static const QString AttrBottomRightPin;
static const QString AttrCenterPin;
static const QString AttrTopPin;
static const QString AttrBottomPin;
@ -151,10 +152,10 @@ private:
void RefreshGeometry();
void SaveDialogChange();
VPieceItem::MoveType FindLabelGeometry(const VPatternLabelData &labelData, qreal &labelWidth, qreal &labelHeight,
QPointF &pos);
VPieceItem::MoveType FindGrainlineGeometry(const VGrainlineData &geom, qreal &length, qreal &rotationAngle,
QPointF &pos);
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
qreal &labelHeight, QPointF &pos);
VPieceItem::MoveTypes FindGrainlineGeometry(const VGrainlineData &geom, qreal &length, qreal &rotationAngle,
QPointF &pos);
void InitNodes(const VPiece &detail, VMainGraphicsScene *scene);
void InitCSAPaths(const VPiece &detail);

View File

@ -145,6 +145,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
if (m_eMode != mRotate)
{
pP->setBrush(clr);
UpdatePolyResize();
pP->drawPolygon(m_polyResize);
}
@ -292,51 +293,66 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
m_dAngle = GetAngle(mapToParent(pME->pos()));
m_ptRotCenter = m_ptCenter;
if (m_moveType == OnlyRotatable)
if ((m_moveType & AllModifications ) == AllModifications)
{
if (m_eMode != mRotate)
AllUserModifications(pME->pos());
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsRotatable)
{
if (m_moveType & IsResizable)
{
AllUserModifications(pME->pos());
}
else if (m_moveType & IsMovable)
{
UserRotateAndMove();
}
else
{
m_eMode = mRotate;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsResizable)
{
if (m_moveType & IsRotatable)
{
AllUserModifications(pME->pos());
}
else if (m_moveType & IsMovable)
{
UserMoveAndResize(pME->pos());
}
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsMovable)
{
if (m_moveType & IsRotatable)
{
UserRotateAndMove();
}
else if (m_moveType & IsResizable)
{
UserMoveAndResize(pME->pos());
}
else
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
else
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType == OnlyMovable)
else
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
setZValue(ACTIVE_Z);
Update();
}
else // All modifications
{
if (m_eMode != mRotate)
{
if (m_polyResize.containsPoint(pME->pos(), Qt::OddEvenFill) == true)
{
m_eMode = mResize;
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
else
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
setZValue(ACTIVE_Z);
Update();
pME->ignore();
return;
}
}
}
@ -351,7 +367,7 @@ void VGrainlineItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
QPointF ptDiff = pME->scenePos() - m_ptStartMove;
qreal dX;
qreal dY;
if (m_eMode == mMove)
if (m_eMode == mMove && m_moveType & IsMovable)
{
QPointF pt = m_ptStartPos + ptDiff;
if (IsContained(pt, m_dRotation, dX, dY) == false)
@ -362,24 +378,57 @@ void VGrainlineItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
setPos(pt);
Update();
}
else if (m_eMode == mResize)
else if (m_eMode == mResize && m_moveType & IsResizable)
{
qreal dLen = qSqrt(ptDiff.x()*ptDiff.x() + ptDiff.y()*ptDiff.y());
qreal dAng = qAtan2(-ptDiff.y(), ptDiff.x());
dLen = dLen*qCos(dAng - m_dRotation);
dLen = -dLen*qCos(dAng - m_dRotation);
qreal dPrevLen = m_dLength;
// try with new length
if (not (m_moveType & IsMovable))
{
dLen *= 2;
}
m_dLength = m_dStartLength + dLen;
QPointF pos;
if (m_moveType & IsMovable)
{
QLineF grainline(this->pos().x(), this->pos().y(),
this->pos().x() + dPrevLen, this->pos().y());
grainline.setAngle(qRadiansToDegrees(m_dRotation));
grainline = QLineF(grainline.p2(), grainline.p1());
grainline.setLength(m_dLength);
pos = grainline.p2();
}
else
{
QLineF grainline(m_ptCenter.x(), m_ptCenter.y(),
m_ptCenter.x() + m_dLength / 2.0, m_ptCenter.y());
grainline.setAngle(qRadiansToDegrees(m_dRotation));
grainline = QLineF(grainline.p2(), grainline.p1());
grainline.setLength(m_dLength);
pos = grainline.p2();
}
qreal dX;
qreal dY;
if (IsContained(m_ptStartPos, m_dRotation, dX, dY) == false)
if (IsContained(pos, m_dRotation, dX, dY) == false)
{
m_dLength = dPrevLen;
}
else
{
setPos(pos);
}
UpdateRectangle();
Update();
}
else if (m_eMode == mRotate)
else if (m_eMode == mRotate && m_moveType & IsRotatable)
{
// prevent strange angle changes due to singularities
qreal dLen = qSqrt(ptDiff.x()*ptDiff.x() + ptDiff.y()*ptDiff.y());
@ -433,7 +482,7 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
{
if (bShort == true)
{
if (m_bReleased == true && m_moveType != OnlyResizable && m_moveType != OnlyMovable)
if (m_bReleased == true && m_moveType & IsRotatable)
{
m_eMode = mRotate;
Update();
@ -441,11 +490,11 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
}
else
{
if (m_eMode == mMove)
if (m_eMode == mMove && m_moveType & IsMovable)
{
emit SignalMoved(pos());
}
else
else if (m_moveType & IsResizable)
{
emit SignalResized(m_dLength);
}
@ -458,7 +507,7 @@ void VGrainlineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
{
m_eMode = mMove;
}
else
else if (m_moveType & IsRotatable)
{
emit SignalRotated(m_dRotation, m_ptStart);
}
@ -498,50 +547,26 @@ void VGrainlineItem::Update()
*/
void VGrainlineItem::UpdateRectangle()
{
m_polyBound.clear();
QPointF pt1(0, 0);
QPointF pt2;
pt2.setX(pt1.x() + m_dLength * cos(m_dRotation));
pt2.setY(pt1.y() - m_dLength * sin(m_dRotation));
QPointF pt2(pt1.x() + m_dLength * cos(m_dRotation), pt1.y() - m_dLength * sin(m_dRotation));
m_ptStart = mapToParent(pt1);
m_ptFinish = mapToParent(pt2);
m_ptCenter = (m_ptStart + m_ptFinish)/2;
QPointF ptA;
ptA.setX(pt1.x() + RECT_WIDTH*cos(m_dRotation + M_PI/2));
ptA.setY(pt1.y() - RECT_WIDTH*sin(m_dRotation + M_PI/2));
m_polyBound << ptA;
ptA.setX(pt1.x() + RECT_WIDTH*cos(m_dRotation - M_PI/2));
ptA.setY(pt1.y() - RECT_WIDTH*sin(m_dRotation - M_PI/2));
m_polyBound << ptA;
ptA.setX(pt2.x() + RECT_WIDTH*cos(m_dRotation - M_PI/2));
ptA.setY(pt2.y() - RECT_WIDTH*sin(m_dRotation - M_PI/2));
m_polyBound << ptA;
ptA.setX(pt2.x() + RECT_WIDTH*cos(m_dRotation + M_PI/2));
ptA.setY(pt2.y() - RECT_WIDTH*sin(m_dRotation + M_PI/2));
m_polyBound << ptA;
m_polyBound.clear();
m_polyBound << QPointF(pt1.x() + RECT_WIDTH*cos(m_dRotation + M_PI/2),
pt1.y() - RECT_WIDTH*sin(m_dRotation + M_PI/2));
m_polyBound << QPointF(pt1.x() + RECT_WIDTH*cos(m_dRotation - M_PI/2),
pt1.y() - RECT_WIDTH*sin(m_dRotation - M_PI/2));
m_polyBound << QPointF(pt2.x() + RECT_WIDTH*cos(m_dRotation - M_PI/2),
pt2.y() - RECT_WIDTH*sin(m_dRotation - M_PI/2));
m_polyBound << QPointF(pt2.x() + RECT_WIDTH*cos(m_dRotation + M_PI/2),
pt2.y() - RECT_WIDTH*sin(m_dRotation + M_PI/2));
m_rectBoundingBox = m_polyBound.boundingRect();
setTransformOriginPoint(m_rectBoundingBox.center());
m_polyResize.clear();
ptA = m_polyBound.at(2);
m_polyResize << ptA;
double dSize = m_dScale * RESIZE_RECT_SIZE;
ptA.setX(ptA.x() + dSize*cos(m_dRotation + M_PI/2));
ptA.setY(ptA.y() - dSize*sin(m_dRotation + M_PI/2));
m_polyResize << ptA;
ptA.setX(ptA.x() - dSize*cos(m_dRotation));
ptA.setY(ptA.y() + dSize*sin(m_dRotation));
m_polyResize << ptA;
ptA.setX(ptA.x() + dSize*cos(m_dRotation - M_PI/2));
ptA.setY(ptA.y() - dSize*sin(m_dRotation - M_PI/2));
m_polyResize << ptA;
UpdatePolyResize();
prepareGeometryChange();
}
@ -628,19 +653,6 @@ QLineF VGrainlineItem::MainLine() const
//---------------------------------------------------------------------------------------------------------------------
QPolygonF VGrainlineItem::FirstArrow(qreal dArrLen) const
{
const QPointF pt1 = MainLine().p1();
QPolygonF poly;
poly << pt1;
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation + ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation + ARROW_ANGLE));
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation - ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation - ARROW_ANGLE));
return poly;
}
//---------------------------------------------------------------------------------------------------------------------
QPolygonF VGrainlineItem::SecondArrow(qreal dArrLen) const
{
const QPointF pt2 = MainLine().p2();
QPolygonF poly;
@ -652,6 +664,19 @@ QPolygonF VGrainlineItem::SecondArrow(qreal dArrLen) const
return poly;
}
//---------------------------------------------------------------------------------------------------------------------
QPolygonF VGrainlineItem::SecondArrow(qreal dArrLen) const
{
const QPointF pt1 = MainLine().p1();
QPolygonF poly;
poly << pt1;
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation + ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation + ARROW_ANGLE));
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation - ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation - ARROW_ANGLE));
return poly;
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VGrainlineItem::MainShape() const
{
@ -687,3 +712,62 @@ QPainterPath VGrainlineItem::MainShape() const
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineItem::AllUserModifications(const QPointF &pos)
{
if (m_eMode != mRotate)
{
UserMoveAndResize(pos);
}
else
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineItem::UserRotateAndMove()
{
if (m_eMode != mRotate)
{
m_eMode = mMove;
}
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineItem::UserMoveAndResize(const QPointF &pos)
{
if (m_polyResize.containsPoint(pos, Qt::OddEvenFill) == true)
{
m_eMode = mResize;
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{
m_eMode = mMove; // block later if need
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineItem::UpdatePolyResize()
{
m_polyResize.clear();
QPointF ptA = m_polyBound.at(1);
m_polyResize << ptA;
const double dSize = m_dScale * RESIZE_RECT_SIZE;
ptA.setX(ptA.x() - dSize*cos(m_dRotation - M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation - M_PI/2));
m_polyResize << ptA;
ptA.setX(ptA.x() + dSize*cos(m_dRotation));
ptA.setY(ptA.y() - dSize*sin(m_dRotation));
m_polyResize << ptA;
ptA.setX(ptA.x() - dSize*cos(m_dRotation + M_PI/2));
ptA.setY(ptA.y() + dSize*sin(m_dRotation + M_PI/2));
m_polyResize << ptA;
}

View File

@ -89,6 +89,12 @@ private:
QPolygonF SecondArrow(qreal dArrLen) const;
QPainterPath MainShape() const;
void AllUserModifications(const QPointF &pos);
void UserRotateAndMove();
void UserMoveAndResize(const QPointF &pos);
void UpdatePolyResize();
};
#endif // VGRAINLINEITEM_H

View File

@ -108,13 +108,13 @@ double VPieceItem::GetAngle(const QPointF &pt) const
}
//---------------------------------------------------------------------------------------------------------------------
VPieceItem::MoveType VPieceItem::GetMoveType() const
VPieceItem::MoveTypes VPieceItem::GetMoveType() const
{
return m_moveType;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceItem::SetMoveType(const MoveType &moveType)
void VPieceItem::SetMoveType(const VPieceItem::MoveTypes &moveType)
{
m_moveType = moveType;
setAcceptHoverEvents(m_moveType != NotMovable);

View File

@ -36,7 +36,16 @@ class VPieceItem : public QGraphicsObject
{
Q_OBJECT
public:
enum MoveType {AllModifications, OnlyResizable, OnlyRotatable, OnlyMovable, NotMovable, Error};
enum MoveType
{
NotMovable = 0x0,
IsRotatable = 0x1, // 0001
IsResizable = 0x2, // 0010
IsMovable = 0x4, // 0100
AllModifications = IsRotatable | IsResizable | IsMovable,
Error = 0x8 // 1000
};
Q_DECLARE_FLAGS(MoveTypes, MoveType)
explicit VPieceItem(QGraphicsItem* pParent = nullptr);
virtual ~VPieceItem();
@ -48,8 +57,8 @@ public:
void Reset();
bool IsIdle() const;
MoveType GetMoveType() const;
void SetMoveType(const MoveType &moveType);
VPieceItem::MoveTypes GetMoveType() const;
void SetMoveType(const VPieceItem::MoveTypes &moveType);
signals:
void SignalMoved(const QPointF &ptPos);
@ -62,11 +71,11 @@ protected:
mResize,
mRotate
};
QRectF m_rectBoundingBox;
Mode m_eMode;
bool m_bReleased;
QPointF m_ptRotCenter;
MoveType m_moveType;
QRectF m_rectBoundingBox;
Mode m_eMode;
bool m_bReleased;
QPointF m_ptRotCenter;
VPieceItem::MoveTypes m_moveType;
qreal m_inactiveZ;
@ -76,4 +85,6 @@ private:
Q_DISABLE_COPY(VPieceItem)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(VPieceItem::MoveTypes)
#endif // VPIECEITEM_H

View File

@ -403,6 +403,12 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
{
if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (m_moveType == NotMovable)
{
pME->ignore();
return;
}
// record the parameters of the mouse press. Specially record the position
// of the press as the origin for the following operations
m_ptStartPos = pos();
@ -414,45 +420,66 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
// in rotation mode, do not do any changes here, because user might want to
// rotate the label more.
if (m_moveType == OnlyRotatable)
if ((m_moveType & AllModifications ) == AllModifications)
{
if (m_eMode != mRotate)
AllUserModifications(pME->pos());
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsRotatable)
{
if (m_moveType & IsResizable)
{
AllUserModifications(pME->pos());
}
else if (m_moveType & IsMovable)
{
UserRotateAndMove();
}
else
{
m_eMode = mRotate;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsResizable)
{
if (m_moveType & IsRotatable)
{
AllUserModifications(pME->pos());
}
else if (m_moveType & IsMovable)
{
UserMoveAndResize(pME->pos());
}
setZValue(ACTIVE_Z);
Update();
}
else if (m_moveType & IsMovable)
{
if (m_moveType & IsRotatable)
{
UserRotateAndMove();
}
else if (m_moveType & IsResizable)
{
UserMoveAndResize(pME->pos());
}
else
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
setZValue(ACTIVE_Z);
Update();
}
else // All modifications
else
{
if (m_eMode != mRotate)
{
// if user pressed the button inside the resize square, switch to resize mode
if (m_rectResize.contains(pME->pos()) == true)
{
m_eMode = mResize;
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{
// if user pressed the button outside the resize square, switch to move mode
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
else
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
// raise the label and redraw it
setZValue(ACTIVE_Z);
UpdateBox();
pME->ignore();
return;
}
}
}
@ -468,7 +495,7 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
qreal dY;
QRectF rectBB;
const QPointF ptDiff = pME->scenePos() - m_ptStart;
if (m_eMode == mMove)
if (m_eMode == mMove && m_moveType & IsMovable)
{
// in move mode move the label along the mouse move from the origin
QPointF pt = m_ptStartPos + ptDiff;
@ -484,10 +511,21 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
setPos(pt);
UpdateBox();
}
else if (m_eMode == mResize)
else if (m_eMode == mResize && m_moveType & IsResizable)
{
// in resize mode, resize the label along the mouse move from the origin
QPointF pt = m_ptStartPos;
QPointF pt;
if (m_moveType & IsMovable)
{
pt = m_ptStartPos;
}
else
{
pt = m_ptRotCenter - QRectF(0, 0, m_szStart.width() + ptDiff.x(),
m_szStart.height() + ptDiff.y()).center();
}
rectBB.setTopLeft(pt);
QSizeF sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
rectBB.setSize(sz);
@ -496,12 +534,19 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
{
sz = QSizeF(sz.width()+dX, sz.height()+dY);
}
else
{
if (not (m_moveType & IsMovable))
{
setPos(pt);
}
}
SetSize(sz.width(), sz.height());
Update();
emit SignalShrink();
}
else if (m_eMode == mRotate)
else if (m_eMode == mRotate && m_moveType & IsRotatable)
{
// if the angle from the original position is small (0.5 degrees), just remeber the new angle
// new angle will be the starting angle for rotation
@ -551,18 +596,18 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
// but if user did some operation (move/resize), emit the proper signal and update the label
if (bShort == true)
{
if (m_bReleased == true)
if (m_bReleased == true && m_moveType & IsRotatable)
{
m_eMode = mRotate;
UpdateBox();
}
}
else if (m_eMode == mMove)
else if (m_eMode == mMove && m_moveType & IsMovable)
{
emit SignalMoved(pos());
UpdateBox();
}
else
else if (m_moveType & IsResizable)
{
emit SignalResized(m_rectBoundingBox.width(), m_tm.GetFont().pixelSize());
Update();
@ -570,20 +615,16 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
}
else
{ // in rotate mode, if user did just press/release, switch to move mode
if (bShort == true)
if (bShort == true && (m_moveType & IsMovable || m_moveType & IsResizable))
{
if (m_moveType != OnlyRotatable)
{
m_eMode = mMove;
}
UpdateBox();
m_eMode = mMove;
}
else
else if (m_moveType & IsRotatable)
{
// if user rotated the item, emit proper signal and update the label
emit SignalRotated(rotation());
UpdateBox();
}
UpdateBox();
}
m_bReleased = true;
}
@ -596,7 +637,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
*/
void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE)
{
if (m_eMode == mMove || m_eMode == mResize)
if (m_eMode == mResize && m_moveType & IsResizable)
{
if (m_rectResize.contains(pHE->pos()) == true)
{
@ -649,3 +690,41 @@ void VTextGraphicsItem::CorrectLabel()
m_tm.FitFontSize(m_rectBoundingBox.width(), m_rectBoundingBox.height());
UpdateBox();
}
//---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::AllUserModifications(const QPointF &pos)
{
if (m_eMode != mRotate)
{
UserMoveAndResize(pos);
}
else
{
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::UserRotateAndMove()
{
if (m_eMode != mRotate)
{
m_eMode = mMove;
}
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
//---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::UserMoveAndResize(const QPointF &pos)
{
if (m_rectResize.contains(pos) == true)
{
m_eMode = mResize;
SetOverrideCursor(Qt::SizeFDiagCursor);
}
else
{
m_eMode = mMove; // block later if need
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}

View File

@ -92,6 +92,10 @@ private:
double m_dAngle;
QRectF m_rectResize;
VTextManager m_tm;
void AllUserModifications(const QPointF &pos);
void UserRotateAndMove();
void UserMoveAndResize(const QPointF &pos);
};
#endif // VTEXTGRAPHICSITEM_H