56 #include "../vgeometry/vpointf.h"
57 #include "../vlayout/vabstractpiece.h"
59 #include <QPainterPath>
87 return CurvePoint(candidate, data, node, curvePoints);
95 if (!points.isEmpty())
98 node.
GetReverse() ? end = points.first() : end = points.last();
114 return CurvePoint(candidate, data, node, curvePoints);
122 if (!points.isEmpty())
125 node.
GetReverse() ? begin = points.last() : begin = points.first();
144 for (
int i = 0; i < list.size(); ++i)
146 if (list.at(i).GetId() ==
id)
151 qDebug()<<
"Can't find node.";
158 #ifdef Q_COMPILER_RVALUE_REFS
160 { Swap(path);
return *
this; }
164 { std::swap(d, path.d); }
199 d->m_nodes.append(node);
211 return d->m_nodes.size();
217 return d->m_nodes[indx];
223 return d->m_nodes.at(indx);
302 points.append(
static_cast<QPointF
>(*point));
313 const QPointF end =
EndSegment(data, i,
at(i).GetReverse());
315 points << curve->GetSegmentPoints(begin, end,
at(i).GetReverse());
319 qDebug() <<
"Got wrong tool type. Ignore." <<
static_cast<char>(
at(i).
GetTypeTool());
340 points.append(*point);
362 for (
int i = 0; i<
d->m_nodes.size(); ++i)
382 qDebug() <<
"Got wrong tool type. Ignore." <<
static_cast<char>(node.
GetTypeTool());
401 if (!points.isEmpty())
403 path.addPolygon(QPolygonF(points));
404 path.setFillRule(Qt::WindingFill);
413 if (i < 0 || i > nodes.size()-1)
421 if (points.isEmpty())
427 reverse ? begin =
VSAPoint(points.last()) : begin =
VSAPoint(points.first());
429 if (nodes.size() > 1)
433 if (index != i && index != -1)
444 if (i < 0 || i > nodes.size()-1)
452 if (points.isEmpty())
460 if (nodes.size() > 2)
464 if (index != i && index != -1)
481 for (qint32 i = 0; i <
d->m_nodes.size(); ++i)
483 set1.insert(
d->m_nodes.at(i).GetId());
487 for (qint32 j = 0; j < path.
CountNodes(); ++j)
489 set2.insert(path.
at(j).
GetId());
494 for (qint32 i = 0; i < set3.size(); ++i)
499 nodes.append(
d->m_nodes.at(index).GetId());
522 if (index >
static_cast<quint32
>(list.size()))
524 qDebug()<<
"Wrong edge index index ="<<index;
527 p1 = list.at(
static_cast<int>(index));
528 if (index + 1 >
static_cast<quint32
>(list.size()) - 1)
534 p2 = list.at(
static_cast<int>(index+1));
541 for (
int i = 0; i <
d->m_nodes.size(); ++i)
543 if (
d->m_nodes.at(i).GetId() ==
id)
564 qDebug()<<
"Not enough points.";
570 if (i == list.size() - 1)
577 j1 = list.size() - 1;
586 if (list.at(j1).GetId() == p2 || list.at(j2).GetId() == p2)
606 if (
OnEdge(p1, p2) ==
false)
608 qDebug()<<
"Points don't on edge.";
616 int min = qMin(i, j);
618 if (min == 0 && (i == list.size() - 1 || j == list.size() - 1))
620 return list.size() - 1;
636 for (
int i = 0; i <
d->m_nodes.size(); ++i)
640 list.append(
d->m_nodes.at(i));
658 const quint32 edges =
static_cast<quint32
>(
ListNodePoint().size());
660 for (quint32 i=0; i<edges; ++i)
664 path.
Append(this->
at(
static_cast<int>(k)));
678 for (
int j=j1; j<j2; ++j)
703 if (i < 0 || i >
d->m_nodes.size()-1)
708 if (
d->m_nodes.size() > 1)
713 index =
d->m_nodes.size()-1;
736 if (points.size() > 1)
738 return points.at(points.size()-2);
743 qDebug() <<
"Got wrong tool type. Ignore." <<
static_cast<char>(node.
GetTypeTool());
755 if (i < 0 || i >
d->m_nodes.size()-1)
760 if (
d->m_nodes.size() > 1)
763 if (i ==
d->m_nodes.size() - 1)
788 if (points.size() > 1)
795 qDebug()<<
"Got wrong tool type. Ignore."<<
static_cast<char>(node.
GetTypeTool());
806 for (
int i = 0; i < nodes.size(); ++i)
808 if (nodes.at(i).GetId() ==
id)
813 qDebug()<<
"Can't find node.";
820 if (start < 0 || start >= nodes.size())
825 int i = (start == 0) ? nodes.size()-1 : start-1;
827 if (i < 0 || i >= nodes.size())
836 if (!nodes.at(i).isExcluded())
846 i = nodes.size() - 1;
848 }
while (checked < nodes.size());
850 return (!found) ? -1 : i;
856 if (start < 0 || start >= nodes.size())
861 int i = (start == nodes.size()-1) ? 0 : start+1;
863 if (i < 0 || i >= nodes.size())
872 if (!nodes.at(i).isExcluded())
880 if (i >= nodes.size())
884 }
while (checked < nodes.size());
886 return (!found) ? -1 : i;
907 bool reverse, qreal width)
914 const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, reverse);
915 if (points.isEmpty())
922 if (w1 < 0 && w2 < 0)
924 for(
int i = 0; i < points.size(); ++i)
933 else if (i == points.size() - 1)
954 const qreal wDiff = w2 - w1;
965 for(
int i = 1; i < points.size(); ++i)
969 if (i == points.size() - 1)
977 length += QLineF(points.at(i-1), points.at(i)).length();
978 const qreal localWidth = w1 + wDiff*(length/fullLength);
static qreal PathLength(const QVector< QPointF > &path)
static bool isPointOnCurve(const QVector< QPointF > &points, const QPointF &p)
The VContainer class container of all variables.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
const Unit * GetPatternUnit() const
static QVector< T > GetReversePoints(const QVector< T > &points)
GetReversePoint return revers container of points.
qreal GetSABefore(const VContainer *data) const
PieceNodeAngle GetAngleType() const
qreal GetSAAfter(const VContainer *data) const
QVector< QPointF > PathPoints(const VContainer *data) const
PiecePathType GetType() const
bool Contains(quint32 id) const
void SetType(PiecePathType type)
QVector< VSAPoint > SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const
qint32 CountNodes() const
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
NodeOnEdge return nodes located on edge with index.
QSharedDataPointer< VPiecePathData > d
VPiecePath & operator=(const VPiecePath &path)
void SetCutPath(bool cut)
static QVector< VSAPoint > CurveSeamAllowanceSegment(const VContainer *data, const QVector< VPieceNode > &nodes, const QSharedPointer< VAbstractCurve > &curve, int i, bool reverse, qreal width)
void Append(const VPieceNode &node)
void Swap(VPiecePath &path) Q_DECL_NOTHROW
static int FindInLoopNotExcludedUp(int start, const QVector< VPieceNode > &nodes)
int Edge(quint32 p1, quint32 p2) const
Edge return edge index in detail. Edge is line between two points. If between two points located arcs...
VPieceNode & operator[](int indx)
QVector< VPointF > PathNodePoints(const VContainer *data, bool showExcluded=true) const
QVector< VPieceNode > GetNodes() const
VPiecePath RemoveEdge(quint32 index) const
RemoveEdge return path without edge with index.
QVector< quint32 > MissingNodes(const VPiecePath &path) const
void SetNodes(const QVector< VPieceNode > &nodes)
void SetPenType(const Qt::PenStyle &type)
void SetName(const QString &name)
QPointF NodePreviousPoint(const VContainer *data, int i) const
bool OnEdge(quint32 p1, quint32 p2) const
OnEdge checks if two poins located on the edge. Edge is line between two points. If between two point...
QPointF NodeNextPoint(const VContainer *data, int i) const
Qt::PenStyle GetPenType() const
const VPieceNode & at(int indx) const
static VSAPoint PreparePointEkv(const VPieceNode &node, const VContainer *data)
static int FindInLoopNotExcludedDown(int start, const QVector< VPieceNode > &nodes)
QVector< VPieceNode > ListNodePoint() const
listNodePoint return list nodes only with points.
VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const
int indexOfNode(quint32 id) const
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const
QPainterPath PainterPath(const VContainer *data) const
The VPointF class keep data of point.
The VSAPoint class seam allowance point.
void SetAngleType(PieceNodeAngle value)
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const
Q_DECL_CONSTEXPR qreal GetSABefore() const
void SetSABefore(qreal value)
Q_DECL_CONSTEXPR qreal GetSAAfter() const
void SetSAAfter(qreal value)
VSAPoint CurvePoint(VSAPoint candidate, const VContainer *data, const VPieceNode &node, const QVector< QPointF > &curvePoints)
int IndexOfNode(const QVector< VPieceNode > &list, quint32 id)
indexOfNode return index in list node using id object.
VSAPoint CurveEndPoint(VSAPoint candidate, const VContainer *data, const VPieceNode &node, const QVector< QPointF > &curvePoints)
VSAPoint CurveStartPoint(VSAPoint candidate, const VContainer *data, const VPieceNode &node, const QVector< QPointF > &curvePoints)