From 04217cc5daeb9b585942d581ae79ae8781c77f8f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 6 May 2024 14:01:29 +0300 Subject: [PATCH] New feature. Hide/Show enabled grainline. --- ChangeLog.txt | 1 + src/app/puzzle/scene/vpgraphicspiece.cpp | 20 +- src/app/puzzle/vpmainwindow.cpp | 28 + src/app/puzzle/vpmainwindow.h | 1 + src/app/puzzle/vpmainwindow.ui | 16 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 2 + src/app/puzzle/xml/vplayoutfilewriter.cpp | 2 + src/app/valentina/mainwindowsnogui.cpp | 2 +- src/app/valentina/xml/vpattern.cpp | 7 +- src/libs/ifc/schema.qrc | 2 + src/libs/ifc/schema/layout/v0.2.0.xsd | 651 +++++++++ src/libs/ifc/schema/pattern/v0.9.6.xsd | 1259 +++++++++++++++++ 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 | 50 +- src/libs/ifc/xml/vpatternconverter.h | 22 +- src/libs/vlayout/vlayoutpiece.cpp | 21 +- src/libs/vlayout/vlayoutpiece.h | 2 + .../floatItemData/vabstractfloatitemdata.cpp | 8 +- .../floatItemData/vabstractfloatitemdata.h | 4 +- .../floatItemData/vabstractfloatitemdata_p.h | 4 +- .../floatItemData/vgrainlinedata.cpp | 12 + .../vpatterndb/floatItemData/vgrainlinedata.h | 3 + .../floatItemData/vgrainlinedata_p.h | 7 +- .../tools/piece/dialogseamallowance.cpp | 14 +- .../dialogs/tools/piece/tabs/tabgrainline.ui | 19 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 17 +- src/libs/vwidgets/vpiecegrainline.cpp | 12 + src/libs/vwidgets/vpiecegrainline.h | 3 + src/libs/vwidgets/vpiecegrainline_p.h | 11 +- 32 files changed, 2148 insertions(+), 78 deletions(-) create mode 100644 src/libs/ifc/schema/layout/v0.2.0.xsd create mode 100644 src/libs/ifc/schema/pattern/v0.9.6.xsd diff --git a/ChangeLog.txt b/ChangeLog.txt index 4c8cb824a..03f2e40ea 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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. diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 7c92bfca7..ab96c357d 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -560,7 +560,10 @@ void VPGraphicsPiece::InitPieceLabel(const QVector &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 diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 88457cae4..e7693f5da 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -821,6 +821,22 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked) } } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::ShowGrainlineToggled(bool checked) +{ + QList 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); diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index f52aa6330..d8850552b 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -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); diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 3e66d253c..5409034d7 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -278,9 +278,9 @@ 0 - 0 + -165 385 - 865 + 894 @@ -700,6 +700,16 @@ + + + + Show grainline + + + true + + + @@ -2506,8 +2516,8 @@ - + diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index be960400f..9cdf8cece 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -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)); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index c8e079960..9a5a9c768 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -318,6 +318,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) writeStartElement(ML::TagGrainline); SetAttributeOrRemoveIf(ML::AttrEnabled, piece->IsGrainlineEnabled(), [](bool enabled) noexcept { return not enabled; }); + SetAttributeOrRemoveIf(ML::AttrVisible, piece->IsGrainlineVisible(), + [](bool visible) noexcept { return visible; }); if (piece->IsGrainlineEnabled()) { SetAttribute(ML::AttrArrowDirection, GrainlineArrowDirrectionToString(piece->GetGrainline().GetArrowType())); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 689c361e3..29f0545fe 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -888,7 +888,7 @@ auto MainWindowsNoGUI::PrepareDetailsForLayout(const QVector &d futureWatcher.setFuture(QtConcurrent::mapped(details, PrepareDetail)); - if (VApplication::VApp()->IsGUIMode()) + if (VApplication::IsGUIMode()) { progress.exec(); } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 766d07f51..d98f1a1cd 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -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(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(GetParametrUInt(domElement, AttrArrows, QChar('0')))); diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 6a32f7a1e..bb8935924 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -71,6 +71,7 @@ schema/pattern/v0.9.3.xsd schema/pattern/v0.9.4.xsd schema/pattern/v0.9.5.xsd + schema/pattern/v0.9.6.xsd schema/multisize_measurements/v0.3.0.xsd schema/multisize_measurements/v0.4.0.xsd schema/multisize_measurements/v0.4.1.xsd @@ -108,6 +109,7 @@ schema/layout/v0.1.7.xsd schema/layout/v0.1.8.xsd schema/layout/v0.1.9.xsd + schema/layout/v0.2.0.xsd schema/known_measurements/v1.0.0.xsd diff --git a/src/libs/ifc/schema/layout/v0.2.0.xsd b/src/libs/ifc/schema/layout/v0.2.0.xsd new file mode 100644 index 000000000..1e0c2413c --- /dev/null +++ b/src/libs/ifc/schema/layout/v0.2.0.xsd @@ -0,0 +1,651 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/pattern/v0.9.6.xsd b/src/libs/ifc/schema/pattern/v0.9.6.xsd new file mode 100644 index 000000000..a5d483c68 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.9.6.xsd @@ -0,0 +1,1259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 00cba6bd3..90aed3102 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -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"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 0866417c2..ae3ca0ede 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -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; diff --git a/src/libs/ifc/xml/vlayoutconverter.cpp b/src/libs/ifc/xml/vlayoutconverter.cpp index d433119d4..c10e9bb4f 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.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 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(); } diff --git a/src/libs/ifc/xml/vlayoutconverter.h b/src/libs/ifc/xml/vlayoutconverter.h index 287e55e96..5cccbc7c4 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 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; @@ -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 diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index a5d77bc11..eed686025 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.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 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() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index d5812ac5e..64ea3f857 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -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; 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 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(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 3c77b1e31..56fd9bd99 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -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; } diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index a9e90e491..151f7ab9f 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -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); diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp index ec6104162..189a69f53 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp @@ -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; } diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h index 630c544ce..88f650083 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h @@ -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 d; diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h index 5588b8421..1f4ec547a 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h @@ -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 diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp index 48900a506..8c83b0dfd 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp @@ -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; +} diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h index 6942f30a3..5f9421494 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h @@ -73,6 +73,9 @@ public: auto BottomPin() const -> quint32; void SetBottomPin(quint32 bottomPin); + auto IsVisible() const -> bool; + void SetVisible(bool visible); + private: QSharedDataPointer d; }; diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h index 9fdf66dc4..2c7b07bcd 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h @@ -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 }; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index e8d2e5895..d65984a82 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -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(uiTabGrainline->comboBoxArrow->currentData().toInt())); + piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->checkBoxGrainlineVisible->isChecked()); if (not flagGPin) { diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabgrainline.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabgrainline.ui index 25bef8c5f..f39592e19 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabgrainline.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabgrainline.ui @@ -36,7 +36,7 @@ - Grainline visible + Grainline enabled true @@ -116,7 +116,7 @@ Formula wizard - + @@ -305,7 +305,7 @@ Formula wizard - + @@ -504,6 +504,19 @@ + + + + true + + + Visible + + + true + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 58de08f89..26a8b3581 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -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(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(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 &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 &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 &pins = detail.GetPins(); - if (geom.IsVisible()) + if (geom.IsEnabled() && geom.IsVisible()) { QPointF pos; qreal dRotation = 0; diff --git a/src/libs/vwidgets/vpiecegrainline.cpp b/src/libs/vwidgets/vpiecegrainline.cpp index fab497c48..8721e33f7 100644 --- a/src/libs/vwidgets/vpiecegrainline.cpp +++ b/src/libs/vwidgets/vpiecegrainline.cpp @@ -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 { diff --git a/src/libs/vwidgets/vpiecegrainline.h b/src/libs/vwidgets/vpiecegrainline.h index 1a367a6e9..6ce0961fb 100644 --- a/src/libs/vwidgets/vpiecegrainline.h +++ b/src/libs/vwidgets/vpiecegrainline.h @@ -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; diff --git a/src/libs/vwidgets/vpiecegrainline_p.h b/src/libs/vwidgets/vpiecegrainline_p.h index 622cd22bc..89f3f0c0a 100644 --- a/src/libs/vwidgets/vpiecegrainline_p.h +++ b/src/libs/vwidgets/vpiecegrainline_p.h @@ -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; }