Seamly2D
Code documentation
VSpline Class Reference

VSpline class that implements the spline. More...

#include <vspline.h>

Inheritance diagram for VSpline:
Collaboration diagram for VSpline:

Public Member Functions

 VSpline ()
 VSpline default constructor. More...
 
 VSpline (const VSpline &spline)
 VSpline constructor. More...
 
 VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, quint32 idObject=0, Draw mode=Draw::Calculation)
 VSpline constructor. More...
 
 VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject=0, Draw mode=Draw::Calculation)
 VSpline constructor. More...
 
 VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2, const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length, const QString &c2LengthFormula, quint32 idObject=0, Draw mode=Draw::Calculation)
 VSpline constructor. More...
 
VSpline Rotate (const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
 
VSpline Flip (const QLineF &axis, const QString &prefix=QString()) const
 
VSpline Move (qreal length, qreal angle, const QString &prefix=QString()) const
 
virtual ~VSpline ()
 
VSplineoperator= (const VSpline &spline)
 
void Swap (VSpline &spline) Q_DECL_NOTHROW
 
virtual VPointF GetP1 () const Q_DECL_OVERRIDE
 GetP1 return first spline point. More...
 
void SetP1 (const VPointF &p)
 
virtual VPointF GetP2 () const Q_DECL_OVERRIDE
 GetP2 return first control point. More...
 
virtual VPointF GetP3 () const Q_DECL_OVERRIDE
 GetP3 return second control point. More...
 
virtual VPointF GetP4 () const Q_DECL_OVERRIDE
 GetP4 return last spline point. More...
 
void SetP4 (const VPointF &p)
 
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE
 GetAngle1 return first angle control line. More...
 
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE
 GetAngle2 return second angle control line. More...
 
QString GetStartAngleFormula () const
 
QString GetEndAngleFormula () const
 
void SetStartAngle (qreal angle, const QString &formula)
 
void SetEndAngle (qreal angle, const QString &formula)
 
virtual qreal GetC1Length () const Q_DECL_OVERRIDE
 
virtual qreal GetC2Length () const Q_DECL_OVERRIDE
 
QString GetC1LengthFormula () const
 
QString GetC2LengthFormula () const
 
void SetC1Length (qreal length, const QString &formula)
 
void SetC2Length (qreal length, const QString &formula)
 
virtual qreal GetLength () const Q_DECL_OVERRIDE
 GetLength return length of spline. More...
 
qreal GetKasm1 () const
 GetKasm1 return coefficient of length first control line. More...
 
qreal GetKasm2 () const
 GetKasm2 return coefficient of length second control line. More...
 
qreal GetKcurve () const
 GetKcurve return coefficient of curvature spline. More...
 
QPointF CutSpline (qreal length, VSpline &spl1, VSpline &spl2) const
 
virtual QVector< QPointF > getPoints () const Q_DECL_OVERRIDE
 GetPoints return list with spline points. More...
 
qreal ParamT (const QPointF &pBt) const
 VSpline::ParamT calculate t coeffient that reprezent point on curve. More...
 
QPointF CutSpline (qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const
 CutSpline cut spline. More...
 
- Public Member Functions inherited from VAbstractCubicBezier
 VAbstractCubicBezier (const GOType &type, const quint32 &idObject=null_id, const Draw &mode=Draw::Calculation)
 
 VAbstractCubicBezier (const VAbstractCubicBezier &curve)
 
VAbstractCubicBezieroperator= (const VAbstractCubicBezier &curve)
 
virtual ~VAbstractCubicBezier ()
 
QPointF CutSpline (qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const
 CutSpline cut spline. More...
 
virtual QString NameForHistory (const QString &toolName) const Q_DECL_OVERRIDE
 
qreal GetParmT (qreal length) const
 
qreal LengthT (qreal t) const
 
- Public Member Functions inherited from VAbstractBezier
 VAbstractBezier (const GOType &type, const quint32 &idObject=null_id, const Draw &mode=Draw::Calculation)
 
 VAbstractBezier (const VAbstractBezier &curve)
 
VAbstractBezieroperator= (const VAbstractBezier &curve)
 
virtual ~VAbstractBezier ()
 
- Public Member Functions inherited from VAbstractCurve
 VAbstractCurve (const GOType &type, const quint32 &idObject=null_id, const Draw &mode=Draw::Calculation)
 
 VAbstractCurve (const VAbstractCurve &curve)
 
virtual ~VAbstractCurve () Q_DECL_OVERRIDE
 
VAbstractCurveoperator= (const VAbstractCurve &curve)
 
void Swap (VAbstractCurve &curve) Q_DECL_NOTHROW
 
QVector< QPointF > GetSegmentPoints (const QPointF &begin, const QPointF &end, bool reverse=false) const
 
virtual QPainterPath GetPath () const
 
qreal GetLengthByPoint (const QPointF &point) const
 
virtual QVector< QPointF > IntersectLine (const QLineF &line) const
 IntersectLine return list of points for real intersection with line. More...
 
virtual bool IsIntersectLine (const QLineF &line) const
 
bool isPointOnCurve (const QPointF &p) const
 
quint32 GetDuplicate () const
 
void SetDuplicate (quint32 number)
 
QString getLineColor () const
 
void setLineColor (const QString &color)
 
QString GetPenStyle () const
 
void SetPenStyle (const QString &penStyle)
 
QString getLineWeight () const
 getLineWeight return weight of the lines More...
 
void setLineWeight (const QString &lineWeight)
 setLineWeight set weight of the lines More...
 
QPointF getFirstPoint ()
 
QPointF getLastPoint ()
 
virtual QVector< DirectionArrowDirectionArrows () const
 
- Public Member Functions inherited from VGObject
 VGObject ()
 VGObject default constructor. More...
 
 VGObject (const GOType &type, const quint32 &idObject=0, const Draw &mode=Draw::Calculation)
 VGObject constructor. More...
 
 VGObject (const VGObject &obj)
 VGObject copy constructor. More...
 
virtual ~VGObject ()
 
VGObjectoperator= (const VGObject &obj)
 operator = assignment operator. More...
 
void Swap (VGObject &obj) Q_DECL_NOTHROW
 
quint32 getIdObject () const
 getIdObject return parent id. More...
 
void setIdObject (const quint32 &value)
 setIdObject set parent id. More...
 
virtual QString name () const
 name return name graphical object. More...
 
void setName (const QString &name)
 setName set name graphical object. More...
 
Draw getMode () const
 getMode return mode creation. More...
 
void setMode (const Draw &value)
 setMode set mode creation. More...
 
GOType getType () const
 getType return object type. More...
 
void setType (const GOType &type)
 
quint32 id () const
 id return id object. More...
 
virtual void setId (const quint32 &id)
 setId set id object. More...
 
quint32 getIdTool () const
 

Static Public Member Functions

static QVector< QPointF > SplinePoints (const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)
 SplinePoints return list with spline points. More...
 
- Static Public Member Functions inherited from VAbstractCurve
static QVector< QPointF > GetSegmentPoints (const QVector< QPointF > &points, const QPointF &begin, const QPointF &end, bool reverse=false)
 
static bool isPointOnCurve (const QVector< QPointF > &points, const QPointF &p)
 
static qreal PathLength (const QVector< QPointF > &path)
 
static QVector< QPointF > CurveIntersectLine (const QVector< QPointF > &points, const QLineF &line)
 
static QPainterPath ShowDirection (const QVector< DirectionArrow > &arrows, qreal width)
 
- Static Public Member Functions inherited from VGObject
static QLineF BuildLine (const QPointF &p1, const qreal &length, const qreal &angle)
 
static QPointF BuildRay (const QPointF &firstPoint, const qreal &angle, const QRectF &scRect)
 
static QLineF BuildAxis (const QPointF &p, const qreal &angle, const QRectF &scRect)
 
static QLineF BuildAxis (const QPointF &p1, const QPointF &p2, const QRectF &scRect)
 
static int ContactPoints (const QPointF &p, const QPointF &center, qreal radius, QPointF &p1, QPointF &p2)
 
static QPointF LineIntersectRect (const QRectF &rec, const QLineF &line)
 LineIntersectRect find point intersection line and rect. More...
 
static int IntersectionCircles (const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2)
 
static qint32 LineIntersectCircle (const QPointF &center, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2)
 LineIntersectCircle find point intersection line and circle. More...
 
static QPointF ClosestPoint (const QLineF &line, const QPointF &point)
 ClosestPoint find point projection of point onto line. More...
 
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k)
 
static void LineCoefficients (const QLineF &line, qreal *a, qreal *b, qreal *c)
 LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. More...
 
static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2)
 IsPointOnLineSegment Check if the point is on the line segment. More...
 
static bool IsPointOnLineviaPDP (const QPointF &t, const QPointF &p1, const QPointF &p2)
 IsPointOnLineviaPDP use the perp dot product (PDP) way. More...
 
template<typename T >
static QVector< T > GetReversePoints (const QVector< T > &points)
 GetReversePoint return revers container of points. More...
 
static int GetLengthContour (const QVector< QPointF > &contour, const QVector< QPointF > &newPoints)
 GetLengthContour return length of contour. More...
 

Protected Member Functions

virtual QPointF GetControlPoint1 () const Q_DECL_OVERRIDE
 
virtual QPointF GetControlPoint2 () const Q_DECL_OVERRIDE
 
- Protected Member Functions inherited from VAbstractCubicBezier
virtual void CreateName () Q_DECL_OVERRIDE
 

Private Member Functions

QVector< qreal > CalcT (qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, qreal pointCoord) const
 

Static Private Member Functions

static qint32 Cubic (QVector< qreal > &x, qreal a, qreal b, qreal c)
 Cubic Cubic equation solution. Real coefficients case. More...
 
static int Sign (long double ld)
 

Private Attributes

QSharedDataPointer< VSplineDatad
 

Additional Inherited Members

- Static Public Attributes inherited from VAbstractCurve
static const qreal lengthCurveDirectionArrow = 14
 
- Static Public Attributes inherited from VGObject
static const double accuracyPointOnLine = (0.1555 / 25.4) * 96.0
 
- Static Protected Member Functions inherited from VAbstractCubicBezier
static qreal CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2)
 CalcSqDistance calculate squared distance. More...
 
static void PointBezier_r (qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4, qint16 level, QVector< qreal > &px, QVector< qreal > &py)
 PointBezier_r find spline point using four point of spline. More...
 
static QVector< QPointF > GetCubicBezierPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
 GetCubicBezierPoints return list with cubic bezier curve points. More...
 
static qreal LengthBezier (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
 LengthBezier return spline length using 4 spline point. More...
 
- Static Protected Member Functions inherited from VGObject
static QTransform flipTransform (const QLineF &axis)
 

Detailed Description

VSpline class that implements the spline.

Definition at line 74 of file vspline.h.

Constructor & Destructor Documentation

◆ VSpline() [1/5]

VSpline::VSpline ( )

VSpline default constructor.

Definition at line 71 of file vspline.cpp.

References Spline.

Referenced by CutSpline().

◆ VSpline() [2/5]

VSpline::VSpline ( const VSpline spline)

VSpline constructor.

Parameters
splinespline from which the copy.

Definition at line 80 of file vspline.cpp.

◆ VSpline() [3/5]

VSpline::VSpline ( const VPointF p1,
const VPointF p4,
qreal  angle1,
qreal  angle2,
qreal  kAsm1,
qreal  kAsm2,
qreal  kCurve,
quint32  idObject = 0,
Draw  mode = Draw::Calculation 
)

VSpline constructor.

Parameters
p1first point spline.
p4last point spline.
angle1angle from first point to first control point.
angle2angle from second point to second control point.
kCurvecoefficient of curvature spline.
kAsm1coefficient of length first control line.
kAsm2coefficient of length second control line.

Definition at line 95 of file vspline.cpp.

References VAbstractCubicBezier::CreateName(), and Spline.

◆ VSpline() [4/5]

VSpline::VSpline ( const VPointF p1,
const QPointF &  p2,
const QPointF &  p3,
const VPointF p4,
quint32  idObject = 0,
Draw  mode = Draw::Calculation 
)

VSpline constructor.

Parameters
p1first point spline.
p2first control point.
p3second control point.
p4second point spline.

Definition at line 111 of file vspline.cpp.

References VAbstractCubicBezier::CreateName(), and Spline.

◆ VSpline() [5/5]

VSpline::VSpline ( const VPointF p1,
const VPointF p4,
qreal  angle1,
const QString &  angle1Formula,
qreal  angle2,
const QString &  angle2Formula,
qreal  c1Length,
const QString &  c1LengthFormula,
qreal  c2Length,
const QString &  c2LengthFormula,
quint32  idObject = 0,
Draw  mode = Draw::Calculation 
)

VSpline constructor.

Parameters
p1first point spline.
p4first control point.
angle1angle from first point to first control point.
angle1Formulaformula angle from first point to first control point.
angle2angle from second point to second control point.
angle2Formulaformula angle from second point to second control point.
c1Lengthlength from first point to first control point.
c1LengthFormulaformula length from first point to first control point.
c2Lengthlength from second point to first control point.
c2LengthFormulaformula length from second point to first control point.

Definition at line 133 of file vspline.cpp.

References VAbstractCubicBezier::CreateName(), and Spline.

◆ ~VSpline()

VSpline::~VSpline ( )
virtual

Definition at line 195 of file vspline.cpp.

Member Function Documentation

◆ CalcT()

QVector< qreal > VSpline::CalcT ( qreal  curveCoord1,
qreal  curveCoord2,
qreal  curveCoord3,
qreal  curveCoord4,
qreal  pointCoord 
) const
private

Definition at line 508 of file vspline.cpp.

References Cubic(), and d.

Referenced by ParamT().

◆ Cubic()

qint32 VSpline::Cubic ( QVector< qreal > &  x,
qreal  a,
qreal  b,
qreal  c 
)
staticprivate

Cubic Cubic equation solution. Real coefficients case.

This method use method Vieta-Cardano for eval cubic equations. Cubic equation write in form x3+a*x2+b*x+c=0.

Output: 3 real roots -> then x is filled with them; 1 real + 2 complex -> x[0] is real, x[1] is real part of complex roots, x[2] - non-negative imaginary part.

Parameters
xsolution array (size 3).
acoefficient
bcoefficient
ccoefficient
Returns
3 - 3 real roots; 1 - 1 real root + 2 complex; 2 - 1 real root + complex roots imaginary part is zero (i.e. 2 real roots).

Definition at line 477 of file vspline.cpp.

References M_2PI, and Sign().

Referenced by CalcT().

◆ CutSpline() [1/2]

QPointF VAbstractCubicBezier::CutSpline

CutSpline cut spline.

Parameters
lengthlength first spline
spl1p2second point of first spline
spl1p3third point of first spline
spl2p2second point of second spline
spl2p3third point of second spline
Returns
point of cutting. This point is forth point of first spline and first point of second spline.

Definition at line 80 of file vabstractcubicbezier.cpp.

Referenced by CutSpline().

◆ CutSpline() [2/2]

QPointF VSpline::CutSpline ( qreal  length,
VSpline spl1,
VSpline spl2 
) const

Definition at line 210 of file vspline.cpp.

References CutSpline(), GetP1(), GetP4(), and VSpline().

Referenced by VAbstractCubicBezierPath::CutSplinePath().

◆ Flip()

◆ GetC1Length()

◆ GetC1LengthFormula()

◆ GetC2Length()

◆ GetC2LengthFormula()

◆ GetControlPoint1()

QPointF VSpline::GetControlPoint1 ( ) const
protectedvirtual

Implements VAbstractCubicBezier.

Definition at line 580 of file vspline.cpp.

References GetP2().

◆ GetControlPoint2()

QPointF VSpline::GetControlPoint2 ( ) const
protectedvirtual

Implements VAbstractCubicBezier.

Definition at line 586 of file vspline.cpp.

References GetP3().

◆ GetEndAngle()

◆ GetEndAngleFormula()

◆ GetKasm1()

qreal VSpline::GetKasm1 ( ) const

GetKasm1 return coefficient of length first control line.

Returns
coefficient.

Definition at line 421 of file vspline.cpp.

References d, VSplineData::GetL(), and GetP2().

Referenced by VSplinePath::GetFSplinePath(), DialogSpline::PointNameChanged(), DialogSpline::SaveData(), and DialogSpline::SetSpline().

◆ GetKasm2()

qreal VSpline::GetKasm2 ( ) const

GetKasm2 return coefficient of length second control line.

Returns
coefficient.

Definition at line 432 of file vspline.cpp.

References d, VSplineData::GetL(), and GetP3().

Referenced by VSplinePath::GetFSplinePath(), DialogSpline::PointNameChanged(), DialogSpline::SaveData(), and DialogSpline::SetSpline().

◆ GetKcurve()

qreal VSpline::GetKcurve ( ) const

GetKcurve return coefficient of curvature spline.

Returns
coefficient

Definition at line 443 of file vspline.cpp.

References d.

Referenced by DialogSpline::PointNameChanged(), DialogSpline::SaveData(), and DialogSpline::SetSpline().

◆ GetLength()

qreal VSpline::GetLength ( ) const
virtual

◆ GetP1()

◆ GetP2()

◆ GetP3()

◆ GetP4()

◆ getPoints()

QVector< QPointF > VSpline::getPoints ( ) const
virtual

GetPoints return list with spline points.

Returns
list of points.

Implements VAbstractCurve.

Definition at line 228 of file vspline.cpp.

References VAbstractCubicBezier::GetCubicBezierPoints(), GetP1(), GetP2(), GetP3(), and GetP4().

Referenced by VAbstractCubicBezierPath::getPoints(), and VArc::getPoints().

◆ GetStartAngle()

◆ GetStartAngleFormula()

◆ Move()

◆ operator=()

VSpline & VSpline::operator= ( const VSpline spline)

Definition at line 265 of file vspline.cpp.

References d, and VAbstractCubicBezier::operator=().

◆ ParamT()

qreal VSpline::ParamT ( const QPointF &  pBt) const

VSpline::ParamT calculate t coeffient that reprezent point on curve.

Each point that belongs to Cubic Bézier curve can be shown by coefficient in interval [0; 1].

Parameters
pBtpoint on curve
Returns
t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve.

Definition at line 540 of file vspline.cpp.

References CalcT(), GetP1(), GetP2(), GetP3(), GetP4(), VPointF::x(), and VPointF::y().

Referenced by VToolSpline::mouseMoveEvent(), VToolSplinePath::mouseMoveEvent(), and VAbstractCubicBezierPath::Segment().

◆ Rotate()

◆ SetC1Length()

void VSpline::SetC1Length ( qreal  length,
const QString &  formula 
)

Definition at line 403 of file vspline.cpp.

References d.

◆ SetC2Length()

void VSpline::SetC2Length ( qreal  length,
const QString &  formula 
)

Definition at line 410 of file vspline.cpp.

References d.

◆ SetEndAngle()

void VSpline::SetEndAngle ( qreal  angle,
const QString &  formula 
)

Definition at line 372 of file vspline.cpp.

References d.

◆ SetP1()

void VSpline::SetP1 ( const VPointF p)

Definition at line 287 of file vspline.cpp.

References d.

◆ SetP4()

void VSpline::SetP4 ( const VPointF p)

Definition at line 327 of file vspline.cpp.

References d.

◆ SetStartAngle()

void VSpline::SetStartAngle ( qreal  angle,
const QString &  formula 
)

Definition at line 365 of file vspline.cpp.

References d.

◆ Sign()

int VSpline::Sign ( long double  ld)
staticprivate

Definition at line 449 of file vspline.cpp.

Referenced by Cubic().

◆ SplinePoints()

QVector< QPointF > VSpline::SplinePoints ( const QPointF &  p1,
const QPointF &  p4,
qreal  angle1,
qreal  angle2,
qreal  kAsm1,
qreal  kAsm2,
qreal  kCurve 
)
static

SplinePoints return list with spline points.

Parameters
p1first spline point.
p4last spline point.
angle1angle from first point to first control point.
angle2angle from second point to second control point.
kAsm1coefficient of length first control line.
kAsm2coefficient of length second control line.
kCurvecoefficient of curvature spline.
Returns
list with spline points.

Definition at line 247 of file vspline.cpp.

References VAbstractCubicBezier::GetCubicBezierPoints().

◆ Swap()

void VSpline::Swap ( VSpline spline)

Definition at line 64 of file vspline.cpp.

References VAbstractCurve::Swap().

Member Data Documentation

◆ d


The documentation for this class was generated from the following files: