diff --git a/ChangeLog.txt b/ChangeLog.txt index e5970b86a..592abbc6e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -38,6 +38,7 @@ - [#262] Automatic Update notification. - [#424] Improve Formula Wizard dialog. - Added "All/None" menu in detail list area for easier handling of many parts. +- [#560] Flipped pattern pieces in Layout. # Version 0.4.5 - [#435] Valentina doesn't change the cursor. diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 6def41607..253185689 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -476,6 +476,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *de } det.setWidth(qApp->toPixel(d.getWidth())); det.CreateTextItems(); + det.setForbidFlipping(d.getForbidFlipping()); listDetails.append(det); ++i; diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 61b45100e..ef5e50824 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -616,6 +616,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); + detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping, "0")); detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 9b8a3e493..c55cd654e 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -17,6 +17,7 @@ schema/pattern/v0.3.1.xsd schema/pattern/v0.3.2.xsd schema/pattern/v0.3.3.xsd + schema/pattern/v0.3.4.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.3.4.xsd b/src/libs/ifc/schema/pattern/v0.3.4.xsd new file mode 100644 index 000000000..98bdfd73e --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.3.4.xsd @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 731f47a14..33b652163 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -58,8 +58,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.3"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.3.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.4"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.4.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -165,6 +165,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000302): return QStringLiteral("://schema/pattern/v0.3.2.xsd"); case (0x000303): + return QStringLiteral("://schema/pattern/v0.3.3.xsd"); + case (0x000304): return CurrentSchema; default: InvalidVersion(ver); @@ -244,6 +246,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000303), fileName); V_FALLTHROUGH case (0x000303): + ToV0_3_4(); + ValidateXML(XSDSchema(0x000304), fileName); + V_FALLTHROUGH + case (0x000304): break; default: break; @@ -397,6 +403,13 @@ void VPatternConverter::ToV0_3_3() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_3_4() +{ + SetVersion(QStringLiteral("0.3.4")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index bbb307a79..b4af935ac 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 3); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 3); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4); #endif protected: @@ -92,6 +92,7 @@ private: void ToV0_3_1(); void ToV0_3_2(); void ToV0_3_3(); + void ToV0_3_4(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vlayout/vabstractdetail.cpp b/src/libs/vlayout/vabstractdetail.cpp index 36bc71826..967581e0f 100644 --- a/src/libs/vlayout/vabstractdetail.cpp +++ b/src/libs/vlayout/vabstractdetail.cpp @@ -178,6 +178,18 @@ void VAbstractDetail::setWidth(const qreal &value) d->width = value; } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractDetail::getForbidFlipping() const +{ + return d->forbidFlipping; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractDetail::setForbidFlipping(bool value) +{ + d->forbidFlipping = value; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VAbstractDetail::Equidistant(const QVector &points, const EquidistantType &eqv, qreal width) { diff --git a/src/libs/vlayout/vabstractdetail.h b/src/libs/vlayout/vabstractdetail.h index 25324a1f8..b73ba99bd 100644 --- a/src/libs/vlayout/vabstractdetail.h +++ b/src/libs/vlayout/vabstractdetail.h @@ -67,6 +67,9 @@ public: qreal getWidth() const; void setWidth(const qreal &value); + bool getForbidFlipping() const; + void setForbidFlipping(bool value); + static QVector Equidistant(const QVector &points, const EquidistantType &eqv, qreal width); static qreal SumTrapezoids(const QVector &points); static QVector CheckLoops(const QVector &points); diff --git a/src/libs/vlayout/vabstractdetail_p.h b/src/libs/vlayout/vabstractdetail_p.h index a84bb5980..54fded0b3 100644 --- a/src/libs/vlayout/vabstractdetail_p.h +++ b/src/libs/vlayout/vabstractdetail_p.h @@ -41,16 +41,16 @@ class VAbstractDetailData : public QSharedData { public: VAbstractDetailData() - :name(QString()), seamAllowance(false), closed(true), width(0) + :name(QString()), seamAllowance(false), closed(true), width(0), forbidFlipping(false) {} explicit VAbstractDetailData(const QString &name) - :name(name), seamAllowance(false), closed(true), width(0) + :name(name), seamAllowance(false), closed(true), width(0), forbidFlipping(false) {} VAbstractDetailData(const VAbstractDetailData &detail) :QSharedData(detail), name(detail.name), seamAllowance(detail.seamAllowance), closed(detail.closed), - width(detail.width) + width(detail.width), forbidFlipping(detail.forbidFlipping) {} ~VAbstractDetailData() {} @@ -63,6 +63,8 @@ public: bool closed; /** @brief width value seamAllowance in mm. */ qreal width; + /** @brief forbidFlipping forbid piece be mirrored in a layout. */ + bool forbidFlipping; private: VAbstractDetailData &operator=(const VAbstractDetailData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index f28787391..2b62ccfe7 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -250,6 +250,20 @@ qreal VBank::GetBiggestDiagonal() const return diagonal; } +//--------------------------------------------------------------------------------------------------------------------- +bool VBank::IsForbiddenFlipping() const +{ + for (int i = 0; i < details.size(); ++i) + { + if (details.at(i).getForbidFlipping()) + { + return true; + } + } + + return false; +} + //--------------------------------------------------------------------------------------------------------------------- int VBank::ArrangedCount() const { diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index 51cd7e312..fdbc8a765 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -72,6 +72,8 @@ public: qreal GetBiggestDiagonal() const; + bool IsForbiddenFlipping() const; + private: Q_DISABLE_COPY(VBank) QVector details; diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index ed0359639..7179851bb 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -85,6 +85,12 @@ void VLayoutGenerator::Generate() papers.clear(); state = LayoutErrors::NoError; + if (bank->IsForbiddenFlipping() && not rotate) + { // Compensate forbidden flipping by rotating. 180 degree will be enough. + rotate = true; + rotationIncrease = 180; + } + #ifdef LAYOUT_DEBUG const QString path = QDir::homePath()+QStringLiteral("/LayoutDebug"); QDir debugDir(path); diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index c1288551d..ef7afd472 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -294,7 +294,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) break; } - if (flagMirror) + if (flagMirror && not detail.getForbidFlipping()) { #ifdef LAYOUT_DEBUG #ifdef SHOW_MIRROR diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 2bea5c536..fa1993949 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -442,6 +442,7 @@ VDetail DialogDetail::CreateDetail() const detail.setName(ui.lineEditName->text()); detail.setSeamAllowance(supplement); detail.setClosed(closed); + detail.setForbidFlipping(ui.checkBoxForbidFlipping->isChecked()); detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text()); @@ -510,6 +511,7 @@ void DialogDetail::setDetail(const VDetail &value) ui.lineEditName->setText(detail.getName()); ui.checkBoxSeams->setChecked(detail.getSeamAllowance()); ui.checkBoxClosed->setChecked(detail.getClosed()); + ui.checkBoxForbidFlipping->setChecked(detail.getForbidFlipping()); ClickedClosed(detail.getClosed()); ClickedSeams(detail.getSeamAllowance()); ui.doubleSpinBoxSeams->setValue(detail.getWidth()); diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index 49bca0cf7..6c9496446 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -7,7 +7,7 @@ 0 0 581 - 442 + 468 @@ -24,7 +24,7 @@ - 1 + 0 @@ -66,7 +66,7 @@ Qt::Horizontal - + @@ -186,6 +186,16 @@ Options + + + + Forbid piece be mirrored in a layout. + + + Forbid flipping + + + @@ -361,7 +371,7 @@ Qt::Horizontal - + diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 2b5e4f35e..313ef38ee 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -112,24 +112,25 @@ class QStyleOptionGraphicsItem; class QWidget; class VDataTool; -const QString VToolDetail::TagNode = QStringLiteral("node"); +const QString VToolDetail::TagNode = QStringLiteral("node"); -const QString VToolDetail::AttrSupplement = QStringLiteral("supplement"); -const QString VToolDetail::AttrClosed = QStringLiteral("closed"); -const QString VToolDetail::AttrWidth = QStringLiteral("width"); -const QString VToolDetail::AttrHeight = QStringLiteral("height"); -const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType"); -const QString VToolDetail::AttrReverse = QStringLiteral("reverse"); -const QString VToolDetail::AttrFont = QStringLiteral("fontSize"); -const QString VToolDetail::AttrRotation = QStringLiteral("rotation"); +const QString VToolDetail::AttrSupplement = QStringLiteral("supplement"); +const QString VToolDetail::AttrClosed = QStringLiteral("closed"); +const QString VToolDetail::AttrForbidFlipping = QStringLiteral("forbidFlipping"); +const QString VToolDetail::AttrWidth = QStringLiteral("width"); +const QString VToolDetail::AttrHeight = QStringLiteral("height"); +const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType"); +const QString VToolDetail::AttrReverse = QStringLiteral("reverse"); +const QString VToolDetail::AttrFont = QStringLiteral("fontSize"); +const QString VToolDetail::AttrRotation = QStringLiteral("rotation"); -const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); -const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); +const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour"); +const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling"); -const QString VToolDetail::NodeArc = QStringLiteral("NodeArc"); -const QString VToolDetail::NodePoint = QStringLiteral("NodePoint"); -const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline"); -const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); +const QString VToolDetail::NodeArc = QStringLiteral("NodeArc"); +const QString VToolDetail::NodePoint = QStringLiteral("NodePoint"); +const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline"); +const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); //--------------------------------------------------------------------------------------------------------------------- /** @@ -306,6 +307,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac det.setWidth(detail.getWidth()); det.setClosed(detail.getClosed()); det.setSeamAllowance(detail.getSeamAllowance()); + det.setForbidFlipping(detail.getForbidFlipping()); Create(0, det, scene, doc, data, Document::FullParse, Source::FromGui); } @@ -432,6 +434,11 @@ void VToolDetail::AddToFile() doc->SetAttribute(domElement, AttrClosed, static_cast(detail.getClosed())); doc->SetAttribute(domElement, AttrWidth, detail.getWidth()); + if (detail.getForbidFlipping())//for backward compatibility + { + doc->SetAttribute(domElement, AttrForbidFlipping, static_cast(detail.getForbidFlipping())); + } + QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = detail.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); @@ -452,10 +459,6 @@ void VToolDetail::AddToFile() { doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef); } - else - { - domMCP.removeAttribute(VAbstractPattern::AttrUserDefined); - } doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber); doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement)); domData.appendChild(domMCP); diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index 250129deb..b2b19e5ed 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -72,6 +72,7 @@ public: static const QString TagNode; static const QString AttrSupplement; static const QString AttrClosed; + static const QString AttrForbidFlipping; static const QString AttrWidth; static const QString AttrHeight; static const QString AttrNodeType; diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index e16d4c107..300648f15 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -140,6 +140,15 @@ void SaveDetailOptions::SaveDet(QDomElement &domElement, const VDetail &det) doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(det.getSeamAllowance())); doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(det.getClosed())); doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(det.getWidth())); + + if (det.getForbidFlipping())//for backward compatibility + { + doc->SetAttribute(domElement, VToolDetail::AttrForbidFlipping, QString().setNum(det.getForbidFlipping())); + } + else + { + domElement.removeAttribute(VToolDetail::AttrForbidFlipping); + } } //---------------------------------------------------------------------------------------------------------------------