2014-06-25 16:08:12 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractcurve.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 25 6, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-06-25 16:08:12 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-06-25 16:08:12 +02:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vabstractcurve.h"
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QLine>
|
|
|
|
#include <QLineF>
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QPainterPath>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QtDebug>
|
|
|
|
|
|
|
|
#include "vabstractcurve_p.h"
|
2018-02-06 19:45:07 +01:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2017-06-23 13:18:31 +02:00
|
|
|
|
2014-06-25 16:08:12 +02:00
|
|
|
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
|
2016-02-15 15:30:48 +01:00
|
|
|
:VGObject(type, idObject, mode), d (new VAbstractCurveData())
|
2014-06-25 16:08:12 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve)
|
2016-02-15 15:30:48 +01:00
|
|
|
:VGObject(curve), d (curve.d)
|
2014-06-25 16:08:12 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve)
|
|
|
|
{
|
2014-07-27 14:30:28 +02:00
|
|
|
if ( &curve == this )
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
2014-06-25 16:08:12 +02:00
|
|
|
VGObject::operator=(curve);
|
2016-02-15 15:30:48 +01:00
|
|
|
d = curve.d;
|
2014-06-25 16:08:12 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-02-15 15:30:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VAbstractCurve::~VAbstractCurve()
|
|
|
|
{}
|
|
|
|
|
2014-12-15 15:25:40 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-15 16:38:07 +01:00
|
|
|
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin,
|
|
|
|
const QPointF &end, bool reverse)
|
2014-12-15 15:25:40 +01:00
|
|
|
{
|
2016-03-15 16:38:07 +01:00
|
|
|
QVector<QPointF> segment = points;
|
2014-12-17 13:56:14 +01:00
|
|
|
if (reverse)
|
2014-12-16 14:33:00 +01:00
|
|
|
{
|
2016-03-15 16:38:07 +01:00
|
|
|
segment = GetReversePoints(segment);
|
2014-12-16 14:33:00 +01:00
|
|
|
}
|
2016-03-10 19:18:26 +01:00
|
|
|
|
|
|
|
QPointF start = begin;
|
|
|
|
QPointF finish = end;
|
|
|
|
|
|
|
|
if (begin == end)
|
|
|
|
{
|
2016-03-15 16:38:07 +01:00
|
|
|
start = segment.first();
|
|
|
|
finish = segment.last();
|
2016-03-10 19:18:26 +01:00
|
|
|
}
|
|
|
|
|
2016-03-15 16:38:07 +01:00
|
|
|
segment = FromBegin(segment, start);
|
|
|
|
segment = ToEnd(segment, finish);
|
|
|
|
return segment;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse) const
|
|
|
|
{
|
|
|
|
return GetSegmentPoints(GetPoints(), begin, end, reverse);
|
2014-12-15 15:25:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-02 13:59:43 +02:00
|
|
|
QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok)
|
2014-12-15 15:25:40 +01:00
|
|
|
{
|
|
|
|
if (points.count() >= 2)
|
|
|
|
{
|
2016-04-02 13:59:43 +02:00
|
|
|
if (points.first().toPoint() == begin.toPoint())
|
|
|
|
{
|
|
|
|
if (ok != nullptr)
|
|
|
|
{
|
|
|
|
*ok = true;
|
|
|
|
}
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
2014-12-15 15:25:40 +01:00
|
|
|
QVector<QPointF> segment;
|
|
|
|
bool theBegin = false;
|
|
|
|
for (qint32 i = 0; i < points.count()-1; ++i)
|
|
|
|
{
|
|
|
|
if (theBegin == false)
|
|
|
|
{
|
2016-01-08 16:59:51 +01:00
|
|
|
if (IsPointOnLineSegment(begin, points.at(i), points.at(i+1)))
|
2014-12-15 15:25:40 +01:00
|
|
|
{
|
|
|
|
theBegin = true;
|
2017-08-03 12:43:25 +02:00
|
|
|
|
|
|
|
if (begin != points.at(i+1))
|
|
|
|
{
|
|
|
|
segment.append(begin);
|
|
|
|
}
|
|
|
|
|
2014-12-15 15:25:40 +01:00
|
|
|
if (i == points.count()-2)
|
|
|
|
{
|
|
|
|
segment.append(points.at(i+1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
segment.append(points.at(i));
|
|
|
|
if (i == points.count()-2)
|
|
|
|
{
|
|
|
|
segment.append(points.at(i+1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (segment.isEmpty())
|
|
|
|
{
|
2016-04-02 13:59:43 +02:00
|
|
|
if (ok != nullptr)
|
|
|
|
{
|
|
|
|
*ok = false;
|
|
|
|
}
|
2014-12-15 15:25:40 +01:00
|
|
|
return points;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-02 13:59:43 +02:00
|
|
|
if (ok != nullptr)
|
|
|
|
{
|
|
|
|
*ok = true;
|
|
|
|
}
|
2014-12-15 15:25:40 +01:00
|
|
|
return segment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-02 13:59:43 +02:00
|
|
|
if (ok != nullptr)
|
|
|
|
{
|
|
|
|
*ok = false;
|
|
|
|
}
|
2014-12-15 15:25:40 +01:00
|
|
|
return points;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-02 13:59:43 +02:00
|
|
|
QVector<QPointF> VAbstractCurve::ToEnd(const QVector<QPointF> &points, const QPointF &end, bool *ok)
|
2014-12-15 15:25:40 +01:00
|
|
|
{
|
|
|
|
QVector<QPointF> reversed = GetReversePoints(points);
|
2016-04-02 13:59:43 +02:00
|
|
|
reversed = FromBegin(reversed, end, ok);
|
2014-12-15 15:25:40 +01:00
|
|
|
return GetReversePoints(reversed);
|
|
|
|
}
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-06-23 13:18:31 +02:00
|
|
|
QPainterPath VAbstractCurve::GetPath() const
|
2014-06-25 16:08:12 +02:00
|
|
|
{
|
|
|
|
QPainterPath path;
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
const QVector<QPointF> points = GetPoints();
|
2014-06-25 16:08:12 +02:00
|
|
|
if (points.count() >= 2)
|
|
|
|
{
|
2017-05-16 12:07:53 +02:00
|
|
|
path.addPolygon(QPolygonF(points));
|
2014-06-25 16:08:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug()<<"points.count() < 2"<<Q_FUNC_INFO;
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
2014-08-17 16:22:30 +02:00
|
|
|
|
2016-04-02 13:59:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VAbstractCurve::GetLengthByPoint(const QPointF &point) const
|
|
|
|
{
|
|
|
|
const QVector<QPointF> points = GetPoints();
|
|
|
|
if (points.size() < 2)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (points.first().toPoint() == point.toPoint())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const QVector<QPointF> segment = ToEnd(points, point, &ok);
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return PathLength(segment);
|
|
|
|
}
|
|
|
|
|
2014-10-23 10:38:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief IntersectLine return list of points for real intersection with line
|
|
|
|
* @param line line that intersect with curve
|
|
|
|
* @return list of intersection points
|
|
|
|
*/
|
|
|
|
QVector<QPointF> VAbstractCurve::IntersectLine(const QLineF &line) const
|
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
return CurveIntersectLine(this->GetPoints(), line);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VAbstractCurve::IsIntersectLine(const QLineF &line) const
|
|
|
|
{
|
|
|
|
const QVector<QPointF> points = IntersectLine(line);
|
|
|
|
return not points.isEmpty();
|
|
|
|
}
|
|
|
|
|
2016-11-12 13:00:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-25 12:21:23 +01:00
|
|
|
bool VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPointF &p)
|
2016-11-12 13:00:07 +01:00
|
|
|
{
|
|
|
|
if (points.isEmpty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (points.size() < 2)
|
|
|
|
{
|
|
|
|
return points.at(0) == p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (qint32 i = 0; i < points.count()-1; ++i)
|
|
|
|
{
|
2017-01-25 12:21:23 +01:00
|
|
|
if (IsPointOnLineSegment(p, points.at(i), points.at(i+1)))
|
2016-11-12 13:00:07 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-25 12:21:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VAbstractCurve::IsPointOnCurve(const QPointF &p) const
|
|
|
|
{
|
|
|
|
return IsPointOnCurve(GetPoints(), p);
|
|
|
|
}
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-02-15 15:30:48 +01:00
|
|
|
quint32 VAbstractCurve::GetDuplicate() const
|
|
|
|
{
|
|
|
|
return d->duplicate;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VAbstractCurve::SetDuplicate(quint32 number)
|
|
|
|
{
|
|
|
|
d->duplicate = number;
|
|
|
|
CreateName();
|
|
|
|
}
|
|
|
|
|
2016-05-19 12:11:50 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VAbstractCurve::GetColor() const
|
|
|
|
{
|
|
|
|
return d->color;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VAbstractCurve::SetColor(const QString &color)
|
|
|
|
{
|
|
|
|
d->color = color;
|
|
|
|
}
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VAbstractCurve::GetPenStyle() const
|
|
|
|
{
|
|
|
|
return d->penStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VAbstractCurve::SetPenStyle(const QString &penStyle)
|
|
|
|
{
|
|
|
|
d->penStyle = penStyle;
|
|
|
|
}
|
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VAbstractCurve::GetApproximationScale() const
|
|
|
|
{
|
|
|
|
return d->approximationScale;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VAbstractCurve::SetApproximationScale(qreal value)
|
|
|
|
{
|
|
|
|
d->approximationScale = value;
|
|
|
|
}
|
|
|
|
|
2016-02-15 15:30:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-01-24 17:15:08 +01:00
|
|
|
QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line)
|
|
|
|
{
|
2014-10-23 10:38:57 +02:00
|
|
|
QVector<QPointF> intersections;
|
2016-01-24 17:15:08 +01:00
|
|
|
for ( auto i = 0; i < points.count()-1; ++i )
|
2014-10-23 10:38:57 +02:00
|
|
|
{
|
|
|
|
QPointF crosPoint;
|
2016-01-24 17:15:08 +01:00
|
|
|
const auto type = line.intersect(QLineF(points.at(i), points.at(i+1)), &crosPoint);
|
2014-10-23 10:38:57 +02:00
|
|
|
if ( type == QLineF::BoundedIntersection )
|
|
|
|
{
|
|
|
|
intersections.append(crosPoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return intersections;
|
|
|
|
}
|
|
|
|
|
2018-07-26 19:00:24 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
|
|
|
|
QPointF *intersectionPoint)
|
|
|
|
{
|
|
|
|
SCASSERT(intersectionPoint != nullptr)
|
|
|
|
|
|
|
|
QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX);
|
|
|
|
rec.translate(-INT_MAX/2.0, -INT_MAX/2.0);
|
|
|
|
|
|
|
|
const QLineF axis = VGObject::BuildAxis(point, angle, rec);
|
|
|
|
const QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(curvePoints, axis);
|
|
|
|
|
|
|
|
if (points.size() > 0)
|
|
|
|
{
|
|
|
|
if (points.size() == 1)
|
|
|
|
{
|
|
|
|
*intersectionPoint = points.at(0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMap<qreal, int> forward;
|
|
|
|
QMap<qreal, int> backward;
|
|
|
|
|
|
|
|
for ( qint32 i = 0; i < points.size(); ++i )
|
|
|
|
{
|
|
|
|
if (points.at(i) == point)
|
|
|
|
{ // Always seek unique intersection
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QLineF length(point, points.at(i));
|
|
|
|
if (qAbs(length.angle()-angle) < 0.1)
|
|
|
|
{
|
|
|
|
forward.insert(length.length(), i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backward.insert(length.length(), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Closest point is not always want we need. First return point in forward direction if exists.
|
|
|
|
if (not forward.isEmpty())
|
|
|
|
{
|
|
|
|
*intersectionPoint = points.at(forward.first());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (not backward.isEmpty())
|
|
|
|
{
|
|
|
|
*intersectionPoint = points.at(backward.first());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-17 16:22:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-06-23 13:18:31 +02:00
|
|
|
QVector<DirectionArrow> VAbstractCurve::DirectionArrows() const
|
2014-08-17 16:22:30 +02:00
|
|
|
{
|
2017-06-23 13:18:31 +02:00
|
|
|
QVector<DirectionArrow> arrows;
|
2014-08-17 16:22:30 +02:00
|
|
|
|
2017-06-23 13:18:31 +02:00
|
|
|
const QVector<QPointF> points = GetPoints();
|
2014-08-17 16:22:30 +02:00
|
|
|
if (points.count() >= 2)
|
|
|
|
{
|
|
|
|
/*Need find coordinate midle of curve.
|
|
|
|
Universal way is take all points and find sum.*/
|
2015-06-09 20:23:37 +02:00
|
|
|
const qreal seek_length = qAbs(GetLength())/2.0;
|
2014-08-17 16:22:30 +02:00
|
|
|
qreal found_length = 0;
|
|
|
|
QLineF arrow;
|
|
|
|
for (qint32 i = 1; i <= points.size()-1; ++i)
|
|
|
|
{
|
|
|
|
arrow = QLineF(points.at(i-1), points.at(i));
|
|
|
|
found_length += arrow.length();//Length that we aready find
|
|
|
|
|
|
|
|
if (seek_length <= found_length)// if have found more that need stop.
|
|
|
|
{
|
|
|
|
//subtract length in last line and you will find position of the middle point.
|
|
|
|
arrow.setLength(arrow.length() - (found_length - seek_length));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Reverse line because we want start arrow from this point
|
|
|
|
arrow = QLineF(arrow.p2(), arrow.p1());
|
|
|
|
const qreal angle = arrow.angle();//we each time change line angle, better save original angle value
|
2018-02-06 19:45:07 +01:00
|
|
|
arrow.setLength(VAbstractCurve::LengthCurveDirectionArrow());
|
2017-06-23 13:18:31 +02:00
|
|
|
|
|
|
|
DirectionArrow dArrow;
|
2014-08-17 16:22:30 +02:00
|
|
|
|
|
|
|
arrow.setAngle(angle-35);
|
2017-06-23 13:18:31 +02:00
|
|
|
dArrow.first = arrow;
|
2014-08-17 16:22:30 +02:00
|
|
|
|
|
|
|
arrow.setAngle(angle+35);
|
2017-06-23 13:18:31 +02:00
|
|
|
dArrow.second = arrow;
|
|
|
|
|
|
|
|
arrows.append(dArrow);
|
|
|
|
}
|
|
|
|
return arrows;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal width)
|
|
|
|
{
|
|
|
|
QPainterPath path;
|
|
|
|
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto arrow : arrows)
|
2017-06-23 13:18:31 +02:00
|
|
|
{
|
|
|
|
if (not arrow.first.isNull() && not arrow.second.isNull())
|
|
|
|
{
|
|
|
|
QPainterPath arrowPath;
|
|
|
|
|
|
|
|
QLineF line = arrow.first;
|
|
|
|
line.setLength(width);
|
|
|
|
arrowPath.moveTo(line.p1());
|
|
|
|
arrowPath.lineTo(line.p2());
|
|
|
|
|
|
|
|
line = arrow.second;
|
|
|
|
line.setLength(width);
|
|
|
|
arrowPath.moveTo(line.p1());
|
|
|
|
arrowPath.lineTo(line.p2());
|
|
|
|
|
|
|
|
path.addPath(arrowPath);
|
|
|
|
}
|
2014-08-17 16:22:30 +02:00
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
2016-04-02 13:59:43 +02:00
|
|
|
|
2018-02-06 19:45:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VAbstractCurve::LengthCurveDirectionArrow()
|
|
|
|
{
|
|
|
|
return qApp->Settings()->GetLineWidth() * 8.0;
|
|
|
|
}
|
|
|
|
|
2016-04-02 13:59:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
|
|
|
|
{
|
2016-11-11 19:15:44 +01:00
|
|
|
if (path.size() < 2)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-02 13:59:43 +02:00
|
|
|
QPainterPath splinePath;
|
|
|
|
splinePath.moveTo(path.at(0));
|
|
|
|
for (qint32 i = 1; i < path.count(); ++i)
|
|
|
|
{
|
|
|
|
splinePath.lineTo(path.at(i));
|
|
|
|
}
|
|
|
|
return splinePath.length();
|
|
|
|
}
|