From a5fc19d7ec978bb8a6b68ba977189ab1dbfa3f64 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Nov 2016 12:53:02 +0200 Subject: [PATCH] Returned storing and reading base seam allowance values: width and enable/disable. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 7 +- src/libs/ifc/schema/pattern/v0.4.0.xsd | 4 +- src/libs/ifc/xml/vpatternconverter.cpp | 4 +- src/libs/vlayout/vabstractpiece.cpp | 24 ++++ src/libs/vlayout/vabstractpiece.h | 6 + src/libs/vlayout/vabstractpiece_p.h | 10 +- .../dialogs/tools/dialogseamallowance.cpp | 19 ++++ .../dialogs/tools/dialogseamallowance.h | 1 + .../dialogs/tools/dialogseamallowance.ui | 107 +++++++++++++++++- src/libs/vtools/tools/vtoolseamallowance.cpp | 6 +- src/libs/vtools/tools/vtoolseamallowance.h | 2 + 11 files changed, 180 insertions(+), 10 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 0e6c2852c..84166e993 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -618,10 +618,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document detail.SetName(GetParametrString(domElement, AttrName, tr("Detail"))); detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0"))); detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0"))); -// 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, VToolSeamAllowance::AttrForbidFlipping, + detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr)); + detail.SetSAWidth(GetParametrDouble(domElement, VToolSeamAllowance::AttrWidth, "0.0")); + detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping, QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); diff --git a/src/libs/ifc/schema/pattern/v0.4.0.xsd b/src/libs/ifc/schema/pattern/v0.4.0.xsd index bad75d2e5..ac4a4907c 100644 --- a/src/libs/ifc/schema/pattern/v0.4.0.xsd +++ b/src/libs/ifc/schema/pattern/v0.4.0.xsd @@ -414,7 +414,9 @@ - + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 95cfab0b3..11bc090fd 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -129,6 +129,7 @@ const QString strMx = QStringLiteral("mx"); const QString strMy = QStringLiteral("my"); const QString strForbidFlipping = QStringLiteral("forbidFlipping"); const QString strInLayout = QStringLiteral("inLayout"); +const QString strSeamAllowance = QStringLiteral("seamAllowance"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -1694,9 +1695,10 @@ void VPatternConverter::TagDetailToV0_4_0() if (not dom.isNull()) { + dom.setAttribute(strSeamAllowance, dom.attribute(strSupplement, "0")); dom.removeAttribute(strSupplement); + dom.removeAttribute(strClosed); - dom.removeAttribute(strWidth); dom.setAttribute(strVersion, "1"); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 18c90e178..003235c5b 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -85,6 +85,30 @@ void VAbstractPiece::SetForbidFlipping(bool value) d->m_forbidFlipping = value; } +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPiece::IsSeamAllowance() const +{ + return d->m_seamAllowance; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetSeamAllowance(bool value) +{ + d->m_seamAllowance = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VAbstractPiece::GetSAWidth() const +{ + return d->m_width; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetSAWidth(qreal value) +{ + value >= 0 ? d->m_width = value : d->m_width = 0; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VAbstractPiece::SumTrapezoids(const QVector &points) { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 9bc90aac1..fdf6908c3 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -50,6 +50,12 @@ public: bool IsForbidFlipping() const; void SetForbidFlipping(bool value); + bool IsSeamAllowance() const; + void SetSeamAllowance(bool value); + + qreal GetSAWidth() const; + void SetSAWidth(qreal 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 831969199..745cdca56 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -42,13 +42,17 @@ class VAbstractPieceData : public QSharedData public: VAbstractPieceData() : m_name(), - m_forbidFlipping(false) + m_forbidFlipping(false), + m_seamAllowance(false), + m_width(0) {} VAbstractPieceData(const VAbstractPieceData &piece) : QSharedData(piece), m_name(piece.m_name), - m_forbidFlipping(piece.m_forbidFlipping) + m_forbidFlipping(piece.m_forbidFlipping), + m_seamAllowance(piece.m_seamAllowance), + m_width(piece.m_width) {} ~VAbstractPieceData(); @@ -56,6 +60,8 @@ public: QString m_name; /** @brief forbidFlipping forbid piece be mirrored in a layout. */ bool m_forbidFlipping; + bool m_seamAllowance; + qreal m_width; 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 e80cceb72..b8c42a614 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.cpp @@ -51,10 +51,19 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & CheckState(); ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping()); + ui->labelUnit->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + + if(qApp->patternUnit() == Unit::Inch) + { + ui->doubleSpinBoxSeams->setDecimals(5); + } + // Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough. + ui->doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit())); ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu); connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged); + connect(ui->checkBoxSeams, &QCheckBox::clicked, this, &DialogSeamAllowance::EnableSeamAllowance); if (not applyAllowed) { @@ -94,6 +103,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) } ui->checkBoxForbidFlipping->setChecked(m_piece.IsForbidFlipping()); + ui->doubleSpinBoxSeams->setValue(m_piece.GetSAWidth()); + + EnableSeamAllowance(m_piece.IsSeamAllowance()); ValidObjects(MainPathIsValid()); } @@ -254,6 +266,12 @@ void DialogSeamAllowance::ListChanged() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::EnableSeamAllowance(bool enable) +{ + ui->groupBoxAutomatic->setEnabled(enable); +} + //--------------------------------------------------------------------------------------------------------------------- VPiece DialogSeamAllowance::CreatePiece() const { @@ -265,6 +283,7 @@ VPiece DialogSeamAllowance::CreatePiece() const } piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked()); + piece.SetSAWidth(ui->doubleSpinBoxSeams->value()); return piece; } diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/dialogseamallowance.h index 5657147a5..220894323 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.h @@ -62,6 +62,7 @@ protected: private slots: void ShowContextMenu(const QPoint &pos); void ListChanged(); + void EnableSeamAllowance(bool enable); private: Q_DISABLE_COPY(DialogSeamAllowance) diff --git a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui index dcf3c2ed6..770b89f1d 100644 --- a/src/libs/vtools/dialogs/tools/dialogseamallowance.ui +++ b/src/libs/vtools/dialogs/tools/dialogseamallowance.ui @@ -21,7 +21,7 @@ - 0 + 1 @@ -94,6 +94,111 @@ Seam allowance + + + + + Seam allowance + + + true + + + + + + + false + + + Automatic + + + false + + + + + + + + + 0 + 0 + + + + + + + Width: + + + + + + + + 0 + 0 + + + + 900.990000000000009 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + 0 + 0 + + + + cm + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 219 + + + + + + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index c14a61dd9..e92a573a8 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -62,6 +62,8 @@ const QString VToolSeamAllowance::TagNode = QStringLiteral("node"); const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); +const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance"); +const QString VToolSeamAllowance::AttrWidth = QStringLiteral("width"); const QString VToolSeamAllowance::NodeArc = QStringLiteral("NodeArc"); const QString VToolSeamAllowance::NodePoint = QStringLiteral("NodePoint"); @@ -253,7 +255,9 @@ 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())); + doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping()); + doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance()); + doc->SetAttribute(domElement, AttrWidth, piece.GetSAWidth()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index d5dbba2bd..cbb9eaec3 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -60,6 +60,8 @@ public: static const QString AttrVersion; static const QString AttrNodeReverse; static const QString AttrForbidFlipping; + static const QString AttrSeamAllowance; + static const QString AttrWidth; static const QString NodeArc; static const QString NodePoint;