diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index fd618fe37..a6b0a8dc5 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -203,6 +203,8 @@ private: static qreal AngleBetweenBisectors(const QLineF &b1, const QLineF &b2); }; +Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE); + //--------------------------------------------------------------------------------------------------------------------- /** * @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant. diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index c2042aa33..da6ff54a0 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -59,12 +59,12 @@ class VAbstractPattern; //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail() - :VAbstractDetail(), d(new VLayoutDetailData) + :VAbstractPiece(), d(new VLayoutDetailData) {} //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail) - :VAbstractDetail(detail), d(detail.d) + :VAbstractPiece(detail), d(detail.d) {} //--------------------------------------------------------------------------------------------------------------------- @@ -74,7 +74,7 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) { return *this; } - VAbstractDetail::operator=(detail); + VAbstractPiece::operator=(detail); d = detail.d; return *this; } @@ -88,8 +88,8 @@ VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *patte { VLayoutDetail det = VLayoutDetail(); det.SetCountourPoints(piece.MainPathPoints(pattern)); - det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance(), false); - det.setName(piece.GetName()); + det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance()); + det.SetName(piece.GetName()); const VPatternPieceData& data = piece.GetPatternPieceData(); if (data.IsVisible() == true) { @@ -111,9 +111,9 @@ VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *patte { det.SetGrainline(grainlineGeom, *pattern); } - det.setWidth(qApp->toPixel(piece.GetSAWidth())); + det.SetSAWidth(qApp->toPixel(piece.GetSAWidth())); det.CreateTextItems(); - det.setForbidFlipping(piece.IsForbidFlipping()); + det.SetForbidFlipping(piece.IsForbidFlipping()); return det; } @@ -139,12 +139,11 @@ QVector VLayoutDetail::GetSeamAllowencePoints() const } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool seamAllowence, bool closed) +void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool seamAllowence) { if (seamAllowence) { - setSeamAllowance(seamAllowence); - setClosed(closed); + SetSeamAllowance(seamAllowence); d->seamAllowence = points; if (not d->seamAllowence.isEmpty()) { @@ -153,7 +152,7 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool else { qWarning()<<"Seam allowence is empty."; - setSeamAllowance(false); + SetSeamAllowance(false); } } } @@ -401,7 +400,7 @@ int VLayoutDetail::LayoutEdgeByPoint(const QPointF &p1) const QRectF VLayoutDetail::DetailBoundingRect() const { QVector points; - if (getSeamAllowance()) + if (IsSeamAllowance()) { points = GetSeamAllowencePoints(); } @@ -434,7 +433,7 @@ bool VLayoutDetail::isNull() const { if (d->contour.isEmpty() == false && d->layoutWidth > 0) { - if (getSeamAllowance() && d->seamAllowence.isEmpty() == false) + if (IsSeamAllowance() && d->seamAllowence.isEmpty() == false) { return false; } @@ -468,10 +467,9 @@ void VLayoutDetail::SetLayoutAllowencePoints() { if (d->layoutWidth > 0) { - if (getSeamAllowance()) + if (IsSeamAllowance()) { - d->layoutAllowence = Equidistant(GetSeamAllowencePoints(), EquidistantType::CloseEquidistant, - d->layoutWidth); + d->layoutAllowence = Equidistant(PrepareAllowance(GetSeamAllowencePoints()), d->layoutWidth); if (d->layoutAllowence.isEmpty() == false) { #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) @@ -483,7 +481,7 @@ void VLayoutDetail::SetLayoutAllowencePoints() } else { - d->layoutAllowence = Equidistant(GetContourPoints(), EquidistantType::CloseEquidistant, d->layoutWidth); + d->layoutAllowence = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth); if (d->layoutAllowence.isEmpty() == false) { #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) @@ -547,13 +545,13 @@ QPainterPath VLayoutDetail::ContourPath() const path.lineTo(points.at(0)); // seam allowence - if (getSeamAllowance() == true) + if (IsSeamAllowance() == true) { points = GetSeamAllowencePoints(); - if (getClosed() == true) + if (points.last().toPoint() != points.first().toPoint()) { - points.append(points.at(0)); + points.append(points.at(0));// Should be always closed } QPainterPath ekv; @@ -799,7 +797,7 @@ QGraphicsItem* VLayoutDetail::GetGrainlineItem() const //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutDetail::DetailPath() const { - if (getSeamAllowance()) + if (IsSeamAllowance()) { return d->seamAllowence; } @@ -809,6 +807,17 @@ QVector VLayoutDetail::DetailPath() const } } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutDetail::PrepareAllowance(const QVector &points) +{ + QVector allowancePoints; + for(int i = 0; i < points.size(); +i) + { + allowancePoints.append(VSAPoint(points.at(i))); + } + return allowancePoints; +} + //--------------------------------------------------------------------------------------------------------------------- bool VLayoutDetail::IsMirror() const { diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index f72e67473..138f65184 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -45,7 +45,7 @@ #include "../vpatterndb/vpatterninfogeometry.h" #include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vcontainer.h" -#include "vabstractdetail.h" +#include "vabstractpiece.h" class QFont; class QGraphicsItem; @@ -60,7 +60,7 @@ class VPatternInfoGeometry; class VPatternPieceData; class VGrainlineGeometry; -class VLayoutDetail :public VAbstractDetail +class VLayoutDetail :public VAbstractPiece { public: VLayoutDetail(); @@ -74,7 +74,7 @@ public: void SetCountourPoints(const QVector &points); QVector GetSeamAllowencePoints() const; - void SetSeamAllowencePoints(const QVector &points, bool seamAllowence = true, bool closed = true); + void SetSeamAllowencePoints(const QVector &points, bool seamAllowence = true); QVector GetLayoutAllowencePoints() const; void SetLayoutAllowencePoints(); @@ -128,6 +128,7 @@ private: QVector DetailPath() const; + static QVector PrepareAllowance(const QVector &points); QVector Map(const QVector &points) const; static QVector RoundPoints(const QVector &points); diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 3cd1b4b15..6422faeea 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -198,7 +198,7 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, volatile bool &sto return false;//Not enough edges } - if (detail.getForbidFlipping() && not d->globalRotate) + if (detail.IsForbidFlipping() && not d->globalRotate) { // Compensate forbidden flipping by rotating. 180 degree will be enough. d->localRotate = true; d->localRotationIncrease = 180; diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 9308536f2..6524dddb6 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 && not detail.getForbidFlipping()) + if (flagMirror && not detail.IsForbidFlipping()) { #ifdef LAYOUT_DEBUG #ifdef SHOW_MIRROR