##// END OF EJS Templates
Fix for blurred text on error QTRD-1898
Mika Salmela -
r2409:74bee2d758ec
parent child
Show More
@@ -1,1005 +1,1008
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 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 //TODO: remove me
472 472 void QAbstractAxis::setLinePenColor(QColor color)
473 473 {
474 474 QPen p = d_ptr->m_axisPen;
475 475 if (p.color() != color) {
476 476 p.setColor(color);
477 477 setLinePen(p);
478 478 emit colorChanged(color);
479 479 }
480 480 }
481 481
482 482 QColor QAbstractAxis::linePenColor() const
483 483 {
484 484 return d_ptr->m_axisPen.color();
485 485 }
486 486
487 487 /*!
488 488 Sets if axis and ticks are \a visible.
489 489 */
490 490 void QAbstractAxis::setLineVisible(bool visible)
491 491 {
492 492 if (d_ptr->m_arrowVisible != visible) {
493 493 d_ptr->m_arrowVisible = visible;
494 494 emit lineVisibleChanged(visible);
495 495 }
496 496 }
497 497
498 498 bool QAbstractAxis::isLineVisible() const
499 499 {
500 500 return d_ptr->m_arrowVisible;
501 501 }
502 502
503 503 void QAbstractAxis::setGridLineVisible(bool visible)
504 504 {
505 505 if (d_ptr->m_gridLineVisible != visible) {
506 506 d_ptr->m_gridLineVisible = visible;
507 507 emit gridVisibleChanged(visible);
508 508 }
509 509 }
510 510
511 511 bool QAbstractAxis::isGridLineVisible() const
512 512 {
513 513 return d_ptr->m_gridLineVisible;
514 514 }
515 515
516 516 /*!
517 517 Sets \a pen used to draw grid line.
518 518 */
519 519 void QAbstractAxis::setGridLinePen(const QPen &pen)
520 520 {
521 521 if (d_ptr->m_gridLinePen != pen) {
522 522 d_ptr->m_gridLinePen = pen;
523 523 emit gridLinePenChanged(pen);
524 524 }
525 525 }
526 526
527 527 /*!
528 528 Returns pen used to draw grid.
529 529 */
530 530 QPen QAbstractAxis::gridLinePen() const
531 531 {
532 532 return d_ptr->m_gridLinePen;
533 533 }
534 534
535 535 void QAbstractAxis::setLabelsVisible(bool visible)
536 536 {
537 537 if (d_ptr->m_labelsVisible != visible) {
538 538 d_ptr->m_labelsVisible = visible;
539 539 emit labelsVisibleChanged(visible);
540 540 }
541 541 }
542 542
543 543 bool QAbstractAxis::labelsVisible() const
544 544 {
545 545 return d_ptr->m_labelsVisible;
546 546 }
547 547
548 548 /*!
549 549 Sets \a pen used to draw labels.
550 550 */
551 551 void QAbstractAxis::setLabelsPen(const QPen &pen)
552 552 {
553 553 if (d_ptr->m_labelsPen != pen) {
554 554 d_ptr->m_labelsPen = pen;
555 555 emit labelsPenChanged(pen);
556 556 }
557 557 }
558 558
559 559 /*!
560 560 Returns the pen used to labels.
561 561 */
562 562 QPen QAbstractAxis::labelsPen() const
563 563 {
564 564 return d_ptr->m_labelsPen;
565 565 }
566 566
567 567 /*!
568 568 Sets \a brush used to draw labels.
569 569 */
570 570 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
571 571 {
572 572 if (d_ptr->m_labelsBrush != brush) {
573 573 d_ptr->m_labelsBrush = brush;
574 574 emit labelsBrushChanged(brush);
575 575 }
576 576 }
577 577
578 578 /*!
579 579 Returns brush used to draw labels.
580 580 */
581 581 QBrush QAbstractAxis::labelsBrush() const
582 582 {
583 583 return d_ptr->m_labelsBrush;
584 584 }
585 585
586 586 /*!
587 587 Sets \a font used to draw labels.
588 588 */
589 589 void QAbstractAxis::setLabelsFont(const QFont &font)
590 590 {
591 591 if (d_ptr->m_labelsFont != font) {
592 592 d_ptr->m_labelsFont = font;
593 593 emit labelsFontChanged(font);
594 594 }
595 595 }
596 596
597 597 /*!
598 598 Returns font used to draw labels.
599 599 */
600 600 QFont QAbstractAxis::labelsFont() const
601 601 {
602 602 return d_ptr->m_labelsFont;
603 603 }
604 604
605 605 void QAbstractAxis::setLabelsAngle(int angle)
606 606 {
607 607 if (d_ptr->m_labelsAngle != angle) {
608 608 d_ptr->m_labelsAngle = angle;
609 609 emit labelsAngleChanged(angle);
610 610 }
611 611 }
612 612
613 613 int QAbstractAxis::labelsAngle() const
614 614 {
615 615 return d_ptr->m_labelsAngle;
616 616 }
617 617 //TODO: remove me
618 618 void QAbstractAxis::setLabelsColor(QColor color)
619 619 {
620 620 QBrush b = d_ptr->m_labelsBrush;
621 621 if (b.color() != color) {
622 622 b.setColor(color);
623 623 setLabelsBrush(b);
624 624 emit labelsColorChanged(color);
625 625 }
626 626 }
627 627
628 628 QColor QAbstractAxis::labelsColor() const
629 629 {
630 630 return d_ptr->m_labelsBrush.color();
631 631 }
632 632
633 633 void QAbstractAxis::setTitleVisible(bool visible)
634 634 {
635 635 if (d_ptr->m_titleVisible != visible) {
636 636 d_ptr->m_titleVisible = visible;
637 637 emit titleVisibleChanged(visible);
638 638 }
639 639 }
640 640
641 641 bool QAbstractAxis::isTitleVisible() const
642 642 {
643 643 return d_ptr->m_titleVisible;
644 644 }
645 645
646 646 /*!
647 647 Sets \a pen used to draw title.
648 648 */
649 649 void QAbstractAxis::setTitlePen(const QPen &pen)
650 650 {
651 651 if (d_ptr->m_titlePen != pen) {
652 652 d_ptr->m_titlePen = pen;
653 653 emit titlePenChanged(pen);
654 654 }
655 655 }
656 656
657 657 /*!
658 658 Returns the pen used to title.
659 659 */
660 660 QPen QAbstractAxis::titlePen() const
661 661 {
662 662 return d_ptr->m_titlePen;
663 663 }
664 664
665 665 /*!
666 666 Sets \a brush used to draw title.
667 667 */
668 668 void QAbstractAxis::setTitleBrush(const QBrush &brush)
669 669 {
670 670 if (d_ptr->m_titleBrush != brush) {
671 671 d_ptr->m_titleBrush = brush;
672 672 emit titleBrushChanged(brush);
673 673 }
674 674 }
675 675
676 676 /*!
677 677 Returns brush used to draw title.
678 678 */
679 679 QBrush QAbstractAxis::titleBrush() const
680 680 {
681 681 return d_ptr->m_titleBrush;
682 682 }
683 683
684 684 /*!
685 685 Sets \a font used to draw title.
686 686 */
687 687 void QAbstractAxis::setTitleFont(const QFont &font)
688 688 {
689 689 if (d_ptr->m_titleFont != font) {
690 690 d_ptr->m_titleFont = font;
691 691 emit titleFontChanged(font);
692 692 }
693 693 }
694 694
695 695 /*!
696 696 Returns font used to draw title.
697 697 */
698 698 QFont QAbstractAxis::titleFont() const
699 699 {
700 700 return d_ptr->m_titleFont;
701 701 }
702 702
703 703 void QAbstractAxis::setTitleText(const QString &title)
704 704 {
705 705 if (d_ptr->m_title != title) {
706 706 d_ptr->m_title = title;
707 707 emit titleTextChanged(title);
708 708 }
709 709 }
710 710
711 711 QString QAbstractAxis::titleText() const
712 712 {
713 713 return d_ptr->m_title;
714 714 }
715 715
716 716
717 717 void QAbstractAxis::setShadesVisible(bool visible)
718 718 {
719 719 if (d_ptr->m_shadesVisible != visible) {
720 720 d_ptr->m_shadesVisible = visible;
721 721 emit shadesVisibleChanged(visible);
722 722 }
723 723 }
724 724
725 725 bool QAbstractAxis::shadesVisible() const
726 726 {
727 727 return d_ptr->m_shadesVisible;
728 728 }
729 729
730 730 /*!
731 731 Sets \a pen used to draw shades.
732 732 */
733 733 void QAbstractAxis::setShadesPen(const QPen &pen)
734 734 {
735 735 if (d_ptr->m_shadesPen != pen) {
736 736 d_ptr->m_shadesPen = pen;
737 737 emit shadesPenChanged(pen);
738 738 }
739 739 }
740 740
741 741 /*!
742 742 Returns pen used to draw shades.
743 743 */
744 744 QPen QAbstractAxis::shadesPen() const
745 745 {
746 746 return d_ptr->m_shadesPen;
747 747 }
748 748
749 749 /*!
750 750 Sets \a brush used to draw shades.
751 751 */
752 752 void QAbstractAxis::setShadesBrush(const QBrush &brush)
753 753 {
754 754 if (d_ptr->m_shadesBrush != brush) {
755 755 d_ptr->m_shadesBrush = brush;
756 756 emit shadesBrushChanged(brush);
757 757 }
758 758 }
759 759
760 760 /*!
761 761 Returns brush used to draw shades.
762 762 */
763 763 QBrush QAbstractAxis::shadesBrush() const
764 764 {
765 765 return d_ptr->m_shadesBrush;
766 766 }
767 767
768 768 void QAbstractAxis::setShadesColor(QColor color)
769 769 {
770 770 QBrush b = d_ptr->m_shadesBrush;
771 771 if (b.color() != color) {
772 772 b.setColor(color);
773 773 setShadesBrush(b);
774 774 emit shadesColorChanged(color);
775 775 }
776 776 }
777 777
778 778 QColor QAbstractAxis::shadesColor() const
779 779 {
780 780 return d_ptr->m_shadesBrush.color();
781 781 }
782 782
783 783 void QAbstractAxis::setShadesBorderColor(QColor color)
784 784 {
785 785 QPen p = d_ptr->m_shadesPen;
786 786 if (p.color() != color) {
787 787 p.setColor(color);
788 788 setShadesPen(p);
789 789 emit shadesColorChanged(color);
790 790 }
791 791 }
792 792
793 793 QColor QAbstractAxis::shadesBorderColor() const
794 794 {
795 795 return d_ptr->m_shadesPen.color();
796 796 }
797 797
798 798
799 799 bool QAbstractAxis::isVisible() const
800 800 {
801 801 return d_ptr->m_visible;
802 802 }
803 803
804 804 /*!
805 805 Sets axis, shades, labels and grid lines to be visible.
806 806 */
807 807 void QAbstractAxis::setVisible(bool visible)
808 808 {
809 809 if (d_ptr->m_visible != visible) {
810 810 d_ptr->m_visible = visible;
811 811 emit visibleChanged(visible);
812 812 }
813 813 }
814 814
815 815
816 816 /*!
817 817 Sets axis, shades, labels and grid lines to be visible.
818 818 */
819 819 void QAbstractAxis::show()
820 820 {
821 821 setVisible(true);
822 822 }
823 823
824 824 /*!
825 825 Sets axis, shades, labels and grid lines to not be visible.
826 826 */
827 827 void QAbstractAxis::hide()
828 828 {
829 829 setVisible(false);
830 830 }
831 831
832 832 /*!
833 833 Sets the minimum value shown on the axis.
834 834 Depending on the actual axis type the \a min parameter is converted to appropriate type.
835 835 If the conversion is impossible then the function call does nothing
836 836 */
837 837 void QAbstractAxis::setMin(const QVariant &min)
838 838 {
839 839 d_ptr->setMin(min);
840 840 }
841 841
842 842 /*!
843 843 Sets the maximum value shown on the axis.
844 844 Depending on the actual axis type the \a max parameter is converted to appropriate type.
845 845 If the conversion is impossible then the function call does nothing
846 846 */
847 847 void QAbstractAxis::setMax(const QVariant &max)
848 848 {
849 849 d_ptr->setMax(max);
850 850 }
851 851
852 852 /*!
853 853 Sets the range shown on the axis.
854 854 Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types.
855 855 If the conversion is impossible then the function call does nothing.
856 856 */
857 857 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
858 858 {
859 859 d_ptr->setRange(min, max);
860 860 }
861 861
862 862
863 863 /*!
864 864 Returns the orientation in which the axis is being used (Vertical or Horizontal)
865 865 */
866 866 // NOTE: should have const but it breaks BC:
867 867 // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function
868 868 Qt::Orientation QAbstractAxis::orientation()
869 869 {
870 870 return d_ptr->orientation();
871 871 }
872 872
873 873 Qt::Alignment QAbstractAxis::alignment() const
874 874 {
875 875 return d_ptr->alignment();
876 876 }
877 877
878 878 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
879 879
880 880 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
881 881 : q_ptr(q),
882 882 m_chart(0),
883 883 m_alignment(0),
884 884 m_orientation(Qt::Orientation(0)),
885 885 m_visible(true),
886 886 m_arrowVisible(true),
887 887 m_gridLineVisible(true),
888 888 m_labelsVisible(true),
889 889 m_labelsAngle(0),
890 890 m_titleVisible(true),
891 891 m_shadesVisible(false),
892 892 m_shadesBrush(Qt::SolidPattern),
893 893 m_shadesOpacity(1.0),
894 894 m_dirty(false)
895 895 {
896 896
897 897 }
898 898
899 899 QAbstractAxisPrivate::~QAbstractAxisPrivate()
900 900 {
901 901 }
902 902
903 903 void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment)
904 904 {
905 905 switch(alignment) {
906 906 case Qt::AlignTop:
907 907 case Qt::AlignBottom:
908 908 m_orientation = Qt::Horizontal;
909 909 break;
910 910 case Qt::AlignLeft:
911 911 case Qt::AlignRight:
912 912 m_orientation = Qt::Vertical;
913 913 break;
914 914 default:
915 915 qWarning()<<"No alignment specified !";
916 916 break;
917 917 };
918 918 m_alignment=alignment;
919 919 }
920 920
921 921 void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced)
922 922 {
923 923 QPen pen;
924 924 QBrush brush;
925 925 QFont font;
926 926
927 927 bool axisX = m_orientation == Qt::Horizontal;
928 928
929 if (m_arrowVisible) {
930
931 if (forced || brush == m_labelsBrush){
932 q_ptr->setLabelsBrush(theme->labelBrush());
929 //TODO: introduce axis brush
930 if (m_visible) {
931 if (m_arrowVisible) {
932 if (forced || pen == m_axisPen) {
933 q_ptr->setLinePen(theme->axisLinePen());
934 }
933 935 }
934 //TODO: introduce axis brush
935 if (forced || brush == m_titleBrush){
936 q_ptr->setTitleBrush(theme->labelBrush());
936 if (m_gridLineVisible) {
937 if (forced || pen == m_gridLinePen) {
938 q_ptr->setGridLinePen(theme->girdLinePen());
939 }
937 940 }
938 if (forced || pen == m_labelsPen){
939 q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons
941 if (m_labelsVisible) {
942 if (forced || brush == m_labelsBrush){
943 q_ptr->setLabelsBrush(theme->labelBrush());
944 }
945 if (forced || pen == m_labelsPen){
946 q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons
947 }
948 if (forced || font == m_labelsFont){
949 q_ptr->setLabelsFont(theme->labelFont());
950 }
940 951 }
941 if (forced || pen == m_titlePen){
942 q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons
952 if (m_titleVisible) {
953 if (forced || brush == m_titleBrush){
954 q_ptr->setTitleBrush(theme->labelBrush());
955 }
956 if (forced || pen == m_titlePen){
957 q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons
958 }
959 //TODO: discuss with Tero
960 if (forced || font == m_titleFont){
961 QFont font(m_labelsFont);
962 font.setBold(true);
963 q_ptr->setTitleFont(font);
964 }
943 965 }
944 966 if (forced || m_shadesVisible) {
945
946 967 if (forced || brush == m_shadesBrush){
947 968 q_ptr->setShadesBrush(theme->backgroundShadesBrush());
948 969 }
949 970 if (forced || pen == m_shadesPen){
950 971 q_ptr->setShadesPen(theme->backgroundShadesPen());
951 972 }
952 973 if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth
953 974 || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX)
954 975 || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) {
955 q_ptr->setShadesVisible(true);
976 q_ptr->setShadesVisible(true);
956 977 }
957 978 }
958
959 if (forced || pen == m_axisPen) {
960 q_ptr->setLinePen(theme->axisLinePen());
961 }
962
963 if (forced || pen == m_gridLinePen) {
964 q_ptr->setGridLinePen(theme->girdLinePen());
965 }
966
967 if (forced || font == m_labelsFont){
968 q_ptr->setLabelsFont(theme->labelFont());
969 }
970 //TODO: discuss with Tero
971 if (forced || font == m_titleFont){
972 QFont font(m_labelsFont);
973 font.setBold(true);
974 q_ptr->setTitleFont(font);
975 }
976 979 }
977 980 }
978 981
979 982 void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
980 983 {
981 984 setRange(min,max);
982 985 }
983 986
984 987 void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent)
985 988 {
986 989 Q_UNUSED(parent);
987 990 }
988 991
989 992 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options)
990 993 {
991 994 ChartAxis* axis = m_item.data();
992 995 Q_ASSERT(axis);
993 996 if(options.testFlag(QChart::GridAxisAnimations)) {
994 997 axis->setAnimation(new AxisAnimation(axis));
995 998 }else{
996 999 axis->setAnimation(0);
997 1000 }
998 1001 }
999 1002
1000 1003
1001 1004
1002 1005 #include "moc_qabstractaxis.cpp"
1003 1006 #include "moc_qabstractaxis_p.cpp"
1004 1007
1005 1008 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now