@@ -1,450 +1,450 | |||||
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 | #include "qvaluesaxis.h" |
|
25 | #include "qvaluesaxis.h" | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | /*! |
|
29 | /*! | |
30 | \class QXYSeries |
|
30 | \class QXYSeries | |
31 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
31 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
32 | */ |
|
32 | */ | |
33 | /*! |
|
33 | /*! | |
34 | \qmlclass XYSeries |
|
34 | \qmlclass XYSeries | |
35 | \inherits AbstractSeries |
|
35 | \inherits AbstractSeries | |
36 | The XYSeries class is a base class for line, spline and scatter series. |
|
36 | The XYSeries class is a base class for line, spline and scatter series. | |
37 |
|
37 | |||
38 | The class cannot be instantiated directly. |
|
38 | The class cannot be instantiated directly. | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \property QXYSeries::pointsVisible |
|
42 | \property QXYSeries::pointsVisible | |
43 | Controls if the data points are visible and should be drawn. |
|
43 | Controls if the data points are visible and should be drawn. | |
44 | */ |
|
44 | */ | |
45 | /*! |
|
45 | /*! | |
46 | \qmlproperty bool XYSeries::pointsVisible |
|
46 | \qmlproperty bool XYSeries::pointsVisible | |
47 | Controls if the data points are visible and should be drawn. |
|
47 | Controls if the data points are visible and should be drawn. | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \fn QPen QXYSeries::pen() const |
|
51 | \fn QPen QXYSeries::pen() const | |
52 | \brief Returns pen used to draw points for series. |
|
52 | \brief Returns pen used to draw points for series. | |
53 | \sa setPen() |
|
53 | \sa setPen() | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \fn QBrush QXYSeries::brush() const |
|
57 | \fn QBrush QXYSeries::brush() const | |
58 | \brief Returns brush used to draw points for series. |
|
58 | \brief Returns brush used to draw points for series. | |
59 | \sa setBrush() |
|
59 | \sa setBrush() | |
60 | */ |
|
60 | */ | |
61 |
|
61 | |||
62 | /*! |
|
62 | /*! | |
63 | \property QXYSeries::color |
|
63 | \property QXYSeries::color | |
64 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
64 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and | |
65 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
65 | fill (brush) color in case of QScatterSeries or QAreaSeries. | |
66 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
66 | \sa QXYSeries::pen(), QXYSeries::brush() | |
67 | */ |
|
67 | */ | |
68 | /*! |
|
68 | /*! | |
69 | \qmlproperty color XYSeries::color |
|
69 | \qmlproperty color XYSeries::color | |
70 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
70 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and | |
71 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
71 | fill (brush) color in case of ScatterSeries or AreaSeries. | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \fn void QXYSeries::clicked(const QPointF& point) |
|
75 | \fn void QXYSeries::clicked(const QPointF& point) | |
76 | \brief Signal is emitted when user clicks the \a point on chart. |
|
76 | \brief Signal is emitted when user clicks the \a point on chart. | |
77 | */ |
|
77 | */ | |
78 | /*! |
|
78 | /*! | |
79 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
79 | \qmlsignal XYSeries::onClicked(QPointF point) | |
80 | Signal is emitted when user clicks the \a point on chart. For example: |
|
80 | Signal is emitted when user clicks the \a point on chart. For example: | |
81 | \code |
|
81 | \code | |
82 | LineSeries { |
|
82 | LineSeries { | |
83 | XYPoint { x: 0; y: 0 } |
|
83 | XYPoint { x: 0; y: 0 } | |
84 | XYPoint { x: 1.1; y: 2.1 } |
|
84 | XYPoint { x: 1.1; y: 2.1 } | |
85 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
85 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
86 | } |
|
86 | } | |
87 | \endcode |
|
87 | \endcode | |
88 | */ |
|
88 | */ | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | \fn void QXYSeries::pointReplaced(int index) |
|
91 | \fn void QXYSeries::pointReplaced(int index) | |
92 | Signal is emitted when a point has been replaced at \a index. |
|
92 | Signal is emitted when a point has been replaced at \a index. | |
93 | \sa replace() |
|
93 | \sa replace() | |
94 | */ |
|
94 | */ | |
95 | /*! |
|
95 | /*! | |
96 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
96 | \qmlsignal XYSeries::onPointReplaced(int index) | |
97 | Signal is emitted when a point has been replaced at \a index. |
|
97 | Signal is emitted when a point has been replaced at \a index. | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | \fn void QXYSeries::pointAdded(int index) |
|
101 | \fn void QXYSeries::pointAdded(int index) | |
102 | Signal is emitted when a point has been added at \a index. |
|
102 | Signal is emitted when a point has been added at \a index. | |
103 | \sa append(), insert() |
|
103 | \sa append(), insert() | |
104 | */ |
|
104 | */ | |
105 | /*! |
|
105 | /*! | |
106 | \qmlsignal XYSeries::onPointAdded(int index) |
|
106 | \qmlsignal XYSeries::onPointAdded(int index) | |
107 | Signal is emitted when a point has been added at \a index. |
|
107 | Signal is emitted when a point has been added at \a index. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | \fn void QXYSeries::pointRemoved(int index) |
|
111 | \fn void QXYSeries::pointRemoved(int index) | |
112 | Signal is emitted when a point has been removed from \a index. |
|
112 | Signal is emitted when a point has been removed from \a index. | |
113 | \sa remove() |
|
113 | \sa remove() | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
116 | \qmlsignal XYSeries::onPointRemoved(int index) | |
117 | Signal is emitted when a point has been removed from \a index. |
|
117 | Signal is emitted when a point has been removed from \a index. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QXYSeries::colorChanged(QColor color) |
|
121 | \fn void QXYSeries::colorChanged(QColor color) | |
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
123 | */ |
|
123 | */ | |
124 | /*! |
|
124 | /*! | |
125 | \qmlsignal XYSeries::onColorChanged(color color) |
|
125 | \qmlsignal XYSeries::onColorChanged(color color) | |
126 | Signal is emitted when the line (pen) color has changed to \a color. |
|
126 | Signal is emitted when the line (pen) color has changed to \a color. | |
127 | */ |
|
127 | */ | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | \fn void QXYSeriesPrivate::updated() |
|
130 | \fn void QXYSeriesPrivate::updated() | |
131 | \brief \internal |
|
131 | \brief \internal | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \qmlmethod XYSeries::append(real x, real y) |
|
135 | \qmlmethod XYSeries::append(real x, real y) | |
136 | Append point (\a x, \a y) to the series |
|
136 | Append point (\a x, \a y) to the series | |
137 | */ |
|
137 | */ | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
140 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
141 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
141 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
142 | exist. |
|
142 | exist. | |
143 | */ |
|
143 | */ | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \qmlmethod XYSeries::remove(real x, real y) |
|
146 | \qmlmethod XYSeries::remove(real x, real y) | |
147 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
147 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
148 | */ |
|
148 | */ | |
149 |
|
149 | |||
150 | /*! |
|
150 | /*! | |
151 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
151 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
152 | 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 | 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 | |
153 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
153 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
154 | */ |
|
154 | */ | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | \qmlmethod QPointF XYSeries::at(int index) |
|
157 | \qmlmethod QPointF XYSeries::at(int index) | |
158 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
158 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | \internal |
|
162 | \internal | |
163 |
|
163 | |||
164 | Constructs empty series object which is a child of \a parent. |
|
164 | Constructs empty series object which is a child of \a parent. | |
165 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
165 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
166 | */ |
|
166 | */ | |
167 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) |
|
167 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) | |
168 | { |
|
168 | { | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
172 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
173 | and are deleted when mentioned object are destroyed. |
|
173 | and are deleted when mentioned object are destroyed. | |
174 | */ |
|
174 | */ | |
175 | QXYSeries::~QXYSeries() |
|
175 | QXYSeries::~QXYSeries() | |
176 | { |
|
176 | { | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
180 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
181 | */ |
|
181 | */ | |
182 | void QXYSeries::append(qreal x,qreal y) |
|
182 | void QXYSeries::append(qreal x,qreal y) | |
183 | { |
|
183 | { | |
184 | append(QPointF(x,y)); |
|
184 | append(QPointF(x,y)); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | This is an overloaded function. |
|
188 | This is an overloaded function. | |
189 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
189 | Adds data \a point to the series. Points are connected with lines on the chart. | |
190 | */ |
|
190 | */ | |
191 | void QXYSeries::append(const QPointF &point) |
|
191 | void QXYSeries::append(const QPointF &point) | |
192 | { |
|
192 | { | |
193 | Q_D(QXYSeries); |
|
193 | Q_D(QXYSeries); | |
194 | d->m_points<<point; |
|
194 | d->m_points<<point; | |
195 | // emit d->pointAdded(d->m_points.count()-1); |
|
195 | // emit d->pointAdded(d->m_points.count()-1); | |
196 | emit pointAdded(d->m_points.count()-1); |
|
196 | emit pointAdded(d->m_points.count()-1); | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | /*! |
|
199 | /*! | |
200 | This is an overloaded function. |
|
200 | This is an overloaded function. | |
201 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
201 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
202 | */ |
|
202 | */ | |
203 | void QXYSeries::append(const QList<QPointF> &points) |
|
203 | void QXYSeries::append(const QList<QPointF> &points) | |
204 | { |
|
204 | { | |
205 | foreach(const QPointF& point , points) { |
|
205 | foreach(const QPointF& point , points) { | |
206 | append(point); |
|
206 | append(point); | |
207 | } |
|
207 | } | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | /*! |
|
210 | /*! | |
211 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
211 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
212 | */ |
|
212 | */ | |
213 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) |
|
213 | void QXYSeries::replace(qreal oldX,qreal oldY,qreal newX,qreal newY) | |
214 | { |
|
214 | { | |
215 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); |
|
215 | replace(QPointF(oldX,oldY),QPointF(newX,newY)); | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | /*! |
|
218 | /*! | |
219 | Replaces \a oldPoint with \a newPoint. |
|
219 | Replaces \a oldPoint with \a newPoint. | |
220 | */ |
|
220 | */ | |
221 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) |
|
221 | void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) | |
222 | { |
|
222 | { | |
223 | Q_D(QXYSeries); |
|
223 | Q_D(QXYSeries); | |
224 | int index = d->m_points.indexOf(oldPoint); |
|
224 | int index = d->m_points.indexOf(oldPoint); | |
225 | if(index==-1) return; |
|
225 | if(index==-1) return; | |
226 | d->m_points[index] = newPoint; |
|
226 | d->m_points[index] = newPoint; | |
227 | // emit d->pointReplaced(index); |
|
227 | // emit d->pointReplaced(index); | |
228 | emit pointReplaced(index); |
|
228 | emit pointReplaced(index); | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | /*! |
|
231 | /*! | |
232 | Removes current \a x and \a y value. |
|
232 | Removes current \a x and \a y value. | |
233 | */ |
|
233 | */ | |
234 | void QXYSeries::remove(qreal x,qreal y) |
|
234 | void QXYSeries::remove(qreal x,qreal y) | |
235 | { |
|
235 | { | |
236 | remove(QPointF(x,y)); |
|
236 | remove(QPointF(x,y)); | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | /*! |
|
239 | /*! | |
240 | Removes current \a point x value. |
|
240 | Removes current \a point x value. | |
241 |
|
241 | |||
242 | Note: point y value is ignored. |
|
242 | Note: point y value is ignored. | |
243 | */ |
|
243 | */ | |
244 | void QXYSeries::remove(const QPointF &point) |
|
244 | void QXYSeries::remove(const QPointF &point) | |
245 | { |
|
245 | { | |
246 | Q_D(QXYSeries); |
|
246 | Q_D(QXYSeries); | |
247 | int index = d->m_points.indexOf(point); |
|
247 | int index = d->m_points.indexOf(point); | |
248 | if(index==-1) return; |
|
248 | if(index==-1) return; | |
249 | d->m_points.remove(index); |
|
249 | d->m_points.remove(index); | |
250 | // emit d->pointRemoved(index); |
|
250 | // emit d->pointRemoved(index); | |
251 | emit pointRemoved(index); |
|
251 | emit pointRemoved(index); | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | /*! |
|
254 | /*! | |
255 | Inserts a \a point in the series at \a index position. |
|
255 | Inserts a \a point in the series at \a index position. | |
256 | */ |
|
256 | */ | |
257 | void QXYSeries::insert(int index, const QPointF &point) |
|
257 | void QXYSeries::insert(int index, const QPointF &point) | |
258 | { |
|
258 | { | |
259 | Q_D(QXYSeries); |
|
259 | Q_D(QXYSeries); | |
260 | d->m_points.insert(index, point); |
|
260 | d->m_points.insert(index, point); | |
261 | // emit d->pointAdded(index); |
|
261 | // emit d->pointAdded(index); | |
262 | emit pointAdded(index); |
|
262 | emit pointAdded(index); | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | /*! |
|
265 | /*! | |
266 | Removes all points from the series. |
|
266 | Removes all points from the series. | |
267 | */ |
|
267 | */ | |
268 | void QXYSeries::clear() |
|
268 | void QXYSeries::clear() | |
269 | { |
|
269 | { | |
270 | Q_D(QXYSeries); |
|
270 | Q_D(QXYSeries); | |
271 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
271 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
272 | remove(d->m_points.at(i)); |
|
272 | remove(d->m_points.at(i)); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | /*! |
|
275 | /*! | |
276 | \internal \a pos |
|
276 | Returns list of points in the series. | |
277 | */ |
|
277 | */ | |
278 | QList<QPointF> QXYSeries::points() const |
|
278 | QList<QPointF> QXYSeries::points() const | |
279 | { |
|
279 | { | |
280 | Q_D(const QXYSeries); |
|
280 | Q_D(const QXYSeries); | |
281 | return d->m_points.toList(); |
|
281 | return d->m_points.toList(); | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | /*! |
|
284 | /*! | |
285 | Returns number of data points within series. |
|
285 | Returns number of data points within series. | |
286 | */ |
|
286 | */ | |
287 | int QXYSeries::count() const |
|
287 | int QXYSeries::count() const | |
288 | { |
|
288 | { | |
289 | Q_D(const QXYSeries); |
|
289 | Q_D(const QXYSeries); | |
290 | return d->m_points.count(); |
|
290 | return d->m_points.count(); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 |
|
293 | |||
294 | /*! |
|
294 | /*! | |
295 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
295 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
296 | pen from chart theme is used. |
|
296 | pen from chart theme is used. | |
297 | \sa QChart::setTheme() |
|
297 | \sa QChart::setTheme() | |
298 | */ |
|
298 | */ | |
299 | void QXYSeries::setPen(const QPen &pen) |
|
299 | void QXYSeries::setPen(const QPen &pen) | |
300 | { |
|
300 | { | |
301 | Q_D(QXYSeries); |
|
301 | Q_D(QXYSeries); | |
302 | if (d->m_pen != pen) { |
|
302 | if (d->m_pen != pen) { | |
303 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
303 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |
304 | d->m_pen = pen; |
|
304 | d->m_pen = pen; | |
305 | emit d->updated(); |
|
305 | emit d->updated(); | |
306 | if (emitColorChanged) |
|
306 | if (emitColorChanged) | |
307 | emit colorChanged(pen.color()); |
|
307 | emit colorChanged(pen.color()); | |
308 | } |
|
308 | } | |
309 | } |
|
309 | } | |
310 |
|
310 | |||
311 | QPen QXYSeries::pen() const |
|
311 | QPen QXYSeries::pen() const | |
312 | { |
|
312 | { | |
313 | Q_D(const QXYSeries); |
|
313 | Q_D(const QXYSeries); | |
314 | return d->m_pen; |
|
314 | return d->m_pen; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | /*! |
|
317 | /*! | |
318 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
318 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
319 | from chart theme setting is used. |
|
319 | from chart theme setting is used. | |
320 | \sa QChart::setTheme() |
|
320 | \sa QChart::setTheme() | |
321 | */ |
|
321 | */ | |
322 | void QXYSeries::setBrush(const QBrush &brush) |
|
322 | void QXYSeries::setBrush(const QBrush &brush) | |
323 | { |
|
323 | { | |
324 | Q_D(QXYSeries); |
|
324 | Q_D(QXYSeries); | |
325 | if (d->m_brush!=brush) { |
|
325 | if (d->m_brush!=brush) { | |
326 | d->m_brush = brush; |
|
326 | d->m_brush = brush; | |
327 | emit d->updated(); |
|
327 | emit d->updated(); | |
328 | } |
|
328 | } | |
329 | } |
|
329 | } | |
330 |
|
330 | |||
331 | QBrush QXYSeries::brush() const |
|
331 | QBrush QXYSeries::brush() const | |
332 | { |
|
332 | { | |
333 | Q_D(const QXYSeries); |
|
333 | Q_D(const QXYSeries); | |
334 | return d->m_brush; |
|
334 | return d->m_brush; | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | void QXYSeries::setColor(const QColor &color) |
|
337 | void QXYSeries::setColor(const QColor &color) | |
338 | { |
|
338 | { | |
339 | QPen p = pen(); |
|
339 | QPen p = pen(); | |
340 | if (p.color() != color) { |
|
340 | if (p.color() != color) { | |
341 | p.setColor(color); |
|
341 | p.setColor(color); | |
342 | setPen(p); |
|
342 | setPen(p); | |
343 | } |
|
343 | } | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | QColor QXYSeries::color() const |
|
346 | QColor QXYSeries::color() const | |
347 | { |
|
347 | { | |
348 | return pen().color(); |
|
348 | return pen().color(); | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | void QXYSeries::setPointsVisible(bool visible) |
|
351 | void QXYSeries::setPointsVisible(bool visible) | |
352 | { |
|
352 | { | |
353 | Q_D(QXYSeries); |
|
353 | Q_D(QXYSeries); | |
354 | if (d->m_pointsVisible != visible){ |
|
354 | if (d->m_pointsVisible != visible){ | |
355 | d->m_pointsVisible = visible; |
|
355 | d->m_pointsVisible = visible; | |
356 | emit d->updated(); |
|
356 | emit d->updated(); | |
357 | } |
|
357 | } | |
358 | } |
|
358 | } | |
359 |
|
359 | |||
360 | bool QXYSeries::pointsVisible() const |
|
360 | bool QXYSeries::pointsVisible() const | |
361 | { |
|
361 | { | |
362 | Q_D(const QXYSeries); |
|
362 | Q_D(const QXYSeries); | |
363 | return d->m_pointsVisible; |
|
363 | return d->m_pointsVisible; | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 |
|
366 | |||
367 | /*! |
|
367 | /*! | |
368 | Stream operator for adding a data \a point to the series. |
|
368 | Stream operator for adding a data \a point to the series. | |
369 | \sa append() |
|
369 | \sa append() | |
370 | */ |
|
370 | */ | |
371 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
371 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
372 | { |
|
372 | { | |
373 | append(point); |
|
373 | append(point); | |
374 | return *this; |
|
374 | return *this; | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 |
|
377 | |||
378 | /*! |
|
378 | /*! | |
379 | Stream operator for adding a list of \a points to the series. |
|
379 | Stream operator for adding a list of \a points to the series. | |
380 | \sa append() |
|
380 | \sa append() | |
381 | */ |
|
381 | */ | |
382 |
|
382 | |||
383 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) |
|
383 | QXYSeries& QXYSeries::operator<< (const QList<QPointF>& points) | |
384 | { |
|
384 | { | |
385 | append(points); |
|
385 | append(points); | |
386 | return *this; |
|
386 | return *this; | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
389 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
390 |
|
390 | |||
391 |
|
391 | |||
392 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : |
|
392 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : | |
393 | QAbstractSeriesPrivate(q), |
|
393 | QAbstractSeriesPrivate(q), | |
394 | m_pointsVisible(false) |
|
394 | m_pointsVisible(false) | |
395 | { |
|
395 | { | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | void QXYSeriesPrivate::scaleDomain(Domain& domain) |
|
398 | void QXYSeriesPrivate::scaleDomain(Domain& domain) | |
399 | { |
|
399 | { | |
400 | qreal minX(domain.minX()); |
|
400 | qreal minX(domain.minX()); | |
401 | qreal minY(domain.minY()); |
|
401 | qreal minY(domain.minY()); | |
402 | qreal maxX(domain.maxX()); |
|
402 | qreal maxX(domain.maxX()); | |
403 | qreal maxY(domain.maxY()); |
|
403 | qreal maxY(domain.maxY()); | |
404 |
|
404 | |||
405 | Q_Q(QXYSeries); |
|
405 | Q_Q(QXYSeries); | |
406 |
|
406 | |||
407 | const QList<QPointF>& points = q->points(); |
|
407 | const QList<QPointF>& points = q->points(); | |
408 |
|
408 | |||
409 |
|
409 | |||
410 | if (points.isEmpty()){ |
|
410 | if (points.isEmpty()){ | |
411 | minX = qMin(minX, (qreal)0.0); |
|
411 | minX = qMin(minX, (qreal)0.0); | |
412 | minY = qMin(minY, (qreal)0.0); |
|
412 | minY = qMin(minY, (qreal)0.0); | |
413 | maxX = qMax(maxX, (qreal)1.0); |
|
413 | maxX = qMax(maxX, (qreal)1.0); | |
414 | maxY = qMax(maxY, (qreal)1.0); |
|
414 | maxY = qMax(maxY, (qreal)1.0); | |
415 | } |
|
415 | } | |
416 |
|
416 | |||
417 | for (int i = 0; i < points.count(); i++) { |
|
417 | for (int i = 0; i < points.count(); i++) { | |
418 | qreal x = points[i].x(); |
|
418 | qreal x = points[i].x(); | |
419 | qreal y = points[i].y(); |
|
419 | qreal y = points[i].y(); | |
420 | minX = qMin(minX, x); |
|
420 | minX = qMin(minX, x); | |
421 | minY = qMin(minY, y); |
|
421 | minY = qMin(minY, y); | |
422 | maxX = qMax(maxX, x); |
|
422 | maxX = qMax(maxX, x); | |
423 | maxY = qMax(maxY, y); |
|
423 | maxY = qMax(maxY, y); | |
424 | } |
|
424 | } | |
425 |
|
425 | |||
426 | domain.setRange(minX,maxX,minY,maxY); |
|
426 | domain.setRange(minX,maxX,minY,maxY); | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) |
|
429 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |
430 | { |
|
430 | { | |
431 | Q_Q(QXYSeries); |
|
431 | Q_Q(QXYSeries); | |
432 | QList<LegendMarker*> list; |
|
432 | QList<LegendMarker*> list; | |
433 | return list << new XYLegendMarker(q,legend); |
|
433 | return list << new XYLegendMarker(q,legend); | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | void QXYSeriesPrivate::initializeAxis(QAbstractAxis* axis) |
|
436 | void QXYSeriesPrivate::initializeAxis(QAbstractAxis* axis) | |
437 | { |
|
437 | { | |
438 | Q_UNUSED(axis); |
|
438 | Q_UNUSED(axis); | |
439 | } |
|
439 | } | |
440 |
|
440 | |||
441 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
441 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
442 | { |
|
442 | { | |
443 | Q_UNUSED(orientation); |
|
443 | Q_UNUSED(orientation); | |
444 | return QAbstractAxis::AxisTypeValues; |
|
444 | return QAbstractAxis::AxisTypeValues; | |
445 | } |
|
445 | } | |
446 |
|
446 | |||
447 | #include "moc_qxyseries.cpp" |
|
447 | #include "moc_qxyseries.cpp" | |
448 | #include "moc_qxyseries_p.cpp" |
|
448 | #include "moc_qxyseries_p.cpp" | |
449 |
|
449 | |||
450 | QTCOMMERCIALCHART_END_NAMESPACE |
|
450 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now