Introduce mapped versions of methods. In some cases we will do mapping manually.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-05-27 17:04:26 +03:00
parent 6294dc0748
commit a87f821327
4 changed files with 27 additions and 13 deletions

View File

@ -467,11 +467,17 @@ QVector<VLayoutPassmark> VLayoutPiece::Map<VLayoutPassmark>(QVector<VLayoutPassm
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
QVector<QPointF> VLayoutPiece::GetContourPoints() const QVector<QPointF> VLayoutPiece::GetMappedContourPoints() const
{ {
return Map(d->contour); return Map(d->contour);
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::GetContourPoints() const
{
return d->contour;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetCountourPoints(const QVector<QPointF> &points, bool hideMainPath) void VLayoutPiece::SetCountourPoints(const QVector<QPointF> &points, bool hideMainPath)
{ {
@ -481,11 +487,17 @@ void VLayoutPiece::SetCountourPoints(const QVector<QPointF> &points, bool hideMa
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
QVector<QPointF> VLayoutPiece::GetSeamAllowancePoints() const QVector<QPointF> VLayoutPiece::GetMappedSeamAllowancePoints() const
{ {
return Map(d->seamAllowance); return Map(d->seamAllowance);
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::GetSeamAllowancePoints() const
{
return d->seamAllowance;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance, bool seamAllowanceBuiltIn) void VLayoutPiece::SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance, bool seamAllowanceBuiltIn)
{ {
@ -800,8 +812,8 @@ int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VLayoutPiece::DetailBoundingRect() const QRectF VLayoutPiece::DetailBoundingRect() const
{ {
return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? BoundingRect(GetSeamAllowancePoints()) : return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? BoundingRect(GetMappedSeamAllowancePoints()) :
BoundingRect(GetContourPoints()); BoundingRect(GetMappedContourPoints());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -850,7 +862,7 @@ void VLayoutPiece::SetLayoutAllowancePoints()
{ {
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) 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) if (d->layoutAllowance.isEmpty() == false)
{ {
d->layoutAllowance.removeLast(); d->layoutAllowance.removeLast();
@ -858,7 +870,7 @@ void VLayoutPiece::SetLayoutAllowancePoints()
} }
else else
{ {
d->layoutAllowance = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth, GetName()); d->layoutAllowance = Equidistant(PrepareAllowance(GetMappedContourPoints()), d->layoutWidth, GetName());
if (d->layoutAllowance.isEmpty() == false) if (d->layoutAllowance.isEmpty() == false)
{ {
d->layoutAllowance.removeLast(); d->layoutAllowance.removeLast();
@ -941,7 +953,7 @@ QPainterPath VLayoutPiece::ContourPath() const
// contour // contour
if (not IsHideMainPath() || not IsSeamAllowance() || IsSeamAllowanceBuiltIn()) if (not IsHideMainPath() || not IsSeamAllowance() || IsSeamAllowanceBuiltIn())
{ {
path = PainterPath(GetContourPoints()); path = PainterPath(GetMappedContourPoints());
} }
// seam allowance // seam allowance
@ -950,7 +962,7 @@ QPainterPath VLayoutPiece::ContourPath() const
if (not IsSeamAllowanceBuiltIn()) if (not IsSeamAllowanceBuiltIn())
{ {
// Draw seam allowance // Draw seam allowance
QVector<QPointF>points = GetSeamAllowancePoints(); QVector<QPointF>points = GetMappedSeamAllowancePoints();
if (points.last().toPoint() != points.first().toPoint()) if (points.last().toPoint() != points.first().toPoint())
{ {
@ -1218,7 +1230,7 @@ QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const
QPainterPath path; QPainterPath path;
// contour // contour
QVector<QPointF> points = GetContourPoints(); QVector<QPointF> points = GetMappedContourPoints();
path.moveTo(points.at(0)); path.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i) for (qint32 i = 1; i < points.count(); ++i)

View File

@ -73,9 +73,11 @@ public:
static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern); static VLayoutPiece Create(const VPiece &piece, const VContainer *pattern);
QVector<QPointF> GetMappedContourPoints() const;
QVector<QPointF> GetContourPoints() const; QVector<QPointF> GetContourPoints() const;
void SetCountourPoints(const QVector<QPointF> &points, bool hideMainPath = false); void SetCountourPoints(const QVector<QPointF> &points, bool hideMainPath = false);
QVector<QPointF> GetMappedSeamAllowancePoints() const;
QVector<QPointF> GetSeamAllowancePoints() const; QVector<QPointF> GetSeamAllowancePoints() const;
void SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance = true, void SetSeamAllowancePoints(const QVector<QPointF> &points, bool seamAllowance = true,
bool seamAllowanceBuiltIn = false); bool seamAllowanceBuiltIn = false);

View File

@ -494,7 +494,7 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints); const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ? const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
detail.GetSeamAllowancePoints() : detail.GetContourPoints(); detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints();
const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints); const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints);
const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints); const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints);

View File

@ -60,7 +60,7 @@ void TST_VLayoutDetail::Case1() const
det.SetCountourPoints(InputPointsCase1()); det.SetCountourPoints(InputPointsCase1());
// Begin comparison // Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase1()); Comparison(det.GetMappedContourPoints(), OutputPointsCase1());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -122,7 +122,7 @@ void TST_VLayoutDetail::Case2() const
det.SetCountourPoints(InputPointsCase2()); det.SetCountourPoints(InputPointsCase2());
// Begin comparison // Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase2()); Comparison(det.GetMappedContourPoints(), OutputPointsCase2());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -163,7 +163,7 @@ void TST_VLayoutDetail::Case3() const
det.SetCountourPoints(InputPointsCase3()); det.SetCountourPoints(InputPointsCase3());
// Begin comparison // Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase3()); Comparison(det.GetMappedContourPoints(), OutputPointsCase3());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------