From a87f821327b80c7a95fc736a524e7ce4383f18b7 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 27 May 2019 17:04:26 +0300 Subject: [PATCH] Introduce mapped versions of methods. In some cases we will do mapping manually. --HG-- branch : develop --- src/libs/vlayout/vlayoutpiece.cpp | 30 ++++++++++++++------ src/libs/vlayout/vlayoutpiece.h | 2 ++ src/libs/vlayout/vposition.cpp | 2 +- src/test/ValentinaTest/tst_vlayoutdetail.cpp | 6 ++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 368ebdc2a..9897266d0 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -467,11 +467,17 @@ QVector VLayoutPiece::Map(QVector VLayoutPiece::GetContourPoints() const +QVector VLayoutPiece::GetMappedContourPoints() const { return Map(d->contour); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPiece::GetContourPoints() const +{ + return d->contour; +} + //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::SetCountourPoints(const QVector &points, bool hideMainPath) { @@ -481,11 +487,17 @@ void VLayoutPiece::SetCountourPoints(const QVector &points, bool hideMa //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction -QVector VLayoutPiece::GetSeamAllowancePoints() const +QVector VLayoutPiece::GetMappedSeamAllowancePoints() const { return Map(d->seamAllowance); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPiece::GetSeamAllowancePoints() const +{ + return d->seamAllowance; +} + //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::SetSeamAllowancePoints(const QVector &points, bool seamAllowance, bool seamAllowanceBuiltIn) { @@ -800,8 +812,8 @@ int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const //--------------------------------------------------------------------------------------------------------------------- QRectF VLayoutPiece::DetailBoundingRect() const { - return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? BoundingRect(GetSeamAllowancePoints()) : - BoundingRect(GetContourPoints()); + return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? BoundingRect(GetMappedSeamAllowancePoints()) : + BoundingRect(GetMappedContourPoints()); } //--------------------------------------------------------------------------------------------------------------------- @@ -850,7 +862,7 @@ void VLayoutPiece::SetLayoutAllowancePoints() { if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) { - d->layoutAllowance = Equidistant(PrepareAllowance(GetSeamAllowancePoints()), d->layoutWidth, GetName()); + d->layoutAllowance = Equidistant(PrepareAllowance(GetMappedSeamAllowancePoints()), d->layoutWidth, GetName()); if (d->layoutAllowance.isEmpty() == false) { d->layoutAllowance.removeLast(); @@ -858,7 +870,7 @@ void VLayoutPiece::SetLayoutAllowancePoints() } else { - d->layoutAllowance = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth, GetName()); + d->layoutAllowance = Equidistant(PrepareAllowance(GetMappedContourPoints()), d->layoutWidth, GetName()); if (d->layoutAllowance.isEmpty() == false) { d->layoutAllowance.removeLast(); @@ -941,7 +953,7 @@ QPainterPath VLayoutPiece::ContourPath() const // contour if (not IsHideMainPath() || not IsSeamAllowance() || IsSeamAllowanceBuiltIn()) { - path = PainterPath(GetContourPoints()); + path = PainterPath(GetMappedContourPoints()); } // seam allowance @@ -950,7 +962,7 @@ QPainterPath VLayoutPiece::ContourPath() const if (not IsSeamAllowanceBuiltIn()) { // Draw seam allowance - QVectorpoints = GetSeamAllowancePoints(); + QVectorpoints = GetMappedSeamAllowancePoints(); if (points.last().toPoint() != points.first().toPoint()) { @@ -1218,7 +1230,7 @@ QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const QPainterPath path; // contour - QVector points = GetContourPoints(); + QVector points = GetMappedContourPoints(); path.moveTo(points.at(0)); for (qint32 i = 1; i < points.count(); ++i) diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index e70783e18..33a67af6f 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -73,9 +73,11 @@ public: static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern); + QVector GetMappedContourPoints() const; QVector GetContourPoints() const; void SetCountourPoints(const QVector &points, bool hideMainPath = false); + QVector GetMappedSeamAllowancePoints() const; QVector GetSeamAllowancePoints() const; void SetSeamAllowancePoints(const QVector &points, bool seamAllowance = true, bool seamAllowanceBuiltIn = false); diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 3ca8ef265..f8544c900 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -494,7 +494,7 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints); const QVector contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ? - detail.GetSeamAllowancePoints() : detail.GetContourPoints(); + detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints(); const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints); const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints); diff --git a/src/test/ValentinaTest/tst_vlayoutdetail.cpp b/src/test/ValentinaTest/tst_vlayoutdetail.cpp index 2007846f8..da57487f6 100644 --- a/src/test/ValentinaTest/tst_vlayoutdetail.cpp +++ b/src/test/ValentinaTest/tst_vlayoutdetail.cpp @@ -60,7 +60,7 @@ void TST_VLayoutDetail::Case1() const det.SetCountourPoints(InputPointsCase1()); // Begin comparison - Comparison(det.GetContourPoints(), OutputPointsCase1()); + Comparison(det.GetMappedContourPoints(), OutputPointsCase1()); } //--------------------------------------------------------------------------------------------------------------------- @@ -122,7 +122,7 @@ void TST_VLayoutDetail::Case2() const det.SetCountourPoints(InputPointsCase2()); // Begin comparison - Comparison(det.GetContourPoints(), OutputPointsCase2()); + Comparison(det.GetMappedContourPoints(), OutputPointsCase2()); } //--------------------------------------------------------------------------------------------------------------------- @@ -163,7 +163,7 @@ void TST_VLayoutDetail::Case3() const det.SetCountourPoints(InputPointsCase3()); // Begin comparison - Comparison(det.GetContourPoints(), OutputPointsCase3()); + Comparison(det.GetMappedContourPoints(), OutputPointsCase3()); } //---------------------------------------------------------------------------------------------------------------------