Switch parent for class VLayoutDetail to VAbstractPiece.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-22 10:50:23 +02:00
parent 8fb6c9c508
commit c6f529992b
5 changed files with 38 additions and 26 deletions

View File

@ -203,6 +203,8 @@ private:
static qreal AngleBetweenBisectors(const QLineF &b1, const QLineF &b2); 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. * @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant.

View File

@ -59,12 +59,12 @@ class VAbstractPattern;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutDetail::VLayoutDetail() VLayoutDetail::VLayoutDetail()
:VAbstractDetail(), d(new VLayoutDetailData) :VAbstractPiece(), d(new VLayoutDetailData)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail) 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; return *this;
} }
VAbstractDetail::operator=(detail); VAbstractPiece::operator=(detail);
d = detail.d; d = detail.d;
return *this; return *this;
} }
@ -88,8 +88,8 @@ VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *patte
{ {
VLayoutDetail det = VLayoutDetail(); VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(piece.MainPathPoints(pattern)); det.SetCountourPoints(piece.MainPathPoints(pattern));
det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance(), false); det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance());
det.setName(piece.GetName()); det.SetName(piece.GetName());
const VPatternPieceData& data = piece.GetPatternPieceData(); const VPatternPieceData& data = piece.GetPatternPieceData();
if (data.IsVisible() == true) if (data.IsVisible() == true)
{ {
@ -111,9 +111,9 @@ VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *patte
{ {
det.SetGrainline(grainlineGeom, *pattern); det.SetGrainline(grainlineGeom, *pattern);
} }
det.setWidth(qApp->toPixel(piece.GetSAWidth())); det.SetSAWidth(qApp->toPixel(piece.GetSAWidth()));
det.CreateTextItems(); det.CreateTextItems();
det.setForbidFlipping(piece.IsForbidFlipping()); det.SetForbidFlipping(piece.IsForbidFlipping());
return det; return det;
} }
@ -139,12 +139,11 @@ QVector<QPointF> VLayoutDetail::GetSeamAllowencePoints() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence, bool closed) void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence)
{ {
if (seamAllowence) if (seamAllowence)
{ {
setSeamAllowance(seamAllowence); SetSeamAllowance(seamAllowence);
setClosed(closed);
d->seamAllowence = points; d->seamAllowence = points;
if (not d->seamAllowence.isEmpty()) if (not d->seamAllowence.isEmpty())
{ {
@ -153,7 +152,7 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points, bool
else else
{ {
qWarning()<<"Seam allowence is empty."; qWarning()<<"Seam allowence is empty.";
setSeamAllowance(false); SetSeamAllowance(false);
} }
} }
} }
@ -401,7 +400,7 @@ int VLayoutDetail::LayoutEdgeByPoint(const QPointF &p1) const
QRectF VLayoutDetail::DetailBoundingRect() const QRectF VLayoutDetail::DetailBoundingRect() const
{ {
QVector<QPointF> points; QVector<QPointF> points;
if (getSeamAllowance()) if (IsSeamAllowance())
{ {
points = GetSeamAllowencePoints(); points = GetSeamAllowencePoints();
} }
@ -434,7 +433,7 @@ bool VLayoutDetail::isNull() const
{ {
if (d->contour.isEmpty() == false && d->layoutWidth > 0) if (d->contour.isEmpty() == false && d->layoutWidth > 0)
{ {
if (getSeamAllowance() && d->seamAllowence.isEmpty() == false) if (IsSeamAllowance() && d->seamAllowence.isEmpty() == false)
{ {
return false; return false;
} }
@ -468,10 +467,9 @@ void VLayoutDetail::SetLayoutAllowencePoints()
{ {
if (d->layoutWidth > 0) if (d->layoutWidth > 0)
{ {
if (getSeamAllowance()) if (IsSeamAllowance())
{ {
d->layoutAllowence = Equidistant(GetSeamAllowencePoints(), EquidistantType::CloseEquidistant, d->layoutAllowence = Equidistant(PrepareAllowance(GetSeamAllowencePoints()), d->layoutWidth);
d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false) if (d->layoutAllowence.isEmpty() == false)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
@ -483,7 +481,7 @@ void VLayoutDetail::SetLayoutAllowencePoints()
} }
else else
{ {
d->layoutAllowence = Equidistant(GetContourPoints(), EquidistantType::CloseEquidistant, d->layoutWidth); d->layoutAllowence = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth);
if (d->layoutAllowence.isEmpty() == false) if (d->layoutAllowence.isEmpty() == false)
{ {
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
@ -547,13 +545,13 @@ QPainterPath VLayoutDetail::ContourPath() const
path.lineTo(points.at(0)); path.lineTo(points.at(0));
// seam allowence // seam allowence
if (getSeamAllowance() == true) if (IsSeamAllowance() == true)
{ {
points = GetSeamAllowencePoints(); 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; QPainterPath ekv;
@ -799,7 +797,7 @@ QGraphicsItem* VLayoutDetail::GetGrainlineItem() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutDetail::DetailPath() const QVector<QPointF> VLayoutDetail::DetailPath() const
{ {
if (getSeamAllowance()) if (IsSeamAllowance())
{ {
return d->seamAllowence; return d->seamAllowence;
} }
@ -809,6 +807,17 @@ QVector<QPointF> VLayoutDetail::DetailPath() const
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<VSAPoint> VLayoutDetail::PrepareAllowance(const QVector<QPointF> &points)
{
QVector<VSAPoint> allowancePoints;
for(int i = 0; i < points.size(); +i)
{
allowancePoints.append(VSAPoint(points.at(i)));
}
return allowancePoints;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VLayoutDetail::IsMirror() const bool VLayoutDetail::IsMirror() const
{ {

View File

@ -45,7 +45,7 @@
#include "../vpatterndb/vpatterninfogeometry.h" #include "../vpatterndb/vpatterninfogeometry.h"
#include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vpatternpiecedata.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "vabstractdetail.h" #include "vabstractpiece.h"
class QFont; class QFont;
class QGraphicsItem; class QGraphicsItem;
@ -60,7 +60,7 @@ class VPatternInfoGeometry;
class VPatternPieceData; class VPatternPieceData;
class VGrainlineGeometry; class VGrainlineGeometry;
class VLayoutDetail :public VAbstractDetail class VLayoutDetail :public VAbstractPiece
{ {
public: public:
VLayoutDetail(); VLayoutDetail();
@ -74,7 +74,7 @@ public:
void SetCountourPoints(const QVector<QPointF> &points); void SetCountourPoints(const QVector<QPointF> &points);
QVector<QPointF> GetSeamAllowencePoints() const; QVector<QPointF> GetSeamAllowencePoints() const;
void SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence = true, bool closed = true); void SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence = true);
QVector<QPointF> GetLayoutAllowencePoints() const; QVector<QPointF> GetLayoutAllowencePoints() const;
void SetLayoutAllowencePoints(); void SetLayoutAllowencePoints();
@ -128,6 +128,7 @@ private:
QVector<QPointF> DetailPath() const; QVector<QPointF> DetailPath() const;
static QVector<VSAPoint> PrepareAllowance(const QVector<QPointF> &points);
QVector<QPointF> Map(const QVector<QPointF> &points) const; QVector<QPointF> Map(const QVector<QPointF> &points) const;
static QVector<QPointF> RoundPoints(const QVector<QPointF> &points); static QVector<QPointF> RoundPoints(const QVector<QPointF> &points);

View File

@ -198,7 +198,7 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, volatile bool &sto
return false;//Not enough edges 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. { // Compensate forbidden flipping by rotating. 180 degree will be enough.
d->localRotate = true; d->localRotate = true;
d->localRotationIncrease = 180; d->localRotationIncrease = 180;

View File

@ -294,7 +294,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge)
break; break;
} }
if (flagMirror && not detail.getForbidFlipping()) if (flagMirror && not detail.IsForbidFlipping())
{ {
#ifdef LAYOUT_DEBUG #ifdef LAYOUT_DEBUG
#ifdef SHOW_MIRROR #ifdef SHOW_MIRROR