@@ -1,444 +1,444 | |||||
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 "qchartaxis.h" |
|
21 | #include "qchartaxis.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | /*! |
|
25 | /*! | |
26 | \class QChartAxis |
|
26 | \class QChartAxis | |
27 | \brief The QChartAxis class is used for manipulating chart's axis |
|
27 | \brief The QChartAxis class is used for manipulating chart's axis | |
28 | and for adding optional axes to the chart. |
|
28 | and for adding optional axes to the chart. | |
29 | \mainclass |
|
29 | \mainclass | |
30 |
|
30 | |||
31 | There is only one x Axis, however there can be multiple y axes. |
|
31 | There is only one x Axis, however there can be multiple y axes. | |
32 | Each chart series can be bound to exactly one Y axis and the share common X axis. |
|
32 | Each chart series can be bound to exactly one Y axis and the share common X axis. | |
33 | Axis can be setup to show axis line with ticks, gird lines and shades. |
|
33 | Axis can be setup to show axis line with ticks, gird lines and shades. | |
34 |
|
34 | |||
35 | */ |
|
35 | */ | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \fn bool QChartAxis::isAxisVisible() const |
|
38 | \fn bool QChartAxis::isAxisVisible() const | |
39 | \brief Returns if axis is visible |
|
39 | \brief Returns if axis is visible | |
40 | \sa setAxisVisible() |
|
40 | \sa setAxisVisible() | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \fn QPen QChartAxis::axisPen() const |
|
44 | \fn QPen QChartAxis::axisPen() const | |
45 | \brief Returns pen used to draw axis and ticks. |
|
45 | \brief Returns pen used to draw axis and ticks. | |
46 | \sa setAxisPen() |
|
46 | \sa setAxisPen() | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \fn bool QChartAxis::isGridLineVisible() const |
|
51 | \fn bool QChartAxis::isGridLineVisible() const | |
52 | \brief Returns if grid is visible |
|
52 | \brief Returns if grid is visible | |
53 | \sa setGridLineVisible() |
|
53 | \sa setGridLineVisible() | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \fn QPen QChartAxis::gridLinePen() const |
|
57 | \fn QPen QChartAxis::gridLinePen() const | |
58 | \brief Returns pen used to draw grid. |
|
58 | \brief Returns pen used to draw grid. | |
59 | \sa setGridLinePen() |
|
59 | \sa setGridLinePen() | |
60 | */ |
|
60 | */ | |
61 |
|
61 | |||
62 | /*! |
|
62 | /*! | |
63 | \fn bool QChartAxis::labelsVisible() const |
|
63 | \fn bool QChartAxis::labelsVisible() const | |
64 | \brief Returns if grid is visible |
|
64 | \brief Returns if grid is visible | |
65 | \sa setLabelsVisible() |
|
65 | \sa setLabelsVisible() | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \fn QPen QChartAxis::labelsPen() const |
|
69 | \fn QPen QChartAxis::labelsPen() const | |
70 | \brief Returns the pen used to labels. |
|
70 | \brief Returns the pen used to labels. | |
71 | \sa setLabelsPen() |
|
71 | \sa setLabelsPen() | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \fn QBrush QChartAxis::labelsBrush() const |
|
75 | \fn QBrush QChartAxis::labelsBrush() const | |
76 | \brief Returns brush used to draw labels. |
|
76 | \brief Returns brush used to draw labels. | |
77 | \sa setLabelsBrush() |
|
77 | \sa setLabelsBrush() | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \fn QFont QChartAxis::labelsFont() const |
|
81 | \fn QFont QChartAxis::labelsFont() const | |
82 | \brief Returns font used to draw labels. |
|
82 | \brief Returns font used to draw labels. | |
83 | \sa setLabelsFont() |
|
83 | \sa setLabelsFont() | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \fn QFont QChartAxis::labelsAngle() const |
|
87 | \fn QFont QChartAxis::labelsAngle() const | |
88 | \brief Returns angle used to draw labels. |
|
88 | \brief Returns angle used to draw labels. | |
89 | \sa setLabelsAngle() |
|
89 | \sa setLabelsAngle() | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | /*! |
|
92 | /*! | |
93 | \fn bool QChartAxis::shadesVisible() const |
|
93 | \fn bool QChartAxis::shadesVisible() const | |
94 | \brief Returns if shades are visible. |
|
94 | \brief Returns if shades are visible. | |
95 | \sa setShadesVisible() |
|
95 | \sa setShadesVisible() | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \fn qreal QChartAxis::shadesOpacity() const |
|
99 | \fn qreal QChartAxis::shadesOpacity() const | |
100 | \brief Returns opacity of shades. |
|
100 | \brief Returns opacity of shades. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \fn QPen QChartAxis::shadesPen() const |
|
104 | \fn QPen QChartAxis::shadesPen() const | |
105 | \brief Returns pen used to draw shades. |
|
105 | \brief Returns pen used to draw shades. | |
106 | \sa setShadesPen() |
|
106 | \sa setShadesPen() | |
107 | */ |
|
107 | */ | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \fn QBrush QChartAxis::shadesBrush() const |
|
110 | \fn QBrush QChartAxis::shadesBrush() const | |
111 | \brief Returns brush used to draw shades. |
|
111 | \brief Returns brush used to draw shades. | |
112 | \sa setShadesBrush() |
|
112 | \sa setShadesBrush() | |
113 | */ |
|
113 | */ | |
114 |
|
114 | |||
115 | /*! |
|
115 | /*! | |
116 | \fn qreal QChartAxis::min() const |
|
116 | \fn qreal QChartAxis::min() const | |
117 | \brief Returns minimum value on the axis. |
|
117 | \brief Returns minimum value on the axis. | |
118 | \sa setMin() |
|
118 | \sa setMin() | |
119 | */ |
|
119 | */ | |
120 |
|
120 | |||
121 | /*! |
|
121 | /*! | |
122 | \fn qreal QChartAxis::max() const |
|
122 | \fn qreal QChartAxis::max() const | |
123 | \brief Returns maximim value on the axis. |
|
123 | \brief Returns maximim value on the axis. | |
124 | \sa setMax() |
|
124 | \sa setMax() | |
125 | */ |
|
125 | */ | |
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | \fn void QChartAxis::minChanged(qreal min) |
|
128 | \fn void QChartAxis::minChanged(qreal min) | |
129 | \brief Axis emits signal when \a min of axis has changed. |
|
129 | \brief Axis emits signal when \a min of axis has changed. | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QChartAxis::maxChanged(qreal max) |
|
133 | \fn void QChartAxis::maxChanged(qreal max) | |
134 | \brief Axis emits signal when \a max of axis has changed. |
|
134 | \brief Axis emits signal when \a max of axis has changed. | |
135 | */ |
|
135 | */ | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \fn void QChartAxis::rangeChanged(qreal min, qreal max) |
|
138 | \fn void QChartAxis::rangeChanged(qreal min, qreal max) | |
139 | \brief Axis emits signal when \a min or \a max of axis has changed. |
|
139 | \brief Axis emits signal when \a min or \a max of axis has changed. | |
140 | */ |
|
140 | */ | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | \fn int QChartAxis::ticksCount() const |
|
143 | \fn int QChartAxis::ticksCount() const | |
144 | \brief Return number of ticks on the axis |
|
144 | \brief Return number of ticks on the axis | |
145 | \sa setTicksCount() |
|
145 | \sa setTicksCount() | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QChartAxis::updated() |
|
149 | \fn void QChartAxis::updated() | |
150 | \brief \internal |
|
150 | \brief \internal | |
151 | */ |
|
151 | */ | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \fn void changed(qreal min, qreal max, int tickCount,bool niceNumbers) |
|
154 | \fn void QChartAxis::changed(qreal min, qreal max, int tickCount,bool niceNumbers) | |
155 | \brief \internal |
|
155 | \brief \internal | |
156 | */ |
|
156 | */ | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | \fn bool QChartAxis::niceNumbers() const |
|
159 | \fn bool QChartAxis::niceNumbers() const | |
160 | \brief Returns whether nice numbers are enabled or not. |
|
160 | \brief Returns whether nice numbers are enabled or not. | |
161 | */ |
|
161 | */ | |
162 |
|
162 | |||
163 | /*! |
|
163 | /*! | |
164 | \fn QChartAxisCategories* categories() |
|
164 | \fn QChartAxisCategories* QChartAxis::categories() | |
165 | \brief Returns pointer to the list of categories which correspond to the values on the axis. |
|
165 | \brief Returns pointer to the list of categories which correspond to the values on the axis. | |
166 | */ |
|
166 | */ | |
167 |
|
167 | |||
168 | /*! |
|
168 | /*! | |
169 | \fn void ticksCountChanged(int count) |
|
169 | \fn void QChartAxis::ticksCountChanged(int count) | |
170 | \brief Emits the new \a count of ticks on the axis |
|
170 | \brief Emits the new \a count of ticks on the axis | |
171 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. |
|
171 | Signal is emitted when the number of the ticks on the axis has been changed to a different value. | |
172 | Parementer count\a count is the new number of ticks on the axis. |
|
172 | Parementer count\a count is the new number of ticks on the axis. | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | /*! |
|
175 | /*! | |
176 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
176 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
177 | QChatView or QChart when axis added. |
|
177 | QChatView or QChart when axis added. | |
178 | */ |
|
178 | */ | |
179 |
|
179 | |||
180 | QChartAxis::QChartAxis(QObject *parent) : QObject(parent), |
|
180 | QChartAxis::QChartAxis(QObject *parent) : QObject(parent), | |
181 | m_axisVisible(true), |
|
181 | m_axisVisible(true), | |
182 | m_gridLineVisible(true), |
|
182 | m_gridLineVisible(true), | |
183 | m_labelsVisible(true), |
|
183 | m_labelsVisible(true), | |
184 | m_labelsAngle(0), |
|
184 | m_labelsAngle(0), | |
185 | m_shadesVisible(false), |
|
185 | m_shadesVisible(false), | |
186 | m_shadesOpacity(1.0), |
|
186 | m_shadesOpacity(1.0), | |
187 | m_min(0), |
|
187 | m_min(0), | |
188 | m_max(0), |
|
188 | m_max(0), | |
189 | m_ticksCount(5), |
|
189 | m_ticksCount(5), | |
190 | m_niceNumbers(false) |
|
190 | m_niceNumbers(false) | |
191 | { |
|
191 | { | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
196 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
197 | */ |
|
197 | */ | |
198 |
|
198 | |||
199 | QChartAxis::~QChartAxis() |
|
199 | QChartAxis::~QChartAxis() | |
200 | { |
|
200 | { | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | Sets \a pen used to draw axis line and ticks. |
|
204 | Sets \a pen used to draw axis line and ticks. | |
205 | */ |
|
205 | */ | |
206 | void QChartAxis::setAxisPen(const QPen &pen) |
|
206 | void QChartAxis::setAxisPen(const QPen &pen) | |
207 | { |
|
207 | { | |
208 | if (pen != m_axisPen) { |
|
208 | if (pen != m_axisPen) { | |
209 | m_axisPen = pen; |
|
209 | m_axisPen = pen; | |
210 | emit updated(); |
|
210 | emit updated(); | |
211 | } |
|
211 | } | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | Sets if axis and ticks are \a visible. |
|
215 | Sets if axis and ticks are \a visible. | |
216 | */ |
|
216 | */ | |
217 | void QChartAxis::setAxisVisible(bool visible) |
|
217 | void QChartAxis::setAxisVisible(bool visible) | |
218 | { |
|
218 | { | |
219 | if (m_axisVisible != visible) { |
|
219 | if (m_axisVisible != visible) { | |
220 | m_axisVisible = visible; |
|
220 | m_axisVisible = visible; | |
221 | emit updated(); |
|
221 | emit updated(); | |
222 | } |
|
222 | } | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | /*! |
|
225 | /*! | |
226 | Sets if grid line is \a visible. |
|
226 | Sets if grid line is \a visible. | |
227 | */ |
|
227 | */ | |
228 | void QChartAxis::setGridLineVisible(bool visible) |
|
228 | void QChartAxis::setGridLineVisible(bool visible) | |
229 | { |
|
229 | { | |
230 | if (m_gridLineVisible != visible) { |
|
230 | if (m_gridLineVisible != visible) { | |
231 | m_gridLineVisible = visible; |
|
231 | m_gridLineVisible = visible; | |
232 | emit updated(); |
|
232 | emit updated(); | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | /*! |
|
236 | /*! | |
237 | Sets \a pen used to draw grid line. |
|
237 | Sets \a pen used to draw grid line. | |
238 | */ |
|
238 | */ | |
239 | void QChartAxis::setGridLinePen(const QPen &pen) |
|
239 | void QChartAxis::setGridLinePen(const QPen &pen) | |
240 | { |
|
240 | { | |
241 | if (m_gridLinePen != pen) { |
|
241 | if (m_gridLinePen != pen) { | |
242 | m_gridLinePen = pen; |
|
242 | m_gridLinePen = pen; | |
243 | emit updated(); |
|
243 | emit updated(); | |
244 | } |
|
244 | } | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | /*! |
|
247 | /*! | |
248 | Sets if axis' labels are \a visible. |
|
248 | Sets if axis' labels are \a visible. | |
249 | */ |
|
249 | */ | |
250 | void QChartAxis::setLabelsVisible(bool visible) |
|
250 | void QChartAxis::setLabelsVisible(bool visible) | |
251 | { |
|
251 | { | |
252 | if (m_labelsVisible != visible) { |
|
252 | if (m_labelsVisible != visible) { | |
253 | m_labelsVisible = visible; |
|
253 | m_labelsVisible = visible; | |
254 | emit updated(); |
|
254 | emit updated(); | |
255 | } |
|
255 | } | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | /*! |
|
258 | /*! | |
259 | Sets \a pen used to draw labels. |
|
259 | Sets \a pen used to draw labels. | |
260 | */ |
|
260 | */ | |
261 | void QChartAxis::setLabelsPen(const QPen &pen) |
|
261 | void QChartAxis::setLabelsPen(const QPen &pen) | |
262 | { |
|
262 | { | |
263 | if (m_labelsPen != pen) { |
|
263 | if (m_labelsPen != pen) { | |
264 | m_labelsPen = pen; |
|
264 | m_labelsPen = pen; | |
265 | emit updated(); |
|
265 | emit updated(); | |
266 | } |
|
266 | } | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | /*! |
|
269 | /*! | |
270 | Sets \a brush used to draw labels. |
|
270 | Sets \a brush used to draw labels. | |
271 | */ |
|
271 | */ | |
272 | void QChartAxis::setLabelsBrush(const QBrush &brush) |
|
272 | void QChartAxis::setLabelsBrush(const QBrush &brush) | |
273 | { |
|
273 | { | |
274 | if (m_labelsBrush != brush) { |
|
274 | if (m_labelsBrush != brush) { | |
275 | m_labelsBrush = brush; |
|
275 | m_labelsBrush = brush; | |
276 | emit updated(); |
|
276 | emit updated(); | |
277 | } |
|
277 | } | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | /*! |
|
280 | /*! | |
281 | Sets \a font used to draw labels. |
|
281 | Sets \a font used to draw labels. | |
282 | */ |
|
282 | */ | |
283 | void QChartAxis::setLabelsFont(const QFont &font) |
|
283 | void QChartAxis::setLabelsFont(const QFont &font) | |
284 | { |
|
284 | { | |
285 | if (m_labelsFont != font) { |
|
285 | if (m_labelsFont != font) { | |
286 | m_labelsFont = font; |
|
286 | m_labelsFont = font; | |
287 | emit updated(); |
|
287 | emit updated(); | |
288 | } |
|
288 | } | |
289 | } |
|
289 | } | |
290 |
|
290 | |||
291 | /*! |
|
291 | /*! | |
292 | Sets \a angle for all the labels on given axis. |
|
292 | Sets \a angle for all the labels on given axis. | |
293 | */ |
|
293 | */ | |
294 | void QChartAxis::setLabelsAngle(int angle) |
|
294 | void QChartAxis::setLabelsAngle(int angle) | |
295 | { |
|
295 | { | |
296 | if (m_labelsAngle != angle) { |
|
296 | if (m_labelsAngle != angle) { | |
297 | m_labelsAngle = angle; |
|
297 | m_labelsAngle = angle; | |
298 | emit updated(); |
|
298 | emit updated(); | |
299 | } |
|
299 | } | |
300 | } |
|
300 | } | |
301 |
|
301 | |||
302 | /*! |
|
302 | /*! | |
303 | Sets if shades are \a visible. |
|
303 | Sets if shades are \a visible. | |
304 | */ |
|
304 | */ | |
305 | void QChartAxis::setShadesVisible(bool visible) |
|
305 | void QChartAxis::setShadesVisible(bool visible) | |
306 | { |
|
306 | { | |
307 | if (m_shadesVisible != visible) { |
|
307 | if (m_shadesVisible != visible) { | |
308 | m_shadesVisible = visible; |
|
308 | m_shadesVisible = visible; | |
309 | emit updated(); |
|
309 | emit updated(); | |
310 | } |
|
310 | } | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | /*! |
|
313 | /*! | |
314 | Sets \a pen used to draw shades. |
|
314 | Sets \a pen used to draw shades. | |
315 | */ |
|
315 | */ | |
316 | void QChartAxis::setShadesPen(const QPen &pen) |
|
316 | void QChartAxis::setShadesPen(const QPen &pen) | |
317 | { |
|
317 | { | |
318 | if (m_shadesPen != pen) { |
|
318 | if (m_shadesPen != pen) { | |
319 | m_shadesPen = pen; |
|
319 | m_shadesPen = pen; | |
320 | emit updated(); |
|
320 | emit updated(); | |
321 | } |
|
321 | } | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | /*! |
|
324 | /*! | |
325 | Sets \a brush used to draw shades. |
|
325 | Sets \a brush used to draw shades. | |
326 | */ |
|
326 | */ | |
327 | void QChartAxis::setShadesBrush(const QBrush &brush) |
|
327 | void QChartAxis::setShadesBrush(const QBrush &brush) | |
328 | { |
|
328 | { | |
329 | if (m_shadesBrush != brush) { |
|
329 | if (m_shadesBrush != brush) { | |
330 | m_shadesBrush = brush; |
|
330 | m_shadesBrush = brush; | |
331 | emit updated(); |
|
331 | emit updated(); | |
332 | } |
|
332 | } | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | /*! |
|
335 | /*! | |
336 | Sets \a opacity of the shades. |
|
336 | Sets \a opacity of the shades. | |
337 | */ |
|
337 | */ | |
338 | void QChartAxis::setShadesOpacity(qreal opacity) |
|
338 | void QChartAxis::setShadesOpacity(qreal opacity) | |
339 | { |
|
339 | { | |
340 | if (m_shadesOpacity != opacity) { |
|
340 | if (m_shadesOpacity != opacity) { | |
341 | m_shadesOpacity=opacity; |
|
341 | m_shadesOpacity=opacity; | |
342 | emit updated(); |
|
342 | emit updated(); | |
343 | } |
|
343 | } | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | /*! |
|
346 | /*! | |
347 | Sets \a min value on the axis. |
|
347 | Sets \a min value on the axis. | |
348 | */ |
|
348 | */ | |
349 | void QChartAxis::setMin(qreal min) |
|
349 | void QChartAxis::setMin(qreal min) | |
350 | { |
|
350 | { | |
351 | setRange(min,m_max); |
|
351 | setRange(min,m_max); | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | /*! |
|
354 | /*! | |
355 | Sets \a max value on the axis. |
|
355 | Sets \a max value on the axis. | |
356 | */ |
|
356 | */ | |
357 | void QChartAxis::setMax(qreal max) |
|
357 | void QChartAxis::setMax(qreal max) | |
358 | { |
|
358 | { | |
359 | setRange(m_min,max); |
|
359 | setRange(m_min,max); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | /*! |
|
362 | /*! | |
363 | Sets range from \a min to \a max on the axis. |
|
363 | Sets range from \a min to \a max on the axis. | |
364 | */ |
|
364 | */ | |
365 | void QChartAxis::setRange(qreal min, qreal max) |
|
365 | void QChartAxis::setRange(qreal min, qreal max) | |
366 | { |
|
366 | { | |
367 | bool changed = false; |
|
367 | bool changed = false; | |
368 | if (!qFuzzyIsNull(m_min - min)) { |
|
368 | if (!qFuzzyIsNull(m_min - min)) { | |
369 | m_min = min; |
|
369 | m_min = min; | |
370 | changed = true; |
|
370 | changed = true; | |
371 | emit minChanged(min); |
|
371 | emit minChanged(min); | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | if (!qFuzzyIsNull(m_max - max)) { |
|
374 | if (!qFuzzyIsNull(m_max - max)) { | |
375 | m_max = max; |
|
375 | m_max = max; | |
376 | changed = true; |
|
376 | changed = true; | |
377 | emit maxChanged(max); |
|
377 | emit maxChanged(max); | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | if (changed) { |
|
380 | if (changed) { | |
381 | emit rangeChanged(m_min,m_max); |
|
381 | emit rangeChanged(m_min,m_max); | |
382 | emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers); |
|
382 | emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
383 | } |
|
383 | } | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | Sets \a count for ticks on the axis. |
|
387 | Sets \a count for ticks on the axis. | |
388 | */ |
|
388 | */ | |
389 | void QChartAxis::setTicksCount(int count) |
|
389 | void QChartAxis::setTicksCount(int count) | |
390 | { |
|
390 | { | |
391 | if (m_ticksCount != count) { |
|
391 | if (m_ticksCount != count) { | |
392 | m_ticksCount = count; |
|
392 | m_ticksCount = count; | |
393 | emit ticksCountChanged(count); |
|
393 | emit ticksCountChanged(count); | |
394 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); |
|
394 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | /*! |
|
398 | /*! | |
399 | Sets axis, shades, labels and grid lines to be visible. |
|
399 | Sets axis, shades, labels and grid lines to be visible. | |
400 | */ |
|
400 | */ | |
401 | void QChartAxis::show() |
|
401 | void QChartAxis::show() | |
402 | { |
|
402 | { | |
403 | m_axisVisible=true; |
|
403 | m_axisVisible=true; | |
404 | m_gridLineVisible=true; |
|
404 | m_gridLineVisible=true; | |
405 | m_labelsVisible=true; |
|
405 | m_labelsVisible=true; | |
406 | m_shadesVisible=true; |
|
406 | m_shadesVisible=true; | |
407 | emit updated(); |
|
407 | emit updated(); | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | /*! |
|
410 | /*! | |
411 | Sets axis, shades, labels and grid lines to not be visible. |
|
411 | Sets axis, shades, labels and grid lines to not be visible. | |
412 | */ |
|
412 | */ | |
413 | void QChartAxis::hide() |
|
413 | void QChartAxis::hide() | |
414 | { |
|
414 | { | |
415 | m_axisVisible = false; |
|
415 | m_axisVisible = false; | |
416 | m_gridLineVisible = false; |
|
416 | m_gridLineVisible = false; | |
417 | m_labelsVisible = false; |
|
417 | m_labelsVisible = false; | |
418 | m_shadesVisible = false; |
|
418 | m_shadesVisible = false; | |
419 | emit updated(); |
|
419 | emit updated(); | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | /*! |
|
422 | /*! | |
423 | \internal |
|
423 | \internal | |
424 | */ |
|
424 | */ | |
425 | void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
425 | void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count) | |
426 | { |
|
426 | { | |
427 | setRange(min,max); |
|
427 | setRange(min,max); | |
428 | setTicksCount(count); |
|
428 | setTicksCount(count); | |
429 | } |
|
429 | } | |
430 |
|
430 | |||
431 | /*! |
|
431 | /*! | |
432 | Sets the nice numbers state to \a enable |
|
432 | Sets the nice numbers state to \a enable | |
433 | */ |
|
433 | */ | |
434 | void QChartAxis::setNiceNumbers(bool enable) |
|
434 | void QChartAxis::setNiceNumbers(bool enable) | |
435 | { |
|
435 | { | |
436 | if (m_niceNumbers != enable){ |
|
436 | if (m_niceNumbers != enable){ | |
437 | m_niceNumbers = enable; |
|
437 | m_niceNumbers = enable; | |
438 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); |
|
438 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
439 | } |
|
439 | } | |
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | #include "moc_qchartaxis.cpp" |
|
442 | #include "moc_qchartaxis.cpp" | |
443 |
|
443 | |||
444 | QTCOMMERCIALCHART_END_NAMESPACE |
|
444 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,414 +1,413 | |||||
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 "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include <QGraphicsScene> |
|
23 | #include <QGraphicsScene> | |
24 | #include <QGraphicsSceneResizeEvent> |
|
24 | #include <QGraphicsSceneResizeEvent> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \enum QChart::ChartTheme |
|
29 | \enum QChart::ChartTheme | |
30 |
|
30 | |||
31 | This enum describes the theme used by the chart. |
|
31 | This enum describes the theme used by the chart. | |
32 |
|
32 | |||
33 | \value ChartThemeLight The default theme |
|
33 | \value ChartThemeLight The default theme | |
34 | \value ChartThemeBlueCerulean |
|
34 | \value ChartThemeBlueCerulean | |
35 | \value ChartThemeDark |
|
35 | \value ChartThemeDark | |
36 | \value ChartThemeBrownSand |
|
36 | \value ChartThemeBrownSand | |
37 | \value ChartThemeBlueNcs |
|
37 | \value ChartThemeBlueNcs | |
38 | \value ChartThemeHighContrast |
|
38 | \value ChartThemeHighContrast | |
39 | \value ChartThemeBlueIcy |
|
39 | \value ChartThemeBlueIcy | |
40 | \value ChartThemeCount Not really a theme; the total count of themes. |
|
|||
41 | */ |
|
40 | */ | |
42 |
|
41 | |||
43 | /*! |
|
42 | /*! | |
44 | \enum QChart::AnimationOption |
|
43 | \enum QChart::AnimationOption | |
45 |
|
44 | |||
46 | For enabling/disabling animations. Defaults to NoAnimation. |
|
45 | For enabling/disabling animations. Defaults to NoAnimation. | |
47 |
|
46 | |||
48 | \value NoAnimation |
|
47 | \value NoAnimation | |
49 | \value GridAxisAnimations |
|
48 | \value GridAxisAnimations | |
50 | \value SeriesAnimations |
|
49 | \value SeriesAnimations | |
51 | \value AllAnimations |
|
50 | \value AllAnimations | |
52 | */ |
|
51 | */ | |
53 |
|
52 | |||
54 | /*! |
|
53 | /*! | |
55 | \class QChart |
|
54 | \class QChart | |
56 | \brief QtCommercial chart API. |
|
55 | \brief QtCommercial chart API. | |
57 |
|
56 | |||
58 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
57 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
59 | representation of different types of QChartSeries and other chart related objects like |
|
58 | representation of different types of QChartSeries and other chart related objects like | |
60 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the |
|
59 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the | |
61 | convenience class QChartView instead of QChart. |
|
60 | convenience class QChartView instead of QChart. | |
62 | \sa QChartView |
|
61 | \sa QChartView | |
63 | */ |
|
62 | */ | |
64 |
|
63 | |||
65 | /*! |
|
64 | /*! | |
66 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
65 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
67 | */ |
|
66 | */ | |
68 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
67 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
69 | d_ptr(new QChartPrivate()) |
|
68 | d_ptr(new QChartPrivate()) | |
70 | { |
|
69 | { | |
71 | d_ptr->m_legend = new ScrolledQLegend(this); |
|
70 | d_ptr->m_legend = new ScrolledQLegend(this); | |
72 | d_ptr->m_legend->setVisible(false); |
|
71 | d_ptr->m_legend->setVisible(false); | |
73 | d_ptr->m_dataset = new ChartDataSet(this); |
|
72 | d_ptr->m_dataset = new ChartDataSet(this); | |
74 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
75 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
74 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
76 | d_ptr->createConnections(); |
|
75 | d_ptr->createConnections(); | |
77 | //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3); |
|
76 | //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3); | |
78 | } |
|
77 | } | |
79 |
|
78 | |||
80 | /*! |
|
79 | /*! | |
81 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. |
|
80 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. | |
82 | */ |
|
81 | */ | |
83 | QChart::~QChart() |
|
82 | QChart::~QChart() | |
84 | { |
|
83 | { | |
85 | //delete first presenter , since this is a root of all the graphical items |
|
84 | //delete first presenter , since this is a root of all the graphical items | |
86 | delete d_ptr->m_presenter; |
|
85 | delete d_ptr->m_presenter; | |
87 | d_ptr->m_presenter=0; |
|
86 | d_ptr->m_presenter=0; | |
88 | } |
|
87 | } | |
89 |
|
88 | |||
90 | /*! |
|
89 | /*! | |
91 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. |
|
90 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. | |
92 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
91 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
93 | the y axis). |
|
92 | the y axis). | |
94 | */ |
|
93 | */ | |
95 | void QChart::addSeries(QSeries* series, QChartAxis* axisY) |
|
94 | void QChart::addSeries(QSeries* series, QChartAxis* axisY) | |
96 | { |
|
95 | { | |
97 | Q_ASSERT(series); |
|
96 | Q_ASSERT(series); | |
98 | d_ptr->m_dataset->addSeries(series, axisY); |
|
97 | d_ptr->m_dataset->addSeries(series, axisY); | |
99 | } |
|
98 | } | |
100 |
|
99 | |||
101 | /*! |
|
100 | /*! | |
102 | Removes the \a series specified in a perameter from the QChartView. |
|
101 | Removes the \a series specified in a perameter from the QChartView. | |
103 | It releses its ownership of the specified QChartSeries object. |
|
102 | It releses its ownership of the specified QChartSeries object. | |
104 | It does not delete the pointed QChartSeries data object |
|
103 | It does not delete the pointed QChartSeries data object | |
105 | \sa addSeries(), removeAllSeries() |
|
104 | \sa addSeries(), removeAllSeries() | |
106 | */ |
|
105 | */ | |
107 | void QChart::removeSeries(QSeries* series) |
|
106 | void QChart::removeSeries(QSeries* series) | |
108 | { |
|
107 | { | |
109 | Q_ASSERT(series); |
|
108 | Q_ASSERT(series); | |
110 | d_ptr->m_dataset->removeSeries(series); |
|
109 | d_ptr->m_dataset->removeSeries(series); | |
111 | } |
|
110 | } | |
112 |
|
111 | |||
113 | /*! |
|
112 | /*! | |
114 | Removes all the QChartSeries that have been added to the QChartView |
|
113 | Removes all the QChartSeries that have been added to the QChartView | |
115 | It also deletes the pointed QChartSeries data objects |
|
114 | It also deletes the pointed QChartSeries data objects | |
116 | \sa addSeries(), removeSeries() |
|
115 | \sa addSeries(), removeSeries() | |
117 | */ |
|
116 | */ | |
118 | void QChart::removeAllSeries() |
|
117 | void QChart::removeAllSeries() | |
119 | { |
|
118 | { | |
120 | d_ptr->m_dataset->removeAllSeries(); |
|
119 | d_ptr->m_dataset->removeAllSeries(); | |
121 | } |
|
120 | } | |
122 |
|
121 | |||
123 | /*! |
|
122 | /*! | |
124 | Sets the \a brush that is used for painting the background of the chart area. |
|
123 | Sets the \a brush that is used for painting the background of the chart area. | |
125 | */ |
|
124 | */ | |
126 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
125 | void QChart::setBackgroundBrush(const QBrush& brush) | |
127 | { |
|
126 | { | |
128 | //TODO: refactor me |
|
127 | //TODO: refactor me | |
129 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
128 | d_ptr->m_presenter->createChartBackgroundItem(); | |
130 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); |
|
129 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); | |
131 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
130 | d_ptr->m_presenter->m_backgroundItem->update(); | |
132 | } |
|
131 | } | |
133 |
|
132 | |||
134 | /*! |
|
133 | /*! | |
135 | Gets the brush that is used for painting the background of the chart area. |
|
134 | Gets the brush that is used for painting the background of the chart area. | |
136 | */ |
|
135 | */ | |
137 | QBrush QChart::backgroundBrush() const |
|
136 | QBrush QChart::backgroundBrush() const | |
138 | { |
|
137 | { | |
139 | //TODO: refactor me |
|
138 | //TODO: refactor me | |
140 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); |
|
139 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); | |
141 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); |
|
140 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); | |
142 | } |
|
141 | } | |
143 |
|
142 | |||
144 | /*! |
|
143 | /*! | |
145 | Sets the \a pen that is used for painting the background of the chart area. |
|
144 | Sets the \a pen that is used for painting the background of the chart area. | |
146 | */ |
|
145 | */ | |
147 | void QChart::setBackgroundPen(const QPen& pen) |
|
146 | void QChart::setBackgroundPen(const QPen& pen) | |
148 | { |
|
147 | { | |
149 | //TODO: refactor me |
|
148 | //TODO: refactor me | |
150 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
149 | d_ptr->m_presenter->createChartBackgroundItem(); | |
151 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); |
|
150 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); | |
152 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
151 | d_ptr->m_presenter->m_backgroundItem->update(); | |
153 | } |
|
152 | } | |
154 |
|
153 | |||
155 | /*! |
|
154 | /*! | |
156 | Gets the pen that is used for painting the background of the chart area. |
|
155 | Gets the pen that is used for painting the background of the chart area. | |
157 | */ |
|
156 | */ | |
158 | QPen QChart::backgroundPen() const |
|
157 | QPen QChart::backgroundPen() const | |
159 | { |
|
158 | { | |
160 | //TODO: refactor me |
|
159 | //TODO: refactor me | |
161 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); |
|
160 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); | |
162 | return d_ptr->m_presenter->m_backgroundItem->pen(); |
|
161 | return d_ptr->m_presenter->m_backgroundItem->pen(); | |
163 | } |
|
162 | } | |
164 |
|
163 | |||
165 | /*! |
|
164 | /*! | |
166 | Sets the chart \a title. The description text that is drawn above the chart. |
|
165 | Sets the chart \a title. The description text that is drawn above the chart. | |
167 | */ |
|
166 | */ | |
168 | void QChart::setTitle(const QString& title) |
|
167 | void QChart::setTitle(const QString& title) | |
169 | { |
|
168 | { | |
170 | //TODO: refactor me |
|
169 | //TODO: refactor me | |
171 | d_ptr->m_presenter->createChartTitleItem(); |
|
170 | d_ptr->m_presenter->createChartTitleItem(); | |
172 | d_ptr->m_presenter->m_titleItem->setText(title); |
|
171 | d_ptr->m_presenter->m_titleItem->setText(title); | |
173 | d_ptr->m_presenter->updateLayout(); |
|
172 | d_ptr->m_presenter->updateLayout(); | |
174 | } |
|
173 | } | |
175 |
|
174 | |||
176 | /*! |
|
175 | /*! | |
177 | Returns the chart title. The description text that is drawn above the chart. |
|
176 | Returns the chart title. The description text that is drawn above the chart. | |
178 | */ |
|
177 | */ | |
179 | QString QChart::title() const |
|
178 | QString QChart::title() const | |
180 | { |
|
179 | { | |
181 | //TODO: refactor me |
|
180 | //TODO: refactor me | |
182 | if (d_ptr->m_presenter->m_titleItem) |
|
181 | if (d_ptr->m_presenter->m_titleItem) | |
183 | return d_ptr->m_presenter->m_titleItem->text(); |
|
182 | return d_ptr->m_presenter->m_titleItem->text(); | |
184 | else |
|
183 | else | |
185 | return QString(); |
|
184 | return QString(); | |
186 | } |
|
185 | } | |
187 |
|
186 | |||
188 | /*! |
|
187 | /*! | |
189 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
188 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
190 | */ |
|
189 | */ | |
191 | void QChart::setTitleFont(const QFont& font) |
|
190 | void QChart::setTitleFont(const QFont& font) | |
192 | { |
|
191 | { | |
193 | //TODO: refactor me |
|
192 | //TODO: refactor me | |
194 | d_ptr->m_presenter->createChartTitleItem(); |
|
193 | d_ptr->m_presenter->createChartTitleItem(); | |
195 | d_ptr->m_presenter->m_titleItem->setFont(font); |
|
194 | d_ptr->m_presenter->m_titleItem->setFont(font); | |
196 | d_ptr->m_presenter->updateLayout(); |
|
195 | d_ptr->m_presenter->updateLayout(); | |
197 | } |
|
196 | } | |
198 |
|
197 | |||
199 | /*! |
|
198 | /*! | |
200 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
199 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
201 | */ |
|
200 | */ | |
202 | QFont QChart::titleFont() const |
|
201 | QFont QChart::titleFont() const | |
203 | { |
|
202 | { | |
204 | if (d_ptr->m_presenter->m_titleItem) |
|
203 | if (d_ptr->m_presenter->m_titleItem) | |
205 | return d_ptr->m_presenter->m_titleItem->font(); |
|
204 | return d_ptr->m_presenter->m_titleItem->font(); | |
206 | else |
|
205 | else | |
207 | return QFont(); |
|
206 | return QFont(); | |
208 | } |
|
207 | } | |
209 |
|
208 | |||
210 | /*! |
|
209 | /*! | |
211 | Sets the \a brush used for rendering the title text. |
|
210 | Sets the \a brush used for rendering the title text. | |
212 | */ |
|
211 | */ | |
213 | void QChart::setTitleBrush(const QBrush &brush) |
|
212 | void QChart::setTitleBrush(const QBrush &brush) | |
214 | { |
|
213 | { | |
215 | //TODO: refactor me |
|
214 | //TODO: refactor me | |
216 | d_ptr->m_presenter->createChartTitleItem(); |
|
215 | d_ptr->m_presenter->createChartTitleItem(); | |
217 | d_ptr->m_presenter->m_titleItem->setBrush(brush); |
|
216 | d_ptr->m_presenter->m_titleItem->setBrush(brush); | |
218 | d_ptr->m_presenter->updateLayout(); |
|
217 | d_ptr->m_presenter->updateLayout(); | |
219 | } |
|
218 | } | |
220 |
|
219 | |||
221 | /*! |
|
220 | /*! | |
222 | Returns the brush used for rendering the title text. |
|
221 | Returns the brush used for rendering the title text. | |
223 | */ |
|
222 | */ | |
224 | QBrush QChart::titleBrush() const |
|
223 | QBrush QChart::titleBrush() const | |
225 | { |
|
224 | { | |
226 | //TODO: refactor me |
|
225 | //TODO: refactor me | |
227 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); |
|
226 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); | |
228 | return d_ptr->m_presenter->m_titleItem->brush(); |
|
227 | return d_ptr->m_presenter->m_titleItem->brush(); | |
229 | } |
|
228 | } | |
230 |
|
229 | |||
231 | /*! |
|
230 | /*! | |
232 | Sets the \a theme used by the chart for rendering the graphical representation of the data |
|
231 | Sets the \a theme used by the chart for rendering the graphical representation of the data | |
233 | \sa theme() |
|
232 | \sa theme() | |
234 | */ |
|
233 | */ | |
235 | void QChart::setTheme(QChart::ChartTheme theme) |
|
234 | void QChart::setTheme(QChart::ChartTheme theme) | |
236 | { |
|
235 | { | |
237 | d_ptr->m_presenter->setTheme(theme); |
|
236 | d_ptr->m_presenter->setTheme(theme); | |
238 | } |
|
237 | } | |
239 |
|
238 | |||
240 | /*! |
|
239 | /*! | |
241 | Returns the theme enum used by the chart. |
|
240 | Returns the theme enum used by the chart. | |
242 | \sa ChartTheme, setTheme() |
|
241 | \sa ChartTheme, setTheme() | |
243 | */ |
|
242 | */ | |
244 | QChart::ChartTheme QChart::theme() const |
|
243 | QChart::ChartTheme QChart::theme() const | |
245 | { |
|
244 | { | |
246 | return d_ptr->m_presenter->theme(); |
|
245 | return d_ptr->m_presenter->theme(); | |
247 | } |
|
246 | } | |
248 |
|
247 | |||
249 | /*! |
|
248 | /*! | |
250 | Zooms in the view by a factor of 2 |
|
249 | Zooms in the view by a factor of 2 | |
251 | */ |
|
250 | */ | |
252 | void QChart::zoomIn() |
|
251 | void QChart::zoomIn() | |
253 | { |
|
252 | { | |
254 | d_ptr->m_presenter->zoomIn(); |
|
253 | d_ptr->m_presenter->zoomIn(); | |
255 | } |
|
254 | } | |
256 |
|
255 | |||
257 | /*! |
|
256 | /*! | |
258 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
257 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
259 | */ |
|
258 | */ | |
260 | void QChart::zoomIn(const QRectF& rect) |
|
259 | void QChart::zoomIn(const QRectF& rect) | |
261 | { |
|
260 | { | |
262 | if (!rect.isValid()) return; |
|
261 | if (!rect.isValid()) return; | |
263 | d_ptr->m_presenter->zoomIn(rect); |
|
262 | d_ptr->m_presenter->zoomIn(rect); | |
264 | } |
|
263 | } | |
265 |
|
264 | |||
266 | /*! |
|
265 | /*! | |
267 | Restores the view zoom level to the previous one. |
|
266 | Restores the view zoom level to the previous one. | |
268 | */ |
|
267 | */ | |
269 | void QChart::zoomOut() |
|
268 | void QChart::zoomOut() | |
270 | { |
|
269 | { | |
271 | d_ptr->m_presenter->zoomOut(); |
|
270 | d_ptr->m_presenter->zoomOut(); | |
272 | } |
|
271 | } | |
273 |
|
272 | |||
274 | /*! |
|
273 | /*! | |
275 | Returns the pointer to the x axis object of the chart |
|
274 | Returns the pointer to the x axis object of the chart | |
276 | */ |
|
275 | */ | |
277 | QChartAxis* QChart::axisX() const |
|
276 | QChartAxis* QChart::axisX() const | |
278 | { |
|
277 | { | |
279 | return d_ptr->m_dataset->axisX(); |
|
278 | return d_ptr->m_dataset->axisX(); | |
280 | } |
|
279 | } | |
281 |
|
280 | |||
282 | /*! |
|
281 | /*! | |
283 | Returns the pointer to the y axis object of the \a series |
|
282 | Returns the pointer to the y axis object of the \a series | |
284 | If no \a series is provided then default Y axis of the chart is returned. |
|
283 | If no \a series is provided then default Y axis of the chart is returned. | |
285 | */ |
|
284 | */ | |
286 | QChartAxis* QChart::axisY(QSeries* series) const |
|
285 | QChartAxis* QChart::axisY(QSeries* series) const | |
287 | { |
|
286 | { | |
288 | return d_ptr->m_dataset->axisY(series); |
|
287 | return d_ptr->m_dataset->axisY(series); | |
289 | } |
|
288 | } | |
290 |
|
289 | |||
291 | /*! |
|
290 | /*! | |
292 | Returns the legend object of the chart. Ownership stays in chart. |
|
291 | Returns the legend object of the chart. Ownership stays in chart. | |
293 | */ |
|
292 | */ | |
294 | QLegend* QChart::legend() const |
|
293 | QLegend* QChart::legend() const | |
295 | { |
|
294 | { | |
296 | return d_ptr->m_legend; |
|
295 | return d_ptr->m_legend; | |
297 | } |
|
296 | } | |
298 |
|
297 | |||
299 | /*! |
|
298 | /*! | |
300 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
299 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
301 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
300 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
302 | */ |
|
301 | */ | |
303 | QRectF QChart::margins() const |
|
302 | QRectF QChart::margins() const | |
304 | { |
|
303 | { | |
305 | return d_ptr->m_presenter->margins(); |
|
304 | return d_ptr->m_presenter->margins(); | |
306 | } |
|
305 | } | |
307 |
|
306 | |||
308 |
|
307 | |||
309 | /*! |
|
308 | /*! | |
310 | Resizes and updates the chart area using the \a event data |
|
309 | Resizes and updates the chart area using the \a event data | |
311 | */ |
|
310 | */ | |
312 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
311 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) | |
313 | { |
|
312 | { | |
314 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); |
|
313 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); | |
315 | QGraphicsWidget::resizeEvent(event); |
|
314 | QGraphicsWidget::resizeEvent(event); | |
316 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); |
|
315 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); | |
317 | } |
|
316 | } | |
318 |
|
317 | |||
319 | /*! |
|
318 | /*! | |
320 | Sets animation \a options for the chart |
|
319 | Sets animation \a options for the chart | |
321 | */ |
|
320 | */ | |
322 | void QChart::setAnimationOptions(AnimationOptions options) |
|
321 | void QChart::setAnimationOptions(AnimationOptions options) | |
323 | { |
|
322 | { | |
324 | d_ptr->m_presenter->setAnimationOptions(options); |
|
323 | d_ptr->m_presenter->setAnimationOptions(options); | |
325 | } |
|
324 | } | |
326 |
|
325 | |||
327 | /*! |
|
326 | /*! | |
328 | Returns animation options for the chart |
|
327 | Returns animation options for the chart | |
329 | */ |
|
328 | */ | |
330 | QChart::AnimationOptions QChart::animationOptions() const |
|
329 | QChart::AnimationOptions QChart::animationOptions() const | |
331 | { |
|
330 | { | |
332 | return d_ptr->m_presenter->animationOptions(); |
|
331 | return d_ptr->m_presenter->animationOptions(); | |
333 | } |
|
332 | } | |
334 |
|
333 | |||
335 | /*! |
|
334 | /*! | |
336 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks |
|
335 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks | |
337 | */ |
|
336 | */ | |
338 | void QChart::scrollLeft() |
|
337 | void QChart::scrollLeft() | |
339 | { |
|
338 | { | |
340 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
339 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
341 | } |
|
340 | } | |
342 |
|
341 | |||
343 | /*! |
|
342 | /*! | |
344 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks |
|
343 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks | |
345 | */ |
|
344 | */ | |
346 | void QChart::scrollRight() |
|
345 | void QChart::scrollRight() | |
347 | { |
|
346 | { | |
348 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
347 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
349 | } |
|
348 | } | |
350 |
|
349 | |||
351 | /*! |
|
350 | /*! | |
352 | Scrolls the visible area of the chart up by the distance between two y axis ticks |
|
351 | Scrolls the visible area of the chart up by the distance between two y axis ticks | |
353 | */ |
|
352 | */ | |
354 | void QChart::scrollUp() |
|
353 | void QChart::scrollUp() | |
355 | { |
|
354 | { | |
356 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
355 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
357 | } |
|
356 | } | |
358 |
|
357 | |||
359 | /*! |
|
358 | /*! | |
360 | Scrolls the visible area of the chart down by the distance between two y axis ticks |
|
359 | Scrolls the visible area of the chart down by the distance between two y axis ticks | |
361 | */ |
|
360 | */ | |
362 | void QChart::scrollDown() |
|
361 | void QChart::scrollDown() | |
363 | { |
|
362 | { | |
364 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
363 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
365 | } |
|
364 | } | |
366 |
|
365 | |||
367 | /*! |
|
366 | /*! | |
368 | Sets the chart background visibility state to \a visible |
|
367 | Sets the chart background visibility state to \a visible | |
369 | */ |
|
368 | */ | |
370 | void QChart::setBackgroundVisible(bool visible) |
|
369 | void QChart::setBackgroundVisible(bool visible) | |
371 | { |
|
370 | { | |
372 | //TODO: refactor me |
|
371 | //TODO: refactor me | |
373 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
372 | d_ptr->m_presenter->createChartBackgroundItem(); | |
374 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); |
|
373 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); | |
375 | } |
|
374 | } | |
376 |
|
375 | |||
377 | /*! |
|
376 | /*! | |
378 | Returns the chart's background visibility state |
|
377 | Returns the chart's background visibility state | |
379 | */ |
|
378 | */ | |
380 | bool QChart::isBackgroundVisible() const |
|
379 | bool QChart::isBackgroundVisible() const | |
381 | { |
|
380 | { | |
382 | //TODO: refactor me |
|
381 | //TODO: refactor me | |
383 | if (!d_ptr->m_presenter->m_backgroundItem) return false; |
|
382 | if (!d_ptr->m_presenter->m_backgroundItem) return false; | |
384 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); |
|
383 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); | |
385 | } |
|
384 | } | |
386 |
|
385 | |||
387 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
386 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
388 |
|
387 | |||
389 | QChartPrivate::QChartPrivate(): |
|
388 | QChartPrivate::QChartPrivate(): | |
390 | m_legend(0), |
|
389 | m_legend(0), | |
391 | m_dataset(0), |
|
390 | m_dataset(0), | |
392 | m_presenter(0) |
|
391 | m_presenter(0) | |
393 | { |
|
392 | { | |
394 |
|
393 | |||
395 | } |
|
394 | } | |
396 |
|
395 | |||
397 | QChartPrivate::~QChartPrivate() |
|
396 | QChartPrivate::~QChartPrivate() | |
398 | { |
|
397 | { | |
399 |
|
398 | |||
400 | } |
|
399 | } | |
401 |
|
400 | |||
402 | void QChartPrivate::createConnections() |
|
401 | void QChartPrivate::createConnections() | |
403 | { |
|
402 | { | |
404 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
403 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
405 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*))); |
|
404 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*))); | |
406 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
405 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
407 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); |
|
406 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); | |
408 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); |
|
407 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | |
409 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); |
|
408 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); | |
410 | } |
|
409 | } | |
411 |
|
410 | |||
412 | #include "moc_qchart.cpp" |
|
411 | #include "moc_qchart.cpp" | |
413 |
|
412 | |||
414 | QTCOMMERCIALCHART_END_NAMESPACE |
|
413 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now