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