1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -1,37 +1,48 | |||||
1 | /*! |
|
1 | /*! | |
2 | \example examples/presenterchart |
|
2 | \example examples/presenterchart | |
3 | \title PresenterChart Example |
|
3 | \title PresenterChart Example | |
4 | \subtitle |
|
4 | \subtitle | |
5 |
|
5 | |||
6 |
The example shows how to create chart which presents the same set of data as line, scatter |
|
6 | The example shows how to create chart which presents the same set of data as line, scatter, spline and area charts. | |
7 |
ChartPresenter will switch between these |
|
7 | ChartPresenter will switch between these four chart types every few seconds. | |
8 | Please note this example does not use common data model. A use of common data model is documented here.[TODO] |
|
8 | Please note this example does not use common data model. A use of common data model is documented here.[TODO] | |
9 |
|
9 | |||
10 | \image presenterchart1.png |
|
10 | \image presenterchart1.png | |
11 | \image presenterchart2.png |
|
11 | \image presenterchart2.png | |
12 | \image presenterchart3.png |
|
12 | \image presenterchart3.png | |
|
13 | \image presenterchart4.png | |||
13 |
|
14 | |||
14 | We create simple ChartView class which derives form QChartView. |
|
15 | We create simple ChartView class which derives form QChartView. | |
15 |
|
16 | |||
16 | \snippet ../examples/presenterchart/chartview.h 1 |
|
17 | \snippet ../examples/presenterchart/chartview.h 1 | |
17 |
|
18 | |||
18 | Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. |
|
19 | Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. | |
|
20 | We are also going to provide \c handlePoitClicked() slot which will show clicked point on the chart. | |||
19 | Class members \c m_series and \c m_titles are going to store series and related titles. In example we are going to present data as a line chart |
|
21 | Class members \c m_series and \c m_titles are going to store series and related titles. In example we are going to present data as a line chart | |
20 |
using QLineSeries , as scatter chart using QScatterSeries, a |
|
22 | using QLineSeries , as scatter chart using QScatterSeries, as a spline chart using QSplineSeries and a area chart using QAreaSeries. We create needed instances in constructor of ChartView class. | |
21 | We set custom line and points colors. |
|
23 | We set custom line and points colors. | |
22 |
|
24 | |||
23 | \snippet ../examples/presenterchart/chartview.cpp 1 |
|
25 | \snippet ../examples/presenterchart/chartview.cpp 1 | |
24 |
|
26 | |||
25 | We add data to all three series. We can use add() member function. If data set is large,it is wiser to use shared data model, as described here.[TODO] |
|
27 | We add data to three series. Please note area chart is going to use QLineSeries as the upper line. We can use add() member function. If data set is large, | |
|
28 | it is wiser to use shared data model, as described here.[TODO] | |||
26 |
|
29 | |||
27 | \snippet ../examples/presenterchart/chartview.cpp 2 |
|
30 | \snippet ../examples/presenterchart/chartview.cpp 2 | |
28 |
|
31 | |||
29 | In the end we store references all the created series and matching titles. |
|
32 | In the end we store references all the created series and matching titles. | |
30 |
|
33 | |||
31 | \snippet ../examples/presenterchart/chartview.cpp 3 |
|
34 | \snippet ../examples/presenterchart/chartview.cpp 3 | |
32 |
|
35 | |||
33 | In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. |
|
36 | We connect \c clicked() signals from each series with our \c handlePointClciked() slot. | |
34 |
|
37 | |||
35 | \snippet ../examples/presenterchart/chartview.cpp 4 |
|
38 | \snippet ../examples/presenterchart/chartview.cpp 4 | |
36 |
|
39 | |||
|
40 | In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. | |||
|
41 | ||||
|
42 | \snippet ../examples/presenterchart/chartview.cpp 5 | |||
|
43 | ||||
|
44 | In \c handlePointClciked() slot we set the chart's title to show clicked point x and y coordinates. | |||
|
45 | ||||
|
46 | \snippet ../examples/presenterchart/chartview.cpp 6 | |||
|
47 | ||||
37 | */ No newline at end of file |
|
48 | */ |
@@ -1,96 +1,100 | |||||
1 | #include "chartview.h" |
|
1 | #include "chartview.h" | |
2 | #include <qlineseries.h> |
|
2 | #include <qlineseries.h> | |
3 | #include <qscatterseries.h> |
|
3 | #include <qscatterseries.h> | |
4 | #include <qsplineseries.h> |
|
4 | #include <qsplineseries.h> | |
5 | #include <qareaseries.h> |
|
5 | #include <qareaseries.h> | |
6 | #include <QTime> |
|
6 | #include <QTime> | |
7 |
|
7 | |||
8 | ChartView::ChartView(QWidget* parent):QChartView(parent), |
|
8 | ChartView::ChartView(QWidget* parent):QChartView(parent), | |
9 | m_index(0) |
|
9 | m_index(0) | |
10 | { |
|
10 | { | |
11 | QTime now = QTime::currentTime(); |
|
11 | QTime now = QTime::currentTime(); | |
12 | qsrand((uint)now.msec()); |
|
12 | qsrand((uint)now.msec()); | |
13 | setChartTitle("Three random line charts"); |
|
13 | setChartTitle("Three random line charts"); | |
14 |
|
14 | |||
15 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); |
|
15 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); | |
16 | m_timer.setInterval(3000); |
|
16 | m_timer.setInterval(3000); | |
17 |
|
17 | |||
18 | //![1] |
|
18 | //![1] | |
19 | QLineSeries* series0 = new QLineSeries(this); |
|
19 | QLineSeries* series0 = new QLineSeries(this); | |
20 | QPen blue(Qt::blue); |
|
20 | QPen blue(Qt::blue); | |
21 | blue.setWidth(3); |
|
21 | blue.setWidth(3); | |
22 | series0->setPen(blue); |
|
22 | series0->setPen(blue); | |
23 |
|
23 | |||
24 | QScatterSeries* series1 = new QScatterSeries(this); |
|
24 | QScatterSeries* series1 = new QScatterSeries(this); | |
25 | QPen red(Qt::red); |
|
25 | QPen red(Qt::red); | |
26 | red.setWidth(3); |
|
26 | red.setWidth(3); | |
27 | series1->setPen(red); |
|
27 | series1->setPen(red); | |
28 | series1->setBrush(Qt::white); |
|
28 | series1->setBrush(Qt::white); | |
29 |
|
29 | |||
30 | QSplineSeries* series2 = new QSplineSeries(this); |
|
30 | QSplineSeries* series2 = new QSplineSeries(this); | |
31 | QPen green(Qt::green); |
|
31 | QPen green(Qt::green); | |
32 | green.setWidth(3); |
|
32 | green.setWidth(3); | |
33 | series2->setPen(green); |
|
33 | series2->setPen(green); | |
34 |
|
34 | |||
35 | QAreaSeries* series3 = new QAreaSeries(series0); |
|
35 | QAreaSeries* series3 = new QAreaSeries(series0); | |
36 | QPen yellow(Qt::black); |
|
36 | QPen yellow(Qt::black); | |
37 | yellow.setWidth(3); |
|
37 | yellow.setWidth(3); | |
38 | series3->setPen(yellow); |
|
38 | series3->setPen(yellow); | |
39 | series3->setBrush(Qt::yellow); |
|
39 | series3->setBrush(Qt::yellow); | |
40 | //![1] |
|
40 | //![1] | |
41 |
|
41 | |||
42 | //![2] |
|
42 | //![2] | |
43 | int numPoints = 10; |
|
43 | int numPoints = 10; | |
44 |
|
44 | |||
45 | for (int x = 0; x <= numPoints; ++x) { |
|
45 | for (int x = 0; x <= numPoints; ++x) { | |
46 | qreal y = qrand() % 100; |
|
46 | qreal y = qrand() % 100; | |
47 | series0->add(x,y); |
|
47 | series0->add(x,y); | |
48 | series1->add(x,y); |
|
48 | series1->add(x,y); | |
49 | series2->add(x,y); |
|
49 | series2->add(x,y); | |
50 | } |
|
50 | } | |
51 | //![2] |
|
51 | //![2] | |
52 |
|
52 | |||
53 | //![3] |
|
53 | //![3] | |
54 | m_series<<series0; |
|
54 | m_series<<series0; | |
55 | m_titles<<chartTitle()+": LineChart"; |
|
55 | m_titles<<chartTitle()+": LineChart"; | |
56 | m_series<<series1; |
|
56 | m_series<<series1; | |
57 | m_titles<<chartTitle()+": ScatterChart"; |
|
57 | m_titles<<chartTitle()+": ScatterChart"; | |
58 | m_series<<series2; |
|
58 | m_series<<series2; | |
59 | m_titles<<chartTitle()+": SplineChart"; |
|
59 | m_titles<<chartTitle()+": SplineChart"; | |
60 | m_series<<series3; |
|
60 | m_series<<series3; | |
61 | m_titles<<chartTitle()+": AreaChart"; |
|
61 | m_titles<<chartTitle()+": AreaChart"; | |
62 | //![3] |
|
62 | //![3] | |
63 |
|
63 | |||
64 | addSeries(series0); |
|
64 | addSeries(series0); | |
65 | setChartTitle(m_titles.at(0)); |
|
65 | setChartTitle(m_titles.at(0)); | |
66 |
|
66 | |||
|
67 | //![4] | |||
67 | foreach (QSeries* series, m_series) { |
|
68 | foreach (QSeries* series, m_series) { | |
68 | QObject::connect(series,SIGNAL(clicked(const QPointF&)),this,SLOT(handlePointClicked(const QPointF&))); |
|
69 | QObject::connect(series,SIGNAL(clicked(const QPointF&)),this,SLOT(handlePointClicked(const QPointF&))); | |
69 | } |
|
70 | } | |
|
71 | //![4] | |||
70 |
|
72 | |||
71 | m_timer.start(); |
|
73 | m_timer.start(); | |
72 | } |
|
74 | } | |
73 |
|
75 | |||
74 | ChartView::~ChartView() |
|
76 | ChartView::~ChartView() | |
75 | { |
|
77 | { | |
76 | if(m_series.size()==0) return; |
|
78 | if(m_series.size()==0) return; | |
77 | removeSeries(m_series.at(m_index)); |
|
79 | removeSeries(m_series.at(m_index)); | |
78 | qDeleteAll(m_series); |
|
80 | qDeleteAll(m_series); | |
79 | } |
|
81 | } | |
80 |
|
82 | |||
81 |
//![ |
|
83 | //![5] | |
82 | void ChartView::handleTimeout() |
|
84 | void ChartView::handleTimeout() | |
83 | { |
|
85 | { | |
84 | if(m_series.size()==0) return; |
|
86 | if(m_series.size()==0) return; | |
85 | removeSeries(m_series.at(m_index)); |
|
87 | removeSeries(m_series.at(m_index)); | |
86 | m_index++; |
|
88 | m_index++; | |
87 | m_index=m_index%m_series.size(); |
|
89 | m_index=m_index%m_series.size(); | |
88 | addSeries(m_series.at(m_index)); |
|
90 | addSeries(m_series.at(m_index)); | |
89 | setChartTitle(m_titles.at(m_index)); |
|
91 | setChartTitle(m_titles.at(m_index)); | |
90 | } |
|
92 | } | |
91 |
//![ |
|
93 | //![5] | |
92 |
|
94 | |||
|
95 | //![6] | |||
93 | void ChartView::handlePointClicked(const QPointF& point) |
|
96 | void ChartView::handlePointClicked(const QPointF& point) | |
94 | { |
|
97 | { | |
95 | setChartTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y())); |
|
98 | setChartTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y())); | |
96 | } |
|
99 | } | |
|
100 | //![6] |
@@ -1,124 +1,129 | |||||
1 | #include "qareaseries.h" |
|
1 | #include "qareaseries.h" | |
2 | #include "qlineseries.h" |
|
2 | #include "qlineseries.h" | |
3 |
|
3 | |||
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 | /*! |
|
6 | /*! | |
7 | \class QAreaSeries |
|
7 | \class QAreaSeries | |
8 | \brief The QAreaSeries class is used for making area charts. |
|
8 | \brief The QAreaSeries class is used for making area charts. | |
9 |
|
9 | |||
10 | \mainclass |
|
10 | \mainclass | |
11 |
|
11 | |||
12 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line |
|
12 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line | |
13 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
13 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
14 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. |
|
14 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. | |
15 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases |
|
15 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
16 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. |
|
16 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
17 |
|
17 | |||
18 | \image areachart.png |
|
18 | \image areachart.png | |
19 |
|
19 | |||
20 | Creating basic area chart is simple: |
|
20 | Creating basic area chart is simple: | |
21 | \code |
|
21 | \code | |
22 | QLineSeries* lineSeries = new QLineSeries(); |
|
22 | QLineSeries* lineSeries = new QLineSeries(); | |
23 | series->add(0, 6); |
|
23 | series->add(0, 6); | |
24 | series->add(2, 4); |
|
24 | series->add(2, 4); | |
25 | QAreaSeries* areaSeries = new QAreaSeries(lineSeries); |
|
25 | QAreaSeries* areaSeries = new QAreaSeries(lineSeries); | |
26 | ... |
|
26 | ... | |
27 | chartView->addSeries(areaSeries); |
|
27 | chartView->addSeries(areaSeries); | |
28 | \endcode |
|
28 | \endcode | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \fn virtual QSeriesType QAreaSeries::type() const |
|
32 | \fn virtual QSeriesType QAreaSeries::type() const | |
33 | \brief Returns type of series. |
|
33 | \brief Returns type of series. | |
34 | \sa QSeries, QSeriesType |
|
34 | \sa QSeries, QSeriesType | |
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \fn QLineSeries* QAreaSeries::upperSeries() const |
|
38 | \fn QLineSeries* QAreaSeries::upperSeries() const | |
39 | \brief Returns upperSeries used to define one of area boundaries. |
|
39 | \brief Returns upperSeries used to define one of area boundaries. | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 | \fn QLineSeries* QAreaSeries::lowerSeries() const |
|
43 | \fn QLineSeries* QAreaSeries::lowerSeries() const | |
44 | \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries |
|
44 | \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries | |
45 | this function return Null pointer. |
|
45 | this function return Null pointer. | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \fn QPen QAreaSeries::pen() const |
|
49 | \fn QPen QAreaSeries::pen() const | |
50 | \brief Returns the pen used to draw line for this series. |
|
50 | \brief Returns the pen used to draw line for this series. | |
51 | \sa setPen() |
|
51 | \sa setPen() | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \fn QPen QAreaSeries::brush() const |
|
55 | \fn QPen QAreaSeries::brush() const | |
56 | \brief Returns the brush used to draw line for this series. |
|
56 | \brief Returns the brush used to draw line for this series. | |
57 | \sa setBrush() |
|
57 | \sa setBrush() | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | \fn bool QAreaSeries::pointsVisible() const |
|
61 | \fn bool QAreaSeries::pointsVisible() const | |
62 | \brief Returns if the points are drawn for this series. |
|
62 | \brief Returns if the points are drawn for this series. | |
63 | \sa setPointsVisible() |
|
63 | \sa setPointsVisible() | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
|
67 | \fn void QAreaSeries::clicked(const QPointF& point) | |||
|
68 | \brief Signal is emitted when user clicks the \a point on area chart. | |||
|
69 | */ | |||
|
70 | ||||
|
71 | /*! | |||
67 | \fn void QAreaSeries::updated() |
|
72 | \fn void QAreaSeries::updated() | |
68 | \brief \internal |
|
73 | \brief \internal | |
69 | */ |
|
74 | */ | |
70 |
|
75 | |||
71 | /*! |
|
76 | /*! | |
72 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
77 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
73 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
78 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
74 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
79 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
75 | */ |
|
80 | */ | |
76 | QAreaSeries::QAreaSeries(QLineSeries* upperSeries,QLineSeries* lowerSeries):QSeries(upperSeries), |
|
81 | QAreaSeries::QAreaSeries(QLineSeries* upperSeries,QLineSeries* lowerSeries):QSeries(upperSeries), | |
77 | m_upperSeries(upperSeries), |
|
82 | m_upperSeries(upperSeries), | |
78 | m_lowerSeries(lowerSeries), |
|
83 | m_lowerSeries(lowerSeries), | |
79 | m_pointsVisible(false) |
|
84 | m_pointsVisible(false) | |
80 | { |
|
85 | { | |
81 | } |
|
86 | } | |
82 | /*! |
|
87 | /*! | |
83 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
88 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
84 | and are deleted when mentioned object are destroyed. |
|
89 | and are deleted when mentioned object are destroyed. | |
85 | */ |
|
90 | */ | |
86 | QAreaSeries::~QAreaSeries() |
|
91 | QAreaSeries::~QAreaSeries() | |
87 | { |
|
92 | { | |
88 | } |
|
93 | } | |
89 |
|
94 | |||
90 | /*! |
|
95 | /*! | |
91 | Sets \a pen used for drawing area outline. |
|
96 | Sets \a pen used for drawing area outline. | |
92 | */ |
|
97 | */ | |
93 | void QAreaSeries::setPen(const QPen& pen) |
|
98 | void QAreaSeries::setPen(const QPen& pen) | |
94 | { |
|
99 | { | |
95 | if(m_pen!=pen){ |
|
100 | if(m_pen!=pen){ | |
96 | m_pen=pen; |
|
101 | m_pen=pen; | |
97 | emit updated(); |
|
102 | emit updated(); | |
98 | } |
|
103 | } | |
99 | } |
|
104 | } | |
100 |
|
105 | |||
101 | /*! |
|
106 | /*! | |
102 | Sets \a brush used for filling the area. |
|
107 | Sets \a brush used for filling the area. | |
103 | */ |
|
108 | */ | |
104 | void QAreaSeries::setBrush(const QBrush& brush) |
|
109 | void QAreaSeries::setBrush(const QBrush& brush) | |
105 | { |
|
110 | { | |
106 | if(m_brush!=brush){ |
|
111 | if(m_brush!=brush){ | |
107 | m_brush=brush; |
|
112 | m_brush=brush; | |
108 | emit updated(); |
|
113 | emit updated(); | |
109 | } |
|
114 | } | |
110 | } |
|
115 | } | |
111 | /*! |
|
116 | /*! | |
112 | Sets if data points are \a visible and should be drawn on line. |
|
117 | Sets if data points are \a visible and should be drawn on line. | |
113 | */ |
|
118 | */ | |
114 | void QAreaSeries::setPointsVisible(bool visible) |
|
119 | void QAreaSeries::setPointsVisible(bool visible) | |
115 | { |
|
120 | { | |
116 | if(m_pointsVisible!=visible){ |
|
121 | if(m_pointsVisible!=visible){ | |
117 | m_pointsVisible=visible; |
|
122 | m_pointsVisible=visible; | |
118 | emit updated(); |
|
123 | emit updated(); | |
119 | } |
|
124 | } | |
120 | } |
|
125 | } | |
121 |
|
126 | |||
122 | #include "moc_qareaseries.cpp" |
|
127 | #include "moc_qareaseries.cpp" | |
123 |
|
128 | |||
124 | QTCOMMERCIALCHART_END_NAMESPACE |
|
129 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,103 +1,98 | |||||
1 | #include "qscatterseries.h" |
|
1 | #include "qscatterseries.h" | |
2 | #include "qchart.h" |
|
2 | #include "qchart.h" | |
3 |
|
3 | |||
4 | /*! |
|
4 | /*! | |
5 | \class QScatterSeries |
|
5 | \class QScatterSeries | |
6 | \brief The QScatterSeries class is used for making scatter charts. |
|
6 | \brief The QScatterSeries class is used for making scatter charts. | |
7 |
|
7 | |||
8 | \mainclass |
|
8 | \mainclass | |
9 |
|
9 | |||
10 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
10 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
11 | and the vertical axis. |
|
11 | and the vertical axis. | |
12 |
|
12 | |||
13 | \image scatterchart.png |
|
13 | \image scatterchart.png | |
14 |
|
14 | |||
15 | Creating basic scatter chart is simple: |
|
15 | Creating basic scatter chart is simple: | |
16 | \code |
|
16 | \code | |
17 | QScatterSeries* series = new QScatterSeries(); |
|
17 | QScatterSeries* series = new QScatterSeries(); | |
18 | series->add(0, 6); |
|
18 | series->add(0, 6); | |
19 | series->add(2, 4); |
|
19 | series->add(2, 4); | |
20 | ... |
|
20 | ... | |
21 | chartView->addSeries(series); |
|
21 | chartView->addSeries(series); | |
22 | \endcode |
|
22 | \endcode | |
23 | */ |
|
23 | */ | |
24 |
|
24 | |||
25 | /*! |
|
25 | /*! | |
26 | \enum QScatterSeries::MarkerShape |
|
26 | \enum QScatterSeries::MarkerShape | |
27 |
|
27 | |||
28 | This enum describes the shape used when rendering marker items. |
|
28 | This enum describes the shape used when rendering marker items. | |
29 |
|
29 | |||
30 | \value MarkerShapeCircle |
|
30 | \value MarkerShapeCircle | |
31 | \value MarkerShapeRectangle |
|
31 | \value MarkerShapeRectangle | |
32 | */ |
|
32 | */ | |
33 |
|
33 | |||
34 | /*! |
|
34 | /*! | |
35 | \fn QChartSeriesType QScatterSeries::type() const |
|
35 | \fn QChartSeriesType QScatterSeries::type() const | |
36 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
36 | \brief Returns QChartSeries::SeriesTypeScatter. | |
37 | \sa QSeries, QSeriesType |
|
37 | \sa QSeries, QSeriesType | |
38 | */ |
|
38 | */ | |
39 |
|
39 | |||
40 | /*! |
|
|||
41 | \fn void QScatterSeries::clicked(const QPointF& point) |
|
|||
42 | \brief Signal is emitted when user clicks the \a point on scatter chart. |
|
|||
43 | */ |
|
|||
44 |
|
||||
45 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
46 |
|
41 | |||
47 | /*! |
|
42 | /*! | |
48 | Constructs a series object which is a child of \a parent. |
|
43 | Constructs a series object which is a child of \a parent. | |
49 | */ |
|
44 | */ | |
50 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
45 | QScatterSeries::QScatterSeries(QObject *parent) : | |
51 | QXYSeries(parent), |
|
46 | QXYSeries(parent), | |
52 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
47 | m_shape(QScatterSeries::MarkerShapeCircle), | |
53 | m_size(9.0) |
|
48 | m_size(9.0) | |
54 | { |
|
49 | { | |
55 | } |
|
50 | } | |
56 |
|
51 | |||
57 | /*! |
|
52 | /*! | |
58 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
53 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
59 | */ |
|
54 | */ | |
60 | QScatterSeries::~QScatterSeries() |
|
55 | QScatterSeries::~QScatterSeries() | |
61 | { |
|
56 | { | |
62 | } |
|
57 | } | |
63 |
|
58 | |||
64 | /*! |
|
59 | /*! | |
65 | Returns the shape used for drawing markers. |
|
60 | Returns the shape used for drawing markers. | |
66 | */ |
|
61 | */ | |
67 | QScatterSeries::MarkerShape QScatterSeries::shape() const |
|
62 | QScatterSeries::MarkerShape QScatterSeries::shape() const | |
68 | { |
|
63 | { | |
69 | return m_shape; |
|
64 | return m_shape; | |
70 | } |
|
65 | } | |
71 |
|
66 | |||
72 | /*! |
|
67 | /*! | |
73 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
68 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
74 | is defined by chart theme setting. |
|
69 | is defined by chart theme setting. | |
75 | */ |
|
70 | */ | |
76 | void QScatterSeries::setShape(MarkerShape shape) |
|
71 | void QScatterSeries::setShape(MarkerShape shape) | |
77 | { |
|
72 | { | |
78 | if(m_shape!= shape){ |
|
73 | if(m_shape!= shape){ | |
79 | m_shape=shape; |
|
74 | m_shape=shape; | |
80 | emit QXYSeries::updated(); |
|
75 | emit QXYSeries::updated(); | |
81 | } |
|
76 | } | |
82 | } |
|
77 | } | |
83 |
|
78 | |||
84 | /*! |
|
79 | /*! | |
85 | Returns the size of the marker items. |
|
80 | Returns the size of the marker items. | |
86 | */ |
|
81 | */ | |
87 | qreal QScatterSeries::size() const |
|
82 | qreal QScatterSeries::size() const | |
88 | { |
|
83 | { | |
89 | return m_size; |
|
84 | return m_size; | |
90 | } |
|
85 | } | |
91 |
|
86 | |||
92 | /*! |
|
87 | /*! | |
93 | Set the \a size of the marker items. The default size is 9.0. |
|
88 | Set the \a size of the marker items. The default size is 9.0. | |
94 | */ |
|
89 | */ | |
95 | void QScatterSeries::setSize(qreal size) |
|
90 | void QScatterSeries::setSize(qreal size) | |
96 | { |
|
91 | { | |
97 | if(m_size != size){ |
|
92 | if(m_size != size){ | |
98 | m_size=size; |
|
93 | m_size=size; | |
99 | emit updated(); |
|
94 | emit updated(); | |
100 | } |
|
95 | } | |
101 | } |
|
96 | } | |
102 |
|
97 | |||
103 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,303 +1,308 | |||||
1 | #include "qxyseries.h" |
|
1 | #include "qxyseries.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 | /*! |
|
5 | /*! | |
6 | \class QXYSeries |
|
6 | \class QXYSeries | |
7 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
7 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | /*! |
|
10 | /*! | |
11 | \fn QPen QXYSeries::pen() const |
|
11 | \fn QPen QXYSeries::pen() const | |
12 | \brief Returns pen used to draw points for series. |
|
12 | \brief Returns pen used to draw points for series. | |
13 | \sa setPen() |
|
13 | \sa setPen() | |
14 | */ |
|
14 | */ | |
15 |
|
15 | |||
16 | /*! |
|
16 | /*! | |
17 | \fn QBrush QXYSeries::brush() const |
|
17 | \fn QBrush QXYSeries::brush() const | |
18 | \brief Returns brush used to draw points for series. |
|
18 | \brief Returns brush used to draw points for series. | |
19 | \sa setBrush() |
|
19 | \sa setBrush() | |
20 | */ |
|
20 | */ | |
21 |
|
21 | |||
22 | /*! |
|
22 | /*! | |
|
23 | \fn void QXYSeries::clicked(const QPointF& point) | |||
|
24 | \brief Signal is emitted when user clicks the \a point on chart. | |||
|
25 | */ | |||
|
26 | ||||
|
27 | /*! | |||
23 | \fn void QXYSeries::pointReplaced(int index) |
|
28 | \fn void QXYSeries::pointReplaced(int index) | |
24 | \brief \internal \a index |
|
29 | \brief \internal \a index | |
25 | */ |
|
30 | */ | |
26 |
|
31 | |||
27 | /*! |
|
32 | /*! | |
28 | \fn void QXYSeries::pointAdded(int index) |
|
33 | \fn void QXYSeries::pointAdded(int index) | |
29 | \brief \internal \a index |
|
34 | \brief \internal \a index | |
30 | */ |
|
35 | */ | |
31 |
|
36 | |||
32 | /*! |
|
37 | /*! | |
33 | \fn void QXYSeries::pointRemoved(int index) |
|
38 | \fn void QXYSeries::pointRemoved(int index) | |
34 | \brief \internal \a index |
|
39 | \brief \internal \a index | |
35 | */ |
|
40 | */ | |
36 |
|
41 | |||
37 | /*! |
|
42 | /*! | |
38 | \fn void QXYSeries::updated() |
|
43 | \fn void QXYSeries::updated() | |
39 | \brief \internal |
|
44 | \brief \internal | |
40 | */ |
|
45 | */ | |
41 |
|
46 | |||
42 | /*! |
|
47 | /*! | |
43 | Constructs empty series object which is a child of \a parent. |
|
48 | Constructs empty series object which is a child of \a parent. | |
44 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
49 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
45 | */ |
|
50 | */ | |
46 | QXYSeries::QXYSeries(QObject* parent):QSeries(parent) |
|
51 | QXYSeries::QXYSeries(QObject* parent):QSeries(parent) | |
47 | { |
|
52 | { | |
48 | m_model = NULL; |
|
53 | m_model = NULL; | |
49 | m_mapX = -1; |
|
54 | m_mapX = -1; | |
50 | m_mapY = -1; |
|
55 | m_mapY = -1; | |
51 | m_mapOrientation = Qt::Vertical; |
|
56 | m_mapOrientation = Qt::Vertical; | |
52 | // m_mapYOrientation = Qt::Vertical; |
|
57 | // m_mapYOrientation = Qt::Vertical; | |
53 | } |
|
58 | } | |
54 | /*! |
|
59 | /*! | |
55 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
60 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
56 | and are deleted when mentioned object are destroyed. |
|
61 | and are deleted when mentioned object are destroyed. | |
57 | */ |
|
62 | */ | |
58 | QXYSeries::~QXYSeries() |
|
63 | QXYSeries::~QXYSeries() | |
59 | { |
|
64 | { | |
60 | } |
|
65 | } | |
61 |
|
66 | |||
62 | /*! |
|
67 | /*! | |
63 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
68 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
64 | */ |
|
69 | */ | |
65 | void QXYSeries::add(qreal x,qreal y) |
|
70 | void QXYSeries::add(qreal x,qreal y) | |
66 | { |
|
71 | { | |
67 | Q_ASSERT(m_x.size() == m_y.size()); |
|
72 | Q_ASSERT(m_x.size() == m_y.size()); | |
68 | m_x<<x; |
|
73 | m_x<<x; | |
69 | m_y<<y; |
|
74 | m_y<<y; | |
70 | emit pointAdded(m_x.size()-1); |
|
75 | emit pointAdded(m_x.size()-1); | |
71 | } |
|
76 | } | |
72 |
|
77 | |||
73 | /*! |
|
78 | /*! | |
74 | This is an overloaded function. |
|
79 | This is an overloaded function. | |
75 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
80 | Adds data \a point to the series. Points are connected with lines on the chart. | |
76 | */ |
|
81 | */ | |
77 | void QXYSeries::add(const QPointF& point) |
|
82 | void QXYSeries::add(const QPointF& point) | |
78 | { |
|
83 | { | |
79 | add(point.x(),point.y()); |
|
84 | add(point.x(),point.y()); | |
80 | } |
|
85 | } | |
81 |
|
86 | |||
82 | /*! |
|
87 | /*! | |
83 | This is an overloaded function. |
|
88 | This is an overloaded function. | |
84 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
89 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
85 | */ |
|
90 | */ | |
86 | void QXYSeries::add(const QList<QPointF> points) |
|
91 | void QXYSeries::add(const QList<QPointF> points) | |
87 | { |
|
92 | { | |
88 | foreach(const QPointF& point , points) { |
|
93 | foreach(const QPointF& point , points) { | |
89 | add(point.x(),point.y()); |
|
94 | add(point.x(),point.y()); | |
90 | } |
|
95 | } | |
91 | } |
|
96 | } | |
92 |
|
97 | |||
93 | /*! |
|
98 | /*! | |
94 | Modifies \a y value for given \a x a value. |
|
99 | Modifies \a y value for given \a x a value. | |
95 | */ |
|
100 | */ | |
96 | void QXYSeries::replace(qreal x,qreal y) |
|
101 | void QXYSeries::replace(qreal x,qreal y) | |
97 | { |
|
102 | { | |
98 | int index = m_x.indexOf(x); |
|
103 | int index = m_x.indexOf(x); | |
99 | m_x[index]=x; |
|
104 | m_x[index]=x; | |
100 | m_y[index]=y; |
|
105 | m_y[index]=y; | |
101 | emit pointReplaced(index); |
|
106 | emit pointReplaced(index); | |
102 | } |
|
107 | } | |
103 |
|
108 | |||
104 | /*! |
|
109 | /*! | |
105 | This is an overloaded function. |
|
110 | This is an overloaded function. | |
106 | Replaces current y value of for given \a point x value with \a point y value. |
|
111 | Replaces current y value of for given \a point x value with \a point y value. | |
107 | */ |
|
112 | */ | |
108 | void QXYSeries::replace(const QPointF& point) |
|
113 | void QXYSeries::replace(const QPointF& point) | |
109 | { |
|
114 | { | |
110 | replace(point.x(),point.y()); |
|
115 | replace(point.x(),point.y()); | |
111 | } |
|
116 | } | |
112 |
|
117 | |||
113 | /*! |
|
118 | /*! | |
114 | Removes current \a x and \a y value. |
|
119 | Removes current \a x and \a y value. | |
115 | */ |
|
120 | */ | |
116 | void QXYSeries::remove(qreal x,qreal y) |
|
121 | void QXYSeries::remove(qreal x,qreal y) | |
117 | { |
|
122 | { | |
118 | int index =-1; |
|
123 | int index =-1; | |
119 | do{ |
|
124 | do{ | |
120 | index = m_x.indexOf(x,index+1); |
|
125 | index = m_x.indexOf(x,index+1); | |
121 | }while(index !=-1 && m_y.at(index)!=y); |
|
126 | }while(index !=-1 && m_y.at(index)!=y); | |
122 |
|
127 | |||
123 | if(index==-1) return; |
|
128 | if(index==-1) return; | |
124 |
|
129 | |||
125 | m_x.remove(index); |
|
130 | m_x.remove(index); | |
126 | m_y.remove(index); |
|
131 | m_y.remove(index); | |
127 | emit pointRemoved(index); |
|
132 | emit pointRemoved(index); | |
128 | } |
|
133 | } | |
129 |
|
134 | |||
130 | /*! |
|
135 | /*! | |
131 | Removes current \a point x value. Note \a point y value is ignored. |
|
136 | Removes current \a point x value. Note \a point y value is ignored. | |
132 | */ |
|
137 | */ | |
133 | void QXYSeries::remove(const QPointF& point) |
|
138 | void QXYSeries::remove(const QPointF& point) | |
134 | { |
|
139 | { | |
135 | remove(point.x(),point.y()); |
|
140 | remove(point.x(),point.y()); | |
136 | } |
|
141 | } | |
137 |
|
142 | |||
138 | /*! |
|
143 | /*! | |
139 | Removes all data points from the series. |
|
144 | Removes all data points from the series. | |
140 | */ |
|
145 | */ | |
141 | void QXYSeries::removeAll() |
|
146 | void QXYSeries::removeAll() | |
142 | { |
|
147 | { | |
143 | m_x.clear(); |
|
148 | m_x.clear(); | |
144 | m_y.clear(); |
|
149 | m_y.clear(); | |
145 | } |
|
150 | } | |
146 |
|
151 | |||
147 | /*! |
|
152 | /*! | |
148 | \internal \a pos |
|
153 | \internal \a pos | |
149 | */ |
|
154 | */ | |
150 | qreal QXYSeries::x(int pos) const |
|
155 | qreal QXYSeries::x(int pos) const | |
151 | { |
|
156 | { | |
152 | if (m_model) |
|
157 | if (m_model) | |
153 | if (m_mapOrientation == Qt::Vertical) |
|
158 | if (m_mapOrientation == Qt::Vertical) | |
154 | // consecutive data is read from model's column |
|
159 | // consecutive data is read from model's column | |
155 | return m_model->data(m_model->index(pos, m_mapX), Qt::DisplayRole).toDouble(); |
|
160 | return m_model->data(m_model->index(pos, m_mapX), Qt::DisplayRole).toDouble(); | |
156 | else |
|
161 | else | |
157 | // consecutive data is read from model's row |
|
162 | // consecutive data is read from model's row | |
158 | return m_model->data(m_model->index(m_mapX, pos), Qt::DisplayRole).toDouble(); |
|
163 | return m_model->data(m_model->index(m_mapX, pos), Qt::DisplayRole).toDouble(); | |
159 | else |
|
164 | else | |
160 | // model is not specified, return the data from series' internal data store |
|
165 | // model is not specified, return the data from series' internal data store | |
161 | return m_x.at(pos); |
|
166 | return m_x.at(pos); | |
162 | } |
|
167 | } | |
163 |
|
168 | |||
164 | /*! |
|
169 | /*! | |
165 | \internal \a pos |
|
170 | \internal \a pos | |
166 | */ |
|
171 | */ | |
167 | qreal QXYSeries::y(int pos) const |
|
172 | qreal QXYSeries::y(int pos) const | |
168 | { |
|
173 | { | |
169 | if (m_model) |
|
174 | if (m_model) | |
170 | if (m_mapOrientation == Qt::Vertical) |
|
175 | if (m_mapOrientation == Qt::Vertical) | |
171 | // consecutive data is read from model's column |
|
176 | // consecutive data is read from model's column | |
172 | return m_model->data(m_model->index(pos, m_mapY), Qt::DisplayRole).toDouble(); |
|
177 | return m_model->data(m_model->index(pos, m_mapY), Qt::DisplayRole).toDouble(); | |
173 | else |
|
178 | else | |
174 | // consecutive data is read from model's row |
|
179 | // consecutive data is read from model's row | |
175 | return m_model->data(m_model->index(m_mapY, pos), Qt::DisplayRole).toDouble(); |
|
180 | return m_model->data(m_model->index(m_mapY, pos), Qt::DisplayRole).toDouble(); | |
176 | else |
|
181 | else | |
177 | // model is not specified, return the data from series' internal data store |
|
182 | // model is not specified, return the data from series' internal data store | |
178 | return m_y.at(pos); |
|
183 | return m_y.at(pos); | |
179 | } |
|
184 | } | |
180 |
|
185 | |||
181 | /*! |
|
186 | /*! | |
182 | Returns number of data points within series. |
|
187 | Returns number of data points within series. | |
183 | */ |
|
188 | */ | |
184 | int QXYSeries::count() const |
|
189 | int QXYSeries::count() const | |
185 | { |
|
190 | { | |
186 | Q_ASSERT(m_x.size() == m_y.size()); |
|
191 | Q_ASSERT(m_x.size() == m_y.size()); | |
187 |
|
192 | |||
188 | if (m_model) |
|
193 | if (m_model) | |
189 | if (m_mapOrientation == Qt::Vertical) |
|
194 | if (m_mapOrientation == Qt::Vertical) | |
190 | // data is in a column, so return the number of items in single column |
|
195 | // data is in a column, so return the number of items in single column | |
191 | return m_model->rowCount(); |
|
196 | return m_model->rowCount(); | |
192 | else |
|
197 | else | |
193 | // data is in a row, so return the number of items in single row |
|
198 | // data is in a row, so return the number of items in single row | |
194 | m_model->columnCount(); |
|
199 | m_model->columnCount(); | |
195 | else |
|
200 | else | |
196 | // model is not specified, return the number of points in the series internal data store |
|
201 | // model is not specified, return the number of points in the series internal data store | |
197 | return m_x.size(); |
|
202 | return m_x.size(); | |
198 | } |
|
203 | } | |
199 |
|
204 | |||
200 | /*! |
|
205 | /*! | |
201 | Returns the data points of the series. |
|
206 | Returns the data points of the series. | |
202 | */ |
|
207 | */ | |
203 | QList<QPointF> QXYSeries::data() |
|
208 | QList<QPointF> QXYSeries::data() | |
204 | { |
|
209 | { | |
205 | QList<QPointF> data; |
|
210 | QList<QPointF> data; | |
206 | for (int i(0); i < m_x.count() && i < m_y.count(); i++) |
|
211 | for (int i(0); i < m_x.count() && i < m_y.count(); i++) | |
207 | data.append(QPointF(m_x.at(i), m_y.at(i))); |
|
212 | data.append(QPointF(m_x.at(i), m_y.at(i))); | |
208 | return data; |
|
213 | return data; | |
209 | } |
|
214 | } | |
210 |
|
215 | |||
211 |
|
216 | |||
212 | /*! |
|
217 | /*! | |
213 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
218 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
214 | pen from chart theme is used. |
|
219 | pen from chart theme is used. | |
215 | \sa QChart::setChartTheme() |
|
220 | \sa QChart::setChartTheme() | |
216 | */ |
|
221 | */ | |
217 | void QXYSeries::setPen(const QPen& pen) |
|
222 | void QXYSeries::setPen(const QPen& pen) | |
218 | { |
|
223 | { | |
219 | if(pen!=m_pen){ |
|
224 | if(pen!=m_pen){ | |
220 | m_pen=pen; |
|
225 | m_pen=pen; | |
221 | emit updated(); |
|
226 | emit updated(); | |
222 | } |
|
227 | } | |
223 | } |
|
228 | } | |
224 |
|
229 | |||
225 | /*! |
|
230 | /*! | |
226 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
231 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
227 | from chart theme setting is used. |
|
232 | from chart theme setting is used. | |
228 | \sa QChart::setChartTheme() |
|
233 | \sa QChart::setChartTheme() | |
229 | */ |
|
234 | */ | |
230 |
|
235 | |||
231 | void QXYSeries::setBrush(const QBrush& brush) |
|
236 | void QXYSeries::setBrush(const QBrush& brush) | |
232 | { |
|
237 | { | |
233 | if(brush!=m_brush){ |
|
238 | if(brush!=m_brush){ | |
234 | m_brush=brush; |
|
239 | m_brush=brush; | |
235 | emit updated(); |
|
240 | emit updated(); | |
236 | } |
|
241 | } | |
237 | } |
|
242 | } | |
238 |
|
243 | |||
239 |
|
244 | |||
240 | /*! |
|
245 | /*! | |
241 | Stream operator for adding a data \a point to the series. |
|
246 | Stream operator for adding a data \a point to the series. | |
242 | \sa add() |
|
247 | \sa add() | |
243 | */ |
|
248 | */ | |
244 |
|
249 | |||
245 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
250 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
246 | { |
|
251 | { | |
247 | add(point); |
|
252 | add(point); | |
248 | return *this; |
|
253 | return *this; | |
249 | } |
|
254 | } | |
250 |
|
255 | |||
251 |
|
256 | |||
252 | /*! |
|
257 | /*! | |
253 | Stream operator for adding a list of \a points to the series. |
|
258 | Stream operator for adding a list of \a points to the series. | |
254 | \sa add() |
|
259 | \sa add() | |
255 | */ |
|
260 | */ | |
256 |
|
261 | |||
257 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) |
|
262 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) | |
258 | { |
|
263 | { | |
259 | add(points); |
|
264 | add(points); | |
260 | return *this; |
|
265 | return *this; | |
261 | } |
|
266 | } | |
262 |
|
267 | |||
263 |
|
268 | |||
264 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
269 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
265 | { |
|
270 | { | |
266 | emit pointReplaced(topLeft.row()); |
|
271 | emit pointReplaced(topLeft.row()); | |
267 | } |
|
272 | } | |
268 |
|
273 | |||
269 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) |
|
274 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) | |
270 | { |
|
275 | { | |
271 | emit pointAdded(start); |
|
276 | emit pointAdded(start); | |
272 | } |
|
277 | } | |
273 |
|
278 | |||
274 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) |
|
279 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) | |
275 | { |
|
280 | { | |
276 | emit pointRemoved(start); |
|
281 | emit pointRemoved(start); | |
277 | } |
|
282 | } | |
278 |
|
283 | |||
279 | bool QXYSeries::setModel(QAbstractItemModel* model) { |
|
284 | bool QXYSeries::setModel(QAbstractItemModel* model) { | |
280 | m_model = model; |
|
285 | m_model = model; | |
281 | // for (int i = 0; i < m_model->rowCount(); i++) |
|
286 | // for (int i = 0; i < m_model->rowCount(); i++) | |
282 | // emit pointAdded(i); |
|
287 | // emit pointAdded(i); | |
283 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
288 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
284 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
289 | connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
285 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
290 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
286 | } |
|
291 | } | |
287 |
|
292 | |||
288 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
293 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
289 | { |
|
294 | { | |
290 | m_mapX = modelX; |
|
295 | m_mapX = modelX; | |
291 | m_mapY = modelY; |
|
296 | m_mapY = modelY; | |
292 | m_mapOrientation = orientation; |
|
297 | m_mapOrientation = orientation; | |
293 | } |
|
298 | } | |
294 |
|
299 | |||
295 | //void QXYSeries::setModelMappingY(int modelLineIndex, Qt::Orientation orientation) |
|
300 | //void QXYSeries::setModelMappingY(int modelLineIndex, Qt::Orientation orientation) | |
296 | //{ |
|
301 | //{ | |
297 | // m_mapY = modelLineIndex; |
|
302 | // m_mapY = modelLineIndex; | |
298 | // m_mapYOrientation = orientation; |
|
303 | // m_mapYOrientation = orientation; | |
299 | //} |
|
304 | //} | |
300 |
|
305 | |||
301 | #include "moc_qxyseries.cpp" |
|
306 | #include "moc_qxyseries.cpp" | |
302 |
|
307 | |||
303 | QTCOMMERCIALCHART_END_NAMESPACE |
|
308 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now