New feature. Hide/Show enabled grainline.

This commit is contained in:
Roman Telezhynskyi 2024-05-06 14:01:29 +03:00
parent 2aea155d61
commit 04217cc5da
32 changed files with 2148 additions and 78 deletions

View File

@ -67,6 +67,7 @@
- Automatic crash reports.
- Improve compatibility with Richpeace CAD.
- New warning "Piece gape position".
- New feature. Hide/Show enabled grainline.
# Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru.

View File

@ -560,7 +560,10 @@ void VPGraphicsPiece::InitPieceLabel(const QVector<QPointF> &labelShape, const V
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::InitGrainlineItem()
{
delete m_grainlineItem;
if (m_grainlineItem != nullptr)
{
m_grainlineItem->hide();
}
VPPiecePtr const piece = m_piece.toStrongRef();
if (piece.isNull())
@ -568,15 +571,19 @@ void VPGraphicsPiece::InitGrainlineItem()
return;
}
if (piece->IsGrainlineEnabled())
if (piece->IsGrainlineEnabled() && piece->IsGrainlineVisible())
{
m_grainlineItem = new VGraphicsFillItem(this);
if (m_grainlineItem == nullptr)
{
m_grainlineItem = new VGraphicsFillItem(this);
}
m_grainlineItem->setPath(VLayoutPiece::GrainlinePath(piece->GetMappedGrainlineShape()));
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
QPen const pen(PieceColor(), settings->GetLayoutLineWidth(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
m_grainlineItem->SetCustomPen(true);
m_grainlineItem->setPen(pen);
m_grainlineItem->show();
}
}
@ -1143,17 +1150,14 @@ auto VPGraphicsPiece::NoBrush() const -> QBrush
void VPGraphicsPiece::on_RefreshPiece(const VPPiecePtr &piece)
{
VPPiecePtr const p = m_piece.toStrongRef();
if (p.isNull())
if (p.isNull() || piece.isNull())
{
return;
}
if (p->GetUniqueID() == piece->GetUniqueID())
{
if (not piece.isNull())
{
setZValue(piece->ZValue());
}
setZValue(piece->ZValue());
prepareGeometryChange();
PaintPiece(); // refresh shapes

View File

@ -821,6 +821,22 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::ShowGrainlineToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
{
const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull() && selectedPiece->IsGrainlineVisible() != checked)
{
selectedPiece->GetGrainline().SetVisible(checked);
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
{
@ -860,6 +876,7 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
&VPMainWindow::CurrentPieceShowSeamLineToggled);
connect(ui->checkBoxShowFullPiece, &QCheckBox::toggled, this, &VPMainWindow::ShowFullPieceToggled);
connect(ui->checkBoxShowMirrorLine, &QCheckBox::toggled, this, &VPMainWindow::ShowMirrorLineToggled);
connect(ui->checkBoxShowGrainline, &QCheckBox::toggled, this, &VPMainWindow::ShowGrainlineToggled);
connect(ui->checkBoxCurrentPieceVerticallyFlipped, &QCheckBox::toggled, this,
&VPMainWindow::CurrentPieceVerticallyFlippedToggled);
connect(ui->checkBoxCurrentPieceHorizontallyFlipped, &QCheckBox::toggled, this,
@ -1383,6 +1400,17 @@ void VPMainWindow::SetPropertyTabCurrentPieceData()
!seamMirrorLine.isNull() ? selectedPiece->IsShowMirrorLine() : true);
ui->checkBoxShowMirrorLine->setEnabled(!seamMirrorLine.isNull());
if (selectedPiece->IsGrainlineEnabled())
{
ui->checkBoxShowGrainline->setEnabled(true);
SetCheckBoxValue(ui->checkBoxShowGrainline, selectedPiece->IsGrainlineVisible());
}
else
{
ui->checkBoxShowGrainline->setEnabled(false);
SetCheckBoxValue(ui->checkBoxShowGrainline, false);
}
const bool disableFlipping = selectedPiece->IsForbidFlipping() || selectedPiece->IsForceFlipping();
ui->checkBoxCurrentPieceVerticallyFlipped->setDisabled(disableFlipping);

View File

@ -304,6 +304,7 @@ private slots:
void CurrentPieceShowSeamLineToggled(bool checked);
void ShowFullPieceToggled(bool checked);
void ShowMirrorLineToggled(bool checked);
void ShowGrainlineToggled(bool checked);
void CurrentPieceVerticallyFlippedToggled(bool checked);
void CurrentPieceHorizontallyFlippedToggled(bool checked);

View File

@ -278,9 +278,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-165</y>
<width>385</width>
<height>865</height>
<height>894</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@ -700,6 +700,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowGrainline">
<property name="text">
<string>Show grainline</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxCurrentPieceVerticallyFlipped">
<property name="text">
@ -2506,8 +2516,8 @@
</resources>
<connections/>
<buttongroups>
<buttongroup name="buttonGroupRotationDirection"/>
<buttongroup name="buttonGroupTileOrientation"/>
<buttongroup name="buttonGroupSheetOrientation"/>
<buttongroup name="buttonGroupRotationDirection"/>
</buttongroups>
</ui>

View File

@ -648,6 +648,8 @@ void VPLayoutFileReader::ReadGrainline(const VPPiecePtr &piece)
if (enabled)
{
grainline.SetVisible(ReadAttributeBool(attribs, ML::AttrVisible, trueStr));
QString const arrowDirection = ReadAttributeEmptyString(attribs, ML::AttrArrowDirection);
grainline.SetArrowType(StringToGrainlineArrowDirrection(arrowDirection));

View File

@ -318,6 +318,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagGrainline);
SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsGrainlineEnabled(),
[](bool enabled) noexcept { return not enabled; });
SetAttributeOrRemoveIf<bool>(ML::AttrVisible, piece->IsGrainlineVisible(),
[](bool visible) noexcept { return visible; });
if (piece->IsGrainlineEnabled())
{
SetAttribute(ML::AttrArrowDirection, GrainlineArrowDirrectionToString(piece->GetGrainline().GetArrowType()));

View File

@ -888,7 +888,7 @@ auto MainWindowsNoGUI::PrepareDetailsForLayout(const QVector<DetailForLayout> &d
futureWatcher.setFuture(QtConcurrent::mapped(details, PrepareDetail));
if (VApplication::VApp()->IsGUIMode())
if (VApplication::IsGUIMode())
{
progress.exec();
}

View File

@ -1210,7 +1210,7 @@ auto VPattern::ParseDetailNodes(const QDomElement &domElement, qreal width, bool
//---------------------------------------------------------------------------------------------------------------------
auto VPattern::ParsePieceDataTag(const QDomElement &domElement, VPieceLabelData ppData) const -> VPieceLabelData
{
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
ppData.SetEnabled(GetParametrBool(domElement, AttrVisible, trueStr));
ppData.SetLetter(GetParametrEmptyString(domElement, AttrLetter));
ppData.SetAnnotation(GetParametrEmptyString(domElement, AttrAnnotation));
ppData.SetOrientation(GetParametrEmptyString(domElement, AttrOrientation));
@ -1252,7 +1252,7 @@ auto VPattern::ParsePieceDataTag(const QDomElement &domElement, VPieceLabelData
auto VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPatternLabelData patternInfo) const
-> VPatternLabelData
{
patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
patternInfo.SetEnabled(GetParametrBool(domElement, AttrVisible, trueStr));
patternInfo.SetPos(
QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0'))));
patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, QChar('0'))));
@ -1284,7 +1284,8 @@ auto VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPatternLabe
//---------------------------------------------------------------------------------------------------------------------
auto VPattern::ParsePieceGrainline(const QDomElement &domElement, VGrainlineData gGeometry) const -> VGrainlineData
{
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
gGeometry.SetEnabled(GetParametrBool(domElement, AttrEnabled, falseStr));
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
gGeometry.SetPos(
QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0'))));
gGeometry.SetArrowType(static_cast<GrainlineArrowDirection>(GetParametrUInt(domElement, AttrArrows, QChar('0'))));

View File

@ -71,6 +71,7 @@
<file>schema/pattern/v0.9.3.xsd</file>
<file>schema/pattern/v0.9.4.xsd</file>
<file>schema/pattern/v0.9.5.xsd</file>
<file>schema/pattern/v0.9.6.xsd</file>
<file>schema/multisize_measurements/v0.3.0.xsd</file>
<file>schema/multisize_measurements/v0.4.0.xsd</file>
<file>schema/multisize_measurements/v0.4.1.xsd</file>
@ -108,6 +109,7 @@
<file>schema/layout/v0.1.7.xsd</file>
<file>schema/layout/v0.1.8.xsd</file>
<file>schema/layout/v0.1.9.xsd</file>
<file>schema/layout/v0.2.0.xsd</file>
<file>schema/known_measurements/v1.0.0.xsd</file>
</qresource>
</RCC>

View File

@ -0,0 +1,651 @@
<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="warningPieceGape"/>
<xs:attribute type="xs:boolean" name="stickyEdges"/>
<xs:attribute type="xs:boolean" name="followGrainline"/>
<xs:attribute type="xs:boolean" name="boundaryTogetherWithNotches"/>
<xs:attribute type="xs:float" name="piecesGap"/>
<xs:attribute type="xs:boolean" name="cutOnFold"/>
</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="LinePathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:boolean" name="visible" 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:attribute type="xs:boolean" name="clockwiseOpening" 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:attribute type="xs:boolean" name="notMirrored" 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:attribute type="xs:boolean" name="notMirrored" use="optional"/>
</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:attribute type="xs:string" name="svgFont"/>
</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:attribute type="xs:string" name="svgFont"/>
</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:element name="mirrorLine" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element type="LinePathOrEmpty" name="seamLine"/>
<xs:element type="LinePathOrEmpty" name="seamAllowance"/>
</xs:sequence>
<xs:attribute name="type" type="foldLineType" use="optional"/>
<xs:attribute name="height" type="xs:double" use="optional"/>
<xs:attribute name="width" type="xs:double" use="optional"/>
<xs:attribute name="center" type="xs:double" use="optional"/>
<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 name="label" type="xs:string" use="optional"/>
<xs:attribute type="xs:string" name="font" use="optional"/>
<xs:attribute type="xs:string" name="svgFont" use="optional"/>
<xs:attribute type="xs:boolean" name="visible" use="optional"/>
</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="verticallyFlipped"/>
<xs:attribute type="xs:boolean" name="horizontallyFlipped"/>
<xs:attribute type="xs:boolean" name="forbidFlipping"/>
<xs:attribute type="xs:boolean" name="forceFlipping"/>
<xs:attribute type="xs:boolean" name="followGrainline"/>
<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:boolean" name="showFullPiece"/>
</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="LinePathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:boolean" name="visible" 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:attribute type="xs:boolean" name="clockwiseOpening" 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:attribute type="xs:boolean" name="notMirrored" 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:attribute type="xs:boolean" name="notMirrored" use="optional"/>
</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:attribute type="xs:string" name="svgFont"/>
</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:attribute type="xs:string" name="svgFont"/>
</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:element name="mirrorLine" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element type="LinePathOrEmpty" name="seamLine"/>
<xs:element type="LinePathOrEmpty" name="seamAllowance"/>
</xs:sequence>
<xs:attribute name="type" type="foldLineType" use="optional"/>
<xs:attribute name="height" type="xs:double" use="optional"/>
<xs:attribute name="width" type="xs:double" use="optional"/>
<xs:attribute name="center" type="xs:double" use="optional"/>
<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 name="label" type="xs:string" use="optional"/>
<xs:attribute type="xs:string" name="font" use="optional"/>
<xs:attribute type="xs:string" name="svgFont" use="optional"/>
<xs:attribute type="xs:boolean" name="visible" use="optional"/>
</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="verticallyFlipped"/>
<xs:attribute type="xs:boolean" name="horizontallyFlipped"/>
<xs:attribute type="xs:boolean" name="forbidFlipping"/>
<xs:attribute type="xs:boolean" name="forceFlipping"/>
<xs:attribute type="xs:boolean" name="followGrainline"/>
<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:attribute type="xs:boolean" name="showFullPiece"/>
</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="oneWayUp"/>
<xs:enumeration value="oneWayDown"/>
<xs:enumeration value="twoWaysUpDown"/>
<xs:enumeration value="fourWays"/>
<xs:enumeration value="twoWaysUpLeft"/>
<xs:enumeration value="twoWaysUpRight"/>
<xs:enumeration value="twoWaysDownLeft"/>
<xs:enumeration value="twoWaysDownRight"/>
<xs:enumeration value="threeWaysUpDownLeft"/>
<xs:enumeration value="threeWaysUpDownRight"/>
<xs:enumeration value="threeWaysUpLeftRight"/>
<xs:enumeration value="threeWaysDownLeftRight"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="NotchType">
<xs:restriction base="xs:unsignedInt">
<!--OneLine-->
<xs:enumeration value="0"/>
<!--TwoLines-->
<xs:enumeration value="1"/>
<!--ThreeLines-->
<xs:enumeration value="2"/>
<!--TMark-->
<xs:enumeration value="3"/>
<!--VMark-->
<xs:enumeration value="4"/>
<!--VMark2-->
<xs:enumeration value="5"/>
<!--UMark-->
<xs:enumeration value="6"/>
<!--BoxMark-->
<xs:enumeration value="7"/>
<!--CheckMark-->
<xs:enumeration value="8"/>
</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="LinePathOrEmpty">
<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="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:simpleType name="foldLineType">
<xs:restriction base="xs:string">
<xs:enumeration value="2ArrowsTextAbove"/><!--Same as default-->
<xs:enumeration value="2ArrowsTextUnder"/>
<xs:enumeration value="2Arrows"/>
<xs:enumeration value="text"/>
<xs:enumeration value="3dots"/>
<xs:enumeration value="3X"/>
<xs:enumeration value="none"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

File diff suppressed because it is too large Load Diff

View File

@ -108,6 +108,7 @@ const QString VAbstractPattern::TagBackgroundImage = QStringLiteral("backgroudIm
const QString VAbstractPattern::TagPieceLabel = QStringLiteral("pieceLabel");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrEnabled = QStringLiteral("enabled");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");

View File

@ -342,6 +342,7 @@ public:
static const QString TagPieceLabel;
static const QString AttrName;
static const QString AttrEnabled;
static const QString AttrVisible;
static const QString AttrObject;
static const QString AttrTool;

View File

@ -45,8 +45,8 @@ using namespace Qt::Literals::StringLiterals;
*/
const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0");
const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.9");
const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.9.xsd");
const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.2.0");
const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.2.0.xsd");
// VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -153,7 +153,8 @@ auto VLayoutConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 1, 6), QStringLiteral("://schema/layout/v0.1.6.xsd")),
std::make_pair(FormatVersion(0, 1, 7), QStringLiteral("://schema/layout/v0.1.7.xsd")),
std::make_pair(FormatVersion(0, 1, 8), QStringLiteral("://schema/layout/v0.1.8.xsd")),
std::make_pair(FormatVersion(0, 1, 9), CurrentSchema),
std::make_pair(FormatVersion(0, 1, 9), QStringLiteral("://schema/layout/v0.1.9.xsd")),
std::make_pair(FormatVersion(0, 2, 0), CurrentSchema),
};
return schemas;
@ -195,10 +196,11 @@ void VLayoutConverter::ApplyPatches()
Q_FALLTHROUGH();
case (FormatVersion(0, 1, 7)):
case (FormatVersion(0, 1, 8)):
ToV0_1_9();
case (FormatVersion(0, 1, 9)):
ToV0_2_0();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 1, 9)):
case (FormatVersion(0, 2, 0)):
break;
default:
InvalidVersion(m_ver);
@ -439,11 +441,11 @@ void VLayoutConverter::ToV0_1_7()
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutConverter::ToV0_1_9()
void VLayoutConverter::ToV0_2_0()
{
// TODO. Delete if minimal supported version is 0.1.9
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 9), "Time to refactor the code.");
// TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
SetVersion(QStringLiteral("0.1.9"));
SetVersion(QStringLiteral("0.2.0"));
Save();
}

View File

@ -47,7 +47,7 @@ public:
static const QString LayoutMaxVerStr;
static const QString CurrentSchema;
static constexpr const unsigned LayoutMinVer = FormatVersion(0, 1, 0);
static constexpr const unsigned LayoutMaxVer = FormatVersion(0, 1, 9);
static constexpr const unsigned LayoutMaxVer = FormatVersion(0, 2, 0);
static auto XSDSchemas() -> QHash<unsigned, QString>;
@ -77,7 +77,7 @@ protected:
void ToV0_1_3();
void ToV0_1_5();
void ToV0_1_7();
void ToV0_1_9();
void ToV0_2_0();
private:
Q_DISABLE_COPY_MOVE(VLayoutConverter) // NOLINT

View File

@ -62,8 +62,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); // NOLINT
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.5"); // NOLINT
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.5.xsd"); // NOLINT
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.6"); // NOLINT
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.6.xsd"); // NOLINT
// VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -180,6 +180,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, ("firstToCountour"_
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, ("firstToContour"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, ("lastToCountour"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, ("lastToContour"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVisible, ("visible"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strEnabled, ("enabled"_L1)) // NOLINT
QT_WARNING_POP
} // anonymous namespace
@ -266,7 +268,8 @@ auto VPatternConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 9, 2), QStringLiteral("://schema/pattern/v0.9.2.xsd")),
std::make_pair(FormatVersion(0, 9, 3), QStringLiteral("://schema/pattern/v0.9.3.xsd")),
std::make_pair(FormatVersion(0, 9, 4), QStringLiteral("://schema/pattern/v0.9.4.xsd")),
std::make_pair(FormatVersion(0, 9, 5), CurrentSchema)};
std::make_pair(FormatVersion(0, 9, 5), QStringLiteral("://schema/pattern/v0.9.5.xsd")),
std::make_pair(FormatVersion(0, 9, 6), CurrentSchema)};
return schemas;
}
@ -388,10 +391,11 @@ void VPatternConverter::ApplyPatches()
case (FormatVersion(0, 9, 2)):
case (FormatVersion(0, 9, 3)):
case (FormatVersion(0, 9, 4)):
ToV0_9_5();
case (FormatVersion(0, 9, 5)):
ToV0_9_6();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 9, 5)):
case (FormatVersion(0, 9, 6)):
break;
default:
InvalidVersion(m_ver);
@ -409,7 +413,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
auto VPatternConverter::IsReadOnly() const -> bool
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 5), "Check attribute readOnly.");
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 6), "Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
// For now position is the same for all supported format versions.
@ -585,12 +589,14 @@ void VPatternConverter::ToV0_9_2()
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_9_5()
void VPatternConverter::ToV0_9_6()
{
// TODO. Delete if minimal supported version is 0.9.5
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 5), "Time to refactor the code.");
// TODO. Delete if minimal supported version is 0.9.6
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 6), "Time to refactor the code.");
SetVersion(QStringLiteral("0.9.5"));
ConvertGrainlineToV0_9_6();
SetVersion(QStringLiteral("0.9.6"));
Save();
}
@ -2211,6 +2217,30 @@ void VPatternConverter::ConvertPathAttributesToV0_9_2()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ConvertGrainlineToV0_9_6()
{
// TODO. Delete if minimal supported version is 0.9.6
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 6), "Time to refactor the code.");
const QDomNodeList grainlines = this->elementsByTagName(*strGrainline);
for (int i = 0; i < grainlines.size(); ++i)
{
QDomElement domElement = grainlines.at(i).toElement();
if (domElement.isNull())
{
continue;
}
if (domElement.hasAttribute(*strVisible))
{
domElement.setAttribute(*strEnabled, domElement.attribute(*strVisible));
domElement.removeAttribute(*strVisible);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnionDetailsToV0_4_0()
{

View File

@ -49,28 +49,28 @@ class VPatternConverter final : public VAbstractConverter
public:
explicit VPatternConverter(const QString &fileName);
virtual ~VPatternConverter() = default;
~VPatternConverter() override = default;
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static constexpr const unsigned PatternMinVer = FormatVersion(0, 1, 4);
static constexpr const unsigned PatternMaxVer = FormatVersion(0, 9, 5);
static constexpr const unsigned PatternMaxVer = FormatVersion(0, 9, 6);
static auto XSDSchemas() -> QHash<unsigned, QString>;
protected:
void Save() override;
virtual auto MinVer() const -> unsigned override;
virtual auto MaxVer() const -> unsigned override;
auto MinVer() const -> unsigned override;
auto MaxVer() const -> unsigned override;
virtual auto MinVerStr() const -> QString override;
virtual auto MaxVerStr() const -> QString override;
auto MinVerStr() const -> QString override;
auto MaxVerStr() const -> QString override;
virtual void ApplyPatches() override;
virtual void DowngradeToCurrentMaxVersion() override;
void ApplyPatches() override;
void DowngradeToCurrentMaxVersion() override;
virtual auto IsReadOnly() const -> bool override;
auto IsReadOnly() const -> bool override;
auto Schemas() const -> QHash<unsigned, QString> override;
@ -91,7 +91,7 @@ private:
void ToV0_9_0();
void ToV0_9_1();
void ToV0_9_2();
void ToV0_9_5();
void ToV0_9_6();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
@ -153,6 +153,8 @@ private:
void ConvertMeasurementsPathToV0_9_1();
void ConvertPathAttributesToV0_9_2();
void ConvertGrainlineToV0_9_6();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -696,21 +696,21 @@ auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pat
const VPieceLabelData &data = piece.GetPieceLabelData();
det.SetQuantity(data.GetQuantity());
if (data.IsVisible())
if (data.IsEnabled())
{
VAbstractPattern *pDoc = VAbstractValApplication::VApp()->getCurrentDocument();
det.SetPieceText(pDoc, piece.GetName(), data, settings->GetLabelFont(), settings->GetLabelSVGFont(), pattern);
}
const VPatternLabelData &geom = piece.GetPatternLabelData();
if (geom.IsVisible())
if (geom.IsEnabled())
{
VAbstractPattern *pDoc = VAbstractValApplication::VApp()->getCurrentDocument();
det.SetPatternInfo(pDoc, geom, settings->GetLabelFont(), settings->GetLabelSVGFont(), pattern);
}
const VGrainlineData &grainlineGeom = piece.GetGrainlineGeometry();
if (grainlineGeom.IsVisible())
if (grainlineGeom.IsEnabled())
{
det.SetGrainline(grainlineGeom, pattern);
}
@ -1145,6 +1145,7 @@ void VLayoutPiece::SetGrainline(const VGrainlineData &geom, const VContainer *pa
return;
}
d->m_grainline = VPieceGrainline(mainLine, geom.GetArrowType());
d->m_grainline.SetVisible(geom.IsVisible());
}
//---------------------------------------------------------------------------------------------------------------------
@ -1153,6 +1154,12 @@ auto VLayoutPiece::GetGrainline() const -> VPieceGrainline
return d->m_grainline;
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetGrainline() -> VPieceGrainline &
{
return d->m_grainline;
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetMappedGrainlineShape() const -> GrainlineShape
{
@ -1183,6 +1190,12 @@ auto VLayoutPiece::IsGrainlineEnabled() const -> bool
return d->m_grainline.IsEnabled();
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::IsGrainlineVisible() const -> bool
{
return d->m_grainline.IsVisible();
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetMatrix() const -> QTransform
{
@ -2154,7 +2167,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
{
SCASSERT(parent != nullptr)
if (not d->m_grainline.IsEnabled())
if (!d->m_grainline.IsEnabled() || !d->m_grainline.IsVisible())
{
return;
}

View File

@ -125,11 +125,13 @@ public:
void SetGrainline(const VGrainlineData &geom, const VContainer *pattern);
auto GetGrainline() const -> VPieceGrainline;
auto GetGrainline() -> VPieceGrainline &;
auto GetMappedGrainlineShape() const -> GrainlineShape;
auto GetGrainlineShape() const -> GrainlineShape;
auto GetMappedGrainlineMainLine() const -> QLineF;
auto GetGrainlineMainLine() const -> QLineF;
auto IsGrainlineEnabled() const -> bool;
auto IsGrainlineVisible() const -> bool;
auto GetMatrix() const -> QTransform;
void SetMatrix(const QTransform &matrix);

View File

@ -84,13 +84,13 @@ void VAbstractFloatItemData::SetPos(const QPointF &ptPos)
}
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractFloatItemData::IsVisible() const -> bool
auto VAbstractFloatItemData::IsEnabled() const -> bool
{
return d->m_bVisible;
return d->m_bEnabled;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFloatItemData::SetVisible(bool bVisible)
void VAbstractFloatItemData::SetEnabled(bool bEnabled)
{
d->m_bVisible = bVisible;
d->m_bEnabled = bEnabled;
}

View File

@ -51,8 +51,8 @@ public:
auto GetPos() const -> QPointF;
void SetPos(const QPointF &ptPos);
auto IsVisible() const -> bool;
void SetVisible(bool bVisible);
auto IsEnabled() const -> bool;
void SetEnabled(bool bEnabled);
private:
QSharedDataPointer<VAbstractFloatItemDataPrivate> d;

View File

@ -47,8 +47,8 @@ public:
/** @brief m_ptPos position of label's top left corner */
QPointF m_ptPos{}; // NOLINT(misc-non-private-member-variables-in-classes)
/** @brief m_bVisible visibility flag */
bool m_bVisible{false}; // NOLINT(misc-non-private-member-variables-in-classes)
/** @brief m_bEnabled activity flag */
bool m_bEnabled{false}; // NOLINT(misc-non-private-member-variables-in-classes)
private:
Q_DISABLE_ASSIGN_MOVE(VAbstractFloatItemDataPrivate) // NOLINT

View File

@ -143,3 +143,15 @@ void VGrainlineData::SetBottomPin(quint32 bottomPin)
{
d->m_bottomPin = bottomPin;
}
//---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::IsVisible() const -> bool
{
return d->m_visible;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetVisible(bool visible)
{
d->m_visible = visible;
}

View File

@ -73,6 +73,9 @@ public:
auto BottomPin() const -> quint32;
void SetBottomPin(quint32 bottomPin);
auto IsVisible() const -> bool;
void SetVisible(bool visible);
private:
QSharedDataPointer<VGrainlineDataPrivate> d;
};

View File

@ -54,8 +54,8 @@ public:
QString m_dRotation{}; // NOLINT(misc-non-private-member-variables-in-classes)
/** @brief m_eArrowType type of arrow on the grainline */
GrainlineArrowDirection m_eArrowType{
GrainlineArrowDirection::twoWaysUpDown}; // NOLINT(misc-non-private-member-variables-in-classes)
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
GrainlineArrowDirection m_eArrowType{GrainlineArrowDirection::twoWaysUpDown};
/** @brief m_centerPin center pin id */
quint32 m_centerPin{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
@ -66,6 +66,9 @@ public:
/** @brief m_bottomPin bottom pin id */
quint32 m_bottomPin{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
/** @brief m_visible visibility flag */
bool m_visible{true}; // NOLINT(misc-non-private-member-variables-in-classes)
private:
Q_DISABLE_ASSIGN_MOVE(VGrainlineDataPrivate) // NOLINT
};

View File

@ -434,7 +434,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
}
uiTabGrainline->comboBoxArrow->setCurrentIndex(index);
uiTabLabels->groupBoxDetailLabel->setChecked(ppData.IsVisible());
uiTabLabels->groupBoxDetailLabel->setChecked(ppData.IsEnabled());
ChangeCurrentData(uiTabLabels->comboBoxDLCenterPin, ppData.CenterPin());
ChangeCurrentData(uiTabLabels->comboBoxDLTopLeftPin, ppData.TopLeftPin());
ChangeCurrentData(uiTabLabels->comboBoxDLBottomRightPin, ppData.BottomRightPin());
@ -444,7 +444,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
const VPatternLabelData &patternInfo = piece.GetPatternLabelData();
uiTabLabels->groupBoxPatternLabel->setEnabled(not m_doc->GetPatternLabelTemplate().isEmpty());
uiTabLabels->groupBoxPatternLabel->setChecked(patternInfo.IsVisible());
uiTabLabels->groupBoxPatternLabel->setChecked(patternInfo.IsEnabled());
ChangeCurrentData(uiTabLabels->comboBoxPLCenterPin, patternInfo.CenterPin());
ChangeCurrentData(uiTabLabels->comboBoxPLTopLeftPin, patternInfo.TopLeftPin());
ChangeCurrentData(uiTabLabels->comboBoxPLBottomRightPin, patternInfo.BottomRightPin());
@ -458,12 +458,13 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
}
const VGrainlineData &grainlineGeometry = piece.GetGrainlineGeometry();
uiTabGrainline->groupBoxGrainline->setChecked(grainlineGeometry.IsVisible());
uiTabGrainline->groupBoxGrainline->setChecked(grainlineGeometry.IsEnabled());
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineCenterPin, grainlineGeometry.CenterPin());
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineTopPin, grainlineGeometry.TopPin());
ChangeCurrentData(uiTabGrainline->comboBoxGrainlineBottomPin, grainlineGeometry.BottomPin());
SetGrainlineAngle(grainlineGeometry.GetRotation());
SetGrainlineLength(grainlineGeometry.GetLength());
uiTabGrainline->checkBoxGrainlineVisible->setChecked(grainlineGeometry.IsVisible());
ValidObjects(MainPathIsValid());
EnabledGrainline();
@ -3266,7 +3267,7 @@ auto DialogSeamAllowance::CreatePiece() const -> VPiece
piece.GetPieceLabelData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
piece.GetPieceLabelData().SetLabelTemplate(m_templateLines);
piece.GetPieceLabelData().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditDLAngleFormula));
piece.GetPieceLabelData().SetVisible(uiTabLabels->groupBoxDetailLabel->isChecked());
piece.GetPieceLabelData().SetEnabled(uiTabLabels->groupBoxDetailLabel->isChecked());
piece.GetPieceLabelData().SetFontSize(uiTabLabels->comboBoxPieceLabelSize->currentData().toInt());
piece.SetMirrorLineStartPoint(GetMirrorLineStartPoint());
piece.SetMirrorLineEndPoint(GetMirrorLineEndPoint());
@ -3321,7 +3322,7 @@ auto DialogSeamAllowance::CreatePiece() const -> VPiece
piece.GetPieceLabelData().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin));
}
piece.GetPatternLabelData().SetVisible(uiTabLabels->groupBoxPatternLabel->isChecked());
piece.GetPatternLabelData().SetEnabled(uiTabLabels->groupBoxPatternLabel->isChecked());
piece.GetPatternLabelData().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditPLAngleFormula));
piece.GetPatternLabelData().SetFontSize(uiTabLabels->comboBoxPatternLabelSize->currentData().toInt());
@ -3342,9 +3343,10 @@ auto DialogSeamAllowance::CreatePiece() const -> VPiece
piece.GetPatternLabelData().SetLabelHeight(m_defLabelValue);
}
piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->groupBoxGrainline->isChecked());
piece.GetGrainlineGeometry().SetEnabled(uiTabGrainline->groupBoxGrainline->isChecked());
piece.GetGrainlineGeometry().SetArrowType(
static_cast<GrainlineArrowDirection>(uiTabGrainline->comboBoxArrow->currentData().toInt()));
piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->checkBoxGrainlineVisible->isChecked());
if (not flagGPin)
{

View File

@ -36,7 +36,7 @@
<item>
<widget class="QGroupBox" name="groupBoxGrainline">
<property name="title">
<string>Grainline visible</string>
<string>Grainline enabled</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -116,7 +116,7 @@
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true"></string>
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../../../../../vmisc/share/resources/icon.qrc">
@ -305,7 +305,7 @@
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true"></string>
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../../../../../vmisc/share/resources/icon.qrc">
@ -504,6 +504,19 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxGrainlineVisible">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Visible</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

View File

@ -720,7 +720,7 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
doc->SetAttribute(domData, VAbstractPattern::AttrTilt, data.GetTilt());
doc->SetAttribute(domData, VAbstractPattern::AttrFoldPosition, data.GetFoldPosition());
doc->SetAttribute(domData, VAbstractPattern::AttrQuantity, data.GetQuantity());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsEnabled());
doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold());
doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y());
@ -745,7 +745,7 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
{
QDomElement domData = doc->createElement(VAbstractPattern::TagPatternInfo);
const VPatternLabelData &geom = piece.GetPatternLabelData();
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsEnabled());
doc->SetAttribute(domData, AttrMx, geom.GetPos().x());
doc->SetAttribute(domData, AttrMy, geom.GetPos().y());
doc->SetAttribute(domData, AttrWidth, geom.GetLabelWidth());
@ -769,6 +769,7 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
// grainline
QDomElement domData = doc->createElement(VAbstractPattern::TagGrainline);
const VGrainlineData &glGeom = piece.GetGrainlineGeometry();
doc->SetAttribute(domData, VAbstractPattern::AttrEnabled, glGeom.IsEnabled());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible());
doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x());
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
@ -966,16 +967,16 @@ void VToolSeamAllowance::ResetChildren(QGraphicsItem *pItem)
const bool selected = isSelected();
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
auto *pVGI = qgraphicsitem_cast<VTextGraphicsItem *>(pItem);
if (pVGI != m_dataLabel && detail.GetPieceLabelData().IsVisible())
if (pVGI != m_dataLabel && detail.GetPieceLabelData().IsEnabled())
{
m_dataLabel->Reset();
}
if (pVGI != m_patternInfo && detail.GetPatternLabelData().IsVisible())
if (pVGI != m_patternInfo && detail.GetPatternLabelData().IsEnabled())
{
m_patternInfo->Reset();
}
auto *pGLI = qgraphicsitem_cast<VGrainlineItem *>(pItem);
if (pGLI != m_grainLine && detail.GetGrainlineGeometry().IsVisible())
if (pGLI != m_grainLine && detail.GetGrainlineGeometry().IsEnabled())
{
m_grainLine->Reset();
}
@ -1017,7 +1018,7 @@ void VToolSeamAllowance::UpdateDetailLabel()
const VPieceLabelData &labelData = detail.GetPieceLabelData();
const QVector<quint32> &pins = detail.GetPins();
if (labelData.IsVisible())
if (labelData.IsEnabled())
{
m_pieceLabelPos = QPointF();
m_pieceLabelAngle = 0;
@ -1060,7 +1061,7 @@ void VToolSeamAllowance::UpdatePatternInfo()
const VPatternLabelData &geom = detail.GetPatternLabelData();
const QVector<quint32> &pins = detail.GetPins();
if (geom.IsVisible())
if (geom.IsEnabled())
{
m_patternLabelPos = QPointF();
m_patternLabelAngle = 0;
@ -1105,7 +1106,7 @@ void VToolSeamAllowance::UpdateGrainline()
const VGrainlineData &geom = detail.GetGrainlineGeometry();
const QVector<quint32> &pins = detail.GetPins();
if (geom.IsVisible())
if (geom.IsEnabled() && geom.IsVisible())
{
QPointF pos;
qreal dRotation = 0;

View File

@ -139,6 +139,18 @@ void VPieceGrainline::SetEnabled(bool enabled)
d->m_enabled = enabled;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceGrainline::IsVisible() const -> bool
{
return d->m_visible;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceGrainline::SetVisible(bool visible)
{
d->m_visible = visible;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceGrainline::SecondaryLine() const -> QLineF
{

View File

@ -64,6 +64,9 @@ public:
auto IsEnabled() const -> bool;
void SetEnabled(bool enabled);
auto IsVisible() const -> bool;
void SetVisible(bool visible);
auto SecondaryLine() const -> QLineF;
auto IsFourWays() const -> bool;

View File

@ -55,12 +55,13 @@ public:
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
GrainlineArrowDirection m_arrowType{GrainlineArrowDirection::oneWayUp};
bool m_enabled{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_visible{true}; // NOLINT(misc-non-private-member-variables-in-classes)
private:
Q_DISABLE_ASSIGN_MOVE(VPieceGrainlinePrivate) // NOLINT
static constexpr quint32 streamHeader{0x5C5D5B3B}; // CRC-32Q string "VGrainlineData"
static constexpr quint16 classVersion{1};
static constexpr quint16 classVersion{2};
};
QT_WARNING_POP
@ -84,6 +85,9 @@ inline auto operator<<(QDataStream &dataStream, const VPieceGrainlinePrivate &da
dataStream << data.m_arrowType;
dataStream << data.m_mainLine;
// Added in classVersion = 2
dataStream << data.m_visible;
return dataStream;
}
@ -120,6 +124,11 @@ inline auto operator>>(QDataStream &dataStream, VPieceGrainlinePrivate &data) ->
dataStream >> data.m_arrowType;
dataStream >> data.m_mainLine;
if (actualClassVersion >= 2)
{
dataStream >> data.m_visible;
}
return dataStream;
}