@@ -1,871 +1,1005 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qabstractaxis.h" |
|
22 | 22 | #include "qabstractaxis_p.h" |
|
23 | 23 | #include "chartdataset_p.h" |
|
24 | 24 | #include "charttheme_p.h" |
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | /*! |
|
29 | 29 | \class QAbstractAxis |
|
30 | 30 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
31 | 31 | \mainclass |
|
32 | 32 | |
|
33 | 33 | There is only one x Axis visible at the time, however there can be multiple y axes. |
|
34 | 34 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
35 | 35 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
36 | 36 | */ |
|
37 | 37 | |
|
38 | 38 | /*! |
|
39 | 39 | \qmlclass AbstractAxis QAbstractAxis |
|
40 | 40 | \brief The Axis element is used for manipulating chart's axes |
|
41 | 41 | |
|
42 | 42 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. |
|
43 | 43 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
44 | 44 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
45 | 45 | |
|
46 | 46 | To access Axes you can use ChartView API. For example: |
|
47 | 47 | \code |
|
48 | 48 | ChartView { |
|
49 | 49 | axisX.min: 0 |
|
50 | 50 | axisX.max: 3 |
|
51 | 51 | axisX.ticksCount: 4 |
|
52 | 52 | axisY.min: 0 |
|
53 | 53 | axisY.max: 4 |
|
54 | 54 | // Add a few series... |
|
55 | 55 | } |
|
56 | 56 | \endcode |
|
57 | 57 | */ |
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \enum QAbstractAxis::AxisType |
|
61 | 61 | |
|
62 | 62 | The type of the series object. |
|
63 | 63 | |
|
64 | 64 | \value AxisTypeNoAxis |
|
65 | 65 | \value AxisTypeValue |
|
66 | 66 | \value AxisTypeBarCategory |
|
67 | 67 | \value AxisTypeCategory |
|
68 | 68 | \value AxisTypeDateTime |
|
69 | 69 | \value AxisTypeLogValue |
|
70 | 70 | */ |
|
71 | 71 | |
|
72 | 72 | /*! |
|
73 | 73 | *\fn void QAbstractAxis::type() const |
|
74 | 74 | Returns the type of the axis |
|
75 | 75 | */ |
|
76 | 76 | |
|
77 | 77 | /*! |
|
78 | 78 | \property QAbstractAxis::lineVisible |
|
79 | 79 | The visibility of the axis line |
|
80 | 80 | */ |
|
81 | 81 | /*! |
|
82 | 82 | \qmlproperty bool AbstractAxis::lineVisible |
|
83 | 83 | The visibility of the axis line |
|
84 | 84 | */ |
|
85 | 85 | |
|
86 | 86 | /*! |
|
87 | \property QAbstractAxis::linePen | |
|
88 | The pen of the line. | |
|
89 | */ | |
|
90 | ||
|
91 | /*! | |
|
87 | 92 | \property QAbstractAxis::labelsVisible |
|
88 | 93 | Defines if axis labels are visible. |
|
89 | 94 | */ |
|
90 | 95 | /*! |
|
91 | 96 | \qmlproperty bool AbstractAxis::labelsVisible |
|
92 | 97 | Defines if axis labels are visible. |
|
93 | 98 | */ |
|
94 | 99 | |
|
95 | 100 | /*! |
|
101 | \property QAbstractAxis::labelsPen | |
|
102 | The pen of the labels. | |
|
103 | */ | |
|
104 | ||
|
105 | /*! | |
|
106 | \property QAbstractAxis::labelsBrush | |
|
107 | The brush of the labels. | |
|
108 | */ | |
|
109 | ||
|
110 | /*! | |
|
96 | 111 | \property QAbstractAxis::visible |
|
97 | 112 | The visibility of the axis. |
|
98 | 113 | */ |
|
99 | 114 | /*! |
|
100 | 115 | \qmlproperty bool AbstractAxis::visible |
|
101 | 116 | The visibility of the axis. |
|
102 | 117 | */ |
|
103 | 118 | |
|
104 | 119 | /*! |
|
105 | 120 | \property QAbstractAxis::gridVisible |
|
106 | 121 | The visibility of the grid lines. |
|
107 | 122 | */ |
|
108 | 123 | /*! |
|
109 | 124 | \qmlproperty bool AbstractAxis::gridVisible |
|
110 | 125 | The visibility of the grid lines. |
|
111 | 126 | */ |
|
112 | 127 | |
|
113 | 128 | /*! |
|
114 | 129 | \property QAbstractAxis::color |
|
115 | 130 | The color of the axis and ticks. |
|
116 | 131 | */ |
|
117 | 132 | /*! |
|
118 | 133 | \qmlproperty color AbstractAxis::color |
|
119 | 134 | The color of the axis and ticks. |
|
120 | 135 | */ |
|
121 | 136 | |
|
122 | 137 | /*! |
|
138 | \property QAbstractAxis::gridLinePen | |
|
139 | The pen of the grid line. | |
|
140 | */ | |
|
141 | ||
|
142 | /*! | |
|
123 | 143 | \property QAbstractAxis::labelsFont |
|
124 | 144 | The font of the axis labels. |
|
125 | 145 | */ |
|
126 | 146 | |
|
127 | 147 | /*! |
|
128 | 148 | \qmlproperty Font AbstractAxis::labelsFont |
|
129 | 149 | The font of the axis labels. |
|
130 | 150 | |
|
131 | 151 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
132 | 152 | */ |
|
133 | 153 | |
|
134 | 154 | /*! |
|
135 | 155 | \property QAbstractAxis::labelsColor |
|
136 | 156 | The color of the axis labels. |
|
137 | 157 | */ |
|
138 | 158 | /*! |
|
139 | 159 | \qmlproperty color AbstractAxis::labelsColor |
|
140 | 160 | The color of the axis labels. |
|
141 | 161 | */ |
|
142 | 162 | |
|
143 | 163 | /*! |
|
144 | 164 | \property QAbstractAxis::labelsAngle |
|
145 | 165 | The angle of the axis labels in degrees. |
|
146 | 166 | */ |
|
147 | 167 | /*! |
|
148 | 168 | \qmlproperty int AbstractAxis::labelsAngle |
|
149 | 169 | The angle of the axis labels in degrees. |
|
150 | 170 | */ |
|
151 | 171 | |
|
152 | 172 | /*! |
|
153 | 173 | \property QAbstractAxis::shadesVisible |
|
154 | 174 | The visibility of the axis shades. |
|
155 | 175 | */ |
|
156 | 176 | /*! |
|
157 | 177 | \qmlproperty bool AbstractAxis::shadesVisible |
|
158 | 178 | The visibility of the axis shades. |
|
159 | 179 | */ |
|
160 | 180 | |
|
161 | 181 | /*! |
|
162 | 182 | \property QAbstractAxis::shadesColor |
|
163 | 183 | The fill (brush) color of the axis shades. |
|
164 | 184 | */ |
|
165 | 185 | /*! |
|
166 | 186 | \qmlproperty color AbstractAxis::shadesColor |
|
167 | 187 | The fill (brush) color of the axis shades. |
|
168 | 188 | */ |
|
169 | 189 | |
|
170 | 190 | /*! |
|
171 | 191 | \property QAbstractAxis::shadesBorderColor |
|
172 | 192 | The border (pen) color of the axis shades. |
|
173 | 193 | */ |
|
174 | 194 | /*! |
|
175 | 195 | \qmlproperty color AbstractAxis::shadesBorderColor |
|
176 | 196 | The border (pen) color of the axis shades. |
|
177 | 197 | */ |
|
178 | 198 | |
|
179 | 199 | /*! |
|
200 | \property QAbstractAxis::shadesPen | |
|
201 | The pen of the axis shades (area between grid lines). | |
|
202 | */ | |
|
203 | ||
|
204 | /*! | |
|
205 | \property QAbstractAxis::shadesBrush | |
|
206 | The brush of the axis shades (area between grid lines). | |
|
207 | */ | |
|
208 | ||
|
209 | /*! | |
|
180 | 210 | \property QAbstractAxis::titleVisible |
|
181 | 211 | The visibility of the axis title. By default the value is true. |
|
182 | 212 | */ |
|
183 | 213 | /*! |
|
184 | 214 | \qmlproperty bool AbstractAxis::titleVisible |
|
185 | 215 | The visibility of the axis title. By default the value is true. |
|
186 | 216 | */ |
|
187 | 217 | |
|
188 | 218 | /*! |
|
219 | \property QAbstractAxis::titleText | |
|
220 | The title of the axis. Empty by default. | |
|
221 | */ | |
|
222 | /*! | |
|
223 | \qmlproperty String AbstractAxis::titleText | |
|
224 | The title of the axis. Empty by default. | |
|
225 | */ | |
|
226 | ||
|
227 | /*! | |
|
228 | \property QAbstractAxis::titlePen | |
|
229 | The pen of the title text. | |
|
230 | */ | |
|
231 | ||
|
232 | /*! | |
|
233 | \property QAbstractAxis::titleBrush | |
|
234 | The brush of the title text. | |
|
235 | */ | |
|
236 | ||
|
237 | /*! | |
|
189 | 238 | \property QAbstractAxis::titleFont |
|
190 | 239 | The font of the title of the axis. |
|
191 | 240 | */ |
|
192 | 241 | /*! |
|
193 | \qmlproperty Font AbstractAxis::title | |
|
242 | \qmlproperty Font AbstractAxis::titleFont | |
|
194 | 243 | The font of the title of the axis. |
|
195 | 244 | */ |
|
196 | 245 | |
|
197 | 246 | /*! |
|
198 |
\property QAbstractAxis:: |
|
|
199 | The title of the axis. Empty by default. | |
|
247 | \property QAbstractAxis::orientation | |
|
248 | The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart. | |
|
200 | 249 | */ |
|
201 | 250 | /*! |
|
202 |
\qmlproperty |
|
|
203 | The title of the axis. Empty string by default. | |
|
251 | \qmlproperty Qt.Orientation AbstractAxis::orientation | |
|
252 | The orientation of the axis. Fixed to either Qt.Horizontal or Qt.Vertical when the axis is set to a Chart/Series. | |
|
204 | 253 | */ |
|
205 | 254 | |
|
206 | 255 | /*! |
|
207 | 256 | \property QAbstractAxis::alignment |
|
208 | 257 | The alignment of the axis. Either Qt::AlignLeft or Qt::AlignBottom. |
|
209 | 258 | */ |
|
210 | 259 | /*! |
|
211 | 260 | \qmlproperty alignment AbstractAxis::alignment |
|
212 | 261 | The alignment of the axis. Either Qt.AlignLeft or Qt.AlignBottom. |
|
213 | 262 | */ |
|
214 | 263 | |
|
215 | 264 | /*! |
|
216 | 265 | \fn void QAbstractAxis::visibleChanged(bool visible) |
|
217 | 266 | Visibility of the axis has changed to \a visible. |
|
218 | 267 | */ |
|
219 | 268 | /*! |
|
220 | 269 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) |
|
221 | 270 | Visibility of the axis has changed to \a visible. |
|
222 | 271 | */ |
|
223 | 272 | |
|
224 | 273 | /*! |
|
274 | \fn void QAbstractAxis::linePenChanged(const QPen& pen) | |
|
275 | The pen of the line of the axis has changed to \a pen. | |
|
276 | */ | |
|
277 | ||
|
278 | /*! | |
|
225 | 279 | \fn void QAbstractAxis::lineVisibleChanged(bool visible) |
|
226 | 280 | Visibility of the axis line has changed to \a visible. |
|
227 | 281 | */ |
|
228 | 282 | /*! |
|
229 | 283 | \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible) |
|
230 | 284 | Visibility of the axis line has changed to \a visible. |
|
231 | 285 | */ |
|
232 | 286 | |
|
233 | 287 | /*! |
|
234 | 288 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) |
|
235 | 289 | Visibility of the labels of the axis has changed to \a visible. |
|
236 | 290 | */ |
|
237 | 291 | /*! |
|
238 | 292 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) |
|
239 | 293 | Visibility of the labels of the axis has changed to \a visible. |
|
240 | 294 | */ |
|
241 | 295 | |
|
242 | 296 | /*! |
|
297 | \fn void QAbstractAxis::labelsFontChanged(const QFont& font) | |
|
298 | The font of the axis labels has changed to \a font. | |
|
299 | */ | |
|
300 | /*! | |
|
301 | \qmlsignal AbstractAxis::onLabelsFontChanged(Font font) | |
|
302 | The font of the axis labels has changed to \a font. | |
|
303 | */ | |
|
304 | ||
|
305 | /*! | |
|
306 | \fn void QAbstractAxis::labelsPenChanged(const QPen& pen) | |
|
307 | The pen of the axis labels has changed to \a pen. | |
|
308 | */ | |
|
309 | ||
|
310 | /*! | |
|
311 | \fn void QAbstractAxis::labelsBrushChanged(const QBrush& brush) | |
|
312 | The brush of the axis labels has changed to \a brush. | |
|
313 | */ | |
|
314 | ||
|
315 | /*! | |
|
316 | \fn void QAbstractAxis::labelsAngleChanged(int angle) | |
|
317 | The angle of the axis labels has changed to \a angle. | |
|
318 | */ | |
|
319 | /*! | |
|
320 | \qmlsignal AbstractAxis::onLabelsAngleChanged(int angle) | |
|
321 | The angle of the axis labels has changed to \a angle. | |
|
322 | */ | |
|
323 | ||
|
324 | /*! | |
|
243 | 325 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) |
|
244 | 326 | Visibility of the grid lines of the axis has changed to \a visible. |
|
245 | 327 | */ |
|
246 | 328 | /*! |
|
247 | 329 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) |
|
248 | 330 | Visibility of the grid lines of the axis has changed to \a visible. |
|
249 | 331 | */ |
|
250 | 332 | |
|
251 | 333 | /*! |
|
334 | \fn void QAbstractAxis::gridLinePenChanged(const QPen& pen) | |
|
335 | The pen of the grid line has changed to \a pen. | |
|
336 | */ | |
|
337 | ||
|
338 | /*! | |
|
252 | 339 | \fn void QAbstractAxis::colorChanged(QColor color) |
|
253 | 340 | Emitted if the \a color of the axis is changed. |
|
254 | 341 | */ |
|
255 | 342 | /*! |
|
256 | 343 | \qmlsignal AbstractAxis::onColorChanged(QColor color) |
|
257 | 344 | Emitted if the \a color of the axis is changed. |
|
258 | 345 | */ |
|
259 | 346 | |
|
260 | 347 | /*! |
|
261 | 348 | \fn void QAbstractAxis::labelsColorChanged(QColor color) |
|
262 | 349 | Emitted if the \a color of the axis labels is changed. |
|
263 | 350 | */ |
|
264 | 351 | /*! |
|
265 | 352 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) |
|
266 | 353 | Emitted if the \a color of the axis labels is changed. |
|
267 | 354 | */ |
|
268 | 355 | |
|
269 | 356 | /*! |
|
357 | \fn void QAbstractAxis::titleVisibleChanged(bool visible) | |
|
358 | Visibility of the title text of the axis has changed to \a visible. | |
|
359 | */ | |
|
360 | /*! | |
|
361 | \qmlsignal AbstractAxis::onTitleVisibleChanged(bool visible) | |
|
362 | Visibility of the title text of the axis has changed to \a visible. | |
|
363 | */ | |
|
364 | ||
|
365 | /*! | |
|
366 | \fn void QAbstractAxis::titleTextChanged(const QString& text) | |
|
367 | The text of the axis title has changed to \a text. | |
|
368 | */ | |
|
369 | /*! | |
|
370 | \qmlsignal AbstractAxis::onTitleTextChanged(String text) | |
|
371 | The text of the axis title has changed to \a text. | |
|
372 | */ | |
|
373 | ||
|
374 | /*! | |
|
375 | \fn void QAbstractAxis::titlePenChanged(const QPen& pen) | |
|
376 | The pen of the axis shades has changed to \a pen. | |
|
377 | */ | |
|
378 | ||
|
379 | /*! | |
|
380 | \fn void QAbstractAxis::titleBrushChanged(const QBrush& brush) | |
|
381 | The brush of the axis title has changed to \a brush. | |
|
382 | */ | |
|
383 | ||
|
384 | /*! | |
|
385 | \fn void QAbstractAxis::titleFontChanged(const QFont& font) | |
|
386 | The font of the axis title has changed to \a font. | |
|
387 | */ | |
|
388 | /*! | |
|
389 | \qmlsignal AbstractAxis::onTitleFontChanged(Font font) | |
|
390 | The font of the axis title has changed to \a font. | |
|
391 | */ | |
|
392 | ||
|
393 | /*! | |
|
270 | 394 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
271 | 395 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
272 | 396 | */ |
|
273 | 397 | /*! |
|
274 | 398 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) |
|
275 | 399 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
276 | 400 | */ |
|
277 | 401 | |
|
278 | 402 | /*! |
|
279 | 403 | \fn void QAbstractAxis::shadesColorChanged(QColor color) |
|
280 | 404 | Emitted if the \a color of the axis shades is changed. |
|
281 | 405 | */ |
|
282 | 406 | /*! |
|
283 | 407 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) |
|
284 | 408 | Emitted if the \a color of the axis shades is changed. |
|
285 | 409 | */ |
|
286 | 410 | |
|
287 | 411 | /*! |
|
288 | 412 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
289 | 413 | Emitted if the border \a color of the axis shades is changed. |
|
290 | 414 | */ |
|
291 | 415 | /*! |
|
292 | 416 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) |
|
293 | 417 | Emitted if the border \a color of the axis shades is changed. |
|
294 | 418 | */ |
|
295 | 419 | |
|
296 | 420 | /*! |
|
421 | \fn void QAbstractAxis::shadesBrushChanged(const QBrush& brush) | |
|
422 | The brush of the axis shades has changed to \a brush. | |
|
423 | */ | |
|
424 | ||
|
425 | /*! | |
|
426 | \fn void QAbstractAxis::shadesPenChanged(const QPen& pen) | |
|
427 | The pen of the axis shades has changed to \a pen. | |
|
428 | */ | |
|
429 | ||
|
430 | /*! | |
|
297 | 431 | \internal |
|
298 | 432 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
299 | 433 | QChart when axis added. |
|
300 | 434 | */ |
|
301 | 435 | |
|
302 | 436 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) |
|
303 | 437 | : QObject(parent), |
|
304 | 438 | d_ptr(&d) |
|
305 | 439 | { |
|
306 | 440 | } |
|
307 | 441 | |
|
308 | 442 | /*! |
|
309 | 443 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
310 | 444 | */ |
|
311 | 445 | |
|
312 | 446 | QAbstractAxis::~QAbstractAxis() |
|
313 | 447 | { |
|
314 | 448 | if (d_ptr->m_chart) |
|
315 | 449 | qFatal("Still binded axis detected !"); |
|
316 | 450 | } |
|
317 | 451 | |
|
318 | 452 | /*! |
|
319 | 453 | Sets \a pen used to draw axis line and ticks. |
|
320 | 454 | */ |
|
321 | 455 | void QAbstractAxis::setLinePen(const QPen &pen) |
|
322 | 456 | { |
|
323 | 457 | if (d_ptr->m_axisPen != pen) { |
|
324 | 458 | d_ptr->m_axisPen = pen; |
|
325 | 459 | emit linePenChanged(pen); |
|
326 | 460 | } |
|
327 | 461 | } |
|
328 | 462 | |
|
329 | 463 | /*! |
|
330 | 464 | Returns pen used to draw axis and ticks. |
|
331 | 465 | */ |
|
332 | 466 | QPen QAbstractAxis::linePen() const |
|
333 | 467 | { |
|
334 | 468 | return d_ptr->m_axisPen; |
|
335 | 469 | } |
|
336 | 470 | |
|
337 | 471 | //TODO: remove me |
|
338 | 472 | void QAbstractAxis::setLinePenColor(QColor color) |
|
339 | 473 | { |
|
340 | 474 | QPen p = d_ptr->m_axisPen; |
|
341 | 475 | if (p.color() != color) { |
|
342 | 476 | p.setColor(color); |
|
343 | 477 | setLinePen(p); |
|
344 | 478 | emit colorChanged(color); |
|
345 | 479 | } |
|
346 | 480 | } |
|
347 | 481 | |
|
348 | 482 | QColor QAbstractAxis::linePenColor() const |
|
349 | 483 | { |
|
350 | 484 | return d_ptr->m_axisPen.color(); |
|
351 | 485 | } |
|
352 | 486 | |
|
353 | 487 | /*! |
|
354 | 488 | Sets if axis and ticks are \a visible. |
|
355 | 489 | */ |
|
356 | 490 | void QAbstractAxis::setLineVisible(bool visible) |
|
357 | 491 | { |
|
358 | 492 | if (d_ptr->m_arrowVisible != visible) { |
|
359 | 493 | d_ptr->m_arrowVisible = visible; |
|
360 | 494 | emit lineVisibleChanged(visible); |
|
361 | 495 | } |
|
362 | 496 | } |
|
363 | 497 | |
|
364 | 498 | bool QAbstractAxis::isLineVisible() const |
|
365 | 499 | { |
|
366 | 500 | return d_ptr->m_arrowVisible; |
|
367 | 501 | } |
|
368 | 502 | |
|
369 | 503 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
370 | 504 | { |
|
371 | 505 | if (d_ptr->m_gridLineVisible != visible) { |
|
372 | 506 | d_ptr->m_gridLineVisible = visible; |
|
373 | 507 | emit gridVisibleChanged(visible); |
|
374 | 508 | } |
|
375 | 509 | } |
|
376 | 510 | |
|
377 | 511 | bool QAbstractAxis::isGridLineVisible() const |
|
378 | 512 | { |
|
379 | 513 | return d_ptr->m_gridLineVisible; |
|
380 | 514 | } |
|
381 | 515 | |
|
382 | 516 | /*! |
|
383 | 517 | Sets \a pen used to draw grid line. |
|
384 | 518 | */ |
|
385 | 519 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
386 | 520 | { |
|
387 | 521 | if (d_ptr->m_gridLinePen != pen) { |
|
388 | 522 | d_ptr->m_gridLinePen = pen; |
|
389 | 523 | emit gridLinePenChanged(pen); |
|
390 | 524 | } |
|
391 | 525 | } |
|
392 | 526 | |
|
393 | 527 | /*! |
|
394 | 528 | Returns pen used to draw grid. |
|
395 | 529 | */ |
|
396 | 530 | QPen QAbstractAxis::gridLinePen() const |
|
397 | 531 | { |
|
398 | 532 | return d_ptr->m_gridLinePen; |
|
399 | 533 | } |
|
400 | 534 | |
|
401 | 535 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
402 | 536 | { |
|
403 | 537 | if (d_ptr->m_labelsVisible != visible) { |
|
404 | 538 | d_ptr->m_labelsVisible = visible; |
|
405 | 539 | emit labelsVisibleChanged(visible); |
|
406 | 540 | } |
|
407 | 541 | } |
|
408 | 542 | |
|
409 | 543 | bool QAbstractAxis::labelsVisible() const |
|
410 | 544 | { |
|
411 | 545 | return d_ptr->m_labelsVisible; |
|
412 | 546 | } |
|
413 | 547 | |
|
414 | 548 | /*! |
|
415 | 549 | Sets \a pen used to draw labels. |
|
416 | 550 | */ |
|
417 | 551 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
418 | 552 | { |
|
419 | 553 | if (d_ptr->m_labelsPen != pen) { |
|
420 | 554 | d_ptr->m_labelsPen = pen; |
|
421 | 555 | emit labelsPenChanged(pen); |
|
422 | 556 | } |
|
423 | 557 | } |
|
424 | 558 | |
|
425 | 559 | /*! |
|
426 | 560 | Returns the pen used to labels. |
|
427 | 561 | */ |
|
428 | 562 | QPen QAbstractAxis::labelsPen() const |
|
429 | 563 | { |
|
430 | 564 | return d_ptr->m_labelsPen; |
|
431 | 565 | } |
|
432 | 566 | |
|
433 | 567 | /*! |
|
434 | 568 | Sets \a brush used to draw labels. |
|
435 | 569 | */ |
|
436 | 570 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
437 | 571 | { |
|
438 | 572 | if (d_ptr->m_labelsBrush != brush) { |
|
439 | 573 | d_ptr->m_labelsBrush = brush; |
|
440 | 574 | emit labelsBrushChanged(brush); |
|
441 | 575 | } |
|
442 | 576 | } |
|
443 | 577 | |
|
444 | 578 | /*! |
|
445 | 579 | Returns brush used to draw labels. |
|
446 | 580 | */ |
|
447 | 581 | QBrush QAbstractAxis::labelsBrush() const |
|
448 | 582 | { |
|
449 | 583 | return d_ptr->m_labelsBrush; |
|
450 | 584 | } |
|
451 | 585 | |
|
452 | 586 | /*! |
|
453 | 587 | Sets \a font used to draw labels. |
|
454 | 588 | */ |
|
455 | 589 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
456 | 590 | { |
|
457 | 591 | if (d_ptr->m_labelsFont != font) { |
|
458 | 592 | d_ptr->m_labelsFont = font; |
|
459 | 593 | emit labelsFontChanged(font); |
|
460 | 594 | } |
|
461 | 595 | } |
|
462 | 596 | |
|
463 | 597 | /*! |
|
464 | 598 | Returns font used to draw labels. |
|
465 | 599 | */ |
|
466 | 600 | QFont QAbstractAxis::labelsFont() const |
|
467 | 601 | { |
|
468 | 602 | return d_ptr->m_labelsFont; |
|
469 | 603 | } |
|
470 | 604 | |
|
471 | 605 | void QAbstractAxis::setLabelsAngle(int angle) |
|
472 | 606 | { |
|
473 | 607 | if (d_ptr->m_labelsAngle != angle) { |
|
474 | 608 | d_ptr->m_labelsAngle = angle; |
|
475 | 609 | emit labelsAngleChanged(angle); |
|
476 | 610 | } |
|
477 | 611 | } |
|
478 | 612 | |
|
479 | 613 | int QAbstractAxis::labelsAngle() const |
|
480 | 614 | { |
|
481 | 615 | return d_ptr->m_labelsAngle; |
|
482 | 616 | } |
|
483 | 617 | //TODO: remove me |
|
484 | 618 | void QAbstractAxis::setLabelsColor(QColor color) |
|
485 | 619 | { |
|
486 | 620 | QBrush b = d_ptr->m_labelsBrush; |
|
487 | 621 | if (b.color() != color) { |
|
488 | 622 | b.setColor(color); |
|
489 | 623 | setLabelsBrush(b); |
|
490 | 624 | emit labelsColorChanged(color); |
|
491 | 625 | } |
|
492 | 626 | } |
|
493 | 627 | |
|
494 | 628 | QColor QAbstractAxis::labelsColor() const |
|
495 | 629 | { |
|
496 | 630 | return d_ptr->m_labelsBrush.color(); |
|
497 | 631 | } |
|
498 | 632 | |
|
499 | 633 | void QAbstractAxis::setTitleVisible(bool visible) |
|
500 | 634 | { |
|
501 | 635 | if (d_ptr->m_titleVisible != visible) { |
|
502 | 636 | d_ptr->m_titleVisible = visible; |
|
503 | 637 | emit titleVisibleChanged(visible); |
|
504 | 638 | } |
|
505 | 639 | } |
|
506 | 640 | |
|
507 | 641 | bool QAbstractAxis::isTitleVisible() const |
|
508 | 642 | { |
|
509 | 643 | return d_ptr->m_titleVisible; |
|
510 | 644 | } |
|
511 | 645 | |
|
512 | 646 | /*! |
|
513 | 647 | Sets \a pen used to draw title. |
|
514 | 648 | */ |
|
515 | 649 | void QAbstractAxis::setTitlePen(const QPen &pen) |
|
516 | 650 | { |
|
517 | 651 | if (d_ptr->m_titlePen != pen) { |
|
518 | 652 | d_ptr->m_titlePen = pen; |
|
519 | 653 | emit titlePenChanged(pen); |
|
520 | 654 | } |
|
521 | 655 | } |
|
522 | 656 | |
|
523 | 657 | /*! |
|
524 | 658 | Returns the pen used to title. |
|
525 | 659 | */ |
|
526 | 660 | QPen QAbstractAxis::titlePen() const |
|
527 | 661 | { |
|
528 | 662 | return d_ptr->m_titlePen; |
|
529 | 663 | } |
|
530 | 664 | |
|
531 | 665 | /*! |
|
532 | 666 | Sets \a brush used to draw title. |
|
533 | 667 | */ |
|
534 | 668 | void QAbstractAxis::setTitleBrush(const QBrush &brush) |
|
535 | 669 | { |
|
536 | 670 | if (d_ptr->m_titleBrush != brush) { |
|
537 | 671 | d_ptr->m_titleBrush = brush; |
|
538 | 672 | emit titleBrushChanged(brush); |
|
539 | 673 | } |
|
540 | 674 | } |
|
541 | 675 | |
|
542 | 676 | /*! |
|
543 | 677 | Returns brush used to draw title. |
|
544 | 678 | */ |
|
545 | 679 | QBrush QAbstractAxis::titleBrush() const |
|
546 | 680 | { |
|
547 | 681 | return d_ptr->m_titleBrush; |
|
548 | 682 | } |
|
549 | 683 | |
|
550 | 684 | /*! |
|
551 | 685 | Sets \a font used to draw title. |
|
552 | 686 | */ |
|
553 | 687 | void QAbstractAxis::setTitleFont(const QFont &font) |
|
554 | 688 | { |
|
555 | 689 | if (d_ptr->m_titleFont != font) { |
|
556 | 690 | d_ptr->m_titleFont = font; |
|
557 | 691 | emit titleFontChanged(font); |
|
558 | 692 | } |
|
559 | 693 | } |
|
560 | 694 | |
|
561 | 695 | /*! |
|
562 | 696 | Returns font used to draw title. |
|
563 | 697 | */ |
|
564 | 698 | QFont QAbstractAxis::titleFont() const |
|
565 | 699 | { |
|
566 | 700 | return d_ptr->m_titleFont; |
|
567 | 701 | } |
|
568 | 702 | |
|
569 | 703 | void QAbstractAxis::setTitleText(const QString &title) |
|
570 | 704 | { |
|
571 | 705 | if (d_ptr->m_title != title) { |
|
572 | 706 | d_ptr->m_title = title; |
|
573 | 707 | emit titleTextChanged(title); |
|
574 | 708 | } |
|
575 | 709 | } |
|
576 | 710 | |
|
577 | 711 | QString QAbstractAxis::titleText() const |
|
578 | 712 | { |
|
579 | 713 | return d_ptr->m_title; |
|
580 | 714 | } |
|
581 | 715 | |
|
582 | 716 | |
|
583 | 717 | void QAbstractAxis::setShadesVisible(bool visible) |
|
584 | 718 | { |
|
585 | 719 | if (d_ptr->m_shadesVisible != visible) { |
|
586 | 720 | d_ptr->m_shadesVisible = visible; |
|
587 | 721 | emit shadesVisibleChanged(visible); |
|
588 | 722 | } |
|
589 | 723 | } |
|
590 | 724 | |
|
591 | 725 | bool QAbstractAxis::shadesVisible() const |
|
592 | 726 | { |
|
593 | 727 | return d_ptr->m_shadesVisible; |
|
594 | 728 | } |
|
595 | 729 | |
|
596 | 730 | /*! |
|
597 | 731 | Sets \a pen used to draw shades. |
|
598 | 732 | */ |
|
599 | 733 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
600 | 734 | { |
|
601 | 735 | if (d_ptr->m_shadesPen != pen) { |
|
602 | 736 | d_ptr->m_shadesPen = pen; |
|
603 | 737 | emit shadesPenChanged(pen); |
|
604 | 738 | } |
|
605 | 739 | } |
|
606 | 740 | |
|
607 | 741 | /*! |
|
608 | 742 | Returns pen used to draw shades. |
|
609 | 743 | */ |
|
610 | 744 | QPen QAbstractAxis::shadesPen() const |
|
611 | 745 | { |
|
612 | 746 | return d_ptr->m_shadesPen; |
|
613 | 747 | } |
|
614 | 748 | |
|
615 | 749 | /*! |
|
616 | 750 | Sets \a brush used to draw shades. |
|
617 | 751 | */ |
|
618 | 752 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
619 | 753 | { |
|
620 | 754 | if (d_ptr->m_shadesBrush != brush) { |
|
621 | 755 | d_ptr->m_shadesBrush = brush; |
|
622 | 756 | emit shadesBrushChanged(brush); |
|
623 | 757 | } |
|
624 | 758 | } |
|
625 | 759 | |
|
626 | 760 | /*! |
|
627 | 761 | Returns brush used to draw shades. |
|
628 | 762 | */ |
|
629 | 763 | QBrush QAbstractAxis::shadesBrush() const |
|
630 | 764 | { |
|
631 | 765 | return d_ptr->m_shadesBrush; |
|
632 | 766 | } |
|
633 | 767 | |
|
634 | 768 | void QAbstractAxis::setShadesColor(QColor color) |
|
635 | 769 | { |
|
636 | 770 | QBrush b = d_ptr->m_shadesBrush; |
|
637 | 771 | if (b.color() != color) { |
|
638 | 772 | b.setColor(color); |
|
639 | 773 | setShadesBrush(b); |
|
640 | 774 | emit shadesColorChanged(color); |
|
641 | 775 | } |
|
642 | 776 | } |
|
643 | 777 | |
|
644 | 778 | QColor QAbstractAxis::shadesColor() const |
|
645 | 779 | { |
|
646 | 780 | return d_ptr->m_shadesBrush.color(); |
|
647 | 781 | } |
|
648 | 782 | |
|
649 | 783 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
650 | 784 | { |
|
651 | 785 | QPen p = d_ptr->m_shadesPen; |
|
652 | 786 | if (p.color() != color) { |
|
653 | 787 | p.setColor(color); |
|
654 | 788 | setShadesPen(p); |
|
655 | 789 | emit shadesColorChanged(color); |
|
656 | 790 | } |
|
657 | 791 | } |
|
658 | 792 | |
|
659 | 793 | QColor QAbstractAxis::shadesBorderColor() const |
|
660 | 794 | { |
|
661 | 795 | return d_ptr->m_shadesPen.color(); |
|
662 | 796 | } |
|
663 | 797 | |
|
664 | 798 | |
|
665 | 799 | bool QAbstractAxis::isVisible() const |
|
666 | 800 | { |
|
667 | 801 | return d_ptr->m_visible; |
|
668 | 802 | } |
|
669 | 803 | |
|
670 | 804 | /*! |
|
671 | 805 | Sets axis, shades, labels and grid lines to be visible. |
|
672 | 806 | */ |
|
673 | 807 | void QAbstractAxis::setVisible(bool visible) |
|
674 | 808 | { |
|
675 | 809 | if (d_ptr->m_visible != visible) { |
|
676 | 810 | d_ptr->m_visible = visible; |
|
677 | 811 | emit visibleChanged(visible); |
|
678 | 812 | } |
|
679 | 813 | } |
|
680 | 814 | |
|
681 | 815 | |
|
682 | 816 | /*! |
|
683 | 817 | Sets axis, shades, labels and grid lines to be visible. |
|
684 | 818 | */ |
|
685 | 819 | void QAbstractAxis::show() |
|
686 | 820 | { |
|
687 | 821 | setVisible(true); |
|
688 | 822 | } |
|
689 | 823 | |
|
690 | 824 | /*! |
|
691 | 825 | Sets axis, shades, labels and grid lines to not be visible. |
|
692 | 826 | */ |
|
693 | 827 | void QAbstractAxis::hide() |
|
694 | 828 | { |
|
695 | 829 | setVisible(false); |
|
696 | 830 | } |
|
697 | 831 | |
|
698 | 832 | /*! |
|
699 | 833 | Sets the minimum value shown on the axis. |
|
700 | 834 | Depending on the actual axis type the \a min parameter is converted to appropriate type. |
|
701 | 835 | If the conversion is impossible then the function call does nothing |
|
702 | 836 | */ |
|
703 | 837 | void QAbstractAxis::setMin(const QVariant &min) |
|
704 | 838 | { |
|
705 | 839 | d_ptr->setMin(min); |
|
706 | 840 | } |
|
707 | 841 | |
|
708 | 842 | /*! |
|
709 | 843 | Sets the maximum value shown on the axis. |
|
710 | 844 | Depending on the actual axis type the \a max parameter is converted to appropriate type. |
|
711 | 845 | If the conversion is impossible then the function call does nothing |
|
712 | 846 | */ |
|
713 | 847 | void QAbstractAxis::setMax(const QVariant &max) |
|
714 | 848 | { |
|
715 | 849 | d_ptr->setMax(max); |
|
716 | 850 | } |
|
717 | 851 | |
|
718 | 852 | /*! |
|
719 | 853 | Sets the range shown on the axis. |
|
720 | 854 | Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types. |
|
721 | 855 | If the conversion is impossible then the function call does nothing. |
|
722 | 856 | */ |
|
723 | 857 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) |
|
724 | 858 | { |
|
725 | 859 | d_ptr->setRange(min, max); |
|
726 | 860 | } |
|
727 | 861 | |
|
728 | 862 | |
|
729 | 863 | /*! |
|
730 | 864 | Returns the orientation in which the axis is being used (Vertical or Horizontal) |
|
731 | 865 | */ |
|
732 | 866 | // NOTE: should have const but it breaks BC: |
|
733 | 867 | // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function |
|
734 | 868 | Qt::Orientation QAbstractAxis::orientation() |
|
735 | 869 | { |
|
736 | 870 | return d_ptr->orientation(); |
|
737 | 871 | } |
|
738 | 872 | |
|
739 | 873 | Qt::Alignment QAbstractAxis::alignment() const |
|
740 | 874 | { |
|
741 | 875 | return d_ptr->alignment(); |
|
742 | 876 | } |
|
743 | 877 | |
|
744 | 878 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
745 | 879 | |
|
746 | 880 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q) |
|
747 | 881 | : q_ptr(q), |
|
748 | 882 | m_chart(0), |
|
749 | 883 | m_alignment(0), |
|
750 | 884 | m_orientation(Qt::Orientation(0)), |
|
751 | 885 | m_visible(true), |
|
752 | 886 | m_arrowVisible(true), |
|
753 | 887 | m_gridLineVisible(true), |
|
754 | 888 | m_labelsVisible(true), |
|
755 | 889 | m_labelsAngle(0), |
|
756 | 890 | m_titleVisible(true), |
|
757 | 891 | m_shadesVisible(false), |
|
758 | 892 | m_shadesBrush(Qt::SolidPattern), |
|
759 | 893 | m_shadesOpacity(1.0), |
|
760 | 894 | m_dirty(false) |
|
761 | 895 | { |
|
762 | 896 | |
|
763 | 897 | } |
|
764 | 898 | |
|
765 | 899 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
766 | 900 | { |
|
767 | 901 | } |
|
768 | 902 | |
|
769 | 903 | void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment) |
|
770 | 904 | { |
|
771 | 905 | switch(alignment) { |
|
772 | 906 | case Qt::AlignTop: |
|
773 | 907 | case Qt::AlignBottom: |
|
774 | 908 | m_orientation = Qt::Horizontal; |
|
775 | 909 | break; |
|
776 | 910 | case Qt::AlignLeft: |
|
777 | 911 | case Qt::AlignRight: |
|
778 | 912 | m_orientation = Qt::Vertical; |
|
779 | 913 | break; |
|
780 | 914 | default: |
|
781 | 915 | qWarning()<<"No alignment specified !"; |
|
782 | 916 | break; |
|
783 | 917 | }; |
|
784 | 918 | m_alignment=alignment; |
|
785 | 919 | } |
|
786 | 920 | |
|
787 | 921 | void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced) |
|
788 | 922 | { |
|
789 | 923 | QPen pen; |
|
790 | 924 | QBrush brush; |
|
791 | 925 | QFont font; |
|
792 | 926 | |
|
793 | 927 | bool axisX = m_orientation == Qt::Horizontal; |
|
794 | 928 | |
|
795 | 929 | if (m_arrowVisible) { |
|
796 | 930 | |
|
797 | 931 | if (forced || brush == m_labelsBrush){ |
|
798 | 932 | q_ptr->setLabelsBrush(theme->labelBrush()); |
|
799 | 933 | } |
|
800 | 934 | //TODO: introduce axis brush |
|
801 | 935 | if (forced || brush == m_titleBrush){ |
|
802 | 936 | q_ptr->setTitleBrush(theme->labelBrush()); |
|
803 | 937 | } |
|
804 | 938 | if (forced || pen == m_labelsPen){ |
|
805 | 939 | q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons |
|
806 | 940 | } |
|
807 | 941 | if (forced || pen == m_titlePen){ |
|
808 | 942 | q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons |
|
809 | 943 | } |
|
810 | 944 | if (forced || m_shadesVisible) { |
|
811 | 945 | |
|
812 | 946 | if (forced || brush == m_shadesBrush){ |
|
813 | 947 | q_ptr->setShadesBrush(theme->backgroundShadesBrush()); |
|
814 | 948 | } |
|
815 | 949 | if (forced || pen == m_shadesPen){ |
|
816 | 950 | q_ptr->setShadesPen(theme->backgroundShadesPen()); |
|
817 | 951 | } |
|
818 | 952 | if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth |
|
819 | 953 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX) |
|
820 | 954 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) { |
|
821 | 955 | q_ptr->setShadesVisible(true); |
|
822 | 956 | } |
|
823 | 957 | } |
|
824 | 958 | |
|
825 | 959 | if (forced || pen == m_axisPen) { |
|
826 | 960 | q_ptr->setLinePen(theme->axisLinePen()); |
|
827 | 961 | } |
|
828 | 962 | |
|
829 | 963 | if (forced || pen == m_gridLinePen) { |
|
830 | 964 | q_ptr->setGridLinePen(theme->girdLinePen()); |
|
831 | 965 | } |
|
832 | 966 | |
|
833 | 967 | if (forced || font == m_labelsFont){ |
|
834 | 968 | q_ptr->setLabelsFont(theme->labelFont()); |
|
835 | 969 | } |
|
836 | 970 | //TODO: discuss with Tero |
|
837 | 971 | if (forced || font == m_titleFont){ |
|
838 | 972 | QFont font(m_labelsFont); |
|
839 | 973 | font.setBold(true); |
|
840 | 974 | q_ptr->setTitleFont(font); |
|
841 | 975 | } |
|
842 | 976 | } |
|
843 | 977 | } |
|
844 | 978 | |
|
845 | 979 | void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max) |
|
846 | 980 | { |
|
847 | 981 | setRange(min,max); |
|
848 | 982 | } |
|
849 | 983 | |
|
850 | 984 | void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent) |
|
851 | 985 | { |
|
852 | 986 | Q_UNUSED(parent); |
|
853 | 987 | } |
|
854 | 988 | |
|
855 | 989 | void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
856 | 990 | { |
|
857 | 991 | ChartAxis* axis = m_item.data(); |
|
858 | 992 | Q_ASSERT(axis); |
|
859 | 993 | if(options.testFlag(QChart::GridAxisAnimations)) { |
|
860 | 994 | axis->setAnimation(new AxisAnimation(axis)); |
|
861 | 995 | }else{ |
|
862 | 996 | axis->setAnimation(0); |
|
863 | 997 | } |
|
864 | 998 | } |
|
865 | 999 | |
|
866 | 1000 | |
|
867 | 1001 | |
|
868 | 1002 | #include "moc_qabstractaxis.cpp" |
|
869 | 1003 | #include "moc_qabstractaxis_p.cpp" |
|
870 | 1004 | |
|
871 | 1005 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,197 +1,194 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef QABSTRACTAXIS_H |
|
22 | 22 | #define QABSTRACTAXIS_H |
|
23 | 23 | |
|
24 | 24 | #include <qchartglobal.h> |
|
25 | 25 | #include <QPen> |
|
26 | 26 | #include <QFont> |
|
27 | 27 | #include <QVariant> |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | 31 | class QAbstractAxisPrivate; |
|
32 | 32 | |
|
33 | 33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject |
|
34 | 34 | { |
|
35 | 35 | Q_OBJECT |
|
36 | 36 | //visibility |
|
37 | 37 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
38 | 38 | //arrow |
|
39 | 39 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
|
40 | 40 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
|
41 | //TODO: make wrapping of color for qml | |
|
42 | 41 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
|
43 | 42 | //labels |
|
44 | 43 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
45 |
Q_PROPERTY(QPen lab |
|
|
46 |
Q_PROPERTY(QBrush lab |
|
|
44 | Q_PROPERTY(QPen labelsPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged) | |
|
45 | Q_PROPERTY(QBrush labelsBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) | |
|
47 | 46 | //TODO: fix labels angles to work with layout |
|
48 | 47 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
|
49 | 48 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
|
50 | //TODO: make wrapping of color for qml | |
|
51 | 49 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
52 | 50 | //grid |
|
53 | 51 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged) |
|
54 |
Q_PROPERTY(QPen g |
|
|
52 | Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) | |
|
55 | 53 | //shades |
|
56 | 54 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
57 | //TODO: make wrapping of color for qml | |
|
58 | 55 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
59 | 56 | //TODO: make wrapping of border for qml |
|
60 | 57 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
61 | 58 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
|
62 | 59 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
|
63 | 60 | //title |
|
64 | 61 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
|
65 | 62 | Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged) |
|
66 | 63 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
|
67 | 64 | Q_PROPERTY(bool titleVisible READ isTitleVisible WRITE setTitleVisible NOTIFY titleVisibleChanged) |
|
68 | 65 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont NOTIFY titleFontChanged) |
|
69 | 66 | //orientation |
|
70 | 67 | Q_PROPERTY(Qt::Orientation orientation READ orientation) |
|
71 | 68 | //aligment |
|
72 | 69 | Q_PROPERTY(Qt::Alignment alignment READ alignment) |
|
73 | 70 | |
|
74 | 71 | public: |
|
75 | 72 | |
|
76 | 73 | enum AxisType { |
|
77 | 74 | AxisTypeNoAxis = 0x0, |
|
78 | 75 | AxisTypeValue = 0x1, |
|
79 | 76 | AxisTypeBarCategory = 0x2, |
|
80 | 77 | AxisTypeCategory = 0x3, |
|
81 | 78 | AxisTypeDateTime = 0x4, |
|
82 | 79 | AxisTypeLogValue = 0x5 |
|
83 | 80 | }; |
|
84 | 81 | |
|
85 | 82 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
|
86 | 83 | |
|
87 | 84 | protected: |
|
88 | 85 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0); |
|
89 | 86 | |
|
90 | 87 | public: |
|
91 | 88 | ~QAbstractAxis(); |
|
92 | 89 | |
|
93 | 90 | virtual AxisType type() const = 0; |
|
94 | 91 | |
|
95 | 92 | //visibility handling |
|
96 | 93 | bool isVisible() const; |
|
97 | 94 | void setVisible(bool visible = true); |
|
98 | 95 | void show(); |
|
99 | 96 | void hide(); |
|
100 | 97 | |
|
101 | 98 | //arrow handling |
|
102 | 99 | bool isLineVisible() const; |
|
103 | 100 | void setLineVisible(bool visible = true); |
|
104 | 101 | void setLinePen(const QPen &pen); |
|
105 | 102 | QPen linePen() const; |
|
106 | 103 | void setLinePenColor(QColor color); |
|
107 | 104 | QColor linePenColor() const; |
|
108 | 105 | |
|
109 | 106 | //grid handling |
|
110 | 107 | bool isGridLineVisible() const; |
|
111 | 108 | void setGridLineVisible(bool visible = true); |
|
112 | 109 | void setGridLinePen(const QPen &pen); |
|
113 | 110 | QPen gridLinePen() const; |
|
114 | 111 | |
|
115 | 112 | //labels handling |
|
116 | 113 | bool labelsVisible() const; |
|
117 | 114 | void setLabelsVisible(bool visible = true); |
|
118 | 115 | void setLabelsPen(const QPen &pen); |
|
119 | 116 | QPen labelsPen() const; |
|
120 | 117 | void setLabelsBrush(const QBrush &brush); |
|
121 | 118 | QBrush labelsBrush() const; |
|
122 | 119 | void setLabelsFont(const QFont &font); |
|
123 | 120 | QFont labelsFont() const; |
|
124 | 121 | void setLabelsAngle(int angle); |
|
125 | 122 | int labelsAngle() const; |
|
126 | 123 | void setLabelsColor(QColor color); |
|
127 | 124 | QColor labelsColor() const; |
|
128 | 125 | |
|
129 | 126 | //title handling |
|
130 | 127 | bool isTitleVisible() const; |
|
131 | 128 | void setTitleVisible(bool visible = true); |
|
132 | 129 | void setTitlePen(const QPen &pen); |
|
133 | 130 | QPen titlePen() const; |
|
134 | 131 | void setTitleBrush(const QBrush &brush); |
|
135 | 132 | QBrush titleBrush() const; |
|
136 | 133 | void setTitleFont(const QFont &font); |
|
137 | 134 | QFont titleFont() const; |
|
138 | 135 | void setTitleText(const QString &title); |
|
139 | 136 | QString titleText() const; |
|
140 | 137 | |
|
141 | 138 | //shades handling |
|
142 | 139 | bool shadesVisible() const; |
|
143 | 140 | void setShadesVisible(bool visible = true); |
|
144 | 141 | void setShadesPen(const QPen &pen); |
|
145 | 142 | QPen shadesPen() const; |
|
146 | 143 | void setShadesBrush(const QBrush &brush); |
|
147 | 144 | QBrush shadesBrush() const; |
|
148 | 145 | void setShadesColor(QColor color); |
|
149 | 146 | QColor shadesColor() const; |
|
150 | 147 | void setShadesBorderColor(QColor color); |
|
151 | 148 | QColor shadesBorderColor() const; |
|
152 | 149 | |
|
153 | 150 | Qt::Orientation orientation(); //TODO: missing const <- BC |
|
154 | 151 | Qt::Alignment alignment() const; |
|
155 | 152 | |
|
156 | 153 | //range handling |
|
157 | 154 | void setMin(const QVariant &min); |
|
158 | 155 | void setMax(const QVariant &max); |
|
159 | 156 | void setRange(const QVariant &min, const QVariant &max); |
|
160 | 157 | |
|
161 | 158 | Q_SIGNALS: |
|
162 | 159 | void visibleChanged(bool visible); |
|
163 | 160 | void linePenChanged(const QPen& pen); |
|
164 | 161 | void lineVisibleChanged(bool visible); |
|
165 | 162 | void labelsVisibleChanged(bool visible); |
|
166 | 163 | void labelsPenChanged(const QPen& pen); |
|
167 | 164 | void labelsBrushChanged(const QBrush& brush); |
|
168 | 165 | void labelsFontChanged(const QFont& pen); |
|
169 | 166 | void labelsAngleChanged(int angle); |
|
170 | 167 | void gridLinePenChanged(const QPen& pen); |
|
171 | 168 | void gridVisibleChanged(bool visible); |
|
172 | 169 | void colorChanged(QColor color); |
|
173 | 170 | void labelsColorChanged(QColor color); |
|
174 | 171 | void titleTextChanged(const QString& title); |
|
175 | 172 | void titlePenChanged(const QPen& pen); |
|
176 | void titleBrushChanged(const QBrush brush); | |
|
173 | void titleBrushChanged(const QBrush& brush); | |
|
177 | 174 | void titleVisibleChanged(bool visible); |
|
178 | 175 | void titleFontChanged(const QFont& font); |
|
179 | 176 | void shadesVisibleChanged(bool visible); |
|
180 | 177 | void shadesColorChanged(QColor color); |
|
181 | 178 | void shadesBorderColorChanged(QColor color); |
|
182 | 179 | void shadesPenChanged(const QPen& pen); |
|
183 | void shadesBrushChanged(const QBrush brush); | |
|
180 | void shadesBrushChanged(const QBrush& brush); | |
|
184 | 181 | |
|
185 | 182 | protected: |
|
186 | 183 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
187 | 184 | Q_DISABLE_COPY(QAbstractAxis) |
|
188 | 185 | friend class ChartDataSet; |
|
189 | 186 | friend class ChartAxis; |
|
190 | 187 | friend class ChartPresenter; |
|
191 | 188 | friend class ChartThemeManager; |
|
192 | 189 | friend class AbstractDomain; |
|
193 | 190 | }; |
|
194 | 191 | |
|
195 | 192 | QTCOMMERCIALCHART_END_NAMESPACE |
|
196 | 193 | |
|
197 | 194 | #endif // QABSTRACTAXIS_H |
@@ -1,106 +1,131 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | import QtQuick 1.0 |
|
22 | 22 | |
|
23 | 23 | Row { |
|
24 | 24 | anchors.fill: parent |
|
25 | 25 | spacing: 5 |
|
26 | 26 | property variant axis |
|
27 | 27 | |
|
28 | 28 | Flow { |
|
29 | 29 | spacing: 5 |
|
30 | 30 | flow: Flow.TopToBottom |
|
31 | height: parent.height | |
|
31 | 32 | |
|
32 | 33 | Button { |
|
33 | 34 | text: "axis visible" |
|
34 | 35 | onClicked: axis.visible = !axis.visible; |
|
35 | 36 | } |
|
36 | 37 | Button { |
|
37 |
text: "axis |
|
|
38 |
onClicked: axis. |
|
|
38 | text: "axis line visible" | |
|
39 | onClicked: axis.lineVisible = !axis.lineVisible; | |
|
39 | 40 | } |
|
40 | 41 | Button { |
|
41 | 42 | text: "axis color" |
|
42 | 43 | onClicked: axis.color = main.nextColor(); |
|
43 | 44 | } |
|
44 | 45 | Button { |
|
45 |
text: "axis labels |
|
|
46 |
onClicked: axis.labels |
|
|
46 | text: "axis labels visible" | |
|
47 | onClicked: axis.labelsVisible = !axis.labelsVisible; | |
|
47 | 48 | } |
|
48 | 49 | Button { |
|
49 | 50 | text: "axis labels angle +" |
|
50 | 51 | onClicked: axis.labelsAngle += 5; |
|
51 | 52 | } |
|
52 | 53 | Button { |
|
53 | 54 | text: "axis labels angle -" |
|
54 | 55 | onClicked: axis.labelsAngle -= 5; |
|
55 | 56 | } |
|
56 | 57 | Button { |
|
58 | text: "axis labels color" | |
|
59 | onClicked: axis.labelsColor = main.nextColor(); | |
|
60 | } | |
|
61 | Button { | |
|
62 | text: "axis grid visible" | |
|
63 | onClicked: axis.gridVisible = !axis.gridVisible; | |
|
64 | } | |
|
65 | Button { | |
|
57 | 66 | text: "axis shades visible" |
|
58 | 67 | onClicked: axis.shadesVisible = !axis.shadesVisible; |
|
59 | 68 | } |
|
60 | 69 | Button { |
|
61 | 70 | text: "axis shades color" |
|
62 | 71 | onClicked: axis.shadesColor = main.nextColor(); |
|
63 | 72 | } |
|
64 | 73 | Button { |
|
65 | 74 | text: "axis shades bcolor" |
|
66 | 75 | onClicked: axis.shadesBorderColor = main.nextColor(); |
|
67 | 76 | } |
|
68 | 77 | Button { |
|
78 | text: "axis title text" | |
|
79 | onClicked: axis.titleText = axis.titleText + "X"; | |
|
80 | } | |
|
81 | Button { | |
|
82 | text: "axis title visible" | |
|
83 | onClicked: axis.titleVisible = !axis.titleVisible; | |
|
84 | } | |
|
85 | Button { | |
|
69 | 86 | text: "axis max +" |
|
70 | 87 | onClicked: axis.max += 0.1; |
|
71 | 88 | } |
|
72 | 89 | Button { |
|
73 | 90 | text: "axis max -" |
|
74 | 91 | onClicked: axis.max -= 0.1; |
|
75 | 92 | } |
|
76 | 93 | Button { |
|
77 | 94 | text: "axis min +" |
|
78 | 95 | onClicked: axis.min += 0.1; |
|
79 | 96 | } |
|
80 | 97 | Button { |
|
81 | 98 | text: "axis min -" |
|
82 | 99 | onClicked: axis.min -= 0.1; |
|
83 | 100 | } |
|
84 | 101 | Button { |
|
85 | 102 | text: "axis tick count +" |
|
86 | 103 | onClicked: axis.tickCount++; |
|
87 | 104 | } |
|
88 | 105 | Button { |
|
89 | 106 | text: "axis tick count -" |
|
90 | 107 | |
|
91 | 108 | onClicked: axis.tickCount--; |
|
92 | 109 | } |
|
93 | 110 | Button { |
|
94 | 111 | text: "axis nice nmb" |
|
95 | 112 | onClicked: axis.niceNumbersEnabled = !axis.niceNumbersEnabled; |
|
96 | 113 | } |
|
97 | } | |
|
98 | 114 | |
|
99 | FontEditor { | |
|
100 | id: fontEditor | |
|
101 | fontDescription: "axis" | |
|
102 | function editedFont() { | |
|
103 | return axis.labelsFont; | |
|
115 | FontEditor { | |
|
116 | id: fontEditor | |
|
117 | fontDescription: "axis" | |
|
118 | function editedFont() { | |
|
119 | return axis.labelsFont; | |
|
120 | } | |
|
121 | } | |
|
122 | ||
|
123 | FontEditor { | |
|
124 | id: titleFontEditor | |
|
125 | fontDescription: "title" | |
|
126 | function editedFont() { | |
|
127 | return axis.titleFont; | |
|
128 | } | |
|
104 | 129 | } |
|
105 | 130 | } |
|
106 | 131 | } |
General Comments 0
You need to be logged in to leave comments.
Login now