From 5ea7817a02d48317479d9843f73311592bb8c298 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 5 Apr 2024 19:54:48 +0300 Subject: [PATCH] New option Show mirror line. Make showing a symmetry line optional. In some cases users don't need it. --- src/app/puzzle/layout/vppiece.cpp | 1 + src/app/puzzle/scene/vpgraphicspiece.cpp | 4 +- src/app/puzzle/vpmainwindow.cpp | 25 +- src/app/puzzle/vpmainwindow.ui | 42 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 1 + src/app/puzzle/xml/vplayoutfilewriter.cpp | 2 + src/app/valentina/xml/vpattern.cpp | 4 + src/libs/ifc/schema.qrc | 2 + src/libs/ifc/schema/layout/v0.1.9.xsd | 648 +++++++++ src/libs/ifc/schema/pattern/v0.9.5.xsd | 1258 +++++++++++++++++ src/libs/ifc/xml/vabstractpattern.cpp | 1 + src/libs/ifc/xml/vabstractpattern.h | 1 + src/libs/ifc/xml/vlayoutconverter.cpp | 20 +- src/libs/ifc/xml/vlayoutconverter.h | 4 +- src/libs/ifc/xml/vpatternconverter.cpp | 26 +- src/libs/ifc/xml/vpatternconverter.h | 4 +- src/libs/vdxf/vdxfengine.cpp | 4 +- src/libs/vhpgl/vhpglengine.cpp | 5 +- src/libs/vlayout/vabstractpiece.cpp | 12 + src/libs/vlayout/vabstractpiece.h | 3 + src/libs/vlayout/vabstractpiece_p.h | 11 +- src/libs/vlayout/vlayoutpiece.cpp | 1 + .../tools/piece/dialogseamallowance.cpp | 3 + .../dialogs/tools/piece/tabs/tabpaths.ui | 48 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 4 +- 25 files changed, 2060 insertions(+), 74 deletions(-) create mode 100644 src/libs/ifc/schema/layout/v0.1.9.xsd create mode 100644 src/libs/ifc/schema/pattern/v0.9.5.xsd diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index c85158fbc..6556e6b32 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -176,6 +176,7 @@ void VPPiece::Update(const VPPiecePtr &piece) SetFoldLineWidth(piece->GetFoldLineWidth()); SetForceFlipping(piece->IsForceFlipping()); SetForbidFlipping(piece->IsForbidFlipping()); + SetShowMirrorLine(piece->IsShowMirrorLine()); if ((IsForceFlipping() && !IsVerticallyFlipped()) || (IsForbidFlipping() && IsVerticallyFlipped())) { diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 50e3b262c..7e2ddf231 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -954,7 +954,7 @@ void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece if (not piece->IsSeamAllowance() || piece->IsSeamAllowanceBuiltIn()) { QLineF const seamMirrorLine = piece->GetMappedSeamMirrorLine(); - if (!seamMirrorLine.isNull()) + if (!seamMirrorLine.isNull() && piece->IsShowMirrorLine()) { QPainterPath mirrorPath; mirrorPath.moveTo(seamMirrorLine.p1()); @@ -966,7 +966,7 @@ void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece else if (not piece->IsSeamAllowanceBuiltIn()) { QLineF const seamAllowanceMirrorLine = piece->GetMappedSeamAllowanceMirrorLine(); - if (!seamAllowanceMirrorLine.isNull()) + if (!seamAllowanceMirrorLine.isNull() && piece->IsShowMirrorLine()) { QPainterPath mirrorPath; mirrorPath.moveTo(seamAllowanceMirrorLine.p1()); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 5970461d1..44d073f7c 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -808,6 +808,25 @@ void VPMainWindow::InitPropertyTabCurrentPiece() } }); + connect(ui->checkBoxShowMirrorLine, &QCheckBox::toggled, this, + [this](bool checked) + { + QList const selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); + if (not selectedPiece.isNull()) + { + if (selectedPiece->IsShowMirrorLine() != checked) + { + selectedPiece->SetShowMirrorLine(checked); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); + } + } + } + }); + connect(ui->checkBoxCurrentPieceVerticallyFlipped, &QCheckBox::toggled, this, [this](bool checked) { @@ -1314,14 +1333,12 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui->groupBoxCurrentPieceInfo->setVisible(false); ui->groupBoxPieceTransformation->setVisible(false); - ui->groupBoxCurrentPieceSeamline->setVisible(false); ui->groupBoxCurrentPieceGeometry->setVisible(false); } else if (selectedPieces.count() == 1) { ui->groupBoxCurrentPieceInfo->setVisible(true); ui->groupBoxPieceTransformation->setVisible(true); - ui->groupBoxCurrentPieceSeamline->setVisible(true); ui->groupBoxCurrentPieceGeometry->setVisible(true); const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); @@ -1338,6 +1355,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() QLineF const seamMirrorLine = selectedPiece->GetSeamMirrorLine(); SetCheckBoxValue(ui->checkBoxShowFullPiece, !seamMirrorLine.isNull() ? selectedPiece->IsShowFullPiece() : true); ui->checkBoxShowFullPiece->setEnabled(!seamMirrorLine.isNull()); + SetCheckBoxValue(ui->checkBoxShowMirrorLine, + !seamMirrorLine.isNull() ? selectedPiece->IsShowMirrorLine() : true); + ui->checkBoxShowMirrorLine->setEnabled(!seamMirrorLine.isNull()); const bool disableFlipping = selectedPiece->IsForbidFlipping() || selectedPiece->IsForceFlipping(); ui->checkBoxCurrentPieceVerticallyFlipped->setDisabled(disableFlipping); @@ -1357,7 +1377,6 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() // show the content "multiple pieces selected" ui->groupBoxCurrentPieceInfo->setVisible(false); ui->groupBoxPieceTransformation->setVisible(true); - ui->groupBoxCurrentPieceSeamline->setVisible(false); ui->groupBoxCurrentPieceGeometry->setVisible(false); if (not ui->checkBoxRelativeTranslation->isChecked()) diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 569eba093..39bbb5497 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -280,7 +280,7 @@ 0 0 378 - 736 + 721 @@ -596,25 +596,6 @@ - - - - Seamline - - - - - - Show Seamline - - - true - - - - - - @@ -634,6 +615,26 @@ + + + + Show Seamline + + + true + + + + + + + Show mirror line + + + true + + + @@ -2415,7 +2416,6 @@ scrollAreaTiles lineEditCurrentPieceName plainTextEditCurrentPieceUUID - checkBoxCurrentPieceShowSeamline checkBoxCurrentPieceVerticallyFlipped doubleSpinBoxCurrentPieceAngle doubleSpinBoxCurrentPieceBoxPositionX diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 1df5fc014..5c36f48e4 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -962,6 +962,7 @@ void VPLayoutFileReader::ReadMirrorLines(const VPPiecePtr &piece) ReadAttributeInt(attribs, ML::AttrAlignment, QString::number(static_cast(Qt::AlignHCenter)))); piece->SetFoldLineLabel(ReadAttributeEmptyString(attribs, ML::AttrFoldLineLabel)); piece->SetFoldLineOutlineFont(FontFromString(ReadAttributeEmptyString(attribs, ML::AttrFont))); + piece->SetShowMirrorLine(ReadAttributeBool(attribs, ML::AttrVisible, trueStr)); if (QStringList const svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(','_L1); !svgFontData.isEmpty()) diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 76d705567..7bca8eaff 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -406,6 +406,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) ML::AttrSVGFont, QStringLiteral("%1,%2").arg(piece->GetFoldLineSVGFontFamily()).arg(piece->GetFoldLineSvgFontSize()), [piece](const QString &) { return piece->GetFoldLineLabel().isEmpty(); }); + SetAttributeOrRemoveIf(ML::AttrVisible, piece->IsShowMirrorLine(), + [](bool visible) noexcept { return visible; }); if (!seamMirrorLine.isNull()) { diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 1e399ec36..07d843b0d 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -152,6 +152,7 @@ struct VPieceFoldLineData { quint32 p1{NULL_ID}; quint32 p2{NULL_ID}; + bool mirrorLineVisible{true}; QString heightFormula{}; QString widthFormula{}; QString centerFormula{}; @@ -173,6 +174,8 @@ auto ParsePieceMirrorLine(const QDomElement &domElement) -> VPieceFoldLineData data.p1 = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrMirrorLineP1, NULL_ID_STR); data.p2 = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrMirrorLineP2, NULL_ID_STR); + data.mirrorLineVisible = + VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrMirrorLineVisible, trueStr); data.heightFormula = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrFoldLineHeightFormula); data.widthFormula = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrFoldLineWidthFormula); data.centerFormula = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrFoldLineCenterFormula); @@ -1173,6 +1176,7 @@ void VPattern::ParseDetailInternals(const QDomElement &domElement, VPiece &detai VPieceFoldLineData const data = futureMirrorLine.result(); detail.SetMirrorLineStartPoint(data.p1); detail.SetMirrorLineEndPoint(data.p2); + detail.SetShowMirrorLine(data.mirrorLineVisible); detail.SetManualFoldHeight(data.manualHeight); detail.SetManualFoldWidth(data.manualWidth); detail.SetManualFoldCenter(data.manualCenter); diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 2910f3e05..6a32f7a1e 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -70,6 +70,7 @@ schema/pattern/v0.9.2.xsd schema/pattern/v0.9.3.xsd schema/pattern/v0.9.4.xsd + schema/pattern/v0.9.5.xsd schema/multisize_measurements/v0.3.0.xsd schema/multisize_measurements/v0.4.0.xsd schema/multisize_measurements/v0.4.1.xsd @@ -106,6 +107,7 @@ schema/layout/v0.1.6.xsd schema/layout/v0.1.7.xsd schema/layout/v0.1.8.xsd + schema/layout/v0.1.9.xsd schema/known_measurements/v1.0.0.xsd diff --git a/src/libs/ifc/schema/layout/v0.1.9.xsd b/src/libs/ifc/schema/layout/v0.1.9.xsd new file mode 100644 index 000000000..40f4172a8 --- /dev/null +++ b/src/libs/ifc/schema/layout/v0.1.9.xsd @@ -0,0 +1,648 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/pattern/v0.9.5.xsd b/src/libs/ifc/schema/pattern/v0.9.5.xsd new file mode 100644 index 000000000..69139f19c --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.9.5.xsd @@ -0,0 +1,1258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index dd7a4bef8..cc9fd797c 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -157,6 +157,7 @@ const QString VAbstractPattern::AttrDimensionB = QStringLiteral("dimensionB"); const QString VAbstractPattern::AttrDimensionC = QStringLiteral("dimensionC"); const QString VAbstractPattern::AttrMirrorLineP1 = QStringLiteral("p1"); const QString VAbstractPattern::AttrMirrorLineP2 = QStringLiteral("p2"); +const QString VAbstractPattern::AttrMirrorLineVisible = QStringLiteral("visible"); const QString VAbstractPattern::AttrFoldLineHeightFormula = QStringLiteral("height"); const QString VAbstractPattern::AttrFoldLineWidthFormula = QStringLiteral("width"); const QString VAbstractPattern::AttrFoldLineCenterFormula = QStringLiteral("center"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 02f12749d..0866417c2 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -391,6 +391,7 @@ public: static const QString AttrDimensionC; static const QString AttrMirrorLineP1; static const QString AttrMirrorLineP2; + static const QString AttrMirrorLineVisible; static const QString AttrFoldLineHeightFormula; static const QString AttrFoldLineWidthFormula; static const QString AttrFoldLineCenterFormula; diff --git a/src/libs/ifc/xml/vlayoutconverter.cpp b/src/libs/ifc/xml/vlayoutconverter.cpp index d508837e6..d433119d4 100644 --- a/src/libs/ifc/xml/vlayoutconverter.cpp +++ b/src/libs/ifc/xml/vlayoutconverter.cpp @@ -45,8 +45,8 @@ using namespace Qt::Literals::StringLiterals; */ const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0"); -const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.8"); -const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.8.xsd"); +const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.9"); +const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.9.xsd"); // VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -152,7 +152,8 @@ auto VLayoutConverter::XSDSchemas() -> QHash std::make_pair(FormatVersion(0, 1, 5), QStringLiteral("://schema/layout/v0.1.5.xsd")), 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), CurrentSchema), + std::make_pair(FormatVersion(0, 1, 8), QStringLiteral("://schema/layout/v0.1.8.xsd")), + std::make_pair(FormatVersion(0, 1, 9), CurrentSchema), }; return schemas; @@ -193,10 +194,11 @@ void VLayoutConverter::ApplyPatches() ToV0_1_7(); Q_FALLTHROUGH(); case (FormatVersion(0, 1, 7)): - ToV0_1_8(); + case (FormatVersion(0, 1, 8)): + ToV0_1_9(); ValidateXML(CurrentSchema); Q_FALLTHROUGH(); - case (FormatVersion(0, 1, 8)): + case (FormatVersion(0, 1, 9)): break; default: InvalidVersion(m_ver); @@ -437,11 +439,11 @@ void VLayoutConverter::ToV0_1_7() } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutConverter::ToV0_1_8() +void VLayoutConverter::ToV0_1_9() { - // TODO. Delete if minimal supported version is 0.1.8 - Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 8), "Time to refactor the code."); + // 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."); - SetVersion(QStringLiteral("0.1.8")); + SetVersion(QStringLiteral("0.1.9")); Save(); } diff --git a/src/libs/ifc/xml/vlayoutconverter.h b/src/libs/ifc/xml/vlayoutconverter.h index a142d08d7..5e40f942b 100644 --- a/src/libs/ifc/xml/vlayoutconverter.h +++ b/src/libs/ifc/xml/vlayoutconverter.h @@ -47,7 +47,7 @@ public: static const QString LayoutMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const unsigned LayoutMinVer = FormatVersion(0, 1, 0); - static Q_DECL_CONSTEXPR const unsigned LayoutMaxVer = FormatVersion(0, 1, 8); + static Q_DECL_CONSTEXPR const unsigned LayoutMaxVer = FormatVersion(0, 1, 9); static auto XSDSchemas() -> QHash; @@ -77,7 +77,7 @@ protected: void ToV0_1_3(); void ToV0_1_5(); void ToV0_1_7(); - void ToV0_1_8(); + void ToV0_1_9(); private: Q_DISABLE_COPY_MOVE(VLayoutConverter) // NOLINT diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 8d63b4e6c..43beb34c9 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -62,8 +62,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); // NOLINT -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.4"); // NOLINT -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.4.xsd"); // NOLINT +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.5"); // NOLINT +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.5.xsd"); // NOLINT // VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -265,7 +265,8 @@ auto VPatternConverter::XSDSchemas() -> QHash std::make_pair(FormatVersion(0, 9, 1), QStringLiteral("://schema/pattern/v0.9.1.xsd")), 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), CurrentSchema)}; + std::make_pair(FormatVersion(0, 9, 4), QStringLiteral("://schema/pattern/v0.9.4.xsd")), + std::make_pair(FormatVersion(0, 9, 5), CurrentSchema)}; return schemas; } @@ -386,10 +387,11 @@ void VPatternConverter::ApplyPatches() Q_FALLTHROUGH(); case (FormatVersion(0, 9, 2)): case (FormatVersion(0, 9, 3)): - ToV0_9_4(); + case (FormatVersion(0, 9, 4)): + ToV0_9_5(); ValidateXML(CurrentSchema); Q_FALLTHROUGH(); - case (FormatVersion(0, 9, 4)): + case (FormatVersion(0, 9, 5)): break; default: InvalidVersion(m_ver); @@ -407,7 +409,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, 4), "Check attribute readOnly."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 5), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. // For now position is the same for all supported format versions. @@ -583,12 +585,12 @@ void VPatternConverter::ToV0_9_2() } //--------------------------------------------------------------------------------------------------------------------- -void VPatternConverter::ToV0_9_4() +void VPatternConverter::ToV0_9_5() { - // TODO. Delete if minimal supported version is 0.9.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 4), "Time to refactor the code."); + // 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."); - SetVersion(QStringLiteral("0.9.4")); + SetVersion(QStringLiteral("0.9.5")); Save(); } @@ -1035,8 +1037,8 @@ auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, co // TODO. Delete if minimal supported version is 0.2.0 Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); - auto *cal = new qmu::QmuTokenParser(formula, false, false); // Eval formula - QMap tokens = cal->GetTokens(); // Tokens (variables, measurements) + auto *cal = new qmu::QmuTokenParser(formula, false, false); // Eval formula + QMap tokens = cal->GetTokens(); // Tokens (variables, measurements) delete cal; QList tKeys = tokens.keys(); // Take all tokens positions diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index b6576127c..92ad6b265 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -54,7 +54,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4); - static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 4); + static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 5); static auto XSDSchemas() -> QHash; @@ -91,7 +91,7 @@ private: void ToV0_9_0(); void ToV0_9_1(); void ToV0_9_2(); - void ToV0_9_4(); + void ToV0_9_5(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 77c9df47e..142f8dbda 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -915,7 +915,7 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer &detailBlock if (detail.IsShowFullPiece()) { const QLineF mirrorLine = detail.GetMappedSeamAllowanceMirrorLine(); - if (not mirrorLine.isNull()) + if (not mirrorLine.isNull() && detail.IsShowMirrorLine()) { if (DRW_Entity *e = AAMALine(mirrorLine, *layer8)) { @@ -1776,7 +1776,7 @@ void VDxfEngine::ExportASTMMirrorLine(const QSharedPointer &detai if (DRW_Entity *e = AAMALine(mirrorLine, layer)) { - if (isShowFullPiece) + if (isShowFullPiece && detail.IsShowMirrorLine()) { e->lineType = dx_iface::QtPenStyleToString(Qt::DashDotLine); } diff --git a/src/libs/vhpgl/vhpglengine.cpp b/src/libs/vhpgl/vhpglengine.cpp index 03c1ca4cf..e64000816 100644 --- a/src/libs/vhpgl/vhpglengine.cpp +++ b/src/libs/vhpgl/vhpglengine.cpp @@ -531,7 +531,8 @@ void VHPGLEngine::PlotPlaceLabels(QTextStream &out, const VLayoutPiece &detail) for (auto &points : shape) { std::transform(points.begin(), points.end(), points.begin(), - [&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); }); + [&matrix](const VLayoutPoint &point) + { return VAbstractPiece::MapPoint(point, matrix); }); } PlotShape(shape); @@ -603,7 +604,7 @@ void VHPGLEngine::PlotMirrorLine(QTextStream &out, const VLayoutPiece &detail) if (detail.IsShowFullPiece()) { const QLineF mirrorLine = detail.GetMappedSeamAllowanceMirrorLine(); - if (not mirrorLine.isNull()) + if (not mirrorLine.isNull() && detail.IsShowMirrorLine()) { PlotPath(out, CastToPoint(ConvertPath({mirrorLine.p1(), mirrorLine.p2()})), Qt::DashDotLine); } diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 5cc8dc467..6b991886e 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1598,6 +1598,18 @@ void VAbstractPiece::SetFoldLineLabelAlignment(int alignment) d->m_foldLineLabelAlignment = alignment; } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsShowMirrorLine() const +{ + return d->m_showMirrorLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetShowMirrorLine(bool show) +{ + d->m_showMirrorLine = show; +} + //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPiece::GetUUID() const -> QUuid { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 44354ce7b..d345c1516 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -135,6 +135,9 @@ public: auto GetFoldLineLabelAlignment() const -> int; void SetFoldLineLabelAlignment(int alignment); + auto IsShowMirrorLine() const -> bool; + void SetShowMirrorLine(bool show); + auto GetUUID() const -> QUuid; void SetUUID(const QUuid &uuid); void SetUUID(const QString &uuid); diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index fc795e5b3..24c801f1a 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -73,6 +73,7 @@ public: bool m_foldLineLabelFontBold{false}; // NOLINT (misc-non-private-member-variables-in-classes) QString m_foldLineLabel{}; // NOLINT (misc-non-private-member-variables-in-classes) int m_foldLineLabelAlignment{Qt::AlignHCenter}; // NOLINT (misc-non-private-member-variables-in-classes) + bool m_showMirrorLine{true}; // NOLINT (misc-non-private-member-variables-in-classes) // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) FoldLineType m_foldLineType{FoldLineType::TwoArrowsTextAbove}; @@ -81,7 +82,7 @@ private: Q_DISABLE_ASSIGN_MOVE(VAbstractPieceData) // NOLINT static constexpr quint32 streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData" - static constexpr quint16 classVersion = 6; + static constexpr quint16 classVersion = 7; }; QT_WARNING_POP @@ -124,6 +125,9 @@ inline auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) dataStream << piece.m_foldLineLabel; dataStream << piece.m_foldLineLabelAlignment; + // Added in classVersion = 7 + dataStream << piece.m_showMirrorLine; + return dataStream; } @@ -197,6 +201,11 @@ inline auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QD dataStream >> piece.m_foldLineLabelAlignment; } + if (actualClassVersion >= 7) + { + dataStream >> piece.m_showMirrorLine; + } + return dataStream; } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 7c2cd8f84..02a3b76f0 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -669,6 +669,7 @@ auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pat det.SetShowFullPiece(piece.IsShowFullPiece()); det.SetSeamMirrorLine(piece.SeamMirrorLine(pattern)); det.SetSeamAllowanceMirrorLine(piece.SeamAllowanceMirrorLine(pattern)); + det.SetShowMirrorLine(piece.IsShowMirrorLine()); det.SetId(id); if (not futureSeamAllowanceValid.result()) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index d8ae7f103..107ba9527 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -763,6 +763,8 @@ void DialogSeamAllowance::InitFold(const VPiece &piece) uiTabPaths->checkBoxShowFullPiece->setChecked(piece.IsShowFullPiece()); } + uiTabPaths->checkBoxShowMirrorLine->setChecked(piece.IsShowMirrorLine()); + InitMirrorLine(); { @@ -3268,6 +3270,7 @@ auto DialogSeamAllowance::CreatePiece() const -> VPiece piece.GetPieceLabelData().SetFontSize(uiTabLabels->comboBoxPieceLabelSize->currentData().toInt()); piece.SetMirrorLineStartPoint(GetMirrorLineStartPoint()); piece.SetMirrorLineEndPoint(GetMirrorLineEndPoint()); + piece.SetShowMirrorLine(uiTabPaths->checkBoxShowMirrorLine->isChecked()); piece.SetShowFullPiece( !piece.SeamAllowanceMirrorLine(data).isNull() ? uiTabPaths->checkBoxShowFullPiece->isChecked() : true); piece.SetManualFoldHeight(uiTabFoldLine->groupBoxManualHeight->isChecked()); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui index a3d13162c..3feddc259 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui @@ -203,27 +203,41 @@ Mirror line - - - + + + + + + + Start point: + + + + + + + + + + End point: + + + + + + + + + + - Start point: + Show mirror line + + + true - - - - - - - End point: - - - - - - diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index c4ae51dee..6f188beaf 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -819,6 +819,8 @@ void VToolSeamAllowance::AddMirrorLine(VAbstractPattern *doc, QDomElement &domEl [](const QString &label) noexcept { return label.isEmpty(); }); doc->SetAttributeOrRemoveIf(domData, VDomDocument::AttrAlignment, piece.GetFoldLineLabelAlignment(), [](int alignment) noexcept { return alignment == Qt::AlignHCenter; }); + doc->SetAttributeOrRemoveIf(domData, VAbstractPattern::AttrMirrorLineVisible, piece.IsShowMirrorLine(), + [](bool visible) noexcept { return visible; }); domElement.appendChild(domData); } @@ -1776,7 +1778,7 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) [this, detail]() { QLineF const mirrorLine = detail.SeamAllowanceMirrorLine(getData()); - if (detail.IsShowFullPiece() && !mirrorLine.isNull()) + if (detail.IsShowFullPiece() && detail.IsShowMirrorLine() && !mirrorLine.isNull()) { QPainterPath path; path.moveTo(mirrorLine.p1());