##// END OF EJS Templates
QSplineSeries documentation added
Marek Rosa -
r433:c8744ab348e4
parent child
Show More
@@ -25,6 +25,7
25 <li><a href="qpieslice.html">QPieSlice</a></li>
25 <li><a href="qpieslice.html">QPieSlice</a></li>
26 <li><a href="qscatterseries.html">QScatterSeries</a></li>
26 <li><a href="qscatterseries.html">QScatterSeries</a></li>
27 <li><a href="qseries.html">QSeries</a></li>
27 <li><a href="qseries.html">QSeries</a></li>
28 <li><a href="qsplineseries.html">QSplineSeries</a></li>
28 <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li>
29 <li><a href="qstackedbarseries.html">QStackedBarSeries</a></li>
29 </ul>
30 </ul>
30 </td>
31 </td>
@@ -1,7 +1,30
1 #include "qsplineseries.h"
1 #include "qsplineseries.h"
2
2
3 /*!
4 \class QSplineSeries
5 \brief Series type used to store data needed to draw a spline.
6
7 QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline
8 Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn.
9 */
10
11 /*!
12 \fn QSeriesType QSplineSeries::type() const
13 Returns the type of the series
14 */
15
16 /*!
17 \fn QSeriesType QSplineSeries::controlPoint(int index) const
18 Returns the control point specified by \a index
19 */
20
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
21 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
22
23 /*!
24 Constructs empty series object which is a child of \a parent.
25 When series object is added to QChartView or QChart instance then the ownerships is transfered.
26 */
27
5 QSplineSeries::QSplineSeries(QObject *parent) :
28 QSplineSeries::QSplineSeries(QObject *parent) :
6 QLineSeries(parent)
29 QLineSeries(parent)
7 {
30 {
@@ -10,11 +33,15 QSplineSeries::QSplineSeries(QObject *parent) :
10 connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints()));
33 connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints()));
11 }
34 }
12
35
36 /*!
37 \internal
38 Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points.
39 */
13 void QSplineSeries::calculateControlPoints()
40 void QSplineSeries::calculateControlPoints()
14 {
41 {
15
42
16 // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit
43 // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit
17 // CPOL Licence
44 // CPOL License
18
45
19 int n = m_x.size() - 1;
46 int n = m_x.size() - 1;
20 if (n == 1)
47 if (n == 1)
@@ -74,6 +101,9 void QSplineSeries::calculateControlPoints()
74 }
101 }
75 }
102 }
76
103
104 /*!
105 \internal
106 */
77 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs)
107 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs)
78 {
108 {
79 QList<qreal> x; // Solution vector.
109 QList<qreal> x; // Solution vector.
@@ -94,6 +124,10 QList<qreal> QSplineSeries::getFirstControlPoints(QList<qreal> rhs)
94 return x;
124 return x;
95 }
125 }
96
126
127 /*!
128 \internal
129 Updates the control points, besed on currently avaiable knots.
130 */
97 void QSplineSeries::updateControlPoints()
131 void QSplineSeries::updateControlPoints()
98 {
132 {
99 if(m_x.size() > 1)
133 if(m_x.size() > 1)
@@ -17,7 +17,7 class QSplineSeries : public QLineSeries
17 QSplineSeries(QObject *parent = 0);
17 QSplineSeries(QObject *parent = 0);
18 QSeriesType type() const { return QSeries::SeriesTypeSpline; }
18 QSeriesType type() const { return QSeries::SeriesTypeSpline; }
19
19
20 int count() const { return m_x.size(); }
20 // int count() const { return m_x.size(); }
21 QPointF controlPoint(int index) const { return m_controlPoints[index]; }
21 QPointF controlPoint(int index) const { return m_controlPoints[index]; }
22
22
23 private:
23 private:
General Comments 0
You need to be logged in to leave comments. Login now