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