New grainline type: Four way.

This commit is contained in:
Roman Telezhynskyi 2023-04-07 10:05:29 +03:00
parent 9cd31f1dd7
commit 857e384221
17 changed files with 722 additions and 34 deletions

View File

@ -21,6 +21,7 @@
- Fix compatibility with Richpeace DXF-AAMA/ASTM R12. - Fix compatibility with Richpeace DXF-AAMA/ASTM R12.
- Fix seam allowance. Loose requirements to case with prong. - Fix seam allowance. Loose requirements to case with prong.
- Fix list of dimension popup list. Make sure it will always has enough space for values. - Fix list of dimension popup list. Make sure it will always has enough space for values.
- New grainline type: Four way.
# Valentina 0.7.52 September 12, 2022 # Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru. - Fix crash when default locale is ru.

View File

@ -270,7 +270,7 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin)
{ {
degrees = DegreesAtRear(); degrees = DegreesAtRear();
} }
else else if (type == GrainlineArrowDirection::atBoth)
{ {
const qreal atFront = DegreesAtFront(); const qreal atFront = DegreesAtFront();
if (atFront <= 90 || atFront >= 270) if (atFront <= 90 || atFront >= 270)
@ -282,6 +282,22 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin)
degrees = DegreesAtRear(); degrees = DegreesAtRear();
} }
} }
else
{
const qreal atFront = DegreesAtFront();
if (atFront <= 45)
{
degrees = atFront;
}
else if (atFront > 45 && atFront < 90)
{
degrees = atFront - 90;
}
else
{
degrees = atFront - 90 * qFloor(atFront / 90);
}
}
if (origin.custom) if (origin.custom)
{ {

View File

@ -113,7 +113,8 @@ auto StringToGrainlineArrowDirrection(const QString &dirrection) -> GrainlineArr
{ {
ML::atFrontStr, // 0 ML::atFrontStr, // 0
ML::atRearStr, // 1 ML::atRearStr, // 1
ML::atBothStr // 2 ML::atFourWayStr, // 2
ML::atBothStr // 3
}; };
GrainlineArrowDirection arrowDirection = GrainlineArrowDirection::atBoth; GrainlineArrowDirection arrowDirection = GrainlineArrowDirection::atBoth;
@ -125,7 +126,10 @@ auto StringToGrainlineArrowDirrection(const QString &dirrection) -> GrainlineArr
case 1:// at rear case 1:// at rear
arrowDirection = GrainlineArrowDirection::atRear; arrowDirection = GrainlineArrowDirection::atRear;
break; break;
case 2:// at both case 2:// at four way
arrowDirection = GrainlineArrowDirection::atFourWay;
break;
case 3:// at both
default: default:
arrowDirection = GrainlineArrowDirection::atBoth; arrowDirection = GrainlineArrowDirection::atBoth;
break; break;

View File

@ -121,6 +121,8 @@ auto GrainlineArrowDirrectionToString(GrainlineArrowDirection type) -> QString
return ML::atFrontStr; return ML::atFrontStr;
case GrainlineArrowDirection::atRear: case GrainlineArrowDirection::atRear:
return ML::atRearStr; return ML::atRearStr;
case GrainlineArrowDirection::atFourWay:
return ML::atFourWayStr;
case GrainlineArrowDirection::atBoth: case GrainlineArrowDirection::atBoth:
default: default:
return ML::atBothStr; return ML::atBothStr;

View File

@ -117,6 +117,7 @@ const QString AttrCurvePoint = QStringLiteral("curvePoint"); // NOLINT
const QString atFrontStr = QStringLiteral("atFront"); // NOLINT(cert-err58-cpp) const QString atFrontStr = QStringLiteral("atFront"); // NOLINT(cert-err58-cpp)
const QString atRearStr = QStringLiteral("atRear"); // NOLINT(cert-err58-cpp) const QString atRearStr = QStringLiteral("atRear"); // NOLINT(cert-err58-cpp)
const QString atFourWayStr = QStringLiteral("atFourWay"); // NOLINT(cert-err58-cpp)
const QString atBothStr = QStringLiteral("atBoth"); // NOLINT(cert-err58-cpp) const QString atBothStr = QStringLiteral("atBoth"); // NOLINT(cert-err58-cpp)
const QChar groupSep = QLatin1Char(';'); const QChar groupSep = QLatin1Char(';');

View File

@ -122,6 +122,7 @@ extern const QString AttrCurvePoint;
extern const QString atFrontStr; extern const QString atFrontStr;
extern const QString atRearStr; extern const QString atRearStr;
extern const QString atFourWayStr;
extern const QString atBothStr; extern const QString atBothStr;
extern const QChar groupSep; extern const QChar groupSep;

View File

@ -95,5 +95,6 @@
<file>schema/layout/v0.1.1.xsd</file> <file>schema/layout/v0.1.1.xsd</file>
<file>schema/layout/v0.1.2.xsd</file> <file>schema/layout/v0.1.2.xsd</file>
<file>schema/layout/v0.1.3.xsd</file> <file>schema/layout/v0.1.3.xsd</file>
<file>schema/layout/v0.1.4.xsd</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,568 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="layout">
<xs:complexType>
<xs:sequence>
<xs:element name="properties">
<xs:complexType>
<xs:sequence>
<xs:element type="units" name="unit"/>
<xs:element type="xs:string" name="title"/>
<xs:element type="xs:string" name="description"/>
<xs:element name="control">
<xs:complexType>
<xs:attribute type="xs:boolean" name="warningSuperposition"/>
<xs:attribute type="xs:boolean" name="warningOutOfBound"/>
<xs:attribute type="xs:boolean" name="stickyEdges"/>
<xs:attribute type="xs:boolean" name="followGrainline"/>
<xs:attribute type="xs:float" name="piecesGap"/>
</xs:complexType>
</xs:element>
<xs:element name="tiles">
<xs:complexType>
<xs:sequence>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
<xs:attribute type="xs:boolean" name="ignoreMargins"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:boolean" name="visible"/>
<xs:attribute type="xs:string" name="matchingMarks"/>
<xs:attribute type="xs:boolean" name="printScheme"/>
<xs:attribute type="xs:boolean" name="tileNumber"/>
</xs:complexType>
</xs:element>
<xs:element name="scale">
<xs:complexType>
<xs:attribute type="LayoutScale" name="xScale"/>
<xs:attribute type="LayoutScale" name="yScale"/>
</xs:complexType>
</xs:element>
<xs:element name="watermark">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="showPreview" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="unplacedPieces">
<xs:complexType>
<xs:sequence>
<xs:element name="piece" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="seamLine">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="3" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="seamAllowance">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="grainline">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:float" name="angle" use="optional"/>
<xs:attribute type="ArrowDirection" name="arrowDirection" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="notches">
<xs:complexType>
<xs:sequence>
<xs:element name="notch" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="internalPaths">
<xs:complexType>
<xs:sequence>
<xs:element name="internalPath" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="2" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:boolean" name="cut" use="optional"/>
<xs:attribute type="CurvePenStyle" name="penStyle" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="markers">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="marker" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="Transformation" name="transform" use="required"/>
<xs:attribute type="MarkerType" name="type" use="required"/>
<xs:attribute type="PointPath" name="center" use="required"/>
<xs:attribute type="RectPath" name="box" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="labels">
<xs:complexType>
<xs:sequence>
<xs:element name="pieceLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="shape" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="shape" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="uid" type="uuid" use="required"/>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="mirrored"/>
<xs:attribute type="xs:boolean" name="forbidFlipping"/>
<xs:attribute type="xs:boolean" name="forceFlipping"/>
<xs:attribute type="xs:boolean" name="sewLineOnDrawing"/>
<xs:attribute type="Transformation" name="transform"/>
<xs:attribute type="xs:string" name="gradationLabel"/>
<xs:attribute type="xs:unsignedInt" name="copyNumber"/>
<xs:attribute type="xs:boolean" name="showSeamline"/>
<xs:attribute type="xs:float" name="xScale"/>
<xs:attribute type="xs:float" name="yScale"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sheets">
<xs:complexType>
<xs:sequence>
<xs:element name="sheet" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
<xs:attribute type="xs:boolean" name="ignoreMargins"/>
</xs:complexType>
</xs:element>
<xs:element name="pieces">
<xs:complexType>
<xs:sequence>
<xs:element name="piece" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="seamLine">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="3" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="seamAllowance">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="grainline">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:float" name="angle" use="optional"/>
<xs:attribute type="ArrowDirection" name="arrowDirection" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="notches">
<xs:complexType>
<xs:sequence>
<xs:element name="notch" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="internalPaths">
<xs:complexType>
<xs:sequence>
<xs:element name="internalPath" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="point" minOccurs="2" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:double" name="x" use="required"/>
<xs:attribute type="xs:double" name="y" use="required"/>
<xs:attribute type="xs:boolean" name="turnPoint" use="optional"/>
<xs:attribute type="xs:boolean" name="curvePoint" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:boolean" name="cut" use="optional"/>
<xs:attribute type="CurvePenStyle" name="penStyle" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="markers">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="marker" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute type="Transformation" name="transform" use="required"/>
<xs:attribute type="MarkerType" name="type" use="required"/>
<xs:attribute type="PointPath" name="center" use="required"/>
<xs:attribute type="RectPath" name="box" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="labels">
<xs:complexType>
<xs:sequence>
<xs:element name="pieceLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="PathNotEmpty" name="shape" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="PathNotEmpty" name="shape" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="uid" type="uuid" use="required"/>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="mirrored"/>
<xs:attribute type="xs:boolean" name="forbidFlipping"/>
<xs:attribute type="xs:boolean" name="forceFlipping"/>
<xs:attribute type="xs:boolean" name="sewLineOnDrawing"/>
<xs:attribute type="Transformation" name="transform"/>
<xs:attribute type="xs:string" name="gradationLabel"/>
<xs:attribute type="xs:unsignedInt" name="copyNumber"/>
<xs:attribute type="xs:boolean" name="showSeamline"/>
<xs:attribute type="xs:float" name="xScale"/>
<xs:attribute type="xs:float" name="yScale"/>
<xs:attribute type="xs:float" name="zValue"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="GrainlineType" name="grainlineType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="formatVersion" name="version" use="required"/>
</xs:complexType>
</xs:element>
<!--Types-->
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
</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="uuid">
<xs:restriction base="xs:string">
<xs:pattern value="|\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ArrowDirection">
<xs:restriction base="xs:string">
<xs:enumeration value="atFront"/>
<xs:enumeration value="atRear"/>
<xs:enumeration value="atBoth"/>
<xs:enumeration value="atFourWay"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="NotchType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--OneLine-->
<xs:enumeration value="1"/>
<!--TwoLines-->
<xs:enumeration value="2"/>
<!--ThreeLines-->
<xs:enumeration value="3"/>
<!--TMark-->
<xs:enumeration value="4"/>
<!--VMark-->
<xs:enumeration value="5"/>
<!--VMark2-->
<xs:enumeration value="6"/>
<!--UMark-->
<xs:enumeration value="7"/>
<!--BoxMark-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CurvePenStyle">
<xs:restriction base="xs:string">
<xs:enumeration value="hair"/>
<xs:enumeration value="dashLine"/>
<xs:enumeration value="dotLine"/>
<xs:enumeration value="dashDotLine"/>
<xs:enumeration value="dashDotDotLine"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MarkerType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--Segment-->
<xs:enumeration value="1"/><!--Rectangle-->
<xs:enumeration value="2"/><!--Cross-->
<xs:enumeration value="3"/><!--Tshaped-->
<xs:enumeration value="4"/><!--Doubletree-->
<xs:enumeration value="5"/><!--Corner-->
<xs:enumeration value="6"/><!--Triangle-->
<xs:enumeration value="7"/><!--Hshaped-->
<xs:enumeration value="8"/><!--Button-->
<xs:enumeration value="9"/><!--Circle-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AlignmentType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--default (no aligns)-->
<xs:enumeration value="1"/><!--aligns with the left edge-->
<xs:enumeration value="2"/><!--aligns with the right edge-->
<xs:enumeration value="4"/><!--Centers horizontally in the available space-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Transformation">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?;){8,}[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PathNotEmpty">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PathOrEmpty">
<xs:restriction base="xs:string">
<xs:pattern value="|([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LinePath">
<xs:restriction base="xs:string">
<xs:pattern value="[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LinesPath">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\*){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PointPath">
<xs:restriction base="xs:string">
<xs:pattern value="[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RectPath">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?;){3,}[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="GrainlineType">
<xs:restriction base="xs:string">
<xs:enumeration value="horizontal"/>
<xs:enumeration value="vertical"/>
<xs:enumeration value="notFixed"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LayoutScale">
<xs:restriction base="xs:float">
<xs:minInclusive value="0.01"/>
<xs:maxInclusive value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -953,6 +953,8 @@
<!--Front--> <!--Front-->
<xs:enumeration value="2"/> <xs:enumeration value="2"/>
<!--Rear--> <!--Rear-->
<xs:enumeration value="3"/>
<!--For way-->
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="pieceVersion"> <xs:simpleType name="pieceVersion">

View File

@ -39,8 +39,8 @@
*/ */
const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0"); const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0");
const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.3"); const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.4");
const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.3.xsd"); const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.4.xsd");
//VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -125,7 +125,8 @@ auto VLayoutConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 1, 0), QStringLiteral("://schema/layout/v0.1.0.xsd")), std::make_pair(FormatVersion(0, 1, 0), QStringLiteral("://schema/layout/v0.1.0.xsd")),
std::make_pair(FormatVersion(0, 1, 1), QStringLiteral("://schema/layout/v0.1.1.xsd")), std::make_pair(FormatVersion(0, 1, 1), QStringLiteral("://schema/layout/v0.1.1.xsd")),
std::make_pair(FormatVersion(0, 1, 2), QStringLiteral("://schema/layout/v0.1.2.xsd")), std::make_pair(FormatVersion(0, 1, 2), QStringLiteral("://schema/layout/v0.1.2.xsd")),
std::make_pair(FormatVersion(0, 1, 3), CurrentSchema), std::make_pair(FormatVersion(0, 1, 3), QStringLiteral("://schema/layout/v0.1.3.xsd")),
std::make_pair(FormatVersion(0, 1, 4), CurrentSchema),
}; };
return schemas; return schemas;
@ -156,9 +157,12 @@ void VLayoutConverter::ApplyPatches()
case (FormatVersion(0, 1, 1)): case (FormatVersion(0, 1, 1)):
case (FormatVersion(0, 1, 2)): case (FormatVersion(0, 1, 2)):
ToV0_1_3(); ToV0_1_3();
ValidateXML(XSDSchema(FormatVersion(0, 1, 3)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FormatVersion(0, 1, 3)): case (FormatVersion(0, 1, 3)):
ToV0_1_4();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 1, 4)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -271,3 +275,13 @@ void VLayoutConverter::ToV0_1_3()
SetVersion(QStringLiteral("0.1.3")); SetVersion(QStringLiteral("0.1.3"));
Save(); Save();
} }
//---------------------------------------------------------------------------------------------------------------------
void VLayoutConverter::ToV0_1_4()
{
// TODO. Delete if minimal supported version is 0.1.4
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 4),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.1.4"));
Save();
}

View File

@ -46,7 +46,7 @@ public:
static const QString LayoutMaxVerStr; static const QString LayoutMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned LayoutMinVer = FormatVersion(0, 1, 0); static Q_DECL_CONSTEXPR const unsigned LayoutMinVer = FormatVersion(0, 1, 0);
static Q_DECL_CONSTEXPR const unsigned LayoutMaxVer = FormatVersion(0, 1, 3); static Q_DECL_CONSTEXPR const unsigned LayoutMaxVer = FormatVersion(0, 1, 4);
static auto XSDSchemas() -> QHash <unsigned, QString>; static auto XSDSchemas() -> QHash <unsigned, QString>;
@ -70,6 +70,7 @@ protected:
void ConvertPathToV0_1_3(QDomElement &node); void ConvertPathToV0_1_3(QDomElement &node);
void ToV0_1_3(); void ToV0_1_3();
void ToV0_1_4();
private: private:
Q_DISABLE_COPY_MOVE(VLayoutConverter) // NOLINT Q_DISABLE_COPY_MOVE(VLayoutConverter) // NOLINT

View File

@ -1778,14 +1778,44 @@ auto VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, const VContaine
v << QPointF(pt1.x() + dArrowLen * qCos(rotation - dArrowAng), v << QPointF(pt1.x() + dArrowLen * qCos(rotation - dArrowAng),
pt1.y() - dArrowLen * qSin(rotation - dArrowAng)); pt1.y() - dArrowLen * qSin(rotation - dArrowAng));
v << pt1; v << pt1;
if (geom.GetArrowType() == GrainlineArrowDirection::atFourWay)
{ // second double arrow
QLineF line(pt2, pt1);
line.setLength(line.length() - dArrowLen - dArrowLen*0.5);
v << line.p2();
v << QPointF(line.p2().x() + dArrowLen * qCos(rotation + dArrowAng),
line.p2().y() - dArrowLen * qSin(rotation + dArrowAng));
v << QPointF(line.p2().x() + dArrowLen * qCos(rotation - dArrowAng),
line.p2().y() - dArrowLen * qSin(rotation - dArrowAng));
v << line.p2();
}
} }
if (geom.GetArrowType() != GrainlineArrowDirection::atFourWay)
{
v << pt2; v << pt2;
}
if (geom.GetArrowType() != GrainlineArrowDirection::atRear) if (geom.GetArrowType() != GrainlineArrowDirection::atRear)
{ {
rotation += M_PI; rotation += M_PI;
if (geom.GetArrowType() == GrainlineArrowDirection::atFourWay)
{ // first double arrow
QLineF line(pt1, pt2);
line.setLength(line.length() - dArrowLen - dArrowLen*0.5);
v << line.p2();
v << QPointF(line.p2().x() + dArrowLen * qCos(rotation + dArrowAng),
line.p2().y() - dArrowLen * qSin(rotation + dArrowAng));
v << QPointF(line.p2().x() + dArrowLen * qCos(rotation - dArrowAng),
line.p2().y() - dArrowLen * qSin(rotation - dArrowAng));
v << line.p2();
v << pt2;
}
v << QPointF(pt2.x() + dArrowLen * qCos(rotation + dArrowAng), v << QPointF(pt2.x() + dArrowLen * qCos(rotation + dArrowAng),
pt2.y() - dArrowLen * qSin(rotation + dArrowAng)); pt2.y() - dArrowLen * qSin(rotation + dArrowAng));
v << QPointF(pt2.x() + dArrowLen * qCos(rotation - dArrowAng), v << QPointF(pt2.x() + dArrowLen * qCos(rotation - dArrowAng),

View File

@ -588,7 +588,24 @@ void VPosition::FollowGrainline()
if (m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atBoth || if (m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atBoth ||
m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atRear) m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atRear)
{ {
RotateOnAngle(angle+180); RotateOnAngle(angle + 180);
}
if (stop->load())
{
return;
}
if (m_data.detail.GrainlineArrowType() == GrainlineArrowDirection::atFourWay)
{
RotateOnAngle(angle + 90);
if (stop->load())
{
return;
}
RotateOnAngle(angle - 90);
} }
} }

View File

@ -37,7 +37,8 @@ enum class GrainlineArrowDirection : qint8
{ {
atBoth, atBoth,
atFront, atFront,
atRear atRear,
atFourWay
}; };
#endif // FLOATITEMDEF_H #endif // FLOATITEMDEF_H

View File

@ -3383,6 +3383,7 @@ void DialogSeamAllowance::InitGrainlineTab()
uiTabGrainline->comboBoxArrow->addItem(tr("Both")); uiTabGrainline->comboBoxArrow->addItem(tr("Both"));
uiTabGrainline->comboBoxArrow->addItem(tr("Just front")); uiTabGrainline->comboBoxArrow->addItem(tr("Just front"));
uiTabGrainline->comboBoxArrow->addItem(tr("Just rear")); uiTabGrainline->comboBoxArrow->addItem(tr("Just rear"));
uiTabGrainline->comboBoxArrow->addItem(tr("Four way"));
m_iRotBaseHeight = uiTabGrainline->lineEditRotFormula->height(); m_iRotBaseHeight = uiTabGrainline->lineEditRotFormula->height();
m_iLenBaseHeight = uiTabGrainline->lineEditLenFormula->height(); m_iLenBaseHeight = uiTabGrainline->lineEditLenFormula->height();

View File

@ -122,12 +122,26 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
if (m_eArrowType != GrainlineArrowDirection::atRear) if (m_eArrowType != GrainlineArrowDirection::atRear)
{ {
// first arrow // first arrow
pP->drawPolygon(FirstArrow(dArrLen)); pP->drawPolygon(FirstArrow(MainLine().p2(), dArrLen));
if (m_eArrowType == GrainlineArrowDirection::atFourWay)
{ // first double arrow
QLineF line = MainLine();
line.setLength(line.length() - dArrLen - dArrLen*0.5);
pP->drawPolygon(FirstArrow(line.p2(), dArrLen));
}
} }
if (m_eArrowType != GrainlineArrowDirection::atFront) if (m_eArrowType != GrainlineArrowDirection::atFront)
{ {
// second arrow // second arrow
pP->drawPolygon(SecondArrow(dArrLen)); pP->drawPolygon(SecondArrow(MainLine().p1(), dArrLen));
if (m_eArrowType == GrainlineArrowDirection::atFourWay)
{ // second double arrow
QLineF line(MainLine().p2(), MainLine().p1());
line.setLength(line.length() - dArrLen - dArrLen*0.5);
pP->drawPolygon(SecondArrow(line.p2(), dArrLen));
}
} }
if (m_eMode != mNormal) if (m_eMode != mNormal)
@ -636,28 +650,26 @@ QLineF VGrainlineItem::MainLine() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPolygonF VGrainlineItem::FirstArrow(qreal dArrLen) const QPolygonF VGrainlineItem::FirstArrow(const QPointF &pt, qreal dArrLen) const
{ {
const QPointF pt2 = MainLine().p2();
QPolygonF poly; QPolygonF poly;
poly << pt2; poly << pt;
poly << QPointF(pt2.x() + dArrLen*cos(M_PI + m_dRotation + ARROW_ANGLE), poly << QPointF(pt.x() + dArrLen*cos(M_PI + m_dRotation + ARROW_ANGLE),
pt2.y() - dArrLen*sin(M_PI + m_dRotation + ARROW_ANGLE)); pt.y() - dArrLen*sin(M_PI + m_dRotation + ARROW_ANGLE));
poly << QPointF(pt2.x() + dArrLen*cos(M_PI + m_dRotation - ARROW_ANGLE), poly << QPointF(pt.x() + dArrLen*cos(M_PI + m_dRotation - ARROW_ANGLE),
pt2.y() - dArrLen*sin(M_PI + m_dRotation - ARROW_ANGLE)); pt.y() - dArrLen*sin(M_PI + m_dRotation - ARROW_ANGLE));
return poly; return poly;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPolygonF VGrainlineItem::SecondArrow(qreal dArrLen) const QPolygonF VGrainlineItem::SecondArrow(const QPointF &pt, qreal dArrLen) const
{ {
const QPointF pt1 = MainLine().p1();
QPolygonF poly; QPolygonF poly;
poly << pt1; poly << pt;
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation + ARROW_ANGLE), poly << QPointF(pt.x() + dArrLen*cos(m_dRotation + ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation + ARROW_ANGLE)); pt.y() - dArrLen*sin(m_dRotation + ARROW_ANGLE));
poly << QPointF(pt1.x() + dArrLen*cos(m_dRotation - ARROW_ANGLE), poly << QPointF(pt.x() + dArrLen*cos(m_dRotation - ARROW_ANGLE),
pt1.y() - dArrLen*sin(m_dRotation - ARROW_ANGLE)); pt.y() - dArrLen*sin(m_dRotation - ARROW_ANGLE));
return poly; return poly;
} }
@ -681,7 +693,15 @@ QPainterPath VGrainlineItem::MainShape() const
{ {
// first arrow // first arrow
QPainterPath polyPath; QPainterPath polyPath;
polyPath.addPolygon(FirstArrow(dArrLen)); polyPath.addPolygon(FirstArrow(MainLine().p2(), dArrLen));
if (m_eArrowType == GrainlineArrowDirection::atFourWay)
{ // first double arrow
QLineF line = MainLine();
line.setLength(line.length() - dArrLen - 0.5);
polyPath.addPolygon(FirstArrow(line.p2(), dArrLen));
}
path.addPath((stroker.createStroke(polyPath) + polyPath).simplified()); path.addPath((stroker.createStroke(polyPath) + polyPath).simplified());
path.closeSubpath(); path.closeSubpath();
} }
@ -690,7 +710,15 @@ QPainterPath VGrainlineItem::MainShape() const
{ {
// second arrow // second arrow
QPainterPath polyPath; QPainterPath polyPath;
polyPath.addPolygon(SecondArrow(dArrLen)); polyPath.addPolygon(SecondArrow(MainLine().p1(), dArrLen));
if (m_eArrowType == GrainlineArrowDirection::atFourWay)
{ // second double arrow
QLineF line(MainLine().p2(), MainLine().p1());
line.setLength(line.length() - dArrLen - 0.5);
polyPath.addPolygon(SecondArrow(line.p2(), dArrLen));
}
path.addPath((stroker.createStroke(polyPath) + polyPath).simplified()); path.addPath((stroker.createStroke(polyPath) + polyPath).simplified());
path.closeSubpath(); path.closeSubpath();
} }

View File

@ -88,8 +88,8 @@ private:
double m_penWidth{1}; double m_penWidth{1};
QLineF MainLine() const; QLineF MainLine() const;
QPolygonF FirstArrow(qreal dArrLen) const; QPolygonF FirstArrow(const QPointF &pt, qreal dArrLen) const;
QPolygonF SecondArrow(qreal dArrLen) const; QPolygonF SecondArrow(const QPointF &pt, qreal dArrLen) const;
QPainterPath MainShape() const; QPainterPath MainShape() const;