Layout now works with passmarks.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-03-30 13:27:57 +03:00
parent f05cd909a2
commit b62aaaf992
3 changed files with 45 additions and 8 deletions

View File

@ -299,14 +299,13 @@ QVector<QPointF> CorrectPosition(const QRectF &parentBoundingRect, QVector<QPoin
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> RoundPoints(const QVector<QPointF> &points)
QVector<QPointF> RoundPoints(QVector<QPointF> points)
{
QVector<QPointF> p;
for (int i=0; i < points.size(); ++i)
{
p.append(QPointF(qRound(points.at(i).x()), qRound(points.at(i).y())));
points[i] = QPointF(qRound(points.at(i).x()), qRound(points.at(i).y()));
}
return p;
return points;
}
//---------------------------------------------------------------------------------------------------------------------
@ -385,6 +384,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
det.SetCountourPoints(piece.MainPathPoints(pattern));
det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance());
det.SetInternalPaths(ConvertInternalPaths(piece, pattern));
det.SetPassmarks(piece.PassmarksLines(pattern));
det.SetName(piece.GetName());
@ -803,6 +803,21 @@ void VLayoutPiece::SetLayoutAllowancePoints()
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> VLayoutPiece::GetPassmarks() const
{
return Map(d->passmarks);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPassmarks(const QVector<QLineF> &passmarks)
{
if (IsSeamAllowance())
{
d->passmarks = passmarks;
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLayoutPiecePath> VLayoutPiece::GetInternalPaths() const
{
@ -816,9 +831,10 @@ void VLayoutPiece::SetInternalPaths(const QVector<VLayoutPiecePath> &internalPat
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VLayoutPiece::Map(const QVector<QPointF> &points) const
template <class T>
QVector<T> VLayoutPiece::Map(const QVector<T> &points) const
{
QVector<QPointF> p;
QVector<T> p;
for (int i = 0; i < points.size(); ++i)
{
p.append(d->matrix.map(points.at(i)));
@ -826,7 +842,7 @@ QVector<QPointF> VLayoutPiece::Map(const QVector<QPointF> &points) const
if (d->mirror)
{
QList<QPointF> list = p.toList();
QList<T> list = p.toList();
for (int k=0, s=list.size(), max=(s/2); k<max; k++)
{
list.swap(k, s-(1+k));
@ -853,6 +869,7 @@ QPainterPath VLayoutPiece::ContourPath() const
// seam allowance
if (IsSeamAllowance() == true)
{
// Draw seam allowance
points = GetSeamAllowancePoints();
if (points.last().toPoint() != points.first().toPoint())
@ -868,6 +885,17 @@ QPainterPath VLayoutPiece::ContourPath() const
}
path.addPath(ekv);
// Draw passmarks
const QVector<QLineF> passmarks = GetPassmarks();
QPainterPath passmaksPath;
for (qint32 i = 0; i < passmarks.count(); ++i)
{
passmaksPath.moveTo(passmarks.at(i).p1());
passmaksPath.lineTo(passmarks.at(i).p2());
}
path.addPath(passmaksPath);
path.setFillRule(Qt::WindingFill);
}

View File

@ -73,6 +73,9 @@ public:
QVector<QPointF> GetLayoutAllowancePoints() const;
void SetLayoutAllowancePoints();
QVector<QLineF> GetPassmarks() const;
void SetPassmarks(const QVector<QLineF> &passmarks);
QVector<VLayoutPiecePath> GetInternalPaths() const;
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
@ -128,7 +131,8 @@ private:
void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
void CreateGrainlineItem(QGraphicsItem *parent) const;
QVector<QPointF> Map(const QVector<QPointF> &points) const;
template <class T>
QVector<T> Map(const QVector<T> &points) const;
QLineF Edge(const QVector<QPointF> &path, int i) const;
int EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const;

View File

@ -52,6 +52,7 @@ public:
: contour(),
seamAllowance(),
layoutAllowance(),
passmarks(),
m_internalPaths(),
matrix(),
layoutWidth(0),
@ -68,6 +69,7 @@ public:
contour(detail.contour),
seamAllowance(detail.seamAllowance),
layoutAllowance(detail.layoutAllowance),
passmarks(detail.passmarks),
m_internalPaths(detail.m_internalPaths),
matrix(detail.matrix),
layoutWidth(detail.layoutWidth),
@ -90,6 +92,9 @@ public:
/** @brief layoutAllowance list of layout allowance points. */
QVector<QPointF> layoutAllowance;
/** @brief passmarks list of passmakrs. */
QVector<QLineF> passmarks;
/** @brief m_internalPaths list of internal paths. */
QVector<VLayoutPiecePath> m_internalPaths;