From df20415e9ea7500f4a2dd7ad16ce4bcc421f5751 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Nov 2016 11:56:40 +0200 Subject: [PATCH] Returned "Forbid flipping" feature. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 4 ++-- src/libs/ifc/schema/pattern/v0.4.0.xsd | 1 + src/libs/ifc/xml/vpatternconverter.cpp | 1 - src/libs/vlayout/vabstractpiece.cpp | 12 ++++++++++++ src/libs/vlayout/vabstractpiece.h | 3 +++ src/libs/vlayout/vabstractpiece_p.h | 8 ++++++-- .../vtools/dialogs/tools/dialogseamallowance.cpp | 6 ++++++ src/libs/vtools/dialogs/tools/dialogseamallowance.ui | 10 ++++++++++ src/libs/vtools/tools/vtoolseamallowance.cpp | 6 ++++-- src/libs/vtools/tools/vtoolseamallowance.h | 1 + 10 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index ab13cbeb8..0e6c2852c 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -621,8 +621,8 @@ 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, -// QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); + detail.SetForbidFlipping(GetParametrUInt(domElement, VToolSeamAllowance::AttrForbidFlipping, + QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); const QStringList tags = QStringList() << VToolSeamAllowance::TagNodes diff --git a/src/libs/ifc/schema/pattern/v0.4.0.xsd b/src/libs/ifc/schema/pattern/v0.4.0.xsd index 4cce2e334..bad75d2e5 100644 --- a/src/libs/ifc/schema/pattern/v0.4.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.4.0.xsd @@ -414,6 +414,7 @@ + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 86276b417..95cfab0b3 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -1697,7 +1697,6 @@ void VPatternConverter::TagDetailToV0_4_0() dom.removeAttribute(strSupplement); dom.removeAttribute(strClosed); dom.removeAttribute(strWidth); - dom.removeAttribute(strForbidFlipping); dom.setAttribute(strVersion, "1"); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 5b7cecdf2..18c90e178 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -73,6 +73,18 @@ void VAbstractPiece::SetName(const QString &value) d->m_name = value; } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsForbidFlipping() const +{ + return d->m_forbidFlipping; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetForbidFlipping(bool value) +{ + d->m_forbidFlipping = value; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VAbstractPiece::SumTrapezoids(const QVector &points) { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 491712f58..9bc90aac1 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -47,6 +47,9 @@ public: QString GetName() const; void SetName(const QString &value); + bool IsForbidFlipping() const; + void SetForbidFlipping(bool value); + static qreal SumTrapezoids(const QVector &points); static QVector CheckLoops(const QVector &points); static QVector CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast = true); diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index 470d25ecb..831969199 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -41,17 +41,21 @@ class VAbstractPieceData : public QSharedData { public: VAbstractPieceData() - : m_name() + : m_name(), + m_forbidFlipping(false) {} VAbstractPieceData(const VAbstractPieceData &piece) : QSharedData(piece), - m_name(piece.m_name) + m_name(piece.m_name), + m_forbidFlipping(piece.m_forbidFlipping) {} ~VAbstractPieceData(); QString m_name; + /** @brief forbidFlipping forbid piece be mirrored in a layout. */ + bool m_forbidFlipping; private: VAbstractPieceData &operator=(const VAbstractPieceData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp index 830cd110e..e80cceb72 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -50,6 +50,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & flagError = MainPathIsValid(); CheckState(); + ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping()); + ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu); connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged); @@ -91,6 +93,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) NewItem(m_piece.at(i)); } + ui->checkBoxForbidFlipping->setChecked(m_piece.IsForbidFlipping()); + ValidObjects(MainPathIsValid()); } @@ -260,6 +264,8 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.Append(qvariant_cast(item->data(Qt::UserRole))); } + piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked()); + return piece; } diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui index d2c6808b9..dcf3c2ed6 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui @@ -58,6 +58,16 @@ + + + + Forbid piece be mirrored in a layout. + + + Forbid flipping + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 04dd71ced..c14a61dd9 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -59,8 +59,9 @@ const quint8 VToolSeamAllowance::pieceVersion = 2; const QString VToolSeamAllowance::TagNodes = QStringLiteral("nodes"); const QString VToolSeamAllowance::TagNode = QStringLiteral("node"); -const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); -const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse"); +const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); +const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse"); +const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString VToolSeamAllowance::NodeArc = QStringLiteral("NodeArc"); const QString VToolSeamAllowance::NodePoint = QStringLiteral("NodePoint"); @@ -252,6 +253,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy())); doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout()); + doc->SetAttribute(domElement, AttrForbidFlipping, static_cast(piece.IsForbidFlipping())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 5a3f6d4e9..d5dbba2bd 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -59,6 +59,7 @@ public: static const QString AttrVersion; static const QString AttrNodeReverse; + static const QString AttrForbidFlipping; static const QString NodeArc; static const QString NodePoint;