@@ -1,71 +1,75 | |||||
1 | #include "qlinechartseries.h" |
|
1 | #include "qlinechartseries.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 | QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent), |
|
5 | QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent), | |
6 | m_pointsVisible(false) |
|
6 | m_pointsVisible(false) | |
7 | { |
|
7 | { | |
8 | } |
|
8 | } | |
9 |
|
9 | |||
10 | QLineChartSeries::~QLineChartSeries() |
|
10 | QLineChartSeries::~QLineChartSeries() | |
11 | { |
|
11 | { | |
12 | } |
|
12 | } | |
13 |
|
13 | |||
14 | int QLineChartSeries::add(qreal x,qreal y) |
|
14 | int QLineChartSeries::add(qreal x,qreal y) | |
15 | { |
|
15 | { | |
16 | m_x<<x; |
|
16 | m_x<<x; | |
17 | m_y<<y; |
|
17 | m_y<<y; | |
18 | return m_x.size()-1; |
|
18 | return m_x.size()-1; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | void QLineChartSeries::set(int index,qreal x,qreal y) |
|
21 | void QLineChartSeries::set(int index,qreal x,qreal y) | |
22 | { |
|
22 | { | |
23 | m_x[index]=x; |
|
23 | m_x[index]=x; | |
24 | m_y[index]=y; |
|
24 | m_y[index]=y; | |
25 | emit changed(index); |
|
25 | emit changed(index); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | void QLineChartSeries::clear() |
|
28 | void QLineChartSeries::clear() | |
29 | { |
|
29 | { | |
30 | m_x.clear(); |
|
30 | m_x.clear(); | |
31 | m_y.clear(); |
|
31 | m_y.clear(); | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | qreal QLineChartSeries::x(int pos) const |
|
34 | qreal QLineChartSeries::x(int pos) const | |
35 | { |
|
35 | { | |
36 | return m_x.at(pos); |
|
36 | return m_x.at(pos); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | qreal QLineChartSeries::y(int pos) const |
|
39 | qreal QLineChartSeries::y(int pos) const | |
40 | { |
|
40 | { | |
41 | return m_y.at(pos); |
|
41 | return m_y.at(pos); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | int QLineChartSeries::count() const |
|
44 | int QLineChartSeries::count() const | |
45 | { |
|
45 | { | |
46 | Q_ASSERT(m_x.size() == m_y.size()); |
|
46 | Q_ASSERT(m_x.size() == m_y.size()); | |
47 |
|
47 | |||
48 | return m_x.size(); |
|
48 | return m_x.size(); | |
49 |
|
49 | |||
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void QLineChartSeries::setPen(const QPen& pen) |
|
52 | void QLineChartSeries::setPen(const QPen& pen) | |
53 | { |
|
53 | { | |
54 | m_pen=pen; |
|
54 | m_pen=pen; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | QDebug operator<< (QDebug debug, const QLineChartSeries series) |
|
57 | QDebug operator<< (QDebug debug, const QLineChartSeries series) | |
58 | { |
|
58 | { | |
59 | Q_ASSERT(series.m_x.size() == series.m_y.size()); |
|
59 | Q_ASSERT(series.m_x.size() == series.m_y.size()); | |
60 |
|
60 | |||
61 | int size = series.m_x.size(); |
|
61 | int size = series.m_x.size(); | |
62 |
|
62 | |||
63 | for (int i=0;i<size;i++) { |
|
63 | for (int i=0;i<size;i++) { | |
64 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; |
|
64 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; | |
65 | } |
|
65 | } | |
66 | return debug.space(); |
|
66 | return debug.space(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
|
69 | void QLineChartSeries::setPointsVisible(bool visible) | |||
|
70 | { | |||
|
71 | m_pointsVisible=visible; | |||
|
72 | } | |||
69 | #include "moc_qlinechartseries.cpp" |
|
73 | #include "moc_qlinechartseries.cpp" | |
70 |
|
74 | |||
71 | QTCOMMERCIALCHART_END_NAMESPACE |
|
75 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,48 +1,48 | |||||
1 | #ifndef QLINECHARTSERIES_H_ |
|
1 | #ifndef QLINECHARTSERIES_H_ | |
2 | #define QLINECHARTSERIES_H_ |
|
2 | #define QLINECHARTSERIES_H_ | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "qchartseries.h" |
|
5 | #include "qchartseries.h" | |
6 | #include <QDebug> |
|
6 | #include <QDebug> | |
7 | #include <QPen> |
|
7 | #include <QPen> | |
8 | #include <QBrush> |
|
8 | #include <QBrush> | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | class QTCOMMERCIALCHART_EXPORT QLineChartSeries : public QChartSeries |
|
12 | class QTCOMMERCIALCHART_EXPORT QLineChartSeries : public QChartSeries | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 | public: |
|
15 | public: | |
16 | QLineChartSeries(QObject* parent=0); |
|
16 | QLineChartSeries(QObject* parent=0); | |
17 | virtual ~QLineChartSeries(); |
|
17 | virtual ~QLineChartSeries(); | |
18 |
|
18 | |||
19 | public: // from QChartSeries |
|
19 | public: // from QChartSeries | |
20 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;} |
|
20 | virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;} | |
21 | int add(qreal x, qreal y); |
|
21 | int add(qreal x, qreal y); | |
22 | void set(int index,qreal x,qreal y); |
|
22 | void set(int index,qreal x,qreal y); | |
23 | void clear(); |
|
23 | void clear(); | |
24 |
|
24 | |||
25 | void setPen(const QPen& pen); |
|
25 | void setPen(const QPen& pen); | |
26 | const QPen& pen() const { return m_pen;} |
|
26 | const QPen& pen() const { return m_pen;} | |
27 |
|
27 | |||
28 |
void |
|
28 | void setPointsVisible(bool visible); | |
29 | bool isPointsVisible() const {return m_pointsVisible;} |
|
29 | bool isPointsVisible() const {return m_pointsVisible;} | |
30 |
|
30 | |||
31 | int count() const; |
|
31 | int count() const; | |
32 | qreal x(int pos) const; |
|
32 | qreal x(int pos) const; | |
33 | qreal y(int pos) const; |
|
33 | qreal y(int pos) const; | |
34 | friend QDebug operator<< (QDebug d, const QLineChartSeries series); |
|
34 | friend QDebug operator<< (QDebug d, const QLineChartSeries series); | |
35 |
|
35 | |||
36 | signals: |
|
36 | signals: | |
37 | void changed(int index); |
|
37 | void changed(int index); | |
38 |
|
38 | |||
39 | private: |
|
39 | private: | |
40 | QVector<qreal> m_x; |
|
40 | QVector<qreal> m_x; | |
41 | QVector<qreal> m_y; |
|
41 | QVector<qreal> m_y; | |
42 | QPen m_pen; |
|
42 | QPen m_pen; | |
43 | bool m_pointsVisible; |
|
43 | bool m_pointsVisible; | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | QTCOMMERCIALCHART_END_NAMESPACE | |
47 |
|
47 | |||
48 | #endif |
|
48 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now