56 #include <QMessageLogger>
57 #include <QPainterPath>
65 #ifdef Q_COMPILER_RVALUE_REFS
67 { Swap(curve);
return *
this; }
100 const QPointF &end,
bool reverse)
108 QPointF start = begin;
109 QPointF finish = end;
113 start = segment.first();
114 finish = segment.last();
118 segment =
ToEnd(segment, finish);
131 if (points.count() >= 2)
133 if (points.first().toPoint() == begin.toPoint())
143 bool theBegin =
false;
144 for (qint32 i = 0; i < points.count()-1; ++i)
146 if (theBegin ==
false)
152 if (begin != points.at(i+1))
154 segment.append(begin);
157 if (i == points.count()-2)
159 segment.append(points.at(i+1));
165 segment.append(points.at(i));
166 if (i == points.count()-2)
168 segment.append(points.at(i+1));
173 if (segment.isEmpty())
214 if (points.count() >= 2)
216 path.addPolygon(QPolygonF(points));
220 qDebug()<<
"points.count() < 2"<<Q_FUNC_INFO;
229 if (points.size() < 2)
234 if (points.first().toPoint() == point.toPoint())
263 return not points.isEmpty();
269 if (points.isEmpty())
273 else if (points.size() < 2)
275 return points.at(0) == p;
279 for (qint32 i = 0; i < points.count()-1; ++i)
306 d->duplicate = number;
331 d->penStyle = penStyle;
341 return d->lineWeight;
351 d->lineWeight = lineWeight;
358 for (
auto i = 0; i < points.count()-1; ++i )
361 const auto type = line.intersects(QLineF(points.at(i), points.at(i+1)), &crosPoint);
362 if ( type == QLineF::BoundedIntersection )
364 intersections.append(crosPoint);
367 return intersections;
376 if (points.count() >= 2)
380 const qreal seek_length = qAbs(
GetLength())/2.0;
381 qreal found_length = 0;
383 for (qint32 i = 1; i <= points.size()-1; ++i)
385 arrow = QLineF(points.at(i-1), points.at(i));
386 found_length += arrow.length();
388 if (seek_length <= found_length)
391 arrow.setLength(arrow.length() - (found_length - seek_length));
397 arrow = QLineF(arrow.p2(), arrow.p1());
398 const qreal angle = arrow.angle();
403 arrow.setAngle(angle-35);
404 dArrow.first = arrow;
406 arrow.setAngle(angle+35);
407 dArrow.second = arrow;
409 arrows.append(dArrow);
419 for (
int i = 0; i < arrows.size(); ++i)
422 if (not arrow.first.isNull() && not arrow.second.isNull())
424 QPainterPath arrowPath;
426 QLineF line = arrow.first;
427 line.setLength(width);
428 arrowPath.moveTo(line.p1());
429 arrowPath.lineTo(line.p2());
432 line.setLength(width);
433 arrowPath.moveTo(line.p1());
434 arrowPath.lineTo(line.p2());
436 path.addPath(arrowPath);
450 QPainterPath splinePath;
451 splinePath.moveTo(path.at(0));
452 for (qint32 i = 1; i < path.count(); ++i)
454 splinePath.lineTo(path.at(i));
456 return splinePath.length();
478 return points.at(points.count() - 1);
QString getLineWeight() const
getLineWeight return weight of the lines
void SetDuplicate(quint32 number)
virtual QVector< DirectionArrow > DirectionArrows() const
virtual ~VAbstractCurve() Q_DECL_OVERRIDE
virtual QVector< QPointF > IntersectLine(const QLineF &line) const
IntersectLine return list of points for real intersection with line.
virtual QVector< QPointF > getPoints() const =0
static qreal PathLength(const QVector< QPointF > &path)
void SetPenStyle(const QString &penStyle)
VAbstractCurve & operator=(const VAbstractCurve &curve)
VAbstractCurve(const GOType &type, const quint32 &idObject=null_id, const Draw &mode=Draw::Calculation)
virtual void CreateName()=0
void setLineColor(const QString &color)
virtual bool IsIntersectLine(const QLineF &line) const
void setLineWeight(const QString &lineWeight)
setLineWeight set weight of the lines
QString GetPenStyle() const
static QVector< QPointF > ToEnd(const QVector< QPointF > &points, const QPointF &end, bool *ok=nullptr)
quint32 GetDuplicate() const
static QVector< QPointF > FromBegin(const QVector< QPointF > &points, const QPointF &begin, bool *ok=nullptr)
void Swap(VAbstractCurve &curve) Q_DECL_NOTHROW
QSharedDataPointer< VAbstractCurveData > d
virtual QPainterPath GetPath() const
static const qreal lengthCurveDirectionArrow
QString getLineColor() const
qreal GetLengthByPoint(const QPointF &point) const
static bool isPointOnCurve(const QVector< QPointF > &points, const QPointF &p)
static QVector< QPointF > CurveIntersectLine(const QVector< QPointF > &points, const QLineF &line)
static QPainterPath ShowDirection(const QVector< DirectionArrow > &arrows, qreal width)
virtual qreal GetLength() const =0
static QVector< QPointF > GetSegmentPoints(const QVector< QPointF > &points, const QPointF &begin, const QPointF &end, bool reverse=false)
The VGObject class keep information graphical objects.
static bool IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2)
IsPointOnLineSegment Check if the point is on the line segment.
VGObject & operator=(const VGObject &obj)
operator = assignment operator.
static QVector< T > GetReversePoints(const QVector< T > &points)
GetReversePoint return revers container of points.
void Swap(VGObject &obj) Q_DECL_NOTHROW
QPair< QLineF, QLineF > DirectionArrow