@@ -66,8 +66,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
66 | Constructs empty series object which is a child of \a parent. |
|
66 | Constructs empty series object which is a child of \a parent. | |
67 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
67 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
68 | */ |
|
68 | */ | |
69 |
QLineSeries::QLineSeries(QObject* parent):QXYSeries(parent) |
|
69 | QLineSeries::QLineSeries(QObject* parent):QXYSeries(parent) | |
70 | m_pointsVisible(false) |
|
|||
71 | { |
|
70 | { | |
72 | } |
|
71 | } | |
73 | /*! |
|
72 | /*! | |
@@ -78,28 +77,6 QLineSeries::~QLineSeries() | |||||
78 | { |
|
77 | { | |
79 | } |
|
78 | } | |
80 |
|
79 | |||
81 | /*! |
|
|||
82 | Sets \a pen used for drawing given series.. |
|
|||
83 | */ |
|
|||
84 | void QLineSeries::setPen(const QPen& pen) |
|
|||
85 | { |
|
|||
86 | if(pen!=m_pen){ |
|
|||
87 | m_pen=pen; |
|
|||
88 | emit updated(); |
|
|||
89 | } |
|
|||
90 | } |
|
|||
91 |
|
||||
92 | /*! |
|
|||
93 | Sets if data points are \a visible and should be drawn on line. |
|
|||
94 | */ |
|
|||
95 | void QLineSeries::setPointsVisible(bool visible) |
|
|||
96 | { |
|
|||
97 | if(m_pointsVisible!=visible){ |
|
|||
98 | m_pointsVisible=visible; |
|
|||
99 | emit updated(); |
|
|||
100 | } |
|
|||
101 | } |
|
|||
102 |
|
||||
103 | QDebug operator<< (QDebug debug, const QLineSeries series) |
|
80 | QDebug operator<< (QDebug debug, const QLineSeries series) | |
104 | { |
|
81 | { | |
105 | Q_ASSERT(series.m_x.size() == series.m_y.size()); |
|
82 | Q_ASSERT(series.m_x.size() == series.m_y.size()); |
@@ -18,16 +18,8 public: | |||||
18 |
|
18 | |||
19 | public: // from QChartSeries |
|
19 | public: // from QChartSeries | |
20 | virtual QSeriesType type() const {return QSeries::SeriesTypeLine;} |
|
20 | virtual QSeriesType type() const {return QSeries::SeriesTypeLine;} | |
21 | void setPen(const QPen& pen); |
|
|||
22 | QPen pen() const {return m_pen;} |
|
|||
23 |
|
||||
24 | void setPointsVisible(bool visible); |
|
|||
25 | bool pointsVisible() const {return m_pointsVisible;} |
|
|||
26 |
|
||||
27 | friend QDebug operator<< (QDebug d, const QLineSeries series); |
|
21 | friend QDebug operator<< (QDebug d, const QLineSeries series); | |
28 | private: |
|
22 | ||
29 | QPen m_pen; |
|
|||
30 | bool m_pointsVisible; |
|
|||
31 | }; |
|
23 | }; | |
32 |
|
24 | |||
33 | QTCOMMERCIALCHART_END_NAMESPACE |
|
25 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -26,7 +26,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
26 | */ |
|
26 | */ | |
27 |
|
27 | |||
28 | QSplineSeries::QSplineSeries(QObject *parent) : |
|
28 | QSplineSeries::QSplineSeries(QObject *parent) : | |
29 |
Q |
|
29 | QXYSeries(parent) | |
30 | { |
|
30 | { | |
31 | connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); |
|
31 | connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); | |
32 | connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); |
|
32 | connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); |
@@ -3,38 +3,39 | |||||
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QtGlobal> |
|
5 | #include <QtGlobal> | |
6 |
#include "q |
|
6 | #include "qxyseries.h" | |
7 | #include <QList> |
|
7 | #include <QList> | |
8 | #include <QPointF> |
|
8 | #include <QPointF> | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 |
class QSplineSeries : public Q |
|
12 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QXYSeries | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 |
|
|
15 | public: | |
16 |
|
16 | |||
17 | QSplineSeries(QObject *parent = 0); |
|
17 | QSplineSeries(QObject *parent = 0); | |
18 |
QSeriesType type() const { |
|
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 { |
|
21 | QPointF controlPoint(int index) const {return m_controlPoints[index];} | |
22 |
|
22 | |||
23 | // TODO: allow the user to set custom control points |
|
23 | // TODO: allow the user to set custom control points | |
24 | // void setCustomControlPoints(QList<QPointsF> controlPoints); |
|
24 | // void setCustomControlPoints(QList<QPointsF> controlPoints); | |
25 | // bool calculateControlPointsAutomatically(); |
|
25 | // bool calculateControlPointsAutomatically(); | |
26 | // void setCalculateControlPointsAutomatically(); |
|
26 | // void setCalculateControlPointsAutomatically(); | |
27 |
|
27 | |||
28 | private: |
|
28 | ||
|
29 | private: | |||
29 | void calculateControlPoints(); |
|
30 | void calculateControlPoints(); | |
30 | QList<qreal> getFirstControlPoints(QList<qreal> rhs); |
|
31 | QList<qreal> getFirstControlPoints(QList<qreal> rhs); | |
31 |
|
32 | |||
32 |
|
|
33 | private slots: | |
33 | void updateControlPoints(); |
|
34 | void updateControlPoints(); | |
34 |
|
35 | |||
35 |
|
|
36 | private: | |
36 | QList<QPointF> m_controlPoints; |
|
37 | QList<QPointF> m_controlPoints; | |
37 |
|
38 | |||
38 | }; |
|
39 | }; | |
39 |
|
40 | |||
40 | QTCOMMERCIALCHART_END_NAMESPACE |
|
41 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -66,7 +66,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
66 | Constructs empty series object which is a child of \a parent. |
|
66 | Constructs empty series object which is a child of \a parent. | |
67 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
67 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
68 | */ |
|
68 | */ | |
69 | QXYSeries::QXYSeries(QObject* parent):QSeries(parent) |
|
69 | QXYSeries::QXYSeries(QObject* parent):QSeries(parent), | |
|
70 | m_pointsVisible(false) | |||
70 | { |
|
71 | { | |
71 | } |
|
72 | } | |
72 | /*! |
|
73 | /*! | |
@@ -173,6 +174,29 int QXYSeries::count() const | |||||
173 | } |
|
174 | } | |
174 |
|
175 | |||
175 | /*! |
|
176 | /*! | |
|
177 | Sets \a pen used for drawing given series.. | |||
|
178 | */ | |||
|
179 | void QXYSeries::setPen(const QPen& pen) | |||
|
180 | { | |||
|
181 | if(pen!=m_pen){ | |||
|
182 | m_pen=pen; | |||
|
183 | emit updated(); | |||
|
184 | } | |||
|
185 | } | |||
|
186 | ||||
|
187 | /*! | |||
|
188 | Sets if data points are \a visible and should be drawn on line. | |||
|
189 | */ | |||
|
190 | void QXYSeries::setPointsVisible(bool visible) | |||
|
191 | { | |||
|
192 | if(m_pointsVisible!=visible){ | |||
|
193 | m_pointsVisible=visible; | |||
|
194 | emit updated(); | |||
|
195 | } | |||
|
196 | } | |||
|
197 | ||||
|
198 | ||||
|
199 | /*! | |||
176 | Stream operator for adding a data \a point to the series. |
|
200 | Stream operator for adding a data \a point to the series. | |
177 | \sa add() |
|
201 | \sa add() | |
178 | */ |
|
202 | */ |
@@ -31,6 +31,12 public: | |||||
31 |
|
31 | |||
32 | QXYSeries& operator << (const QPointF &point); |
|
32 | QXYSeries& operator << (const QPointF &point); | |
33 |
|
33 | |||
|
34 | void setPen(const QPen& pen); | |||
|
35 | QPen pen() const {return m_pen;} | |||
|
36 | ||||
|
37 | void setPointsVisible(bool visible); | |||
|
38 | bool pointsVisible() const {return m_pointsVisible;} | |||
|
39 | ||||
34 | signals: |
|
40 | signals: | |
35 | void updated(); |
|
41 | void updated(); | |
36 | void pointReplaced(int index); |
|
42 | void pointReplaced(int index); | |
@@ -42,6 +48,9 protected: | |||||
42 | QVector<qreal> m_x; |
|
48 | QVector<qreal> m_x; | |
43 | QVector<qreal> m_y; |
|
49 | QVector<qreal> m_y; | |
44 |
|
50 | |||
|
51 | QPen m_pen; | |||
|
52 | bool m_pointsVisible; | |||
|
53 | ||||
45 | }; |
|
54 | }; | |
46 |
|
55 | |||
47 | QTCOMMERCIALCHART_END_NAMESPACE |
|
56 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now