Layout now works with passmarks.
--HG-- branch : feature
This commit is contained in:
parent
f05cd909a2
commit
b62aaaf992
|
@ -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)
|
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.SetCountourPoints(piece.MainPathPoints(pattern));
|
||||||
det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance());
|
det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance());
|
||||||
det.SetInternalPaths(ConvertInternalPaths(piece, pattern));
|
det.SetInternalPaths(ConvertInternalPaths(piece, pattern));
|
||||||
|
det.SetPassmarks(piece.PassmarksLines(pattern));
|
||||||
|
|
||||||
det.SetName(piece.GetName());
|
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
|
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)
|
for (int i = 0; i < points.size(); ++i)
|
||||||
{
|
{
|
||||||
p.append(d->matrix.map(points.at(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)
|
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++)
|
for (int k=0, s=list.size(), max=(s/2); k<max; k++)
|
||||||
{
|
{
|
||||||
list.swap(k, s-(1+k));
|
list.swap(k, s-(1+k));
|
||||||
|
@ -853,6 +869,7 @@ QPainterPath VLayoutPiece::ContourPath() const
|
||||||
// seam allowance
|
// seam allowance
|
||||||
if (IsSeamAllowance() == true)
|
if (IsSeamAllowance() == true)
|
||||||
{
|
{
|
||||||
|
// Draw seam allowance
|
||||||
points = GetSeamAllowancePoints();
|
points = GetSeamAllowancePoints();
|
||||||
|
|
||||||
if (points.last().toPoint() != points.first().toPoint())
|
if (points.last().toPoint() != points.first().toPoint())
|
||||||
|
@ -868,6 +885,17 @@ QPainterPath VLayoutPiece::ContourPath() const
|
||||||
}
|
}
|
||||||
|
|
||||||
path.addPath(ekv);
|
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);
|
path.setFillRule(Qt::WindingFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
QVector<QPointF> GetLayoutAllowancePoints() const;
|
QVector<QPointF> GetLayoutAllowancePoints() const;
|
||||||
void SetLayoutAllowancePoints();
|
void SetLayoutAllowancePoints();
|
||||||
|
|
||||||
|
QVector<QLineF> GetPassmarks() const;
|
||||||
|
void SetPassmarks(const QVector<QLineF> &passmarks);
|
||||||
|
|
||||||
QVector<VLayoutPiecePath> GetInternalPaths() const;
|
QVector<VLayoutPiecePath> GetInternalPaths() const;
|
||||||
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
|
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
|
||||||
|
|
||||||
|
@ -128,7 +131,8 @@ private:
|
||||||
void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
|
void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
|
||||||
void CreateGrainlineItem(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;
|
QLineF Edge(const QVector<QPointF> &path, int i) const;
|
||||||
int EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const;
|
int EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const;
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
: contour(),
|
: contour(),
|
||||||
seamAllowance(),
|
seamAllowance(),
|
||||||
layoutAllowance(),
|
layoutAllowance(),
|
||||||
|
passmarks(),
|
||||||
m_internalPaths(),
|
m_internalPaths(),
|
||||||
matrix(),
|
matrix(),
|
||||||
layoutWidth(0),
|
layoutWidth(0),
|
||||||
|
@ -68,6 +69,7 @@ public:
|
||||||
contour(detail.contour),
|
contour(detail.contour),
|
||||||
seamAllowance(detail.seamAllowance),
|
seamAllowance(detail.seamAllowance),
|
||||||
layoutAllowance(detail.layoutAllowance),
|
layoutAllowance(detail.layoutAllowance),
|
||||||
|
passmarks(detail.passmarks),
|
||||||
m_internalPaths(detail.m_internalPaths),
|
m_internalPaths(detail.m_internalPaths),
|
||||||
matrix(detail.matrix),
|
matrix(detail.matrix),
|
||||||
layoutWidth(detail.layoutWidth),
|
layoutWidth(detail.layoutWidth),
|
||||||
|
@ -90,6 +92,9 @@ public:
|
||||||
/** @brief layoutAllowance list of layout allowance points. */
|
/** @brief layoutAllowance list of layout allowance points. */
|
||||||
QVector<QPointF> layoutAllowance;
|
QVector<QPointF> layoutAllowance;
|
||||||
|
|
||||||
|
/** @brief passmarks list of passmakrs. */
|
||||||
|
QVector<QLineF> passmarks;
|
||||||
|
|
||||||
/** @brief m_internalPaths list of internal paths. */
|
/** @brief m_internalPaths list of internal paths. */
|
||||||
QVector<VLayoutPiecePath> m_internalPaths;
|
QVector<VLayoutPiecePath> m_internalPaths;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user