From 850bb88c6b95f5b96606c608e9e0c5f148d084e5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 11 Dec 2017 17:46:13 +0200 Subject: [PATCH] Show warning when a layout allowance is smaller than main piece path. This is usually idicates issue with seam allowance. ref #782. --HG-- branch : develop --- src/app/valentina/mainwindowsnogui.cpp | 8 +++++++- src/libs/vlayout/vlayoutpiece.cpp | 15 +++++++++++++++ src/libs/vlayout/vlayoutpiece.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index badfe2046..d603d9f71 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -742,7 +742,13 @@ QVector MainWindowsNoGUI::PrepareDetailsForLayout(const QHash(VAbstractPattern::getTool(i.key())); SCASSERT(tool != nullptr) - listDetails.append(VLayoutPiece::Create(i.value(), tool->getData())); + const VLayoutPiece piece = VLayoutPiece::Create(i.value(), tool->getData()); + if (not piece.IsLayoutAllowanceValid()) + { + qWarning()<< tr("Piece '%1' may broke a layout. Please, check seam allowance to check how seam " + "allowance behave.").arg(piece.GetName()); + } + listDetails.append(piece); ++i; } } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 05280ec9c..f607c983b 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -1055,6 +1055,21 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const return item; } +//--------------------------------------------------------------------------------------------------------------------- +bool VLayoutPiece::IsLayoutAllowanceValid() const +{ + QVector piecePath; + if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) + { + piecePath = d->seamAllowance; + } + else + { + piecePath = d->contour; + } + return qFloor(qAbs(SumTrapezoids(d->layoutAllowance)/2.0)) >= qFloor(qAbs(SumTrapezoids(piecePath)/2.0)); +} + //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector &labelShape, const VTextManager &tm, bool textAsPaths) const diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index bf88b905a..05a9f96b7 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -138,6 +138,8 @@ public: QPainterPath LayoutAllowancePath() const; Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const; + bool IsLayoutAllowanceValid() const; + private: QSharedDataPointer d;