diff --git a/ChangeLog.txt b/ChangeLog.txt index 2994b7ce2..08af2601c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -15,6 +15,7 @@ - Fix menu on Mac OS X. - Add function's argument template with name in the Formula Wizard. - Unit type for increments. +- Support for options Force Flipping and Forbid Flipping in Puzzle. # Valentina 0.7.51 April 18, 2022 - Z value change for a layout piece. diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index e15ba3039..2f5120ba7 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -127,6 +127,11 @@ VPPiece::VPPiece(const VLayoutPiece &layoutPiece) : VLayoutPiece(layoutPiece) { ClearTransformations(); + + if (IsForceFlipping()) + { + Flip(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 82a35ba90..2c759ca2d 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -1304,6 +1304,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() SetCheckBoxValue(ui->checkBoxCurrentPieceShowSeamline, not selectedPiece->IsHideMainPath()); SetCheckBoxValue(ui->checkBoxCurrentPieceMirrorPiece, selectedPiece->IsMirror()); + const bool disableFlipping = selectedPiece->IsForbidFlipping() || selectedPiece->IsForceFlipping(); + ui->checkBoxCurrentPieceMirrorPiece->setDisabled(disableFlipping); + if (not ui->checkBoxRelativeTranslation->isChecked()) { QRectF rect = PiecesBoundingRect(selectedPieces); diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 7ac1c725f..30572ab0a 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -472,12 +472,10 @@ void VPLayoutFileReader::ReadPiece(const VPPiecePtr &piece) piece->SetXScale(ReadAttributeDouble(attribs, ML::AttrXScale, QChar('1'))); piece->SetYScale(ReadAttributeDouble(attribs, ML::AttrYScale, QChar('1'))); piece->SetZValue(ReadAttributeDouble(attribs, ML::AttrZValue, QChar('1'))); - - bool pieceMirrored = ReadAttributeBool(attribs, ML::AttrMirrored, falseStr); - piece->SetMirror(pieceMirrored); - - QString matrix = ReadAttributeEmptyString(attribs, ML::AttrTransform); - piece->SetMatrix(StringToTransfrom(matrix)); + piece->SetMirror(ReadAttributeBool(attribs, ML::AttrMirrored, falseStr)); + piece->SetForbidFlipping(ReadAttributeBool(attribs, ML::AttrForbidFlipping, falseStr)); + piece->SetForceFlipping(ReadAttributeBool(attribs, ML::AttrForceFlipping, falseStr)); + piece->SetMatrix(StringToTransfrom(ReadAttributeEmptyString(attribs, ML::AttrTransform))); const QStringList tags { diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index aeb58bb80..c8e9d2155 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -263,6 +263,10 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) SetAttribute(ML::AttrName, piece->GetName()); SetAttributeOrRemoveIf(ML::AttrMirrored, piece->IsMirror(), [](bool mirrored) noexcept {return not mirrored;}); + SetAttributeOrRemoveIf(ML::AttrForbidFlipping, piece->IsForbidFlipping(), + [](bool forbid) noexcept {return not forbid;}); + SetAttributeOrRemoveIf(ML::AttrForceFlipping, piece->IsForceFlipping(), + [](bool force) noexcept {return not force;}); SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix())); SetAttributeOrRemoveIf(ML::AttrGradationLabel, piece->GetGradationId(), [](const QString &label) noexcept {return label.isEmpty();}); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 19d811117..4be6d42f2 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -77,6 +77,8 @@ const QString AttrLength = QStringLiteral("length"); const QString AttrFollowGrainline = QStringLiteral("followGrainline"); const QString AttrID = QStringLiteral("id"); const QString AttrMirrored = QStringLiteral("mirrored"); +const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); +const QString AttrForceFlipping = QStringLiteral("forceFlipping"); const QString AttrTransform = QStringLiteral("transform"); const QString AttrShowSeamline = QStringLiteral("showSeamline"); const QString AttrEnabled = QStringLiteral("enabled"); diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index 13645c170..12488150f 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -82,6 +82,8 @@ extern const QString AttrLength; extern const QString AttrFollowGrainline; extern const QString AttrID; extern const QString AttrMirrored; +extern const QString AttrForbidFlipping; +extern const QString AttrForceFlipping; extern const QString AttrTransform; extern const QString AttrShowSeamline; extern const QString AttrEnabled; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index df1ac87b4..4b23cbc4d 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -92,5 +92,6 @@ schema/watermark/v1.1.0.xsd schema/layout/v0.1.0.xsd schema/layout/v0.1.1.xsd + schema/layout/v0.1.2.xsd diff --git a/src/libs/ifc/schema/layout/v0.1.2.xsd b/src/libs/ifc/schema/layout/v0.1.2.xsd new file mode 100644 index 000000000..9c2b0e82b --- /dev/null +++ b/src/libs/ifc/schema/layout/v0.1.2.xsd @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vlayoutconverter.cpp b/src/libs/ifc/xml/vlayoutconverter.cpp index b5326df30..3fd661221 100644 --- a/src/libs/ifc/xml/vlayoutconverter.cpp +++ b/src/libs/ifc/xml/vlayoutconverter.cpp @@ -38,8 +38,8 @@ */ const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0"); -const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.1"); -const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.1.xsd"); +const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.2"); +const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.2.xsd"); //VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -89,7 +89,8 @@ auto VLayoutConverter::XSDSchema(unsigned ver) const -> QString QHash schemas = { std::make_pair(FormatVersion(0, 1, 0), QStringLiteral("://schema/layout/v0.1.0.xsd")), - std::make_pair(FormatVersion(0, 1, 1), CurrentSchema), + std::make_pair(FormatVersion(0, 1, 1), QStringLiteral("://schema/layout/v0.1.1.xsd")), + std::make_pair(FormatVersion(0, 1, 2), CurrentSchema), }; if (schemas.contains(ver)) @@ -106,10 +107,11 @@ void VLayoutConverter::ApplyPatches() switch (m_ver) { case (FormatVersion(0, 1, 0)): - ToV0_1_1(); - ValidateXML(XSDSchema(FormatVersion(0, 1, 1))); - Q_FALLTHROUGH(); case (FormatVersion(0, 1, 1)): + ToV0_1_2(); + ValidateXML(XSDSchema(FormatVersion(0, 1, 12))); + Q_FALLTHROUGH(); + case (FormatVersion(0, 1, 2)): break; default: InvalidVersion(m_ver); @@ -130,12 +132,12 @@ auto VLayoutConverter::IsReadOnly() const -> bool } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutConverter::ToV0_1_1() +void VLayoutConverter::ToV0_1_2() { - // TODO. Delete if minimal supported version is 0.1.1 - Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 1), + // TODO. Delete if minimal supported version is 0.1.2 + Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 2), "Time to refactor the code."); - SetVersion(QStringLiteral("0.1.1")); + SetVersion(QStringLiteral("0.1.2")); Save(); } diff --git a/src/libs/ifc/xml/vlayoutconverter.h b/src/libs/ifc/xml/vlayoutconverter.h index 3cac97f81..3bd43352e 100644 --- a/src/libs/ifc/xml/vlayoutconverter.h +++ b/src/libs/ifc/xml/vlayoutconverter.h @@ -44,7 +44,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, 1); + static Q_DECL_CONSTEXPR const unsigned LayoutMaxVer = FormatVersion(0, 1, 2); protected: void SetVersion(const QString &version) override; @@ -61,7 +61,7 @@ protected: auto IsReadOnly() const -> bool override; - void ToV0_1_1(); + void ToV0_1_2(); private: Q_DISABLE_COPY(VLayoutConverter)