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