54 #include <QGraphicsLineItem>
55 #include <QGraphicsPathItem>
57 #include <QPainterPath>
60 #include <QtAlgorithms>
62 #include "../vgeometry/vabstractcurve.h"
63 #include "../vgeometry/vpointf.h"
64 #include "../vgeometry/vspline.h"
65 #include "../visualization.h"
67 #include "../vwidgets/scalesceneitems.h"
75 newCurveSegment(nullptr),
97 const int size = pathPoints.size();
102 for (
int i = 0; i < size; ++i)
121 if (countSubSpl >= 1)
125 for (qint32 i = 1; i<=countSubSpl; ++i)
127 const int preLastPoint = (countSubSpl - 1) * 2;
128 const int lastPoint = preLastPoint + 1;
133 DrawLine(ctrlLine1, QLineF(
static_cast<QPointF
>(spl.
GetP1()),
static_cast<QPointF
>(spl.
GetP2())),
140 DrawLine(ctrlLine2, QLineF(
static_cast<QPointF
>(spl.
GetP4()),
static_cast<QPointF
>(spl.
GetP3())),
170 if (not points.isEmpty() &&
static_cast<quint32
>(points.size() - 1) >= i)
172 return points.at(
static_cast<int>(i));
177 points.append(point);
185 if (
static_cast<quint32
>(
lines.size() - 1) >= i &&
lines.isEmpty() ==
false)
187 return lines.at(
static_cast<int>(i));
191 auto line = InitItem<VScaledLine>(
mainColor,
this);
201 const int size = pathPoints.size();
202 if (pathPoints.isEmpty() || size+1 < pointsLeft)
207 int subSplPoints = 0;
209 if (subSplCount >= 1)
218 const VPointF p1 = pathPoints.last();
219 if (pathPoints.size() >= 4)
222 QLineF prP3p1(
static_cast<QPointF
>(pathPoints.at(size-2)),
static_cast<QPointF
>(p1));
223 p1p2.setAngle(prP3p1.angle());
225 const QPointF p2 = p1p2.p2();
232 const int preLastPoint = subSplCount * 2;
245 const VPointF p1 = pathPoints.at(subSplPoints + pointsLeft-1);
246 QPointF p2 =
static_cast<QPointF
>(pathPoints.at(subSplPoints + pointsLeft));
248 if (subSplCount >= 1)
250 QLineF p1p2(
static_cast<QPointF
>(p1), p2);
251 QLineF prP3p1(
static_cast<QPointF
>(pathPoints.at(subSplPoints + pointsLeft-2)),
252 static_cast<QPointF
>(p1));
253 p1p2.setAngle(prP3p1.angle());
262 const int preLastPoint = subSplCount * 2;
269 const VPointF p1 = pathPoints.at(subSplPoints + pointsLeft-2);
270 QPointF p2 =
static_cast<QPointF
>(pathPoints.at(subSplPoints + pointsLeft-1));
271 const QPointF p3 =
static_cast<QPointF
>(pathPoints.at(subSplPoints + pointsLeft));
273 if (subSplCount >= 1)
275 QLineF p1p2(
static_cast<QPointF
>(p1), p2);
276 QLineF prP3p1(
static_cast<QPointF
>(pathPoints.at(subSplPoints + pointsLeft-3)),
277 static_cast<QPointF
>(p1));
278 p1p2.setAngle(prP3p1.angle());
288 const int preLastPoint = subSplCount * 2;
313 "Press <b>ENTER</b> to finish tool creation");
virtual QPainterPath GetPath() const Q_DECL_OVERRIDE
GetPath return QPainterPath which reprezent spline path.
virtual QVector< DirectionArrow > DirectionArrows() const Q_DECL_OVERRIDE
virtual QPainterPath GetPath() const
The VContainer class container of all variables.
static qint32 SubSplPointsCount(qint32 countSubSpl)
QVector< VPointF > GetCubicPath() const
virtual qint32 CountPoints() const Q_DECL_OVERRIDE
virtual qint32 CountSubSpl() const Q_DECL_OVERRIDE
virtual VSpline GetSpline(qint32 index) const Q_DECL_OVERRIDE
static qint32 SubSplOffset(qint32 subSplIndex)
The VPointF class keep data of point.
VSpline class that implements the spline.
virtual VPointF GetP4() const Q_DECL_OVERRIDE
GetP4 return last spline point.
virtual VPointF GetP1() const Q_DECL_OVERRIDE
GetP1 return first spline point.
virtual VPointF GetP2() const Q_DECL_OVERRIDE
GetP2 return first control point.
virtual VPointF GetP3() const Q_DECL_OVERRIDE
GetP3 return second control point.
void ToolTip(const QString &toolTip)
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style=Qt::SolidLine)
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, Qt::PenStyle style=Qt::SolidLine, const qreal &weight=0.35, Qt::PenCapStyle cap=Qt::SquareCap)
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, const qreal &lineWeight, Qt::PenStyle style=Qt::SolidLine)
VScaledEllipse * InitPoint(const QColor &color, QGraphicsItem *parent, qreal z=0) const