@@ -1,232 +1,254 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QScatterSeries |
|
29 | \class QScatterSeries | |
30 | \brief The QScatterSeries class is used for making scatter charts. |
|
30 | \brief The QScatterSeries class is used for making scatter charts. | |
31 |
|
31 | |||
32 | \mainclass |
|
32 | \mainclass | |
33 |
|
33 | |||
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
35 | and the vertical axis. |
|
35 | and the vertical axis. | |
36 |
|
36 | |||
37 | \image examples_scatterchart.png |
|
37 | \image examples_scatterchart.png | |
38 |
|
38 | |||
39 | Creating basic scatter chart is simple: |
|
39 | Creating basic scatter chart is simple: | |
40 | \code |
|
40 | \code | |
41 | QScatterSeries* series = new QScatterSeries(); |
|
41 | QScatterSeries* series = new QScatterSeries(); | |
42 | series->append(0, 6); |
|
42 | series->append(0, 6); | |
43 | series->append(2, 4); |
|
43 | series->append(2, 4); | |
44 | ... |
|
44 | ... | |
45 | chart->addSeries(series); |
|
45 | chart->addSeries(series); | |
46 | \endcode |
|
46 | \endcode | |
47 | */ |
|
47 | */ | |
48 | /*! |
|
48 | /*! | |
49 | \qmlclass ScatterSeries QScatterSeries |
|
49 | \qmlclass ScatterSeries QScatterSeries | |
50 | \inherits XYSeries |
|
50 | \inherits XYSeries | |
51 |
|
51 | |||
52 | The following QML shows how to create a chart with two simple scatter series: |
|
52 | The following QML shows how to create a chart with two simple scatter series: | |
53 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 |
|
53 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 | |
54 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2 |
|
54 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2 | |
55 |
|
55 | |||
56 | \beginfloatleft |
|
56 | \beginfloatleft | |
57 | \image demos_qmlchart5.png |
|
57 | \image demos_qmlchart5.png | |
58 | \endfloat |
|
58 | \endfloat | |
59 | \clearfloat |
|
59 | \clearfloat | |
60 | */ |
|
60 | */ | |
61 |
|
61 | |||
62 | /*! |
|
62 | /*! | |
63 | \enum QScatterSeries::MarkerShape |
|
63 | \enum QScatterSeries::MarkerShape | |
64 |
|
64 | |||
65 | This enum describes the shape used when rendering marker items. |
|
65 | This enum describes the shape used when rendering marker items. | |
66 |
|
66 | |||
67 | \value MarkerShapeCircle |
|
67 | \value MarkerShapeCircle | |
68 | \value MarkerShapeRectangle |
|
68 | \value MarkerShapeRectangle | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \property QScatterSeries::color |
|
72 | \property QScatterSeries::color | |
73 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. |
|
73 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |
74 | \sa QScatterSeries::brush() |
|
74 | \sa QScatterSeries::brush() | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \property QScatterSeries::borderColor |
|
78 | \property QScatterSeries::borderColor | |
79 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. |
|
79 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
80 | \sa QScatterSeries::pen() |
|
80 | \sa QScatterSeries::pen() | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \property QScatterSeries::markerShape |
|
84 | \property QScatterSeries::markerShape | |
85 | Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. |
|
85 | Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle. | |
86 | */ |
|
86 | */ | |
87 | /*! |
|
87 | /*! | |
88 | \qmlproperty MarkerShape ScatterSeries::markerShape |
|
88 | \qmlproperty MarkerShape ScatterSeries::markerShape | |
89 | Defines the shape of the marker used to draw the points in the series. One of ScatterSeries |
|
89 | Defines the shape of the marker used to draw the points in the series. One of ScatterSeries | |
90 | ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle. |
|
90 | ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle. | |
91 | The default shape is ScatterSeries.MarkerShapeCircle. |
|
91 | The default shape is ScatterSeries.MarkerShapeCircle. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QScatterSeries::markerSize |
|
95 | \property QScatterSeries::markerSize | |
96 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. |
|
96 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty real ScatterSeries::markerSize |
|
99 | \qmlproperty real ScatterSeries::markerSize | |
100 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. |
|
100 | Defines the size of the marker used to draw the points in the series. The default size is 15.0. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \fn void QScatterSeries::colorChanged(QColor color) |
|
104 | \fn void QScatterSeries::colorChanged(QColor color) | |
105 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
105 | Signal is emitted when the fill (brush) color has changed to \a color. | |
106 | */ |
|
106 | */ | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | \fn void QScatterSeries::borderColorChanged(QColor color) |
|
109 | \fn void QScatterSeries::borderColorChanged(QColor color) | |
110 | Signal is emitted when the line (pen) color has changed to \a color. |
|
110 | Signal is emitted when the line (pen) color has changed to \a color. | |
111 | */ |
|
111 | */ | |
112 | /*! |
|
112 | /*! | |
113 | \qmlsignal ScatterSeries::borderColorChanged(color color) |
|
113 | \qmlsignal ScatterSeries::borderColorChanged(color color) | |
114 | Signal is emitted when the line (pen) color has changed to \a color. |
|
114 | Signal is emitted when the line (pen) color has changed to \a color. | |
115 | */ |
|
115 | */ | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | \fn QChartSeriesType QScatterSeries::type() const |
|
118 | \fn QChartSeriesType QScatterSeries::type() const | |
119 | Returns QChartSeries::SeriesTypeScatter. |
|
119 | Returns QChartSeries::SeriesTypeScatter. | |
120 | \sa QAbstractSeries, SeriesType |
|
120 | \sa QAbstractSeries, SeriesType | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
123 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | Constructs a series object which is a child of \a parent. |
|
126 | Constructs a series object which is a child of \a parent. | |
127 | */ |
|
127 | */ | |
128 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
128 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
129 | { |
|
129 | { | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
133 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
134 | */ |
|
134 | */ | |
135 | QScatterSeries::~QScatterSeries() |
|
135 | QScatterSeries::~QScatterSeries() | |
136 | { |
|
136 | { | |
137 | Q_D(QScatterSeries); |
|
137 | Q_D(QScatterSeries); | |
138 | if(d->m_dataset) { |
|
138 | if(d->m_dataset) { | |
139 | d->m_dataset->removeSeries(this); |
|
139 | d->m_dataset->removeSeries(this); | |
140 | } |
|
140 | } | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
143 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
144 | { |
|
144 | { | |
145 | return QAbstractSeries::SeriesTypeScatter; |
|
145 | return QAbstractSeries::SeriesTypeScatter; | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
|
148 | void QScatterSeries::setPen(const QPen &pen) | |||
|
149 | { | |||
|
150 | Q_D(QXYSeries); | |||
|
151 | if (d->m_pen != pen) { | |||
|
152 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |||
|
153 | d->m_pen = pen; | |||
|
154 | emit d->updated(); | |||
|
155 | if (emitColorChanged) | |||
|
156 | emit borderColorChanged(pen.color()); | |||
|
157 | } | |||
|
158 | } | |||
|
159 | ||||
|
160 | void QScatterSeries::setBrush(const QBrush &brush) | |||
|
161 | { | |||
|
162 | Q_D(QScatterSeries); | |||
|
163 | if (d->m_brush != brush) { | |||
|
164 | bool emitColorChanged = d->m_brush.color() != brush.color(); | |||
|
165 | d->m_brush = brush; | |||
|
166 | emit d->updated(); | |||
|
167 | if (emitColorChanged) | |||
|
168 | emit colorChanged(brush.color()); | |||
|
169 | } | |||
|
170 | } | |||
|
171 | ||||
148 | void QScatterSeries::setColor(const QColor &color) |
|
172 | void QScatterSeries::setColor(const QColor &color) | |
149 | { |
|
173 | { | |
150 | QBrush b = brush(); |
|
174 | QBrush b = brush(); | |
151 | if (b.color() != color) { |
|
175 | if (b.color() != color) { | |
152 | b.setColor(color); |
|
176 | b.setColor(color); | |
153 | setBrush(b); |
|
177 | setBrush(b); | |
154 | emit colorChanged(color); |
|
|||
155 | } |
|
178 | } | |
156 | } |
|
179 | } | |
157 |
|
180 | |||
158 | QColor QScatterSeries::color() const |
|
181 | QColor QScatterSeries::color() const | |
159 | { |
|
182 | { | |
160 | return brush().color(); |
|
183 | return brush().color(); | |
161 | } |
|
184 | } | |
162 |
|
185 | |||
163 | void QScatterSeries::setBorderColor(const QColor &color) |
|
186 | void QScatterSeries::setBorderColor(const QColor &color) | |
164 | { |
|
187 | { | |
165 | QPen p = pen(); |
|
188 | QPen p = pen(); | |
166 | if (p.color() != color) { |
|
189 | if (p.color() != color) { | |
167 | p.setColor(color); |
|
190 | p.setColor(color); | |
168 | setPen(p); |
|
191 | setPen(p); | |
169 | emit borderColorChanged(color); |
|
|||
170 | } |
|
192 | } | |
171 | } |
|
193 | } | |
172 |
|
194 | |||
173 | QColor QScatterSeries::borderColor() const |
|
195 | QColor QScatterSeries::borderColor() const | |
174 | { |
|
196 | { | |
175 | return pen().color(); |
|
197 | return pen().color(); | |
176 | } |
|
198 | } | |
177 |
|
199 | |||
178 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const |
|
200 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const | |
179 | { |
|
201 | { | |
180 | Q_D(const QScatterSeries); |
|
202 | Q_D(const QScatterSeries); | |
181 | return d->m_shape; |
|
203 | return d->m_shape; | |
182 | } |
|
204 | } | |
183 |
|
205 | |||
184 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
206 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
185 | { |
|
207 | { | |
186 | Q_D(QScatterSeries); |
|
208 | Q_D(QScatterSeries); | |
187 | if (d->m_shape != shape) { |
|
209 | if (d->m_shape != shape) { | |
188 | d->m_shape = shape; |
|
210 | d->m_shape = shape; | |
189 | emit d->updated(); |
|
211 | emit d->updated(); | |
190 | } |
|
212 | } | |
191 | } |
|
213 | } | |
192 |
|
214 | |||
193 | qreal QScatterSeries::markerSize() const |
|
215 | qreal QScatterSeries::markerSize() const | |
194 | { |
|
216 | { | |
195 | Q_D(const QScatterSeries); |
|
217 | Q_D(const QScatterSeries); | |
196 | return d->m_size; |
|
218 | return d->m_size; | |
197 | } |
|
219 | } | |
198 |
|
220 | |||
199 | void QScatterSeries::setMarkerSize(qreal size) |
|
221 | void QScatterSeries::setMarkerSize(qreal size) | |
200 | { |
|
222 | { | |
201 | Q_D(QScatterSeries); |
|
223 | Q_D(QScatterSeries); | |
202 |
|
224 | |||
203 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
225 | if (!qFuzzyIsNull(d->m_size - size)) { | |
204 | d->m_size = size; |
|
226 | d->m_size = size; | |
205 | emit d->updated(); |
|
227 | emit d->updated(); | |
206 | } |
|
228 | } | |
207 | } |
|
229 | } | |
208 |
|
230 | |||
209 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
231 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
210 |
|
232 | |||
211 |
QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q): |
|
233 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q) : | |
212 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
234 | QXYSeriesPrivate(q), | |
213 | m_size(15.0) |
|
235 | m_shape(QScatterSeries::MarkerShapeCircle), | |
|
236 | m_size(15.0) | |||
214 | { |
|
237 | { | |
215 |
|
238 | } | ||
216 | }; |
|
|||
217 |
|
239 | |||
218 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
240 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
219 | { |
|
241 | { | |
220 | Q_Q(QScatterSeries); |
|
242 | Q_Q(QScatterSeries); | |
221 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
243 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
222 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
244 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
223 | scatter->setAnimator(presenter->animator()); |
|
245 | scatter->setAnimator(presenter->animator()); | |
224 | scatter->setAnimation(new XYAnimation(scatter)); |
|
246 | scatter->setAnimation(new XYAnimation(scatter)); | |
225 | } |
|
247 | } | |
226 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
248 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
227 | return scatter; |
|
249 | return scatter; | |
228 | } |
|
250 | } | |
229 |
|
251 | |||
230 | #include "moc_qscatterseries.cpp" |
|
252 | #include "moc_qscatterseries.cpp" | |
231 |
|
253 | |||
232 | QTCOMMERCIALCHART_END_NAMESPACE |
|
254 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,71 +1,73 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QSCATTERSERIES_H |
|
21 | #ifndef QSCATTERSERIES_H | |
22 | #define QSCATTERSERIES_H |
|
22 | #define QSCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QScatterSeriesPrivate; |
|
29 | class QScatterSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
34 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
35 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
35 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
36 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape) |
|
36 | Q_PROPERTY(MarkerShape markerShape READ markerShape WRITE setMarkerShape) | |
37 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize) |
|
37 | Q_PROPERTY(qreal markerSize READ markerSize WRITE setMarkerSize) | |
38 | Q_ENUMS(MarkerShape) |
|
38 | Q_ENUMS(MarkerShape) | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | enum MarkerShape { |
|
41 | enum MarkerShape { | |
42 | MarkerShapeCircle, |
|
42 | MarkerShapeCircle, | |
43 | MarkerShapeRectangle |
|
43 | MarkerShapeRectangle | |
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | explicit QScatterSeries(QObject *parent = 0); |
|
47 | explicit QScatterSeries(QObject *parent = 0); | |
48 | ~QScatterSeries(); |
|
48 | ~QScatterSeries(); | |
49 | QAbstractSeries::SeriesType type() const; |
|
49 | QAbstractSeries::SeriesType type() const; | |
|
50 | void setPen(const QPen &pen); | |||
|
51 | void setBrush(const QBrush &brush); | |||
50 | void setColor(const QColor &color); |
|
52 | void setColor(const QColor &color); | |
51 | QColor color() const; |
|
53 | QColor color() const; | |
52 | void setBorderColor(const QColor &color); |
|
54 | void setBorderColor(const QColor &color); | |
53 | QColor borderColor() const; |
|
55 | QColor borderColor() const; | |
54 | MarkerShape markerShape() const; |
|
56 | MarkerShape markerShape() const; | |
55 | void setMarkerShape(MarkerShape shape); |
|
57 | void setMarkerShape(MarkerShape shape); | |
56 | qreal markerSize() const; |
|
58 | qreal markerSize() const; | |
57 | void setMarkerSize(qreal size); |
|
59 | void setMarkerSize(qreal size); | |
58 |
|
60 | |||
59 | Q_SIGNALS: |
|
61 | Q_SIGNALS: | |
60 | void colorChanged(QColor color); |
|
62 | void colorChanged(QColor color); | |
61 | void borderColorChanged(QColor color); |
|
63 | void borderColorChanged(QColor color); | |
62 |
|
64 | |||
63 | private: |
|
65 | private: | |
64 | Q_DECLARE_PRIVATE(QScatterSeries) |
|
66 | Q_DECLARE_PRIVATE(QScatterSeries) | |
65 | Q_DISABLE_COPY(QScatterSeries) |
|
67 | Q_DISABLE_COPY(QScatterSeries) | |
66 | friend class ScatterChartItem; |
|
68 | friend class ScatterChartItem; | |
67 | }; |
|
69 | }; | |
68 |
|
70 | |||
69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
71 | QTCOMMERCIALCHART_END_NAMESPACE | |
70 |
|
72 | |||
71 | #endif // QSCATTERSERIES_H |
|
73 | #endif // QSCATTERSERIES_H |
@@ -1,52 +1,51 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QSCATTERSERIES_P_H |
|
30 | #ifndef QSCATTERSERIES_P_H | |
31 | #define QSCATTERSERIES_P_H |
|
31 | #define QSCATTERSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qxyseries_p.h" |
|
33 | #include "qxyseries_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QScatterSeriesPrivate: public QXYSeriesPrivate |
|
37 | class QScatterSeriesPrivate: public QXYSeriesPrivate | |
38 | { |
|
38 | { | |
39 | public: |
|
39 | public: | |
40 | QScatterSeriesPrivate(QScatterSeries* q); |
|
40 | QScatterSeriesPrivate(QScatterSeries* q); | |
41 | Chart* createGraphics(ChartPresenter* presenter); |
|
41 | Chart* createGraphics(ChartPresenter* presenter); | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | QScatterSeries::MarkerShape m_shape; |
|
44 | QScatterSeries::MarkerShape m_shape; | |
45 | qreal m_size; |
|
45 | qreal m_size; | |
46 |
Q_DECLARE_PUBLIC(QScatterSeries) |
|
46 | Q_DECLARE_PUBLIC(QScatterSeries) | |
47 |
|
||||
48 | }; |
|
47 | }; | |
49 |
|
48 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
49 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
50 | |||
52 | #endif |
|
51 | #endif |
@@ -1,438 +1,440 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "domain_p.h" |
|
23 | #include "domain_p.h" | |
24 | #include "legendmarker_p.h" |
|
24 | #include "legendmarker_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QXYSeries |
|
29 | \class QXYSeries | |
30 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
30 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
31 | */ |
|
31 | */ | |
32 | /*! |
|
32 | /*! | |
33 | \qmlclass XYSeries |
|
33 | \qmlclass XYSeries | |
34 | \inherits AbstractSeries |
|
34 | \inherits AbstractSeries | |
35 | The XYSeries class is a base class for line, spline and scatter series. |
|
35 | The XYSeries class is a base class for line, spline and scatter series. | |
36 |
|
36 | |||
37 | The class cannot be instantiated directly. |
|
37 | The class cannot be instantiated directly. | |
38 | */ |
|
38 | */ | |
39 |
|
39 | |||
40 | /*! |
|
40 | /*! | |
41 | \property QXYSeries::pointsVisible |
|
41 | \property QXYSeries::pointsVisible | |
42 | Controls if the data points are visible and should be drawn. |
|
42 | Controls if the data points are visible and should be drawn. | |
43 | */ |
|
43 | */ | |
44 | /*! |
|
44 | /*! | |
45 | \qmlproperty bool XYSeries::pointsVisible |
|
45 | \qmlproperty bool XYSeries::pointsVisible | |
46 | Controls if the data points are visible and should be drawn. |
|
46 | Controls if the data points are visible and should be drawn. | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \fn QPen QXYSeries::pen() const |
|
50 | \fn QPen QXYSeries::pen() const | |
51 | \brief Returns pen used to draw points for series. |
|
51 | \brief Returns pen used to draw points for series. | |
52 | \sa setPen() |
|
52 | \sa setPen() | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \fn QBrush QXYSeries::brush() const |
|
56 | \fn QBrush QXYSeries::brush() const | |
57 | \brief Returns brush used to draw points for series. |
|
57 | \brief Returns brush used to draw points for series. | |
58 | \sa setBrush() |
|
58 | \sa setBrush() | |
59 | */ |
|
59 | */ | |
60 |
|
60 | |||
61 | /*! |
|
61 | /*! | |
62 | \property QXYSeries::color |
|
62 | \property QXYSeries::color | |
63 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
63 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and | |
64 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
64 | fill (brush) color in case of QScatterSeries or QAreaSeries. | |
65 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
65 | \sa QXYSeries::pen(), QXYSeries::brush() | |
66 | */ |
|
66 | */ | |
67 | /*! |
|
67 | /*! | |
68 | \qmlproperty color XYSeries::color |
|
68 | \qmlproperty color XYSeries::color | |
69 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
69 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and | |
70 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
70 | fill (brush) color in case of ScatterSeries or AreaSeries. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \fn void QXYSeries::clicked(const QPointF& point) |
|
74 | \fn void QXYSeries::clicked(const QPointF& point) | |
75 | \brief Signal is emitted when user clicks the \a point on chart. |
|
75 | \brief Signal is emitted when user clicks the \a point on chart. | |
76 | */ |
|
76 | */ | |
77 | /*! |
|
77 | /*! | |
78 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
78 | \qmlsignal XYSeries::onClicked(QPointF point) | |
79 | Signal is emitted when user clicks the \a point on chart. For example: |
|
79 | Signal is emitted when user clicks the \a point on chart. For example: | |
80 | \code |
|
80 | \code | |
81 | LineSeries { |
|
81 | LineSeries { | |
82 | XYPoint { x: 0; y: 0 } |
|
82 | XYPoint { x: 0; y: 0 } | |
83 | XYPoint { x: 1.1; y: 2.1 } |
|
83 | XYPoint { x: 1.1; y: 2.1 } | |
84 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
84 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
85 | } |
|
85 | } | |
86 | \endcode |
|
86 | \endcode | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \fn void QXYSeries::pointReplaced(int index) |
|
90 | \fn void QXYSeries::pointReplaced(int index) | |
91 | Signal is emitted when a point has been replaced at \a index. |
|
91 | Signal is emitted when a point has been replaced at \a index. | |
92 | \sa replace() |
|
92 | \sa replace() | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
95 | \qmlsignal XYSeries::onPointReplaced(int index) | |
96 | Signal is emitted when a point has been replaced at \a index. |
|
96 | Signal is emitted when a point has been replaced at \a index. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn void QXYSeries::pointAdded(int index) |
|
100 | \fn void QXYSeries::pointAdded(int index) | |
101 | Signal is emitted when a point has been added at \a index. |
|
101 | Signal is emitted when a point has been added at \a index. | |
102 | \sa append(), insert() |
|
102 | \sa append(), insert() | |
103 | */ |
|
103 | */ | |
104 | /*! |
|
104 | /*! | |
105 | \qmlsignal XYSeries::onPointAdded(int index) |
|
105 | \qmlsignal XYSeries::onPointAdded(int index) | |
106 | Signal is emitted when a point has been added at \a index. |
|
106 | Signal is emitted when a point has been added at \a index. | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \fn void QXYSeries::pointRemoved(int index) |
|
110 | \fn void QXYSeries::pointRemoved(int index) | |
111 | Signal is emitted when a point has been removed from \a index. |
|
111 | Signal is emitted when a point has been removed from \a index. | |
112 | \sa remove() |
|
112 | \sa remove() | |
113 | */ |
|
113 | */ | |
114 | /*! |
|
114 | /*! | |
115 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
115 | \qmlsignal XYSeries::onPointRemoved(int index) | |
116 | Signal is emitted when a point has been removed from \a index. |
|
116 | Signal is emitted when a point has been removed from \a index. | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
120 | \fn void QXYSeries::colorChanged(QColor color) |
|
120 | \fn void QXYSeries::colorChanged(QColor color) | |
121 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
121 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
122 | */ |
|
122 | */ | |
123 | /*! |
|
123 | /*! | |
124 | \qmlsignal XYSeries::onColorChanged(color color) |
|
124 | \qmlsignal XYSeries::onColorChanged(color color) | |
125 | Signal is emitted when the line (pen) color has changed to \a color. |
|
125 | Signal is emitted when the line (pen) color has changed to \a color. | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \fn void QXYSeriesPrivate::updated() |
|
129 | \fn void QXYSeriesPrivate::updated() | |
130 | \brief \internal |
|
130 | \brief \internal | |
131 | */ |
|
131 | */ | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | \qmlmethod XYSeries::append(real x, real y) |
|
134 | \qmlmethod XYSeries::append(real x, real y) | |
135 | Append point (\a x, \a y) to the series |
|
135 | Append point (\a x, \a y) to the series | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
139 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
140 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
140 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
141 | exist. |
|
141 | exist. | |
142 | */ |
|
142 | */ | |
143 |
|
143 | |||
144 | /*! |
|
144 | /*! | |
145 | \qmlmethod XYSeries::remove(real x, real y) |
|
145 | \qmlmethod XYSeries::remove(real x, real y) | |
146 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
146 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
150 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
151 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
151 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of | |
152 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
152 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
153 | */ |
|
153 | */ | |
154 |
|
154 | |||
155 | /*! |
|
155 | /*! | |
156 | \qmlmethod QPointF XYSeries::at(int index) |
|
156 | \qmlmethod QPointF XYSeries::at(int index) | |
157 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
157 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
158 | */ |
|
158 | */ | |
159 |
|
159 | |||
160 | /*! |
|
160 | /*! | |
161 | \internal |
|
161 | \internal | |
162 |
|
162 | |||
163 | Constructs empty series object which is a child of \a parent. |
|
163 | Constructs empty series object which is a child of \a parent. | |
164 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
164 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
165 | */ |
|
165 | */ | |
166 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) |
|
166 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) | |
167 | { |
|
167 | { | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
171 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
171 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
172 | and are deleted when mentioned object are destroyed. |
|
172 | and are deleted when mentioned object are destroyed. | |
173 | */ |
|
173 | */ | |
174 | QXYSeries::~QXYSeries() |
|
174 | QXYSeries::~QXYSeries() | |
175 | { |
|
175 | { | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | /*! |
|
178 | /*! | |
179 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
179 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
180 | */ |
|
180 | */ | |
181 | void QXYSeries::append(qreal x,qreal y) |
|
181 | void QXYSeries::append(qreal x,qreal y) | |
182 | { |
|
182 | { | |
183 | append(QPointF(x,y)); |
|
183 | append(QPointF(x,y)); | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | /*! |
|
186 | /*! | |
187 | This is an overloaded function. |
|
187 | This is an overloaded function. | |
188 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
188 | Adds data \a point to the series. Points are connected with lines on the chart. | |
189 | */ |
|
189 | */ | |
190 | void QXYSeries::append(const QPointF &point) |
|
190 | void QXYSeries::append(const QPointF &point) | |
191 | { |
|
191 | { | |
192 | Q_D(QXYSeries); |
|
192 | Q_D(QXYSeries); | |
193 | d->m_points<<point; |
|
193 | d->m_points<<point; | |
194 | // emit d->pointAdded(d->m_points.count()-1); |
|
194 | // emit d->pointAdded(d->m_points.count()-1); | |
195 | emit pointAdded(d->m_points.count()-1); |
|
195 | emit pointAdded(d->m_points.count()-1); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | This is an overloaded function. |
|
199 | This is an overloaded function. | |
200 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
200 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
201 | */ |
|
201 | */ | |
202 | void QXYSeries::append(const QList<QPointF> &points) |
|
202 | void QXYSeries::append(const QList<QPointF> &points) | |
203 | { |
|
203 | { | |
204 | foreach(const QPointF& point , points) { |
|
204 | foreach(const QPointF& point , points) { | |
205 | append(point); |
|
205 | append(point); | |
206 | } |
|
206 | } | |
207 | } |
|
207 | } | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
210 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
211 | */ |
|
211 | */ | |
212 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) |
|
212 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) | |
213 | { |
|
213 | { | |
214 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); |
|
214 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | /*! |
|
217 | /*! | |
218 | Replaces \a oldPoint with \a newPoint. |
|
218 | Replaces \a oldPoint with \a newPoint. | |
219 | */ |
|
219 | */ | |
220 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) |
|
220 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) | |
221 | { |
|
221 | { | |
222 | Q_D(QXYSeries); |
|
222 | Q_D(QXYSeries); | |
223 | int index = d->m_points.indexOf(oldPoint); |
|
223 | int index = d->m_points.indexOf(oldPoint); | |
224 | if(index==-1) return; |
|
224 | if(index==-1) return; | |
225 | d->m_points[index] = newPoint; |
|
225 | d->m_points[index] = newPoint; | |
226 | // emit d->pointReplaced(index); |
|
226 | // emit d->pointReplaced(index); | |
227 | emit pointReplaced(index); |
|
227 | emit pointReplaced(index); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | /*! |
|
230 | /*! | |
231 | Removes current \a x and \a y value. |
|
231 | Removes current \a x and \a y value. | |
232 | */ |
|
232 | */ | |
233 | void QXYSeries::remove(qreal x,qreal y) |
|
233 | void QXYSeries::remove(qreal x,qreal y) | |
234 | { |
|
234 | { | |
235 | remove(QPointF(x,y)); |
|
235 | remove(QPointF(x,y)); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | /*! |
|
238 | /*! | |
239 | Removes current \a point x value. |
|
239 | Removes current \a point x value. | |
240 |
|
240 | |||
241 | Note: point y value is ignored. |
|
241 | Note: point y value is ignored. | |
242 | */ |
|
242 | */ | |
243 | void QXYSeries::remove(const QPointF &point) |
|
243 | void QXYSeries::remove(const QPointF &point) | |
244 | { |
|
244 | { | |
245 | Q_D(QXYSeries); |
|
245 | Q_D(QXYSeries); | |
246 | int index = d->m_points.indexOf(point); |
|
246 | int index = d->m_points.indexOf(point); | |
247 | if(index==-1) return; |
|
247 | if(index==-1) return; | |
248 | d->m_points.remove(index); |
|
248 | d->m_points.remove(index); | |
249 | // emit d->pointRemoved(index); |
|
249 | // emit d->pointRemoved(index); | |
250 | emit pointRemoved(index); |
|
250 | emit pointRemoved(index); | |
251 | } |
|
251 | } | |
252 |
|
252 | |||
253 | /*! |
|
253 | /*! | |
254 | Inserts a \a point in the series at \a index position. |
|
254 | Inserts a \a point in the series at \a index position. | |
255 | */ |
|
255 | */ | |
256 | void QXYSeries::insert(int index, const QPointF &point) |
|
256 | void QXYSeries::insert(int index, const QPointF &point) | |
257 | { |
|
257 | { | |
258 | Q_D(QXYSeries); |
|
258 | Q_D(QXYSeries); | |
259 | d->m_points.insert(index, point); |
|
259 | d->m_points.insert(index, point); | |
260 | // emit d->pointAdded(index); |
|
260 | // emit d->pointAdded(index); | |
261 | emit pointAdded(index); |
|
261 | emit pointAdded(index); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | /*! |
|
264 | /*! | |
265 | Removes all points from the series. |
|
265 | Removes all points from the series. | |
266 | */ |
|
266 | */ | |
267 | void QXYSeries::clear() |
|
267 | void QXYSeries::clear() | |
268 | { |
|
268 | { | |
269 | Q_D(QXYSeries); |
|
269 | Q_D(QXYSeries); | |
270 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
270 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
271 | remove(d->m_points.at(i)); |
|
271 | remove(d->m_points.at(i)); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | /*! |
|
274 | /*! | |
275 | \internal \a pos |
|
275 | \internal \a pos | |
276 | */ |
|
276 | */ | |
277 | QList<QPointF> QXYSeries::points() const |
|
277 | QList<QPointF> QXYSeries::points() const | |
278 | { |
|
278 | { | |
279 | Q_D(const QXYSeries); |
|
279 | Q_D(const QXYSeries); | |
280 | return d->m_points.toList(); |
|
280 | return d->m_points.toList(); | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | /*! |
|
283 | /*! | |
284 | Returns number of data points within series. |
|
284 | Returns number of data points within series. | |
285 | */ |
|
285 | */ | |
286 | int QXYSeries::count() const |
|
286 | int QXYSeries::count() const | |
287 | { |
|
287 | { | |
288 | Q_D(const QXYSeries); |
|
288 | Q_D(const QXYSeries); | |
289 | return d->m_points.count(); |
|
289 | return d->m_points.count(); | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 |
|
292 | |||
293 | /*! |
|
293 | /*! | |
294 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
294 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
295 | pen from chart theme is used. |
|
295 | pen from chart theme is used. | |
296 | \sa QChart::setTheme() |
|
296 | \sa QChart::setTheme() | |
297 | */ |
|
297 | */ | |
298 | void QXYSeries::setPen(const QPen &pen) |
|
298 | void QXYSeries::setPen(const QPen &pen) | |
299 | { |
|
299 | { | |
300 | Q_D(QXYSeries); |
|
300 | Q_D(QXYSeries); | |
301 | if (d->m_pen!=pen) { |
|
301 | if (d->m_pen != pen) { | |
|
302 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |||
302 | d->m_pen = pen; |
|
303 | d->m_pen = pen; | |
303 | emit d->updated(); |
|
304 | emit d->updated(); | |
|
305 | if (emitColorChanged) | |||
|
306 | emit colorChanged(pen.color()); | |||
304 | } |
|
307 | } | |
305 | } |
|
308 | } | |
306 |
|
309 | |||
307 | QPen QXYSeries::pen() const |
|
310 | QPen QXYSeries::pen() const | |
308 | { |
|
311 | { | |
309 | Q_D(const QXYSeries); |
|
312 | Q_D(const QXYSeries); | |
310 | return d->m_pen; |
|
313 | return d->m_pen; | |
311 | } |
|
314 | } | |
312 |
|
315 | |||
313 | /*! |
|
316 | /*! | |
314 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
317 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
315 | from chart theme setting is used. |
|
318 | from chart theme setting is used. | |
316 | \sa QChart::setTheme() |
|
319 | \sa QChart::setTheme() | |
317 | */ |
|
320 | */ | |
318 | void QXYSeries::setBrush(const QBrush &brush) |
|
321 | void QXYSeries::setBrush(const QBrush &brush) | |
319 | { |
|
322 | { | |
320 | Q_D(QXYSeries); |
|
323 | Q_D(QXYSeries); | |
321 | if (d->m_brush!=brush) { |
|
324 | if (d->m_brush!=brush) { | |
322 | d->m_brush = brush; |
|
325 | d->m_brush = brush; | |
323 | emit d->updated(); |
|
326 | emit d->updated(); | |
324 | } |
|
327 | } | |
325 | } |
|
328 | } | |
326 |
|
329 | |||
327 | QBrush QXYSeries::brush() const |
|
330 | QBrush QXYSeries::brush() const | |
328 | { |
|
331 | { | |
329 | Q_D(const QXYSeries); |
|
332 | Q_D(const QXYSeries); | |
330 | return d->m_brush; |
|
333 | return d->m_brush; | |
331 | } |
|
334 | } | |
332 |
|
335 | |||
333 | void QXYSeries::setColor(const QColor &color) |
|
336 | void QXYSeries::setColor(const QColor &color) | |
334 | { |
|
337 | { | |
335 | QPen p = pen(); |
|
338 | QPen p = pen(); | |
336 | if (p.color() != color) { |
|
339 | if (p.color() != color) { | |
337 | p.setColor(color); |
|
340 | p.setColor(color); | |
338 | setPen(p); |
|
341 | setPen(p); | |
339 | emit colorChanged(color); |
|
|||
340 | } |
|
342 | } | |
341 | } |
|
343 | } | |
342 |
|
344 | |||
343 | QColor QXYSeries::color() const |
|
345 | QColor QXYSeries::color() const | |
344 | { |
|
346 | { | |
345 | return pen().color(); |
|
347 | return pen().color(); | |
346 | } |
|
348 | } | |
347 |
|
349 | |||
348 | void QXYSeries::setPointsVisible(bool visible) |
|
350 | void QXYSeries::setPointsVisible(bool visible) | |
349 | { |
|
351 | { | |
350 | Q_D(QXYSeries); |
|
352 | Q_D(QXYSeries); | |
351 | if (d->m_pointsVisible != visible){ |
|
353 | if (d->m_pointsVisible != visible){ | |
352 | d->m_pointsVisible = visible; |
|
354 | d->m_pointsVisible = visible; | |
353 | emit d->updated(); |
|
355 | emit d->updated(); | |
354 | } |
|
356 | } | |
355 | } |
|
357 | } | |
356 |
|
358 | |||
357 | bool QXYSeries::pointsVisible() const |
|
359 | bool QXYSeries::pointsVisible() const | |
358 | { |
|
360 | { | |
359 | Q_D(const QXYSeries); |
|
361 | Q_D(const QXYSeries); | |
360 | return d->m_pointsVisible; |
|
362 | return d->m_pointsVisible; | |
361 | } |
|
363 | } | |
362 |
|
364 | |||
363 |
|
365 | |||
364 | /*! |
|
366 | /*! | |
365 | Stream operator for adding a data \a point to the series. |
|
367 | Stream operator for adding a data \a point to the series. | |
366 | \sa append() |
|
368 | \sa append() | |
367 | */ |
|
369 | */ | |
368 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
370 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
369 | { |
|
371 | { | |
370 | append(point); |
|
372 | append(point); | |
371 | return *this; |
|
373 | return *this; | |
372 | } |
|
374 | } | |
373 |
|
375 | |||
374 |
|
376 | |||
375 | /*! |
|
377 | /*! | |
376 | Stream operator for adding a list of \a points to the series. |
|
378 | Stream operator for adding a list of \a points to the series. | |
377 | \sa append() |
|
379 | \sa append() | |
378 | */ |
|
380 | */ | |
379 |
|
381 | |||
380 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) |
|
382 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) | |
381 | { |
|
383 | { | |
382 | append(points); |
|
384 | append(points); | |
383 | return *this; |
|
385 | return *this; | |
384 | } |
|
386 | } | |
385 |
|
387 | |||
386 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
388 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
387 |
|
389 | |||
388 |
|
390 | |||
389 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : |
|
391 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : | |
390 | QAbstractSeriesPrivate(q), |
|
392 | QAbstractSeriesPrivate(q), | |
391 | m_pointsVisible(false) |
|
393 | m_pointsVisible(false) | |
392 | { |
|
394 | { | |
393 | } |
|
395 | } | |
394 |
|
396 | |||
395 | void QXYSeriesPrivate::scaleDomain(Domain& domain) |
|
397 | void QXYSeriesPrivate::scaleDomain(Domain& domain) | |
396 | { |
|
398 | { | |
397 | qreal minX(domain.minX()); |
|
399 | qreal minX(domain.minX()); | |
398 | qreal minY(domain.minY()); |
|
400 | qreal minY(domain.minY()); | |
399 | qreal maxX(domain.maxX()); |
|
401 | qreal maxX(domain.maxX()); | |
400 | qreal maxY(domain.maxY()); |
|
402 | qreal maxY(domain.maxY()); | |
401 | int tickXCount(domain.tickXCount()); |
|
403 | int tickXCount(domain.tickXCount()); | |
402 | int tickYCount(domain.tickYCount()); |
|
404 | int tickYCount(domain.tickYCount()); | |
403 |
|
405 | |||
404 | Q_Q(QXYSeries); |
|
406 | Q_Q(QXYSeries); | |
405 |
|
407 | |||
406 | const QList<QPointF>& points = q->points(); |
|
408 | const QList<QPointF>& points = q->points(); | |
407 |
|
409 | |||
408 |
|
410 | |||
409 | if (points.isEmpty()){ |
|
411 | if (points.isEmpty()){ | |
410 | minX = qMin(minX, 0.0); |
|
412 | minX = qMin(minX, 0.0); | |
411 | minY = qMin(minY, 0.0); |
|
413 | minY = qMin(minY, 0.0); | |
412 | maxX = qMax(maxX, 1.0); |
|
414 | maxX = qMax(maxX, 1.0); | |
413 | maxY = qMax(maxY, 1.0); |
|
415 | maxY = qMax(maxY, 1.0); | |
414 | } |
|
416 | } | |
415 |
|
417 | |||
416 | for (int i = 0; i < points.count(); i++) { |
|
418 | for (int i = 0; i < points.count(); i++) { | |
417 | qreal x = points[i].x(); |
|
419 | qreal x = points[i].x(); | |
418 | qreal y = points[i].y(); |
|
420 | qreal y = points[i].y(); | |
419 | minX = qMin(minX, x); |
|
421 | minX = qMin(minX, x); | |
420 | minY = qMin(minY, y); |
|
422 | minY = qMin(minY, y); | |
421 | maxX = qMax(maxX, x); |
|
423 | maxX = qMax(maxX, x); | |
422 | maxY = qMax(maxY, y); |
|
424 | maxY = qMax(maxY, y); | |
423 | } |
|
425 | } | |
424 |
|
426 | |||
425 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
427 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
426 | } |
|
428 | } | |
427 |
|
429 | |||
428 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) |
|
430 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |
429 | { |
|
431 | { | |
430 | Q_Q(QXYSeries); |
|
432 | Q_Q(QXYSeries); | |
431 | QList<LegendMarker*> list; |
|
433 | QList<LegendMarker*> list; | |
432 | return list << new XYLegendMarker(q,legend); |
|
434 | return list << new XYLegendMarker(q,legend); | |
433 | } |
|
435 | } | |
434 |
|
436 | |||
435 | #include "moc_qxyseries.cpp" |
|
437 | #include "moc_qxyseries.cpp" | |
436 | #include "moc_qxyseries_p.cpp" |
|
438 | #include "moc_qxyseries_p.cpp" | |
437 |
|
439 | |||
438 | QTCOMMERCIALCHART_END_NAMESPACE |
|
440 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,91 +1,91 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qabstractseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 | class QXYModelMapper; |
|
34 | class QXYModelMapper; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries |
|
36 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) |
|
39 | Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
41 |
|
41 | |||
42 | protected: |
|
42 | protected: | |
43 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); |
|
43 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 | ~QXYSeries(); |
|
46 | ~QXYSeries(); | |
47 | void append(qreal x, qreal y); |
|
47 | void append(qreal x, qreal y); | |
48 | void append(const QPointF &point); |
|
48 | void append(const QPointF &point); | |
49 | void append(const QList<QPointF> &points); |
|
49 | void append(const QList<QPointF> &points); | |
50 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); |
|
50 | void replace(qreal oldX,qreal oldY,qreal newX,qreal newY); | |
51 | void replace(const QPointF &oldPoint,const QPointF &newPoint); |
|
51 | void replace(const QPointF &oldPoint,const QPointF &newPoint); | |
52 | void remove(qreal x, qreal y); |
|
52 | void remove(qreal x, qreal y); | |
53 | void remove(const QPointF &point); |
|
53 | void remove(const QPointF &point); | |
54 | void insert(int index, const QPointF &point); |
|
54 | void insert(int index, const QPointF &point); | |
55 | void clear(); |
|
55 | void clear(); | |
56 |
|
56 | |||
57 | int count() const; |
|
57 | int count() const; | |
58 | QList<QPointF> points() const; |
|
58 | QList<QPointF> points() const; | |
59 |
|
59 | |||
60 | QXYSeries& operator << (const QPointF &point); |
|
60 | QXYSeries& operator << (const QPointF &point); | |
61 | QXYSeries& operator << (const QList<QPointF> &points); |
|
61 | QXYSeries& operator << (const QList<QPointF> &points); | |
62 |
|
62 | |||
63 | void setPen(const QPen &pen); |
|
63 | virtual void setPen(const QPen &pen); | |
64 | QPen pen() const; |
|
64 | QPen pen() const; | |
65 |
|
65 | |||
66 | void setBrush(const QBrush &brush); |
|
66 | virtual void setBrush(const QBrush &brush); | |
67 | QBrush brush() const; |
|
67 | QBrush brush() const; | |
68 |
|
68 | |||
69 | virtual void setColor(const QColor &color); |
|
69 | virtual void setColor(const QColor &color); | |
70 | virtual QColor color() const; |
|
70 | virtual QColor color() const; | |
71 |
|
71 | |||
72 | void setPointsVisible(bool visible = true); |
|
72 | void setPointsVisible(bool visible = true); | |
73 | bool pointsVisible() const; |
|
73 | bool pointsVisible() const; | |
74 |
|
74 | |||
75 | Q_SIGNALS: |
|
75 | Q_SIGNALS: | |
76 | void clicked(const QPointF &point); |
|
76 | void clicked(const QPointF &point); | |
77 | void pointReplaced(int index); |
|
77 | void pointReplaced(int index); | |
78 | void pointRemoved(int index); |
|
78 | void pointRemoved(int index); | |
79 | void pointAdded(int index); |
|
79 | void pointAdded(int index); | |
80 | void colorChanged(QColor color); |
|
80 | void colorChanged(QColor color); | |
81 |
|
81 | |||
82 | private: |
|
82 | private: | |
83 | Q_DECLARE_PRIVATE(QXYSeries) |
|
83 | Q_DECLARE_PRIVATE(QXYSeries) | |
84 | Q_DISABLE_COPY(QXYSeries) |
|
84 | Q_DISABLE_COPY(QXYSeries) | |
85 | friend class XYLegendMarker; |
|
85 | friend class XYLegendMarker; | |
86 | friend class XYChart; |
|
86 | friend class XYChart; | |
87 | }; |
|
87 | }; | |
88 |
|
88 | |||
89 | QTCOMMERCIALCHART_END_NAMESPACE |
|
89 | QTCOMMERCIALCHART_END_NAMESPACE | |
90 |
|
90 | |||
91 | #endif |
|
91 | #endif |
@@ -1,69 +1,68 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QXYSERIES_P_H |
|
30 | #ifndef QXYSERIES_P_H | |
31 | #define QXYSERIES_P_H |
|
31 | #define QXYSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qabstractseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QXYSeries; |
|
37 | class QXYSeries; | |
38 |
|
38 | |||
39 | class QXYSeriesPrivate: public QAbstractSeriesPrivate |
|
39 | class QXYSeriesPrivate: public QAbstractSeriesPrivate | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | QXYSeriesPrivate(QXYSeries* q); |
|
44 | QXYSeriesPrivate(QXYSeries* q); | |
45 |
|
45 | |||
46 | void scaleDomain(Domain& domain); |
|
46 | void scaleDomain(Domain& domain); | |
47 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
47 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
48 |
|
48 | |||
49 | Q_SIGNALS: |
|
49 | Q_SIGNALS: | |
50 | void updated(); |
|
50 | void updated(); | |
51 | // void pointReplaced(int index); |
|
51 | // void pointReplaced(int index); | |
52 | // void pointRemoved(int index); |
|
52 | // void pointRemoved(int index); | |
53 | // void pointAdded(int index); |
|
53 | // void pointAdded(int index); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 | QVector<QPointF> m_points; |
|
56 | QVector<QPointF> m_points; | |
57 | QPen m_pen; |
|
57 | QPen m_pen; | |
58 | QBrush m_brush; |
|
58 | QBrush m_brush; | |
59 | bool m_pointsVisible; |
|
59 | bool m_pointsVisible; | |
60 |
|
60 | |||
61 | private: |
|
61 | private: | |
62 |
Q_DECLARE_PUBLIC(QXYSeries) |
|
62 | Q_DECLARE_PUBLIC(QXYSeries) | |
63 | friend class QScatterSeries; |
|
63 | friend class QScatterSeries; | |
64 |
|
||||
65 | }; |
|
64 | }; | |
66 |
|
65 | |||
67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
66 | QTCOMMERCIALCHART_END_NAMESPACE | |
68 |
|
67 | |||
69 | #endif |
|
68 | #endif |
@@ -1,100 +1,131 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "../qxyseries/tst_qxyseries.h" |
|
21 | #include "../qxyseries/tst_qxyseries.h" | |
22 | #include <qscatterseries.h> |
|
22 | #include <qscatterseries.h> | |
23 |
|
23 | |||
24 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
24 | Q_DECLARE_METATYPE(QList<QPointF>) | |
25 |
|
25 | |||
26 | class tst_QScatterSeries : public tst_QXYSeries |
|
26 | class tst_QScatterSeries : public tst_QXYSeries | |
27 | { |
|
27 | { | |
28 | Q_OBJECT |
|
28 | Q_OBJECT | |
29 |
|
29 | |||
30 | public slots: |
|
30 | public slots: | |
31 | void initTestCase(); |
|
31 | void initTestCase(); | |
32 | void cleanupTestCase(); |
|
32 | void cleanupTestCase(); | |
33 | void init(); |
|
33 | void init(); | |
34 | void cleanup(); |
|
34 | void cleanup(); | |
35 | private slots: |
|
35 | private slots: | |
36 | void qscatterseries_data(); |
|
36 | void qscatterseries_data(); | |
37 | void qscatterseries(); |
|
37 | void qscatterseries(); | |
|
38 | void scatterChangedSignals(); | |||
|
39 | ||||
38 | protected: |
|
40 | protected: | |
39 | void pointsVisible_data(); |
|
41 | void pointsVisible_data(); | |
40 | }; |
|
42 | }; | |
41 |
|
43 | |||
42 | void tst_QScatterSeries::initTestCase() |
|
44 | void tst_QScatterSeries::initTestCase() | |
43 | { |
|
45 | { | |
44 | } |
|
46 | } | |
45 |
|
47 | |||
46 | void tst_QScatterSeries::cleanupTestCase() |
|
48 | void tst_QScatterSeries::cleanupTestCase() | |
47 | { |
|
49 | { | |
48 | } |
|
50 | } | |
49 |
|
51 | |||
50 | void tst_QScatterSeries::init() |
|
52 | void tst_QScatterSeries::init() | |
51 | { |
|
53 | { | |
52 | tst_QXYSeries::init(); |
|
54 | tst_QXYSeries::init(); | |
53 | m_series = new QScatterSeries(); |
|
55 | m_series = new QScatterSeries(); | |
54 | } |
|
56 | } | |
55 |
|
57 | |||
56 | void tst_QScatterSeries::cleanup() |
|
58 | void tst_QScatterSeries::cleanup() | |
57 | { |
|
59 | { | |
58 | delete m_series; |
|
60 | delete m_series; | |
59 | tst_QXYSeries::cleanup(); |
|
61 | tst_QXYSeries::cleanup(); | |
60 | } |
|
62 | } | |
61 |
|
63 | |||
62 | void tst_QScatterSeries::qscatterseries_data() |
|
64 | void tst_QScatterSeries::qscatterseries_data() | |
63 | { |
|
65 | { | |
64 |
|
66 | |||
65 | } |
|
67 | } | |
66 |
|
68 | |||
67 | void tst_QScatterSeries::qscatterseries() |
|
69 | void tst_QScatterSeries::qscatterseries() | |
68 | { |
|
70 | { | |
69 | QScatterSeries series; |
|
71 | QScatterSeries series; | |
70 |
|
72 | |||
71 | QCOMPARE(series.count(),0); |
|
73 | QCOMPARE(series.count(),0); | |
72 | QCOMPARE(series.brush(), QBrush()); |
|
74 | QCOMPARE(series.brush(), QBrush()); | |
73 | QCOMPARE(series.points(), QList<QPointF>()); |
|
75 | QCOMPARE(series.points(), QList<QPointF>()); | |
74 | QCOMPARE(series.pen(), QPen()); |
|
76 | QCOMPARE(series.pen(), QPen()); | |
75 | QCOMPARE(series.pointsVisible(), false); |
|
77 | QCOMPARE(series.pointsVisible(), false); | |
76 |
|
78 | |||
77 | series.append(QList<QPointF>()); |
|
79 | series.append(QList<QPointF>()); | |
78 | series.append(0.0,0.0); |
|
80 | series.append(0.0,0.0); | |
79 | series.append(QPointF()); |
|
81 | series.append(QPointF()); | |
80 |
|
82 | |||
81 | series.remove(0.0,0.0); |
|
83 | series.remove(0.0,0.0); | |
82 | series.remove(QPointF()); |
|
84 | series.remove(QPointF()); | |
83 | series.clear(); |
|
85 | series.clear(); | |
84 |
|
86 | |||
85 | series.replace(QPointF(),QPointF()); |
|
87 | series.replace(QPointF(),QPointF()); | |
86 | series.replace(0,0,0,0); |
|
88 | series.replace(0,0,0,0); | |
87 | series.setBrush(QBrush()); |
|
89 | series.setBrush(QBrush()); | |
88 |
|
90 | |||
89 | series.setPen(QPen()); |
|
91 | series.setPen(QPen()); | |
90 | series.setPointsVisible(false); |
|
92 | series.setPointsVisible(false); | |
91 |
|
93 | |||
92 | m_chart->addSeries(&series); |
|
94 | m_chart->addSeries(&series); | |
93 | m_view->show(); |
|
95 | m_view->show(); | |
94 | QTest::qWaitForWindowShown(m_view); |
|
96 | QTest::qWaitForWindowShown(m_view); | |
95 | } |
|
97 | } | |
96 |
|
98 | |||
|
99 | void tst_QScatterSeries::scatterChangedSignals() | |||
|
100 | { | |||
|
101 | QScatterSeries *series = qobject_cast<QScatterSeries *>(m_series); | |||
|
102 | QVERIFY(series); | |||
|
103 | ||||
|
104 | QSignalSpy colorSpy(series, SIGNAL(colorChanged(QColor))); | |||
|
105 | QSignalSpy borderColorSpy(series, SIGNAL(borderColorChanged(QColor))); | |||
|
106 | ||||
|
107 | // Color | |||
|
108 | series->setColor(QColor("blueviolet")); | |||
|
109 | TRY_COMPARE(colorSpy.count(), 1); | |||
|
110 | ||||
|
111 | // Border color | |||
|
112 | series->setBorderColor(QColor("burlywood")); | |||
|
113 | TRY_COMPARE(borderColorSpy.count(), 1); | |||
|
114 | ||||
|
115 | // Pen | |||
|
116 | QPen p = series->pen(); | |||
|
117 | p.setColor("lightpink"); | |||
|
118 | series->setPen(p); | |||
|
119 | TRY_COMPARE(borderColorSpy.count(), 2); | |||
|
120 | ||||
|
121 | // Brush | |||
|
122 | QBrush b = series->brush(); | |||
|
123 | b.setColor("lime"); | |||
|
124 | series->setBrush(b); | |||
|
125 | TRY_COMPARE(colorSpy.count(), 2); | |||
|
126 | } | |||
|
127 | ||||
97 | QTEST_MAIN(tst_QScatterSeries) |
|
128 | QTEST_MAIN(tst_QScatterSeries) | |
98 |
|
129 | |||
99 | #include "tst_qscatterseries.moc" |
|
130 | #include "tst_qscatterseries.moc" | |
100 |
|
131 |
@@ -1,409 +1,429 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "tst_qxyseries.h" |
|
21 | #include "tst_qxyseries.h" | |
22 |
|
22 | |||
23 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
23 | Q_DECLARE_METATYPE(QList<QPointF>) | |
24 |
|
24 | |||
25 | void tst_QXYSeries::initTestCase() |
|
25 | void tst_QXYSeries::initTestCase() | |
26 | { |
|
26 | { | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | void tst_QXYSeries::cleanupTestCase() |
|
29 | void tst_QXYSeries::cleanupTestCase() | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | void tst_QXYSeries::init() |
|
33 | void tst_QXYSeries::init() | |
34 | { |
|
34 | { | |
35 | m_view = new QChartView(new QChart()); |
|
35 | m_view = new QChartView(new QChart()); | |
36 | m_chart = m_view->chart(); |
|
36 | m_chart = m_view->chart(); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void tst_QXYSeries::cleanup() |
|
39 | void tst_QXYSeries::cleanup() | |
40 | { |
|
40 | { | |
41 | delete m_view; |
|
41 | delete m_view; | |
42 | m_view = 0; |
|
42 | m_view = 0; | |
43 | m_chart = 0; |
|
43 | m_chart = 0; | |
44 | m_series = 0; |
|
44 | m_series = 0; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void tst_QXYSeries::seriesName() |
|
47 | void tst_QXYSeries::seriesName() | |
48 | { |
|
48 | { | |
49 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); |
|
49 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); | |
50 | QCOMPARE(m_series->name(), QString()); |
|
50 | QCOMPARE(m_series->name(), QString()); | |
51 | m_series->setName("seriesname"); |
|
51 | m_series->setName("seriesname"); | |
52 | QCOMPARE(m_series->name(), QString("seriesname")); |
|
52 | QCOMPARE(m_series->name(), QString("seriesname")); | |
53 | TRY_COMPARE(nameSpy.count(), 1); |
|
53 | TRY_COMPARE(nameSpy.count(), 1); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | void tst_QXYSeries::seriesVisible() |
|
56 | void tst_QXYSeries::seriesVisible() | |
57 | { |
|
57 | { | |
58 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); |
|
58 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); | |
59 | QCOMPARE(m_series->isVisible(), true); |
|
59 | QCOMPARE(m_series->isVisible(), true); | |
60 | m_series->setVisible(false); |
|
60 | m_series->setVisible(false); | |
61 | QCOMPARE(m_series->isVisible(), false); |
|
61 | QCOMPARE(m_series->isVisible(), false); | |
62 | m_series->setVisible(true); |
|
62 | m_series->setVisible(true); | |
63 | TRY_COMPARE(visibleSpy.count(), 2); |
|
63 | TRY_COMPARE(visibleSpy.count(), 2); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | void tst_QXYSeries::append_data() |
|
66 | void tst_QXYSeries::append_data() | |
67 | { |
|
67 | { | |
68 | QTest::addColumn< QList<QPointF> >("points"); |
|
68 | QTest::addColumn< QList<QPointF> >("points"); | |
69 | QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); |
|
69 | QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); | |
70 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); |
|
70 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | void tst_QXYSeries::append_raw_data() |
|
74 | void tst_QXYSeries::append_raw_data() | |
75 | { |
|
75 | { | |
76 | append_data(); |
|
76 | append_data(); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void tst_QXYSeries::append_raw() |
|
79 | void tst_QXYSeries::append_raw() | |
80 | { |
|
80 | { | |
81 | QFETCH(QList<QPointF>, points); |
|
81 | QFETCH(QList<QPointF>, points); | |
82 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
82 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
83 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); |
|
83 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
84 | m_series->append(points); |
|
84 | m_series->append(points); | |
85 | TRY_COMPARE(spy0.count(), 0); |
|
85 | TRY_COMPARE(spy0.count(), 0); | |
86 | TRY_COMPARE(addedSpy.count(), points.count()); |
|
86 | TRY_COMPARE(addedSpy.count(), points.count()); | |
87 | QCOMPARE(m_series->points(), points); |
|
87 | QCOMPARE(m_series->points(), points); | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | void tst_QXYSeries::chart_append_data() |
|
90 | void tst_QXYSeries::chart_append_data() | |
91 | { |
|
91 | { | |
92 | append_data(); |
|
92 | append_data(); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | void tst_QXYSeries::chart_append() |
|
95 | void tst_QXYSeries::chart_append() | |
96 | { |
|
96 | { | |
97 | append_raw(); |
|
97 | append_raw(); | |
98 | m_chart->addSeries(m_series); |
|
98 | m_chart->addSeries(m_series); | |
99 | m_view->show(); |
|
99 | m_view->show(); | |
100 | QTest::qWaitForWindowShown(m_view); |
|
100 | QTest::qWaitForWindowShown(m_view); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | void tst_QXYSeries::append_chart_data() |
|
103 | void tst_QXYSeries::append_chart_data() | |
104 | { |
|
104 | { | |
105 | append_data(); |
|
105 | append_data(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | void tst_QXYSeries::append_chart() |
|
108 | void tst_QXYSeries::append_chart() | |
109 | { |
|
109 | { | |
110 | m_view->show(); |
|
110 | m_view->show(); | |
111 | m_chart->addSeries(m_series); |
|
111 | m_chart->addSeries(m_series); | |
112 | QTest::qWaitForWindowShown(m_view); |
|
112 | QTest::qWaitForWindowShown(m_view); | |
113 | append_raw(); |
|
113 | append_raw(); | |
114 |
|
114 | |||
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | void tst_QXYSeries::append_chart_animation_data() |
|
117 | void tst_QXYSeries::append_chart_animation_data() | |
118 | { |
|
118 | { | |
119 | append_data(); |
|
119 | append_data(); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | void tst_QXYSeries::append_chart_animation() |
|
122 | void tst_QXYSeries::append_chart_animation() | |
123 | { |
|
123 | { | |
124 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
124 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
125 | append_chart(); |
|
125 | append_chart(); | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | void tst_QXYSeries::count_data() |
|
128 | void tst_QXYSeries::count_data() | |
129 | { |
|
129 | { | |
130 | QTest::addColumn<int>("count"); |
|
130 | QTest::addColumn<int>("count"); | |
131 | QTest::newRow("0") << 0; |
|
131 | QTest::newRow("0") << 0; | |
132 | QTest::newRow("5") << 5; |
|
132 | QTest::newRow("5") << 5; | |
133 | QTest::newRow("10") << 5; |
|
133 | QTest::newRow("10") << 5; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | void tst_QXYSeries::count_raw_data() |
|
136 | void tst_QXYSeries::count_raw_data() | |
137 | { |
|
137 | { | |
138 | count_data(); |
|
138 | count_data(); | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | void tst_QXYSeries::count_raw() |
|
141 | void tst_QXYSeries::count_raw() | |
142 | { |
|
142 | { | |
143 | QFETCH(int, count); |
|
143 | QFETCH(int, count); | |
144 |
|
144 | |||
145 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
145 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
146 |
|
146 | |||
147 | for(int i=0 ; i< count; ++i) |
|
147 | for(int i=0 ; i< count; ++i) | |
148 | m_series->append(i,i); |
|
148 | m_series->append(i,i); | |
149 |
|
149 | |||
150 | TRY_COMPARE(spy0.count(), 0); |
|
150 | TRY_COMPARE(spy0.count(), 0); | |
151 | QCOMPARE(m_series->count(), count); |
|
151 | QCOMPARE(m_series->count(), count); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | void tst_QXYSeries::remove_raw_data() |
|
154 | void tst_QXYSeries::remove_raw_data() | |
155 | { |
|
155 | { | |
156 | append_data(); |
|
156 | append_data(); | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | void tst_QXYSeries::remove_raw() |
|
159 | void tst_QXYSeries::remove_raw() | |
160 | { |
|
160 | { | |
161 | QFETCH(QList<QPointF>, points); |
|
161 | QFETCH(QList<QPointF>, points); | |
162 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
162 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
163 | m_series->append(points); |
|
163 | m_series->append(points); | |
164 | TRY_COMPARE(spy0.count(), 0); |
|
164 | TRY_COMPARE(spy0.count(), 0); | |
165 | QCOMPARE(m_series->points(), points); |
|
165 | QCOMPARE(m_series->points(), points); | |
166 |
|
166 | |||
167 | foreach(const QPointF& point,points) |
|
167 | foreach(const QPointF& point,points) | |
168 | m_series->remove(point); |
|
168 | m_series->remove(point); | |
169 |
|
169 | |||
170 | QCOMPARE(m_series->points().count(), 0); |
|
170 | QCOMPARE(m_series->points().count(), 0); | |
171 | TRY_COMPARE(spy0.count(), 0); |
|
171 | TRY_COMPARE(spy0.count(), 0); | |
172 |
|
172 | |||
173 | m_series->append(points); |
|
173 | m_series->append(points); | |
174 | QCOMPARE(m_series->points(), points); |
|
174 | QCOMPARE(m_series->points(), points); | |
175 |
|
175 | |||
176 | //reverse order |
|
176 | //reverse order | |
177 | for(int i = points.count()-1 ; i>=0; i--){ |
|
177 | for(int i = points.count()-1 ; i>=0; i--){ | |
178 | m_series->remove(points[i]); |
|
178 | m_series->remove(points[i]); | |
179 | } |
|
179 | } | |
180 | QCOMPARE(m_series->points().count(), 0); |
|
180 | QCOMPARE(m_series->points().count(), 0); | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | void tst_QXYSeries::remove_chart_data() |
|
183 | void tst_QXYSeries::remove_chart_data() | |
184 | { |
|
184 | { | |
185 | append_data(); |
|
185 | append_data(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void tst_QXYSeries::remove_chart() |
|
188 | void tst_QXYSeries::remove_chart() | |
189 | { |
|
189 | { | |
190 | m_view->show(); |
|
190 | m_view->show(); | |
191 | m_chart->addSeries(m_series); |
|
191 | m_chart->addSeries(m_series); | |
192 | QTest::qWaitForWindowShown(m_view); |
|
192 | QTest::qWaitForWindowShown(m_view); | |
193 | remove_raw(); |
|
193 | remove_raw(); | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | void tst_QXYSeries::remove_chart_animation_data() |
|
196 | void tst_QXYSeries::remove_chart_animation_data() | |
197 | { |
|
197 | { | |
198 | append_data(); |
|
198 | append_data(); | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | void tst_QXYSeries::remove_chart_animation() |
|
201 | void tst_QXYSeries::remove_chart_animation() | |
202 | { |
|
202 | { | |
203 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
203 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
204 | remove_chart(); |
|
204 | remove_chart(); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 |
|
207 | |||
208 | void tst_QXYSeries::clear_raw_data() |
|
208 | void tst_QXYSeries::clear_raw_data() | |
209 | { |
|
209 | { | |
210 | append_data(); |
|
210 | append_data(); | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | void tst_QXYSeries::clear_raw() |
|
213 | void tst_QXYSeries::clear_raw() | |
214 | { |
|
214 | { | |
215 | QFETCH(QList<QPointF>, points); |
|
215 | QFETCH(QList<QPointF>, points); | |
216 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
216 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
217 | m_series->append(points); |
|
217 | m_series->append(points); | |
218 | TRY_COMPARE(spy0.count(), 0); |
|
218 | TRY_COMPARE(spy0.count(), 0); | |
219 | QCOMPARE(m_series->points(), points); |
|
219 | QCOMPARE(m_series->points(), points); | |
220 | m_series->clear(); |
|
220 | m_series->clear(); | |
221 | TRY_COMPARE(spy0.count(), 0); |
|
221 | TRY_COMPARE(spy0.count(), 0); | |
222 | QCOMPARE(m_series->points().count(), 0); |
|
222 | QCOMPARE(m_series->points().count(), 0); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | void tst_QXYSeries::clear_chart_data() |
|
225 | void tst_QXYSeries::clear_chart_data() | |
226 | { |
|
226 | { | |
227 | append_data(); |
|
227 | append_data(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void tst_QXYSeries::clear_chart() |
|
230 | void tst_QXYSeries::clear_chart() | |
231 | { |
|
231 | { | |
232 | m_view->show(); |
|
232 | m_view->show(); | |
233 | m_chart->addSeries(m_series); |
|
233 | m_chart->addSeries(m_series); | |
234 | QTest::qWaitForWindowShown(m_view); |
|
234 | QTest::qWaitForWindowShown(m_view); | |
235 | clear_raw(); |
|
235 | clear_raw(); | |
236 | } |
|
236 | } | |
237 |
|
237 | |||
238 | void tst_QXYSeries::clear_chart_animation_data() |
|
238 | void tst_QXYSeries::clear_chart_animation_data() | |
239 | { |
|
239 | { | |
240 | append_data(); |
|
240 | append_data(); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | void tst_QXYSeries::clear_chart_animation() |
|
243 | void tst_QXYSeries::clear_chart_animation() | |
244 | { |
|
244 | { | |
245 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
245 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
246 | clear_chart(); |
|
246 | clear_chart(); | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | void tst_QXYSeries::replace_raw_data() |
|
249 | void tst_QXYSeries::replace_raw_data() | |
250 | { |
|
250 | { | |
251 | append_data(); |
|
251 | append_data(); | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | void tst_QXYSeries::replace_raw() |
|
254 | void tst_QXYSeries::replace_raw() | |
255 | { |
|
255 | { | |
256 | QFETCH(QList<QPointF>, points); |
|
256 | QFETCH(QList<QPointF>, points); | |
257 | QSignalSpy replacedSpy(m_series, SIGNAL(pointReplaced(int))); |
|
257 | QSignalSpy replacedSpy(m_series, SIGNAL(pointReplaced(int))); | |
258 | m_series->append(points); |
|
258 | m_series->append(points); | |
259 | TRY_COMPARE(replacedSpy.count(), 0); |
|
259 | TRY_COMPARE(replacedSpy.count(), 0); | |
260 | QCOMPARE(m_series->points(), points); |
|
260 | QCOMPARE(m_series->points(), points); | |
261 |
|
261 | |||
262 | foreach(const QPointF& point, points) |
|
262 | foreach(const QPointF& point, points) | |
263 | m_series->replace(point.x(),point.y(),point.x(),0); |
|
263 | m_series->replace(point.x(),point.y(),point.x(),0); | |
264 | TRY_COMPARE(replacedSpy.count(), points.count()); |
|
264 | TRY_COMPARE(replacedSpy.count(), points.count()); | |
265 |
|
265 | |||
266 | // Replace a point that does not exist |
|
266 | // Replace a point that does not exist | |
267 | m_series->replace(-123, 999, 0, 0); |
|
267 | m_series->replace(-123, 999, 0, 0); | |
268 | TRY_COMPARE(replacedSpy.count(), points.count()); |
|
268 | TRY_COMPARE(replacedSpy.count(), points.count()); | |
269 |
|
269 | |||
270 | QList<QPointF> newPoints = m_series->points(); |
|
270 | QList<QPointF> newPoints = m_series->points(); | |
271 |
|
271 | |||
272 | QCOMPARE(newPoints.count(), points.count()); |
|
272 | QCOMPARE(newPoints.count(), points.count()); | |
273 |
|
273 | |||
274 | for(int i =0 ; i<points.count() ; ++i) { |
|
274 | for(int i =0 ; i<points.count() ; ++i) { | |
275 | QCOMPARE(points[i].x(), newPoints[i].x()); |
|
275 | QCOMPARE(points[i].x(), newPoints[i].x()); | |
276 | QCOMPARE(newPoints[i].y(), 0.0); |
|
276 | QCOMPARE(newPoints[i].y(), 0.0); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 |
|
280 | |||
281 | void tst_QXYSeries::replace_chart_data() |
|
281 | void tst_QXYSeries::replace_chart_data() | |
282 | { |
|
282 | { | |
283 | append_data(); |
|
283 | append_data(); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void tst_QXYSeries::replace_chart() |
|
286 | void tst_QXYSeries::replace_chart() | |
287 | { |
|
287 | { | |
288 | m_view->show(); |
|
288 | m_view->show(); | |
289 | m_chart->addSeries(m_series); |
|
289 | m_chart->addSeries(m_series); | |
290 | QTest::qWaitForWindowShown(m_view); |
|
290 | QTest::qWaitForWindowShown(m_view); | |
291 | replace_raw(); |
|
291 | replace_raw(); | |
292 | } |
|
292 | } | |
293 |
|
293 | |||
294 | void tst_QXYSeries::replace_chart_animation_data() |
|
294 | void tst_QXYSeries::replace_chart_animation_data() | |
295 | { |
|
295 | { | |
296 | append_data(); |
|
296 | append_data(); | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | void tst_QXYSeries::replace_chart_animation() |
|
299 | void tst_QXYSeries::replace_chart_animation() | |
300 | { |
|
300 | { | |
301 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
301 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
302 | replace_chart(); |
|
302 | replace_chart(); | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | void tst_QXYSeries::insert_data() |
|
305 | void tst_QXYSeries::insert_data() | |
306 | { |
|
306 | { | |
307 | append_data(); |
|
307 | append_data(); | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void tst_QXYSeries::insert() |
|
310 | void tst_QXYSeries::insert() | |
311 | { |
|
311 | { | |
312 | QFETCH(QList<QPointF>, points); |
|
312 | QFETCH(QList<QPointF>, points); | |
313 | m_series->append(points); |
|
313 | m_series->append(points); | |
314 |
|
314 | |||
315 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); |
|
315 | QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); | |
316 |
|
316 | |||
317 | m_series->insert(0, QPointF(5, 5)); |
|
317 | m_series->insert(0, QPointF(5, 5)); | |
318 | TRY_COMPARE(addedSpy.count(), 1); |
|
318 | TRY_COMPARE(addedSpy.count(), 1); | |
319 | QCOMPARE(m_series->points().count(), points.count() + 1); |
|
319 | QCOMPARE(m_series->points().count(), points.count() + 1); | |
320 |
|
320 | |||
321 | m_series->insert(m_series->count(), QPointF(6, 6)); |
|
321 | m_series->insert(m_series->count(), QPointF(6, 6)); | |
322 | TRY_COMPARE(addedSpy.count(), 2); |
|
322 | TRY_COMPARE(addedSpy.count(), 2); | |
323 | QCOMPARE(m_series->points().count(), points.count() + 2); |
|
323 | QCOMPARE(m_series->points().count(), points.count() + 2); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | void tst_QXYSeries::oper_data() |
|
326 | void tst_QXYSeries::oper_data() | |
327 | { |
|
327 | { | |
328 | append_data(); |
|
328 | append_data(); | |
329 | } |
|
329 | } | |
330 |
|
330 | |||
331 | void tst_QXYSeries::oper() |
|
331 | void tst_QXYSeries::oper() | |
332 | { |
|
332 | { | |
333 | QFETCH(QList<QPointF>, points); |
|
333 | QFETCH(QList<QPointF>, points); | |
334 |
|
334 | |||
335 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
335 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
336 |
|
336 | |||
337 | foreach(const QPointF& point,points) |
|
337 | foreach(const QPointF& point,points) | |
338 | { |
|
338 | { | |
339 | *m_series<<point; |
|
339 | *m_series<<point; | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | QCOMPARE(m_series->points(), points); |
|
342 | QCOMPARE(m_series->points(), points); | |
343 | TRY_COMPARE(spy0.count(), 0); |
|
343 | TRY_COMPARE(spy0.count(), 0); | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 |
|
346 | |||
347 | void tst_QXYSeries::pen_data() |
|
347 | void tst_QXYSeries::pen_data() | |
348 | { |
|
348 | { | |
349 | QTest::addColumn<QPen>("pen"); |
|
349 | QTest::addColumn<QPen>("pen"); | |
350 | QTest::newRow("null") << QPen(); |
|
350 | QTest::newRow("null") << QPen(); | |
351 | QTest::newRow("blue") << QPen(Qt::blue); |
|
351 | QTest::newRow("blue") << QPen(Qt::blue); | |
352 | QTest::newRow("black") << QPen(Qt::black); |
|
352 | QTest::newRow("black") << QPen(Qt::black); | |
353 | QTest::newRow("red") << QPen(Qt::red); |
|
353 | QTest::newRow("red") << QPen(Qt::red); | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | void tst_QXYSeries::pen() |
|
356 | void tst_QXYSeries::pen() | |
357 | { |
|
357 | { | |
358 | QFETCH(QPen, pen); |
|
358 | QFETCH(QPen, pen); | |
359 |
|
359 | |||
360 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
360 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
361 | m_series->setPen(pen); |
|
361 | m_series->setPen(pen); | |
362 |
|
362 | |||
363 | TRY_COMPARE(spy0.count(), 0); |
|
363 | TRY_COMPARE(spy0.count(), 0); | |
364 | QCOMPARE(m_series->pen(), pen); |
|
364 | QCOMPARE(m_series->pen(), pen); | |
365 |
|
365 | |||
366 | m_chart->addSeries(m_series); |
|
366 | m_chart->addSeries(m_series); | |
367 |
|
367 | |||
368 | if (pen != QPen()) |
|
368 | if (pen != QPen()) | |
369 | QCOMPARE(m_series->pen(), pen); |
|
369 | QCOMPARE(m_series->pen(), pen); | |
370 |
|
370 | |||
371 | m_chart->setTheme(QChart::ChartThemeDark); |
|
371 | m_chart->setTheme(QChart::ChartThemeDark); | |
372 |
|
372 | |||
373 | // setting a theme will overwrite all customizations |
|
373 | // setting a theme will overwrite all customizations | |
374 | if (pen != QPen()) |
|
374 | if (pen != QPen()) | |
375 | QVERIFY(m_series->pen() != pen); |
|
375 | QVERIFY(m_series->pen() != pen); | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | void tst_QXYSeries::pointsVisible_data() |
|
378 | void tst_QXYSeries::pointsVisible_data() | |
379 | { |
|
379 | { | |
380 | QTest::addColumn<bool>("pointsVisible"); |
|
380 | QTest::addColumn<bool>("pointsVisible"); | |
381 | QTest::newRow("true") << true; |
|
381 | QTest::newRow("true") << true; | |
382 | QTest::newRow("false") << false; |
|
382 | QTest::newRow("false") << false; | |
383 | } |
|
383 | } | |
384 |
|
384 | |||
385 | void tst_QXYSeries::pointsVisible_raw_data() |
|
385 | void tst_QXYSeries::pointsVisible_raw_data() | |
386 | { |
|
386 | { | |
387 | pointsVisible_data(); |
|
387 | pointsVisible_data(); | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | void tst_QXYSeries::pointsVisible_raw() |
|
390 | void tst_QXYSeries::pointsVisible_raw() | |
391 | { |
|
391 | { | |
392 | QFETCH(bool, pointsVisible); |
|
392 | QFETCH(bool, pointsVisible); | |
393 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
393 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
394 | m_series->setPointsVisible(pointsVisible); |
|
394 | m_series->setPointsVisible(pointsVisible); | |
395 | TRY_COMPARE(spy0.count(), 0); |
|
395 | TRY_COMPARE(spy0.count(), 0); | |
396 | QCOMPARE(m_series->pointsVisible(), pointsVisible); |
|
396 | QCOMPARE(m_series->pointsVisible(), pointsVisible); | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | void tst_QXYSeries::changedSignals() |
|
399 | void tst_QXYSeries::changedSignals() | |
400 | { |
|
400 | { | |
401 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); |
|
401 | QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); | |
|
402 | QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); | |||
|
403 | QSignalSpy colorSpy(m_series, SIGNAL(colorChanged(QColor))); | |||
402 |
|
404 | |||
|
405 | // Visibility | |||
403 | m_series->setVisible(false); |
|
406 | m_series->setVisible(false); | |
404 | m_series->setVisible(false); |
|
407 | m_series->setVisible(false); | |
405 | TRY_COMPARE(visibleSpy.count(), 1); |
|
408 | TRY_COMPARE(visibleSpy.count(), 1); | |
406 | m_series->setVisible(true); |
|
409 | m_series->setVisible(true); | |
407 | TRY_COMPARE(visibleSpy.count(), 2); |
|
410 | TRY_COMPARE(visibleSpy.count(), 2); | |
408 | } |
|
|||
409 |
|
411 | |||
|
412 | // Color | |||
|
413 | m_series->setColor(QColor("aliceblue")); | |||
|
414 | TRY_COMPARE(colorSpy.count(), 1); | |||
|
415 | ||||
|
416 | // Pen and Brush | |||
|
417 | QPen p = m_series->pen(); | |||
|
418 | p.setColor("aquamarine"); | |||
|
419 | m_series->setPen(p); | |||
|
420 | QBrush b = m_series->brush(); | |||
|
421 | b.setColor("beige"); | |||
|
422 | m_series->setBrush(b); | |||
|
423 | TRY_COMPARE(colorSpy.count(), 2); | |||
|
424 | ||||
|
425 | // Verify all the signals again, to make sure no extra signals were emitted | |||
|
426 | TRY_COMPARE(visibleSpy.count(), 2); | |||
|
427 | TRY_COMPARE(nameSpy.count(), 0); | |||
|
428 | TRY_COMPARE(colorSpy.count(), 2); | |||
|
429 | } |
General Comments 0
You need to be logged in to leave comments.
Login now