##// END OF EJS Templates
Fix android build issues...
Heikkinen Miikka -
r2522:e2eb16a7c3b1
parent child
Show More
@@ -1,1020 +1,1020
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 #include "qchart_p.h"
26 26
27 27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 28
29 29 /*!
30 30 \class QAbstractAxis
31 31 \brief The QAbstractAxis class is used for manipulating chart's axis.
32 32 \mainclass
33 33
34 34 Each series can be bound to one or more horizontal and vertical axes, but mixing axis types
35 35 that would result in different domains is not supported, such as specifying
36 36 QValueAxis and QLogValueAxis on the same orientation.
37 37
38 38 Properties and visibility of various axis elements such as axis line, title, labels, grid lines,
39 39 and shades can be individually controlled.
40 40 */
41 41
42 42 /*!
43 43 \qmlclass AbstractAxis QAbstractAxis
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 series 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::labelsPen
95 95 The pen of the labels.
96 96 */
97 97
98 98 /*!
99 99 \property QAbstractAxis::labelsBrush
100 100 The brush of the labels.
101 101 */
102 102
103 103 /*!
104 104 \property QAbstractAxis::visible
105 105 The visibility of the axis.
106 106 */
107 107 /*!
108 108 \qmlproperty bool AbstractAxis::visible
109 109 The visibility of the axis.
110 110 */
111 111
112 112 /*!
113 113 \property QAbstractAxis::gridVisible
114 114 The visibility of the grid lines.
115 115 */
116 116 /*!
117 117 \qmlproperty bool AbstractAxis::gridVisible
118 118 The visibility of the grid lines.
119 119 */
120 120
121 121 /*!
122 122 \property QAbstractAxis::color
123 123 The color of the axis and ticks.
124 124 */
125 125 /*!
126 126 \qmlproperty color AbstractAxis::color
127 127 The color of the axis and ticks.
128 128 */
129 129
130 130 /*!
131 131 \property QAbstractAxis::gridLinePen
132 132 The pen of the grid line.
133 133 */
134 134
135 135 /*!
136 136 \property QAbstractAxis::labelsFont
137 137 The font of the axis labels.
138 138 */
139 139
140 140 /*!
141 141 \qmlproperty Font AbstractAxis::labelsFont
142 142 The font of the axis labels.
143 143
144 144 See the \l {Font} {QML Font Element} for detailed documentation.
145 145 */
146 146
147 147 /*!
148 148 \property QAbstractAxis::labelsColor
149 149 The color of the axis labels.
150 150 */
151 151 /*!
152 152 \qmlproperty color AbstractAxis::labelsColor
153 153 The color of the axis labels.
154 154 */
155 155
156 156 /*!
157 157 \property QAbstractAxis::labelsAngle
158 158 The angle of the axis labels in degrees.
159 159 */
160 160 /*!
161 161 \qmlproperty int AbstractAxis::labelsAngle
162 162 The angle of the axis labels in degrees.
163 163 */
164 164
165 165 /*!
166 166 \property QAbstractAxis::shadesVisible
167 167 The visibility of the axis shades.
168 168 */
169 169 /*!
170 170 \qmlproperty bool AbstractAxis::shadesVisible
171 171 The visibility of the axis shades.
172 172 */
173 173
174 174 /*!
175 175 \property QAbstractAxis::shadesColor
176 176 The fill (brush) color of the axis shades.
177 177 */
178 178 /*!
179 179 \qmlproperty color AbstractAxis::shadesColor
180 180 The fill (brush) color of the axis shades.
181 181 */
182 182
183 183 /*!
184 184 \property QAbstractAxis::shadesBorderColor
185 185 The border (pen) color of the axis shades.
186 186 */
187 187 /*!
188 188 \qmlproperty color AbstractAxis::shadesBorderColor
189 189 The border (pen) color of the axis shades.
190 190 */
191 191
192 192 /*!
193 193 \property QAbstractAxis::shadesPen
194 194 The pen of the axis shades (area between grid lines).
195 195 */
196 196
197 197 /*!
198 198 \property QAbstractAxis::shadesBrush
199 199 The brush of the axis shades (area between grid lines).
200 200 */
201 201
202 202 /*!
203 203 \property QAbstractAxis::titleVisible
204 204 The visibility of the axis title. By default the value is true.
205 205 */
206 206 /*!
207 207 \qmlproperty bool AbstractAxis::titleVisible
208 208 The visibility of the axis title. By default the value is true.
209 209 */
210 210
211 211 /*!
212 212 \property QAbstractAxis::titleText
213 213 The title of the axis. Empty by default.
214 214 */
215 215 /*!
216 216 \qmlproperty String AbstractAxis::titleText
217 217 The title of the axis. Empty by default.
218 218 */
219 219
220 220 /*!
221 221 \property QAbstractAxis::titlePen
222 222 The pen of the title text.
223 223 */
224 224
225 225 /*!
226 226 \property QAbstractAxis::titleBrush
227 227 The brush of the title text.
228 228 */
229 229
230 230 /*!
231 231 \property QAbstractAxis::titleFont
232 232 The font of the title of the axis.
233 233 */
234 234 /*!
235 235 \qmlproperty Font AbstractAxis::titleFont
236 236 The font of the title of the axis.
237 237 */
238 238
239 239 /*!
240 240 \property QAbstractAxis::orientation
241 241 The orientation of the axis. Fixed to either Qt::Horizontal or Qt::Vertical when you add the axis to a chart.
242 242 */
243 243 /*!
244 244 \qmlproperty Qt.Orientation AbstractAxis::orientation
245 245 The orientation of the axis. Fixed to either Qt.Horizontal or Qt.Vertical when the axis is set to a series.
246 246 */
247 247
248 248 /*!
249 249 \property QAbstractAxis::alignment
250 250 The alignment of the axis. Can be Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.
251 251 */
252 252 /*!
253 253 \qmlproperty alignment AbstractAxis::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 /*!
258 258 \fn void QAbstractAxis::visibleChanged(bool visible)
259 259 Visibility of the axis has changed to \a visible.
260 260 */
261 261 /*!
262 262 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
263 263 Visibility of the axis has changed to \a visible.
264 264 */
265 265
266 266 /*!
267 267 \fn void QAbstractAxis::linePenChanged(const QPen& pen)
268 268 The pen of the line of the axis has changed to \a pen.
269 269 */
270 270
271 271 /*!
272 272 \fn void QAbstractAxis::lineVisibleChanged(bool visible)
273 273 Visibility of the axis line has changed to \a visible.
274 274 */
275 275 /*!
276 276 \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible)
277 277 Visibility of the axis line has changed to \a visible.
278 278 */
279 279
280 280 /*!
281 281 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
282 282 Visibility of the labels of the axis has changed to \a visible.
283 283 */
284 284 /*!
285 285 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
286 286 Visibility of the labels of the axis has changed to \a visible.
287 287 */
288 288
289 289 /*!
290 290 \fn void QAbstractAxis::labelsFontChanged(const QFont& font)
291 291 The font of the axis labels has changed to \a font.
292 292 */
293 293 /*!
294 294 \qmlsignal AbstractAxis::onLabelsFontChanged(Font font)
295 295 The font of the axis labels has changed to \a font.
296 296 */
297 297
298 298 /*!
299 299 \fn void QAbstractAxis::labelsPenChanged(const QPen& pen)
300 300 The pen of the axis labels has changed to \a pen.
301 301 */
302 302
303 303 /*!
304 304 \fn void QAbstractAxis::labelsBrushChanged(const QBrush& brush)
305 305 The brush of the axis labels has changed to \a brush.
306 306 */
307 307
308 308 /*!
309 309 \fn void QAbstractAxis::labelsAngleChanged(int angle)
310 310 The angle of the axis labels has changed to \a angle.
311 311 */
312 312 /*!
313 313 \qmlsignal AbstractAxis::onLabelsAngleChanged(int angle)
314 314 The angle of the axis labels has changed to \a angle.
315 315 */
316 316
317 317 /*!
318 318 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
319 319 Visibility of the grid lines of the axis has changed to \a visible.
320 320 */
321 321 /*!
322 322 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
323 323 Visibility of the grid lines of the axis has changed to \a visible.
324 324 */
325 325
326 326 /*!
327 327 \fn void QAbstractAxis::gridLinePenChanged(const QPen& pen)
328 328 The pen of the grid line has changed to \a pen.
329 329 */
330 330
331 331 /*!
332 332 \fn void QAbstractAxis::colorChanged(QColor color)
333 333 Emitted if the \a color of the axis is changed.
334 334 */
335 335 /*!
336 336 \qmlsignal AbstractAxis::onColorChanged(QColor color)
337 337 Emitted if the \a color of the axis is changed.
338 338 */
339 339
340 340 /*!
341 341 \fn void QAbstractAxis::labelsColorChanged(QColor color)
342 342 Emitted if the \a color of the axis labels is changed.
343 343 */
344 344 /*!
345 345 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
346 346 Emitted if the \a color of the axis labels is changed.
347 347 */
348 348
349 349 /*!
350 350 \fn void QAbstractAxis::titleVisibleChanged(bool visible)
351 351 Visibility of the title text of the axis has changed to \a visible.
352 352 */
353 353 /*!
354 354 \qmlsignal AbstractAxis::onTitleVisibleChanged(bool visible)
355 355 Visibility of the title text of the axis has changed to \a visible.
356 356 */
357 357
358 358 /*!
359 359 \fn void QAbstractAxis::titleTextChanged(const QString& text)
360 360 The text of the axis title has changed to \a text.
361 361 */
362 362 /*!
363 363 \qmlsignal AbstractAxis::onTitleTextChanged(String text)
364 364 The text of the axis title has changed to \a text.
365 365 */
366 366
367 367 /*!
368 368 \fn void QAbstractAxis::titlePenChanged(const QPen& pen)
369 369 The pen of the axis shades has changed to \a pen.
370 370 */
371 371
372 372 /*!
373 373 \fn void QAbstractAxis::titleBrushChanged(const QBrush& brush)
374 374 The brush of the axis title has changed to \a brush.
375 375 */
376 376
377 377 /*!
378 378 \fn void QAbstractAxis::titleFontChanged(const QFont& font)
379 379 The font of the axis title has changed to \a font.
380 380 */
381 381 /*!
382 382 \qmlsignal AbstractAxis::onTitleFontChanged(Font font)
383 383 The font of the axis title has changed to \a font.
384 384 */
385 385
386 386 /*!
387 387 \fn void QAbstractAxis::shadesVisibleChanged(bool)
388 388 Emitted if the visibility of the axis shades is changed to \a visible.
389 389 */
390 390 /*!
391 391 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
392 392 Emitted if the visibility of the axis shades is changed to \a visible.
393 393 */
394 394
395 395 /*!
396 396 \fn void QAbstractAxis::shadesColorChanged(QColor color)
397 397 Emitted if the \a color of the axis shades is changed.
398 398 */
399 399 /*!
400 400 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
401 401 Emitted if the \a color of the axis shades is changed.
402 402 */
403 403
404 404 /*!
405 405 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
406 406 Emitted if the border \a color of the axis shades is changed.
407 407 */
408 408 /*!
409 409 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
410 410 Emitted if the border \a color of the axis shades is changed.
411 411 */
412 412
413 413 /*!
414 414 \fn void QAbstractAxis::shadesBrushChanged(const QBrush& brush)
415 415 The brush of the axis shades has changed to \a brush.
416 416 */
417 417
418 418 /*!
419 419 \fn void QAbstractAxis::shadesPenChanged(const QPen& pen)
420 420 The pen of the axis shades has changed to \a pen.
421 421 */
422 422
423 423 /*!
424 424 \internal
425 425 Constructs new axis object which is a child of \a parent. Ownership is taken by
426 426 QChart when axis added.
427 427 */
428 428
429 429 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent)
430 430 : QObject(parent),
431 431 d_ptr(&d)
432 432 {
433 433 }
434 434
435 435 /*!
436 436 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
437 437 */
438 438
439 439 QAbstractAxis::~QAbstractAxis()
440 440 {
441 441 if (d_ptr->m_chart)
442 442 qFatal("Still binded axis detected !");
443 443 }
444 444
445 445 /*!
446 446 Sets \a pen used to draw axis line and ticks.
447 447 */
448 448 void QAbstractAxis::setLinePen(const QPen &pen)
449 449 {
450 450 if (d_ptr->m_axisPen != pen) {
451 451 d_ptr->m_axisPen = pen;
452 452 emit linePenChanged(pen);
453 453 }
454 454 }
455 455
456 456 /*!
457 457 Returns pen used to draw axis and ticks.
458 458 */
459 459 QPen QAbstractAxis::linePen() const
460 460 {
461 461 if (d_ptr->m_axisPen == QChartPrivate::defaultPen())
462 462 return QPen();
463 463 else
464 464 return d_ptr->m_axisPen;
465 465 }
466 466
467 467 //TODO: remove me 2.0
468 468 void QAbstractAxis::setLinePenColor(QColor color)
469 469 {
470 470 QPen p = d_ptr->m_axisPen;
471 471 if (p.color() != color) {
472 472 p.setColor(color);
473 473 setLinePen(p);
474 474 emit colorChanged(color);
475 475 }
476 476 }
477 477
478 478 QColor QAbstractAxis::linePenColor() const
479 479 {
480 480 return linePen().color();
481 481 }
482 482
483 483 /*!
484 484 Sets if axis and ticks are \a visible.
485 485 */
486 486 void QAbstractAxis::setLineVisible(bool visible)
487 487 {
488 488 if (d_ptr->m_arrowVisible != visible) {
489 489 d_ptr->m_arrowVisible = visible;
490 490 emit lineVisibleChanged(visible);
491 491 }
492 492 }
493 493
494 494 bool QAbstractAxis::isLineVisible() const
495 495 {
496 496 return d_ptr->m_arrowVisible;
497 497 }
498 498
499 499 void QAbstractAxis::setGridLineVisible(bool visible)
500 500 {
501 501 if (d_ptr->m_gridLineVisible != visible) {
502 502 d_ptr->m_gridLineVisible = visible;
503 503 emit gridVisibleChanged(visible);
504 504 }
505 505 }
506 506
507 507 bool QAbstractAxis::isGridLineVisible() const
508 508 {
509 509 return d_ptr->m_gridLineVisible;
510 510 }
511 511
512 512 /*!
513 513 Sets \a pen used to draw grid line.
514 514 */
515 515 void QAbstractAxis::setGridLinePen(const QPen &pen)
516 516 {
517 517 if (d_ptr->m_gridLinePen != pen) {
518 518 d_ptr->m_gridLinePen = pen;
519 519 emit gridLinePenChanged(pen);
520 520 }
521 521 }
522 522
523 523 /*!
524 524 Returns pen used to draw grid.
525 525 */
526 526 QPen QAbstractAxis::gridLinePen() const
527 527 {
528 528 if (d_ptr->m_gridLinePen == QChartPrivate::defaultPen())
529 529 return QPen();
530 530 else
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 if (d_ptr->m_labelsPen == QChartPrivate::defaultPen())
564 564 return QPen();
565 565 else
566 566 return d_ptr->m_labelsPen;
567 567 }
568 568
569 569 /*!
570 570 Sets \a brush used to draw labels.
571 571 */
572 572 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
573 573 {
574 574 if (d_ptr->m_labelsBrush != brush) {
575 575 d_ptr->m_labelsBrush = brush;
576 576 emit labelsBrushChanged(brush);
577 577 }
578 578 }
579 579
580 580 /*!
581 581 Returns brush used to draw labels.
582 582 */
583 583 QBrush QAbstractAxis::labelsBrush() const
584 584 {
585 585 if (d_ptr->m_labelsBrush == QChartPrivate::defaultBrush())
586 586 return QBrush();
587 587 else
588 588 return d_ptr->m_labelsBrush;
589 589 }
590 590
591 591 /*!
592 592 Sets \a font used to draw labels.
593 593 */
594 594 void QAbstractAxis::setLabelsFont(const QFont &font)
595 595 {
596 596 if (d_ptr->m_labelsFont != font) {
597 597 d_ptr->m_labelsFont = font;
598 598 emit labelsFontChanged(font);
599 599 }
600 600 }
601 601
602 602 /*!
603 603 Returns font used to draw labels.
604 604 */
605 605 QFont QAbstractAxis::labelsFont() const
606 606 {
607 607 if (d_ptr->m_labelsFont == QChartPrivate::defaultFont())
608 608 return QFont();
609 609 else
610 610 return d_ptr->m_labelsFont;
611 611 }
612 612
613 613 void QAbstractAxis::setLabelsAngle(int angle)
614 614 {
615 615 if (d_ptr->m_labelsAngle != angle) {
616 616 d_ptr->m_labelsAngle = angle;
617 617 emit labelsAngleChanged(angle);
618 618 }
619 619 }
620 620
621 621 int QAbstractAxis::labelsAngle() const
622 622 {
623 623 return d_ptr->m_labelsAngle;
624 624 }
625 625 //TODO: remove me 2.0
626 626 void QAbstractAxis::setLabelsColor(QColor color)
627 627 {
628 628 QBrush b = d_ptr->m_labelsBrush;
629 629 if (b.color() != color) {
630 630 b.setColor(color);
631 631 setLabelsBrush(b);
632 632 emit labelsColorChanged(color);
633 633 }
634 634 }
635 635
636 636 QColor QAbstractAxis::labelsColor() const
637 637 {
638 638 return labelsBrush().color();
639 639 }
640 640
641 641 void QAbstractAxis::setTitleVisible(bool visible)
642 642 {
643 643 if (d_ptr->m_titleVisible != visible) {
644 644 d_ptr->m_titleVisible = visible;
645 645 emit titleVisibleChanged(visible);
646 646 }
647 647 }
648 648
649 649 bool QAbstractAxis::isTitleVisible() const
650 650 {
651 651 return d_ptr->m_titleVisible;
652 652 }
653 653
654 654 /*!
655 655 Sets \a pen used to draw title.
656 656 */
657 657 void QAbstractAxis::setTitlePen(const QPen &pen)
658 658 {
659 659 if (d_ptr->m_titlePen != pen) {
660 660 d_ptr->m_titlePen = pen;
661 661 emit titlePenChanged(pen);
662 662 }
663 663 }
664 664
665 665 /*!
666 666 Returns the pen used to title.
667 667 */
668 668 QPen QAbstractAxis::titlePen() const
669 669 {
670 670 if (d_ptr->m_titlePen == QChartPrivate::defaultPen())
671 671 return QPen();
672 672 else
673 673 return d_ptr->m_titlePen;
674 674 }
675 675
676 676 /*!
677 677 Sets \a brush used to draw title.
678 678 */
679 679 void QAbstractAxis::setTitleBrush(const QBrush &brush)
680 680 {
681 681 if (d_ptr->m_titleBrush != brush) {
682 682 d_ptr->m_titleBrush = brush;
683 683 emit titleBrushChanged(brush);
684 684 }
685 685 }
686 686
687 687 /*!
688 688 Returns brush used to draw title.
689 689 */
690 690 QBrush QAbstractAxis::titleBrush() const
691 691 {
692 692 if (d_ptr->m_titleBrush == QChartPrivate::defaultBrush())
693 693 return QBrush();
694 694 else
695 695 return d_ptr->m_titleBrush;
696 696 }
697 697
698 698 /*!
699 699 Sets \a font used to draw title.
700 700 */
701 701 void QAbstractAxis::setTitleFont(const QFont &font)
702 702 {
703 703 if (d_ptr->m_titleFont != font) {
704 704 d_ptr->m_titleFont = font;
705 705 emit titleFontChanged(font);
706 706 }
707 707 }
708 708
709 709 /*!
710 710 Returns font used to draw title.
711 711 */
712 712 QFont QAbstractAxis::titleFont() const
713 713 {
714 714 if (d_ptr->m_titleFont == QChartPrivate::defaultFont())
715 715 return QFont();
716 716 else
717 717 return d_ptr->m_titleFont;
718 718 }
719 719
720 720 void QAbstractAxis::setTitleText(const QString &title)
721 721 {
722 722 if (d_ptr->m_title != title) {
723 723 d_ptr->m_title = title;
724 724 emit titleTextChanged(title);
725 725 }
726 726 }
727 727
728 728 QString QAbstractAxis::titleText() const
729 729 {
730 730 return d_ptr->m_title;
731 731 }
732 732
733 733
734 734 void QAbstractAxis::setShadesVisible(bool visible)
735 735 {
736 736 if (d_ptr->m_shadesVisible != visible) {
737 737 d_ptr->m_shadesVisible = visible;
738 738 emit shadesVisibleChanged(visible);
739 739 }
740 740 }
741 741
742 742 bool QAbstractAxis::shadesVisible() const
743 743 {
744 744 return d_ptr->m_shadesVisible;
745 745 }
746 746
747 747 /*!
748 748 Sets \a pen used to draw shades.
749 749 */
750 750 void QAbstractAxis::setShadesPen(const QPen &pen)
751 751 {
752 752 if (d_ptr->m_shadesPen != pen) {
753 753 d_ptr->m_shadesPen = pen;
754 754 emit shadesPenChanged(pen);
755 755 }
756 756 }
757 757
758 758 /*!
759 759 Returns pen used to draw shades.
760 760 */
761 761 QPen QAbstractAxis::shadesPen() const
762 762 {
763 763 if (d_ptr->m_shadesPen == QChartPrivate::defaultPen())
764 764 return QPen();
765 765 else
766 766 return d_ptr->m_shadesPen;
767 767 }
768 768
769 769 /*!
770 770 Sets \a brush used to draw shades.
771 771 */
772 772 void QAbstractAxis::setShadesBrush(const QBrush &brush)
773 773 {
774 774 if (d_ptr->m_shadesBrush != brush) {
775 775 d_ptr->m_shadesBrush = brush;
776 776 emit shadesBrushChanged(brush);
777 777 }
778 778 }
779 779
780 780 /*!
781 781 Returns brush used to draw shades.
782 782 */
783 783 QBrush QAbstractAxis::shadesBrush() const
784 784 {
785 785 if (d_ptr->m_shadesBrush == QChartPrivate::defaultBrush())
786 786 return QBrush(Qt::SolidPattern);
787 787 else
788 788 return d_ptr->m_shadesBrush;
789 789 }
790 790
791 791 void QAbstractAxis::setShadesColor(QColor color)
792 792 {
793 793 QBrush b = d_ptr->m_shadesBrush;
794 794 if (b.color() != color) {
795 795 b.setColor(color);
796 796 setShadesBrush(b);
797 797 emit shadesColorChanged(color);
798 798 }
799 799 }
800 800
801 801 QColor QAbstractAxis::shadesColor() const
802 802 {
803 803 return shadesBrush().color();
804 804 }
805 805
806 806 void QAbstractAxis::setShadesBorderColor(QColor color)
807 807 {
808 808 QPen p = d_ptr->m_shadesPen;
809 809 if (p.color() != color) {
810 810 p.setColor(color);
811 811 setShadesPen(p);
812 812 emit shadesColorChanged(color);
813 813 }
814 814 }
815 815
816 816 QColor QAbstractAxis::shadesBorderColor() const
817 817 {
818 818 return shadesPen().color();
819 819 }
820 820
821 821
822 822 bool QAbstractAxis::isVisible() const
823 823 {
824 824 return d_ptr->m_visible;
825 825 }
826 826
827 827 /*!
828 828 Sets axis, shades, labels and grid lines to be visible.
829 829 */
830 830 void QAbstractAxis::setVisible(bool visible)
831 831 {
832 832 if (d_ptr->m_visible != visible) {
833 833 d_ptr->m_visible = visible;
834 834 emit visibleChanged(visible);
835 835 }
836 836 }
837 837
838 838
839 839 /*!
840 840 Sets axis, shades, labels and grid lines to be visible.
841 841 */
842 842 void QAbstractAxis::show()
843 843 {
844 844 setVisible(true);
845 845 }
846 846
847 847 /*!
848 848 Sets axis, shades, labels and grid lines to not be visible.
849 849 */
850 850 void QAbstractAxis::hide()
851 851 {
852 852 setVisible(false);
853 853 }
854 854
855 855 /*!
856 856 Sets the minimum value shown on the axis.
857 857 Depending on the actual axis type the \a min parameter is converted to appropriate type.
858 858 If the conversion is impossible then the function call does nothing
859 859 */
860 860 void QAbstractAxis::setMin(const QVariant &min)
861 861 {
862 862 d_ptr->setMin(min);
863 863 }
864 864
865 865 /*!
866 866 Sets the maximum value shown on the axis.
867 867 Depending on the actual axis type the \a max parameter is converted to appropriate type.
868 868 If the conversion is impossible then the function call does nothing
869 869 */
870 870 void QAbstractAxis::setMax(const QVariant &max)
871 871 {
872 872 d_ptr->setMax(max);
873 873 }
874 874
875 875 /*!
876 876 Sets the range shown on the axis.
877 877 Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types.
878 878 If the conversion is impossible then the function call does nothing.
879 879 */
880 880 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
881 881 {
882 882 d_ptr->setRange(min, max);
883 883 }
884 884
885 885
886 886 /*!
887 887 Returns the orientation in which the axis is being used (Vertical or Horizontal)
888 888 */
889 889 // NOTE: should have const but it breaks BC:
890 890 // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function
891 891 Qt::Orientation QAbstractAxis::orientation()
892 892 {
893 893 return d_ptr->orientation();
894 894 }
895 895
896 896 Qt::Alignment QAbstractAxis::alignment() const
897 897 {
898 898 return d_ptr->alignment();
899 899 }
900 900
901 901 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
902 902
903 903 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
904 904 : q_ptr(q),
905 905 m_chart(0),
906 906 m_alignment(0),
907 907 m_orientation(Qt::Orientation(0)),
908 908 m_visible(true),
909 909 m_arrowVisible(true),
910 910 m_axisPen(QChartPrivate::defaultPen()),
911 911 m_axisBrush(QChartPrivate::defaultBrush()),
912 912 m_gridLineVisible(true),
913 913 m_gridLinePen(QChartPrivate::defaultPen()),
914 914 m_labelsVisible(true),
915 915 m_labelsPen(QChartPrivate::defaultPen()),
916 916 m_labelsBrush(QChartPrivate::defaultBrush()),
917 917 m_labelsFont(QChartPrivate::defaultFont()),
918 918 m_labelsAngle(0),
919 919 m_titleVisible(true),
920 920 m_titlePen(QChartPrivate::defaultPen()),
921 921 m_titleBrush(QChartPrivate::defaultBrush()),
922 922 m_titleFont(QChartPrivate::defaultFont()),
923 923 m_shadesVisible(false),
924 m_shadesBrush(QChartPrivate::defaultBrush()),
925 924 m_shadesPen(QChartPrivate::defaultPen()),
925 m_shadesBrush(QChartPrivate::defaultBrush()),
926 926 m_shadesOpacity(1.0),
927 927 m_dirty(false)
928 928 {
929 929 }
930 930
931 931 QAbstractAxisPrivate::~QAbstractAxisPrivate()
932 932 {
933 933 }
934 934
935 935 void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment)
936 936 {
937 937 switch(alignment) {
938 938 case Qt::AlignTop:
939 939 case Qt::AlignBottom:
940 940 m_orientation = Qt::Horizontal;
941 941 break;
942 942 case Qt::AlignLeft:
943 943 case Qt::AlignRight:
944 944 m_orientation = Qt::Vertical;
945 945 break;
946 946 default:
947 947 qWarning()<<"No alignment specified !";
948 948 break;
949 949 };
950 950 m_alignment=alignment;
951 951 }
952 952
953 953 void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced)
954 954 {
955 955 //TODO: introduce axis brush
956 956 if (forced || QChartPrivate::defaultPen() == m_axisPen)
957 957 q_ptr->setLinePen(theme->axisLinePen());
958 958
959 959 if (forced || QChartPrivate::defaultPen() == m_gridLinePen)
960 960 q_ptr->setGridLinePen(theme->girdLinePen());
961 961
962 962 if (forced || QChartPrivate::defaultBrush() == m_labelsBrush)
963 963 q_ptr->setLabelsBrush(theme->labelBrush());
964 964 if (forced || QChartPrivate::defaultPen() == m_labelsPen)
965 965 q_ptr->setLabelsPen(Qt::NoPen); // NoPen for performance reasons
966 966 if (forced || QChartPrivate::defaultFont() == m_labelsFont)
967 967 q_ptr->setLabelsFont(theme->labelFont());
968 968
969 969 if (forced || QChartPrivate::defaultBrush() == m_titleBrush)
970 970 q_ptr->setTitleBrush(theme->labelBrush());
971 971 if (forced || QChartPrivate::defaultPen() == m_titlePen)
972 972 q_ptr->setTitlePen(Qt::NoPen); // NoPen for performance reasons
973 973 if (forced || QChartPrivate::defaultFont() == m_titleFont) {
974 974 QFont font(m_labelsFont);
975 975 font.setBold(true);
976 976 q_ptr->setTitleFont(font);
977 977 }
978 978
979 979 if (forced || QChartPrivate::defaultBrush() == m_shadesBrush)
980 980 q_ptr->setShadesBrush(theme->backgroundShadesBrush());
981 981 if (forced || QChartPrivate::defaultPen() == m_shadesPen)
982 982 q_ptr->setShadesPen(theme->backgroundShadesPen());
983 983
984 984 bool axisX = m_orientation == Qt::Horizontal;
985 985 if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth
986 986 || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX)
987 987 || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) {
988 988 q_ptr->setShadesVisible(true);
989 989 } else if (forced) {
990 990 q_ptr->setShadesVisible(false);
991 991 }
992 992 }
993 993
994 994 void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
995 995 {
996 996 setRange(min,max);
997 997 }
998 998
999 999 void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent)
1000 1000 {
1001 1001 Q_UNUSED(parent);
1002 1002 }
1003 1003
1004 1004 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options)
1005 1005 {
1006 1006 ChartAxisElement *axis = m_item.data();
1007 1007 Q_ASSERT(axis);
1008 1008 if (options.testFlag(QChart::GridAxisAnimations)) {
1009 1009 axis->setAnimation(new AxisAnimation(axis));
1010 1010 } else {
1011 1011 axis->setAnimation(0);
1012 1012 }
1013 1013 }
1014 1014
1015 1015
1016 1016
1017 1017 #include "moc_qabstractaxis.cpp"
1018 1018 #include "moc_qabstractaxis_p.cpp"
1019 1019
1020 1020 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,86 +1,91
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 // W A R N I N G
22 22 // -------------
23 23 //
24 24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 25 // implementation detail. This header file may change from version to
26 26 // version without notice, or even be removed.
27 27 //
28 28 // We mean it.
29 29
30 30 #ifndef CHARTCONFIG_H
31 31 #define CHARTCONFIG_H
32 32
33 33 #include "qchartglobal.h"
34 34
35 35 #ifdef Q_CC_MSVC
36 36 // There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
37 37 // This is the case at least with shadow builds.
38 38 // http://qt-project.org/wiki/jom
39 39 #undef DEVELOPMENT_BUILD
40 40 #endif
41 41
42 42 #ifndef DEVELOPMENT_BUILD
43 #ifdef Q_OS_ANDROID
44 // Android builds do not have __DATE__
45 const char *buildTime = __TIME__;
46 #else
43 47 const char *buildTime = __TIME__" "__DATE__;
48 #endif
44 49 const char *gitHead = "unknown";
45 50 #else
46 51 #include "qchartversion_p.h"
47 52 #endif
48 53
49 54 QTCOMMERCIALCHART_BEGIN_NAMESPACE
50 55
51 56 class ChartConfig
52 57 {
53 58 private:
54 59 ChartConfig() {
55 60 #if defined(DEVELOPMENT_BUILD) && !defined(QT_NO_DEBUG)
56 61 qDebug() << "buildTime" << buildTime;
57 62 qDebug() << "gitHead" << gitHead;
58 63 #endif
59 64 m_instance = this;
60 65 }
61 66 public:
62 67 static ChartConfig *instance() {
63 68 if (!m_instance) {
64 69 m_instance = new ChartConfig();
65 70 }
66 71 return m_instance;
67 72 }
68 73
69 74 QString compilationTime() {
70 75 return QString(buildTime);
71 76 }
72 77
73 78 QString compilationHead() {
74 79 return QString(gitHead);
75 80 }
76 81
77 82 private:
78 83 static ChartConfig *m_instance;
79 84 };
80 85
81 86
82 87 ChartConfig *ChartConfig::m_instance = 0;
83 88
84 89 QTCOMMERCIALCHART_END_NAMESPACE
85 90
86 91 #endif
@@ -1,91 +1,91
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 // W A R N I N G
22 22 // -------------
23 23 //
24 24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 25 // implementation detail. This header file may change from version to
26 26 // version without notice, or even be removed.
27 27 //
28 28 // We mean it.
29 29
30 30 #ifndef CHARTTHEME_H
31 31 #define CHARTTHEME_H
32 32
33 33 #include "chartthememanager_p.h"
34 34 #include <QColor>
35 35 #include <QGradientStops>
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 39 class ChartTheme
40 40 {
41 41
42 42 public:
43 43 enum BackgroundShadesMode {
44 44 BackgroundShadesNone = 0,
45 45 BackgroundShadesVertical,
46 46 BackgroundShadesHorizontal,
47 47 BackgroundShadesBoth
48 48 };
49 49
50 50 protected:
51 51 explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeLight):m_id(id),
52 m_backgroundShades(BackgroundShadesNone),
53 52 m_backgroundShadesBrush(Qt::SolidPattern),
53 m_backgroundShades(BackgroundShadesNone),
54 54 m_backgroundDropShadowEnabled(false)
55 55 {};
56 56 public:
57 57 QChart::ChartTheme id() const { return m_id; }
58 58 QList<QGradient> seriesGradients() const { return m_seriesGradients; }
59 59 QList<QColor> seriesColors() const { return m_seriesColors; }
60 60 QLinearGradient chartBackgroundGradient() const { return m_chartBackgroundGradient; }
61 61 QFont masterFont() const { return m_masterFont; }
62 62 QFont labelFont() const { return m_labelFont; }
63 63 QBrush labelBrush() const { return m_labelBrush; }
64 64 QPen axisLinePen() const { return m_axisLinePen; }
65 65 QPen backgroundShadesPen() const { return m_backgroundShadesPen; }
66 66 QBrush backgroundShadesBrush() const { return m_backgroundShadesBrush; }
67 67 BackgroundShadesMode backgroundShades() const { return m_backgroundShades; }
68 68 bool isBackgroundDropShadowEnabled() const { return m_backgroundDropShadowEnabled; }
69 69 QPen girdLinePen() const { return m_gridLinePen; }
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 QBrush m_backgroundShadesBrush;
83 83 BackgroundShadesMode m_backgroundShades;
84 84 bool m_backgroundDropShadowEnabled;
85 85 QPen m_gridLinePen;
86 86
87 87 };
88 88
89 89 QTCOMMERCIALCHART_END_NAMESPACE
90 90
91 91 #endif // CHARTTHEME_H
@@ -1,1199 +1,1199
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 "mainwindow.h"
22 22 #include "chartview.h"
23 23 #include <QScatterSeries>
24 24 #include <QLineSeries>
25 25 #include <QSplineSeries>
26 26 #include <QAreaSeries>
27 27 #include <QBarSeries>
28 28 #include <QBarSet>
29 29 #include <QValueAxis>
30 30 #include <QLogValueAxis>
31 31 #include <QDateTimeAxis>
32 32 #include <QCategoryAxis>
33 33 #include <QPolarChart>
34 34 #include <QDebug>
35 35 #include <qmath.h>
36 36 #include <QDateTime>
37 37
38 38 QTCOMMERCIALCHART_USE_NAMESPACE
39 39 #include "ui_mainwindow.h"
40 40
41 41 MainWindow::MainWindow(QWidget *parent) :
42 42 QMainWindow(parent),
43 43 ui(new Ui::MainWindow),
44 44 m_angularTickCount(9),
45 45 m_radialTickCount(11),
46 46 m_labelsAngle(0),
47 47 m_angularMin(0.0),
48 48 m_angularMax(40000.0),
49 49 m_radialMin(0.0),
50 50 m_radialMax(30000.0),
51 51 m_angularShadesVisible(false),
52 52 m_radialShadesVisible(false),
53 53 m_labelsVisible(true),
54 54 m_titleVisible(true),
55 55 m_gridVisible(true),
56 56 m_arrowVisible(true),
57 57 m_angularShadesBrush(new QBrush(Qt::NoBrush)),
58 58 m_radialShadesBrush(new QBrush(Qt::NoBrush)),
59 59 m_labelBrush(new QBrush(Qt::black)),
60 60 m_titleBrush(new QBrush(Qt::black)),
61 61 m_backgroundBrush(new QBrush(Qt::white)),
62 62 m_plotAreaBackgroundBrush(new QBrush(Qt::NoBrush)),
63 63 m_angularShadesPen(new QPen(Qt::NoPen)),
64 64 m_radialShadesPen(new QPen(Qt::NoPen)),
65 65 m_labelPen(new QPen(Qt::NoPen)),
66 66 m_titlePen(new QPen(Qt::NoPen)),
67 67 m_gridPen(new QPen(QRgb(0x010101))), // Note: Pure black is default color, so it gets overridden by
68 68 m_arrowPen(new QPen(QRgb(0x010101))), // default theme if set to that initially. This is an example of workaround.
69 69 m_backgroundPen(new QPen(Qt::NoPen)),
70 70 m_plotAreaBackgroundPen(new QPen(Qt::NoPen)),
71 71 m_labelFormat(QString("%.2f")),
72 72 m_animationOptions(QChart::NoAnimation),
73 73 m_angularTitle(QString("Angular Title")),
74 74 m_radialTitle(QString("Radial Title")),
75 75 m_base(2.0),
76 m_dateFormat(QString("mm-ss-zzz")),
76 77 m_chart(0),
77 78 m_angularAxis(0),
78 79 m_radialAxis(0),
79 80 m_angularAxisMode(AxisModeNone),
80 81 m_radialAxisMode(AxisModeNone),
82 m_moreCategories(false),
81 83 m_series1(0),
82 84 m_series2(0),
83 85 m_series3(0),
84 86 m_series4(0),
85 87 m_series5(0),
86 88 m_series6(0),
87 m_series7(0),
88 m_dateFormat(QString("mm-ss-zzz")),
89 m_moreCategories(false)
89 m_series7(0)
90 90 {
91 91 ui->setupUi(this);
92 92
93 93 ui->angularTicksSpin->setValue(m_angularTickCount);
94 94 ui->radialTicksSpin->setValue(m_radialTickCount);
95 95 ui->anglesSpin->setValue(m_labelsAngle);
96 96 ui->radialMinSpin->setValue(m_radialMin);
97 97 ui->radialMaxSpin->setValue(m_radialMax);
98 98 ui->angularMinSpin->setValue(m_angularMin);
99 99 ui->angularMaxSpin->setValue(m_angularMax);
100 100 ui->angularShadesComboBox->setCurrentIndex(0);
101 101 ui->radialShadesComboBox->setCurrentIndex(0);
102 102 ui->labelFormatEdit->setText(m_labelFormat);
103 103 ui->dateFormatEdit->setText(m_dateFormat);
104 104 ui->moreCategoriesCheckBox->setChecked(m_moreCategories);
105 105
106 106 ui->series1checkBox->setChecked(true);
107 107 ui->series2checkBox->setChecked(true);
108 108 ui->series3checkBox->setChecked(true);
109 109 ui->series4checkBox->setChecked(true);
110 110 ui->series5checkBox->setChecked(true);
111 111 ui->series6checkBox->setChecked(true);
112 112 ui->series7checkBox->setChecked(true);
113 113
114 114 m_currentLabelFont.setFamily(ui->labelFontComboBox->currentFont().family());
115 115 m_currentLabelFont.setPixelSize(15);
116 116 m_currentTitleFont.setFamily(ui->titleFontComboBox->currentFont().family());
117 117 m_currentTitleFont.setPixelSize(30);
118 118
119 119 ui->labelFontSizeSpin->setValue(m_currentLabelFont.pixelSize());
120 120 ui->titleFontSizeSpin->setValue(m_currentTitleFont.pixelSize());
121 121
122 122 ui->logBaseSpin->setValue(m_base);
123 123
124 124 initXYValueChart();
125 125 setAngularAxis(AxisModeValue);
126 126 setRadialAxis(AxisModeValue);
127 127
128 128 ui->angularAxisComboBox->setCurrentIndex(int(m_angularAxisMode));
129 129 ui->radialAxisComboBox->setCurrentIndex(int(m_radialAxisMode));
130 130
131 131 connect(ui->angularTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(angularTicksChanged(int)));
132 132 connect(ui->radialTicksSpin, SIGNAL(valueChanged(int)), this, SLOT(radialTicksChanged(int)));
133 133 connect(ui->anglesSpin, SIGNAL(valueChanged(int)), this, SLOT(anglesChanged(int)));
134 134 connect(ui->radialMinSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMinChanged(double)));
135 135 connect(ui->radialMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(radialMaxChanged(double)));
136 136 connect(ui->angularMinSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMinChanged(double)));
137 137 connect(ui->angularMaxSpin, SIGNAL(valueChanged(double)), this, SLOT(angularMaxChanged(double)));
138 138 connect(ui->angularShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularShadesIndexChanged(int)));
139 139 connect(ui->radialShadesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialShadesIndexChanged(int)));
140 140 connect(ui->animationsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(animationIndexChanged(int)));
141 141 connect(ui->labelFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(labelFormatEdited(QString)));
142 142 connect(ui->labelFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(labelFontChanged(QFont)));
143 143 connect(ui->labelFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(labelFontSizeChanged(int)));
144 144 connect(ui->labelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(labelsIndexChanged(int)));
145 145 connect(ui->titleFontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(titleFontChanged(QFont)));
146 146 connect(ui->titleFontSizeSpin, SIGNAL(valueChanged(int)), this, SLOT(titleFontSizeChanged(int)));
147 147 connect(ui->titleComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(titleIndexChanged(int)));
148 148 connect(ui->gridComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(gridIndexChanged(int)));
149 149 connect(ui->arrowComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(arrowIndexChanged(int)));
150 150 connect(ui->logBaseSpin, SIGNAL(valueChanged(double)), this, SLOT(logBaseChanged(double)));
151 151 connect(ui->angularAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(angularAxisIndexChanged(int)));
152 152 connect(ui->radialAxisComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(radialAxisIndexChanged(int)));
153 153 connect(ui->niceNumbersCheckBox, SIGNAL(clicked()), this, SLOT(niceNumbersChecked()));
154 154 connect(ui->dateFormatEdit, SIGNAL(textEdited(QString)), this, SLOT(dateFormatEdited(QString)));
155 155 connect(ui->moreCategoriesCheckBox, SIGNAL(clicked()), this, SLOT(moreCategoriesChecked()));
156 156 connect(ui->series1checkBox, SIGNAL(clicked()), this, SLOT(series1CheckBoxChecked()));
157 157 connect(ui->series2checkBox, SIGNAL(clicked()), this, SLOT(series2CheckBoxChecked()));
158 158 connect(ui->series3checkBox, SIGNAL(clicked()), this, SLOT(series3CheckBoxChecked()));
159 159 connect(ui->series4checkBox, SIGNAL(clicked()), this, SLOT(series4CheckBoxChecked()));
160 160 connect(ui->series5checkBox, SIGNAL(clicked()), this, SLOT(series5CheckBoxChecked()));
161 161 connect(ui->series6checkBox, SIGNAL(clicked()), this, SLOT(series6CheckBoxChecked()));
162 162 connect(ui->series7checkBox, SIGNAL(clicked()), this, SLOT(series7CheckBoxChecked()));
163 163 connect(ui->themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(themeIndexChanged(int)));
164 164 connect(ui->backgroundComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(backgroundIndexChanged(int)));
165 165 connect(ui->plotAreaComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(plotAreaIndexChanged(int)));
166 166
167 167 ui->chartView->setChart(m_chart);
168 168 ui->chartView->setRenderHint(QPainter::Antialiasing);
169 169 }
170 170
171 171 MainWindow::~MainWindow()
172 172 {
173 173 delete ui;
174 174 delete m_angularShadesBrush;
175 175 delete m_radialShadesBrush;
176 176 delete m_angularShadesPen;
177 177 delete m_radialShadesPen;
178 178 }
179 179
180 180 void MainWindow::initXYValueChart()
181 181 {
182 182 qreal seriesAngularMin = 1;
183 183 qreal seriesAngularMax = 46000;
184 184 qreal seriesRadialMin = 1;
185 185 qreal seriesRadialMax = 23500;
186 186 qreal radialDimension = seriesRadialMax - seriesRadialMin;
187 187 qreal angularDimension = seriesAngularMax - seriesAngularMin;
188 188
189 189 // Scatter series, points outside min-max ranges should not be drawn
190 190 m_series1 = new QScatterSeries();
191 191 m_series1->setName("scatter");
192 192 qreal scatterCount = 10;
193 193 qreal scatterAngularStep = angularDimension / scatterCount;
194 194 qreal scatterRadialStep = radialDimension / scatterCount;
195 195 for (qreal i = 0.0; i < scatterCount; i++) {
196 196 m_series1->append((i * scatterAngularStep) + seriesAngularMin, (i * scatterRadialStep) + seriesRadialMin);
197 197 //qDebug() << m_series1->points().last();
198 198 }
199 199 m_series1->setMarkerSize(10);
200 200 *m_series1 << QPointF(50, 50) << QPointF(150, 150) << QPointF(250, 250) << QPointF(350, 350) << QPointF(450, 450);
201 201 *m_series1 << QPointF(1050, 0.50) << QPointF(1150, 0.25) << QPointF(1250, 0.12) << QPointF(1350, 0.075) << QPointF(1450, 0.036);
202 202 *m_series1 << QPointF(0.50, 2000) << QPointF(0.25, 3500) << QPointF(0.12, 5000) << QPointF(0.075, 6500) << QPointF(0.036, 8000);
203 203
204 204 // Line series, points outside min-max ranges should not be drawn,
205 205 // but lines should be properly interpolated at chart edges
206 206 m_series2 = new QLineSeries();
207 207 m_series2->setName("line 1");
208 208 qreal lineCount = 100;
209 209 qreal lineAngularStep = angularDimension / lineCount;
210 210 qreal lineRadialStep = radialDimension / lineCount;
211 211 for (qreal i = 0.0; i < lineCount; i++) {
212 212 m_series2->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin);
213 213 //qDebug() << m_series2->points().last();
214 214 }
215 215 QPen series2Pen = QPen(Qt::blue, 10);
216 216 //series2Pen.setStyle(Qt::DashDotDotLine);
217 217 m_series2->setPen(series2Pen);
218 218
219 219 m_series3 = new QLineSeries();
220 220 m_series3->setName("Area upper");
221 221 lineCount = 87;
222 222 lineAngularStep = angularDimension / lineCount;
223 223 lineRadialStep = radialDimension / lineCount;
224 224 for (qreal i = 1.0; i <= lineCount; i++) {
225 225 m_series3->append((i * lineAngularStep) + seriesAngularMin, (i * lineRadialStep) + seriesRadialMin + 200.0);
226 226 //qDebug() << m_series3->points().last();
227 227 }
228 228
229 229 m_series4 = new QLineSeries();
230 230 m_series4->setName("Area lower");
231 231 lineCount = 89;
232 232 lineAngularStep = angularDimension / lineCount;
233 233 lineRadialStep = radialDimension / lineCount;
234 234 for (qreal i = 1.0; i <= lineCount; i++) {
235 235 m_series4->append((i * lineAngularStep) + seriesAngularMin + 100.0, (i * lineRadialStep) + seriesRadialMin + i * 300.0);
236 236 //qDebug() << m_series4->points().last();
237 237 }
238 238
239 239 m_series5 = new QAreaSeries();
240 240 m_series5->setName("area");
241 241 m_series5->setUpperSeries(m_series3);
242 242 m_series5->setLowerSeries(m_series4);
243 243 m_series5->setOpacity(0.5);
244 244
245 245 m_series6 = new QSplineSeries();
246 246 m_series6->setName("spline");
247 247 qreal ad = angularDimension / 20;
248 248 qreal rd = radialDimension / 10;
249 249 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 2);
250 250 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 5);
251 251 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 4);
252 252 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 9);
253 253 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 11);
254 254 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
255 255 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 9);
256 256 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 11);
257 257 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 12);
258 258 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 6);
259 259 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
260 260 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 8);
261 261 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 9);
262 262 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 11);
263 263 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 12);
264 264 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 6);
265 265 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 3);
266 266 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 2);
267 267 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 6);
268 268 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 6);
269 269 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 6);
270 270 m_series6->append(seriesAngularMin + ad * 20, seriesRadialMin + rd * 6);
271 271 m_series6->append(seriesAngularMin + ad * 19, seriesRadialMin + rd * 2);
272 272 m_series6->append(seriesAngularMin + ad * 18, seriesRadialMin + rd * 9);
273 273 m_series6->append(seriesAngularMin + ad * 17, seriesRadialMin + rd * 7);
274 274 m_series6->append(seriesAngularMin + ad * 16, seriesRadialMin + rd * 3);
275 275 m_series6->append(seriesAngularMin + ad * 15, seriesRadialMin + rd * 1);
276 276 m_series6->append(seriesAngularMin + ad * 14, seriesRadialMin + rd * 7);
277 277 m_series6->append(seriesAngularMin + ad * 13, seriesRadialMin + rd * 5);
278 278 m_series6->append(seriesAngularMin + ad * 12, seriesRadialMin + rd * 9);
279 279 m_series6->append(seriesAngularMin + ad * 11, seriesRadialMin + rd * 1);
280 280 m_series6->append(seriesAngularMin + ad * 10, seriesRadialMin + rd * 4);
281 281 m_series6->append(seriesAngularMin + ad * 9, seriesRadialMin + rd * 1);
282 282 m_series6->append(seriesAngularMin + ad * 8, seriesRadialMin + rd * 2);
283 283 m_series6->append(seriesAngularMin + ad * 7, seriesRadialMin + rd * 4);
284 284 m_series6->append(seriesAngularMin + ad * 6, seriesRadialMin + rd * 8);
285 285 m_series6->append(seriesAngularMin + ad * 5, seriesRadialMin + rd * 12);
286 286 m_series6->append(seriesAngularMin + ad * 4, seriesRadialMin + rd * 9);
287 287 m_series6->append(seriesAngularMin + ad * 3, seriesRadialMin + rd * 8);
288 288 m_series6->append(seriesAngularMin + ad * 2, seriesRadialMin + rd * 7);
289 289 m_series6->append(seriesAngularMin + ad, seriesRadialMin + rd * 4);
290 290 m_series6->append(seriesAngularMin, seriesRadialMin + rd * 10);
291 291
292 292 m_series6->setPointsVisible(true);
293 293 QPen series6Pen = QPen(Qt::red, 10);
294 294 //series6Pen.setStyle(Qt::DashDotDotLine);
295 295 m_series6->setPen(series6Pen);
296 296
297 297 // m_series7 shows points at category intersections
298 298 m_series7 = new QScatterSeries();
299 299 m_series7->setName("Category check");
300 300 m_series7->setMarkerSize(7);
301 301 m_series7->setBrush(QColor(Qt::red));
302 302 m_series7->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
303 303 *m_series7 << QPointF(1000, 1000)
304 304 << QPointF(1000, 2000)
305 305 << QPointF(1000, 4000)
306 306 << QPointF(1000, 9000)
307 307 << QPointF(1000, 14000)
308 308 << QPointF(1000, 16500)
309 309 << QPointF(1000, 19000)
310 310
311 311 << QPointF(4000, 1000)
312 312 << QPointF(4000, 2000)
313 313 << QPointF(4000, 4000)
314 314 << QPointF(4000, 9000)
315 315 << QPointF(4000, 14000)
316 316 << QPointF(4000, 16500)
317 317 << QPointF(4000, 19000)
318 318
319 319 << QPointF(7000, 1000)
320 320 << QPointF(7000, 2000)
321 321 << QPointF(7000, 4000)
322 322 << QPointF(7000, 9000)
323 323 << QPointF(7000, 14000)
324 324 << QPointF(7000, 16500)
325 325 << QPointF(7000, 19000)
326 326
327 327 << QPointF(12000, 1000)
328 328 << QPointF(12000, 2000)
329 329 << QPointF(12000, 4000)
330 330 << QPointF(12000, 9000)
331 331 << QPointF(12000, 14000)
332 332 << QPointF(12000, 16500)
333 333 << QPointF(12000, 19000)
334 334
335 335 << QPointF(17000, 1000)
336 336 << QPointF(17000, 2000)
337 337 << QPointF(17000, 4000)
338 338 << QPointF(17000, 9000)
339 339 << QPointF(17000, 14000)
340 340 << QPointF(17000, 16500)
341 341 << QPointF(17000, 19000)
342 342
343 343 << QPointF(22000, 1000)
344 344 << QPointF(22000, 2000)
345 345 << QPointF(22000, 4000)
346 346 << QPointF(22000, 9000)
347 347 << QPointF(22000, 14000)
348 348 << QPointF(22000, 16500)
349 349 << QPointF(22000, 19000)
350 350
351 351 << QPointF(28000, 1000)
352 352 << QPointF(28000, 2000)
353 353 << QPointF(28000, 4000)
354 354 << QPointF(28000, 9000)
355 355 << QPointF(28000, 14000)
356 356 << QPointF(28000, 16500)
357 357 << QPointF(28000, 19000);
358 358
359 359 m_chart = new QPolarChart();
360 360
361 361 m_chart->addSeries(m_series1);
362 362 m_chart->addSeries(m_series2);
363 363 m_chart->addSeries(m_series3);
364 364 m_chart->addSeries(m_series4);
365 365 m_chart->addSeries(m_series5);
366 366 m_chart->addSeries(m_series6);
367 367 m_chart->addSeries(m_series7);
368 368
369 369 connect(m_series1, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
370 370 connect(m_series2, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
371 371 connect(m_series3, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
372 372 connect(m_series4, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
373 373 connect(m_series5, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
374 374 connect(m_series6, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
375 375 connect(m_series7, SIGNAL(clicked(QPointF)), this, SLOT(seriesClicked(QPointF)));
376 376 connect(m_series1, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
377 377 connect(m_series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
378 378 connect(m_series3, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
379 379 connect(m_series4, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
380 380 connect(m_series5, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
381 381 connect(m_series6, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
382 382 connect(m_series7, SIGNAL(hovered(QPointF, bool)), this, SLOT(seriesHovered(QPointF, bool)));
383 383
384 384 m_chart->setTitle("Use arrow keys to scroll and +/- to zoom");
385 385 m_chart->setAnimationOptions(m_animationOptions);
386 386 //m_chart->legend()->setVisible(false);
387 387 m_chart->setAcceptHoverEvents(true);
388 388 m_chart->setBackgroundBrush(*m_backgroundBrush);
389 389 m_chart->setBackgroundPen(*m_backgroundPen);
390 390 m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
391 391 m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
392 392 }
393 393
394 394 void MainWindow::setAngularAxis(MainWindow::AxisMode mode)
395 395 {
396 396 if (m_angularAxis) {
397 397 m_chart->removeAxis(m_angularAxis);
398 398 delete m_angularAxis;
399 399 m_angularAxis = 0;
400 400 }
401 401
402 402 m_angularAxisMode = mode;
403 403
404 404 switch (m_angularAxisMode) {
405 405 case AxisModeNone:
406 406 return;
407 407 case AxisModeValue:
408 408 m_angularAxis = new QValueAxis();
409 409 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
410 410 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
411 411 break;
412 412 case AxisModeLogValue:
413 413 m_angularAxis = new QLogValueAxis();
414 414 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
415 415 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
416 416 break;
417 417 case AxisModeDateTime:
418 418 m_angularAxis = new QDateTimeAxis();
419 419 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
420 420 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
421 421 break;
422 422 case AxisModeCategory:
423 423 m_angularAxis = new QCategoryAxis();
424 424 applyCategories();
425 425 break;
426 426 default:
427 427 qWarning() << "Unsupported AxisMode";
428 428 break;
429 429 }
430 430
431 431 m_angularAxis->setLabelsAngle(m_labelsAngle);
432 432 m_angularAxis->setLabelsFont(m_currentLabelFont);
433 433 m_angularAxis->setLabelsBrush(*m_labelBrush);
434 434 m_angularAxis->setLabelsPen(*m_labelPen);
435 435 m_angularAxis->setLabelsVisible(m_labelsVisible);
436 436 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
437 437 m_angularAxis->setShadesPen(*m_angularShadesPen);
438 438 m_angularAxis->setShadesVisible(m_angularShadesVisible);
439 439 m_angularAxis->setTitleFont(m_currentTitleFont);
440 440 m_angularAxis->setTitleBrush(*m_titleBrush);
441 441 m_angularAxis->setTitlePen(*m_titlePen);
442 442 m_angularAxis->setTitleVisible(m_titleVisible);
443 443 m_angularAxis->setTitleText(m_angularTitle);
444 444 m_angularAxis->setGridLinePen(*m_gridPen);
445 445 m_angularAxis->setGridLineVisible(m_gridVisible);
446 446 m_angularAxis->setLinePen(*m_arrowPen);
447 447 m_angularAxis->setLineVisible(m_arrowVisible);
448 448
449 449 m_chart->addAxis(m_angularAxis, QPolarChart::PolarOrientationAngular);
450 450
451 451 m_series1->attachAxis(m_angularAxis);
452 452 m_series2->attachAxis(m_angularAxis);
453 453 m_series3->attachAxis(m_angularAxis);
454 454 m_series4->attachAxis(m_angularAxis);
455 455 m_series5->attachAxis(m_angularAxis);
456 456 m_series6->attachAxis(m_angularAxis);
457 457 m_series7->attachAxis(m_angularAxis);
458 458
459 459 applyRanges();
460 460
461 461 //connect(m_angularAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(angularRangeChanged(qreal, qreal)));
462 462 }
463 463
464 464 void MainWindow::setRadialAxis(MainWindow::AxisMode mode)
465 465 {
466 466 if (m_radialAxis) {
467 467 m_chart->removeAxis(m_radialAxis);
468 468 delete m_radialAxis;
469 469 m_radialAxis = 0;
470 470 }
471 471
472 472 m_radialAxisMode = mode;
473 473
474 474 switch (m_radialAxisMode) {
475 475 case AxisModeNone:
476 476 return;
477 477 case AxisModeValue:
478 478 m_radialAxis = new QValueAxis();
479 479 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
480 480 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
481 481 break;
482 482 case AxisModeLogValue:
483 483 m_radialAxis = new QLogValueAxis();
484 484 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
485 485 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
486 486 break;
487 487 case AxisModeDateTime:
488 488 m_radialAxis = new QDateTimeAxis();
489 489 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
490 490 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
491 491 break;
492 492 case AxisModeCategory:
493 493 m_radialAxis = new QCategoryAxis();
494 494 applyCategories();
495 495 break;
496 496 default:
497 497 qWarning() << "Unsupported AxisMode";
498 498 break;
499 499 }
500 500
501 501 m_radialAxis->setLabelsAngle(m_labelsAngle);
502 502 m_radialAxis->setLabelsFont(m_currentLabelFont);
503 503 m_radialAxis->setLabelsBrush(*m_labelBrush);
504 504 m_radialAxis->setLabelsPen(*m_labelPen);
505 505 m_radialAxis->setLabelsVisible(m_labelsVisible);
506 506 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
507 507 m_radialAxis->setShadesPen(*m_radialShadesPen);
508 508 m_radialAxis->setShadesVisible(m_radialShadesVisible);
509 509 m_radialAxis->setTitleFont(m_currentTitleFont);
510 510 m_radialAxis->setTitleBrush(*m_titleBrush);
511 511 m_radialAxis->setTitlePen(*m_titlePen);
512 512 m_radialAxis->setTitleVisible(m_titleVisible);
513 513 m_radialAxis->setTitleText(m_radialTitle);
514 514 m_radialAxis->setGridLinePen(*m_gridPen);
515 515 m_radialAxis->setGridLineVisible(m_gridVisible);
516 516 m_radialAxis->setLinePen(*m_arrowPen);
517 517 m_radialAxis->setLineVisible(m_arrowVisible);
518 518
519 519 m_chart->addAxis(m_radialAxis, QPolarChart::PolarOrientationRadial);
520 520
521 521 m_series1->attachAxis(m_radialAxis);
522 522 m_series2->attachAxis(m_radialAxis);
523 523 m_series3->attachAxis(m_radialAxis);
524 524 m_series4->attachAxis(m_radialAxis);
525 525 m_series5->attachAxis(m_radialAxis);
526 526 m_series6->attachAxis(m_radialAxis);
527 527 m_series7->attachAxis(m_radialAxis);
528 528
529 529 applyRanges();
530 530
531 531 series1CheckBoxChecked();
532 532 series2CheckBoxChecked();
533 533 series3CheckBoxChecked();
534 534 series4CheckBoxChecked();
535 535 series5CheckBoxChecked();
536 536 series6CheckBoxChecked();
537 537 series7CheckBoxChecked();
538 538
539 539 //connect(m_radialAxis, SIGNAL(rangeChanged(qreal, qreal)), this, SLOT(radialRangeChanged(qreal, qreal)));
540 540 }
541 541
542 542 void MainWindow::applyRanges()
543 543 {
544 544 if (ui->niceNumbersCheckBox->isChecked()) {
545 545 if (m_angularAxisMode == AxisModeValue) {
546 546 static_cast<QValueAxis *>(m_angularAxis)->applyNiceNumbers();
547 547 m_angularMin = static_cast<QValueAxis *>(m_angularAxis)->min();
548 548 m_angularMax = static_cast<QValueAxis *>(m_angularAxis)->max();
549 549 m_angularTickCount = static_cast<QValueAxis *>(m_angularAxis)->tickCount();
550 550 }
551 551 if (m_radialAxisMode == AxisModeValue) {
552 552 static_cast<QValueAxis *>(m_radialAxis)->applyNiceNumbers();
553 553 m_radialMin = static_cast<QValueAxis *>(m_radialAxis)->min();
554 554 m_radialMax = static_cast<QValueAxis *>(m_radialAxis)->max();
555 555 m_radialTickCount = static_cast<QValueAxis *>(m_radialAxis)->tickCount();
556 556 }
557 557 }
558 558
559 559 if (m_angularAxis)
560 560 m_angularAxis->setRange(m_angularMin, m_angularMax);
561 561 if (m_radialAxis)
562 562 m_radialAxis->setRange(m_radialMin, m_radialMax);
563 563 }
564 564
565 565 void MainWindow::angularTicksChanged(int value)
566 566 {
567 567 m_angularTickCount = value;
568 568 if (m_angularAxisMode == AxisModeValue)
569 569 static_cast<QValueAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
570 570 else if (m_angularAxisMode == AxisModeDateTime)
571 571 static_cast<QDateTimeAxis *>(m_angularAxis)->setTickCount(m_angularTickCount);
572 572 }
573 573
574 574 void MainWindow::radialTicksChanged(int value)
575 575 {
576 576 m_radialTickCount = value;
577 577 if (m_radialAxisMode == AxisModeValue)
578 578 static_cast<QValueAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
579 579 else if (m_radialAxisMode == AxisModeDateTime)
580 580 static_cast<QDateTimeAxis *>(m_radialAxis)->setTickCount(m_radialTickCount);
581 581 }
582 582
583 583 void MainWindow::anglesChanged(int value)
584 584 {
585 585 m_labelsAngle = value;
586 586 m_radialAxis->setLabelsAngle(m_labelsAngle);
587 587 m_angularAxis->setLabelsAngle(m_labelsAngle);
588 588 }
589 589
590 590 void MainWindow::angularMinChanged(double value)
591 591 {
592 592 m_angularMin = value;
593 593 if (m_angularAxisMode != AxisModeDateTime) {
594 594 m_angularAxis->setMin(m_angularMin);
595 595 } else {
596 596 QDateTime dateTime;
597 597 dateTime.setMSecsSinceEpoch(qint64(m_angularMin));
598 598 m_angularAxis->setMin(dateTime);
599 599 }
600 600 }
601 601
602 602 void MainWindow::angularMaxChanged(double value)
603 603 {
604 604 m_angularMax = value;
605 605 if (m_angularAxisMode != AxisModeDateTime) {
606 606 m_angularAxis->setMax(m_angularMax);
607 607 } else {
608 608 QDateTime dateTime;
609 609 dateTime.setMSecsSinceEpoch(qint64(m_angularMax));
610 610 m_angularAxis->setMax(dateTime);
611 611 }
612 612 }
613 613
614 614 void MainWindow::radialMinChanged(double value)
615 615 {
616 616 m_radialMin = value;
617 617 if (m_radialAxisMode != AxisModeDateTime) {
618 618 m_radialAxis->setMin(m_radialMin);
619 619 } else {
620 620 QDateTime dateTime;
621 621 dateTime.setMSecsSinceEpoch(qint64(m_radialMin));
622 622 m_radialAxis->setMin(dateTime);
623 623 }
624 624 }
625 625
626 626 void MainWindow::radialMaxChanged(double value)
627 627 {
628 628 m_radialMax = value;
629 629 if (m_radialAxisMode != AxisModeDateTime) {
630 630 m_radialAxis->setMax(m_radialMax);
631 631 } else {
632 632 QDateTime dateTime;
633 633 dateTime.setMSecsSinceEpoch(qint64(m_radialMax));
634 634 m_radialAxis->setMax(dateTime);
635 635 }
636 636 }
637 637
638 638 void MainWindow::angularShadesIndexChanged(int index)
639 639 {
640 640 delete m_angularShadesBrush;
641 641 delete m_angularShadesPen;
642 642
643 643 switch (index) {
644 644 case 0:
645 645 m_angularShadesBrush = new QBrush(Qt::NoBrush);
646 646 m_angularShadesPen = new QPen(Qt::NoPen);
647 647 m_angularShadesVisible = false;
648 648 break;
649 649 case 1:
650 650 m_angularShadesBrush = new QBrush(Qt::lightGray);
651 651 m_angularShadesPen = new QPen(Qt::NoPen);
652 652 m_angularShadesVisible = true;
653 653 break;
654 654 case 2:
655 655 m_angularShadesBrush = new QBrush(Qt::yellow);
656 656 m_angularShadesPen = new QPen(Qt::DotLine);
657 657 m_angularShadesPen->setWidth(2);
658 658 m_angularShadesVisible = true;
659 659 break;
660 660 default:
661 661 break;
662 662 }
663 663
664 664 m_angularAxis->setShadesBrush(*m_angularShadesBrush);
665 665 m_angularAxis->setShadesPen(*m_angularShadesPen);
666 666 m_angularAxis->setShadesVisible(m_angularShadesVisible);
667 667 }
668 668
669 669 void MainWindow::radialShadesIndexChanged(int index)
670 670 {
671 671 delete m_radialShadesBrush;
672 672 delete m_radialShadesPen;
673 673
674 674 switch (index) {
675 675 case 0:
676 676 m_radialShadesBrush = new QBrush(Qt::NoBrush);
677 677 m_radialShadesPen = new QPen(Qt::NoPen);
678 678 m_radialShadesVisible = false;
679 679 break;
680 680 case 1:
681 681 m_radialShadesBrush = new QBrush(Qt::green);
682 682 m_radialShadesPen = new QPen(Qt::NoPen);
683 683 m_radialShadesVisible = true;
684 684 break;
685 685 case 2:
686 686 m_radialShadesBrush = new QBrush(Qt::blue);
687 687 m_radialShadesPen = new QPen(Qt::DotLine);
688 688 m_radialShadesPen->setWidth(2);
689 689 m_radialShadesVisible = true;
690 690 break;
691 691 default:
692 692 break;
693 693 }
694 694
695 695 m_radialAxis->setShadesBrush(*m_radialShadesBrush);
696 696 m_radialAxis->setShadesPen(*m_radialShadesPen);
697 697 m_radialAxis->setShadesVisible(m_radialShadesVisible);
698 698 }
699 699
700 700 void MainWindow::labelFormatEdited(const QString &text)
701 701 {
702 702 m_labelFormat = text;
703 703 if (m_angularAxisMode == AxisModeValue)
704 704 static_cast<QValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
705 705 else if (m_angularAxisMode == AxisModeLogValue)
706 706 static_cast<QLogValueAxis *>(m_angularAxis)->setLabelFormat(m_labelFormat);
707 707
708 708 if (m_radialAxisMode == AxisModeValue)
709 709 static_cast<QValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
710 710 else if (m_radialAxisMode == AxisModeLogValue)
711 711 static_cast<QLogValueAxis *>(m_radialAxis)->setLabelFormat(m_labelFormat);
712 712 }
713 713
714 714 void MainWindow::labelFontChanged(const QFont &font)
715 715 {
716 716 m_currentLabelFont = font;
717 717 m_currentLabelFont.setPixelSize(ui->labelFontSizeSpin->value());
718 718 m_angularAxis->setLabelsFont(m_currentLabelFont);
719 719 m_radialAxis->setLabelsFont(m_currentLabelFont);
720 720 }
721 721
722 722 void MainWindow::labelFontSizeChanged(int value)
723 723 {
724 724 m_currentLabelFont = ui->labelFontComboBox->currentFont();
725 725 m_currentLabelFont.setPixelSize(value);
726 726 m_angularAxis->setLabelsFont(m_currentLabelFont);
727 727 m_radialAxis->setLabelsFont(m_currentLabelFont);
728 728 }
729 729
730 730 void MainWindow::animationIndexChanged(int index)
731 731 {
732 732 switch (index) {
733 733 case 0:
734 734 m_animationOptions = QChart::NoAnimation;
735 735 break;
736 736 case 1:
737 737 m_animationOptions = QChart::SeriesAnimations;
738 738 break;
739 739 case 2:
740 740 m_animationOptions = QChart::GridAxisAnimations;
741 741 break;
742 742 case 3:
743 743 m_animationOptions = QChart::AllAnimations;
744 744 break;
745 745 default:
746 746 break;
747 747 }
748 748
749 749 m_chart->setAnimationOptions(m_animationOptions);
750 750 }
751 751
752 752 void MainWindow::labelsIndexChanged(int index)
753 753 {
754 754 delete m_labelBrush;
755 755 delete m_labelPen;
756 756
757 757 switch (index) {
758 758 case 0:
759 759 m_labelBrush = new QBrush(Qt::NoBrush);
760 760 m_labelPen = new QPen(Qt::NoPen);
761 761 m_labelsVisible = false;
762 762 break;
763 763 case 1:
764 764 m_labelBrush = new QBrush(Qt::black);
765 765 m_labelPen = new QPen(Qt::NoPen);
766 766 m_labelsVisible = true;
767 767 break;
768 768 case 2:
769 769 m_labelBrush = new QBrush(Qt::white);
770 770 m_labelPen = new QPen(Qt::blue);
771 771 m_labelsVisible = true;
772 772 break;
773 773 default:
774 774 break;
775 775 }
776 776
777 777 m_radialAxis->setLabelsBrush(*m_labelBrush);
778 778 m_radialAxis->setLabelsPen(*m_labelPen);
779 779 m_radialAxis->setLabelsVisible(m_labelsVisible);
780 780 m_angularAxis->setLabelsBrush(*m_labelBrush);
781 781 m_angularAxis->setLabelsPen(*m_labelPen);
782 782 m_angularAxis->setLabelsVisible(m_labelsVisible);
783 783 }
784 784
785 785 void MainWindow::titleIndexChanged(int index)
786 786 {
787 787 delete m_titleBrush;
788 788 delete m_titlePen;
789 789
790 790 switch (index) {
791 791 case 0:
792 792 m_titleBrush = new QBrush(Qt::NoBrush);
793 793 m_titlePen = new QPen(Qt::NoPen);
794 794 m_titleVisible = false;
795 795 m_angularTitle = QString();
796 796 m_radialTitle = QString();
797 797 break;
798 798 case 1:
799 799 m_titleBrush = new QBrush(Qt::NoBrush);
800 800 m_titlePen = new QPen(Qt::NoPen);
801 801 m_titleVisible = true;
802 802 m_angularTitle = QString();
803 803 m_radialTitle = QString();
804 804 break;
805 805 case 2:
806 806 m_titleBrush = new QBrush(Qt::NoBrush);
807 807 m_titlePen = new QPen(Qt::NoPen);
808 808 m_titleVisible = false;
809 809 m_angularTitle = QString("Invisible Ang. Title!");
810 810 m_radialTitle = QString("Invisible Rad. Title!");
811 811 break;
812 812 case 3:
813 813 m_titleBrush = new QBrush(Qt::black);
814 814 m_titlePen = new QPen(Qt::NoPen);
815 815 m_titleVisible = true;
816 816 m_angularTitle = QString("Angular Title");
817 817 m_radialTitle = QString("Radial Title");
818 818 break;
819 819 case 4:
820 820 m_titleBrush = new QBrush(Qt::white);
821 821 m_titlePen = new QPen(Qt::blue);
822 822 m_titleVisible = true;
823 823 m_angularTitle = QString("Angular Blue Title");
824 824 m_radialTitle = QString("Radial Blue Title");
825 825 break;
826 826 default:
827 827 break;
828 828 }
829 829
830 830 m_radialAxis->setTitleBrush(*m_titleBrush);
831 831 m_radialAxis->setTitlePen(*m_titlePen);
832 832 m_radialAxis->setTitleVisible(m_titleVisible);
833 833 m_radialAxis->setTitleText(m_radialTitle);
834 834 m_angularAxis->setTitleBrush(*m_titleBrush);
835 835 m_angularAxis->setTitlePen(*m_titlePen);
836 836 m_angularAxis->setTitleVisible(m_titleVisible);
837 837 m_angularAxis->setTitleText(m_angularTitle);
838 838 }
839 839
840 840 void MainWindow::titleFontChanged(const QFont &font)
841 841 {
842 842 m_currentTitleFont = font;
843 843 m_currentTitleFont.setPixelSize(ui->titleFontSizeSpin->value());
844 844 m_angularAxis->setTitleFont(m_currentTitleFont);
845 845 m_radialAxis->setTitleFont(m_currentTitleFont);
846 846 }
847 847
848 848 void MainWindow::titleFontSizeChanged(int value)
849 849 {
850 850 m_currentTitleFont = ui->titleFontComboBox->currentFont();
851 851 m_currentTitleFont.setPixelSize(value);
852 852 m_angularAxis->setTitleFont(m_currentTitleFont);
853 853 m_radialAxis->setTitleFont(m_currentTitleFont);
854 854 }
855 855
856 856 void MainWindow::gridIndexChanged(int index)
857 857 {
858 858 delete m_gridPen;
859 859
860 860 switch (index) {
861 861 case 0:
862 862 m_gridPen = new QPen(Qt::NoPen);
863 863 m_gridVisible = false;
864 864 break;
865 865 case 1:
866 866 m_gridPen = new QPen(Qt::black);
867 867 m_gridVisible = true;
868 868 break;
869 869 case 2:
870 870 m_gridPen = new QPen(Qt::red);
871 871 m_gridPen->setStyle(Qt::DashDotLine);
872 872 m_gridPen->setWidth(3);
873 873 m_gridVisible = true;
874 874 break;
875 875 default:
876 876 break;
877 877 }
878 878
879 879 m_angularAxis->setGridLinePen(*m_gridPen);
880 880 m_angularAxis->setGridLineVisible(m_gridVisible);
881 881 m_radialAxis->setGridLinePen(*m_gridPen);
882 882 m_radialAxis->setGridLineVisible(m_gridVisible);
883 883 }
884 884
885 885 void MainWindow::arrowIndexChanged(int index)
886 886 {
887 887 delete m_arrowPen;
888 888
889 889 switch (index) {
890 890 case 0:
891 891 m_arrowPen = new QPen(Qt::NoPen);
892 892 m_arrowVisible = false;
893 893 break;
894 894 case 1:
895 895 m_arrowPen = new QPen(Qt::black);
896 896 m_arrowVisible = true;
897 897 break;
898 898 case 2:
899 899 m_arrowPen = new QPen(Qt::red);
900 900 m_arrowPen->setStyle(Qt::DashDotLine);
901 901 m_arrowPen->setWidth(3);
902 902 m_arrowVisible = true;
903 903 break;
904 904 default:
905 905 break;
906 906 }
907 907
908 908 m_angularAxis->setLinePen(*m_arrowPen);
909 909 m_angularAxis->setLineVisible(m_arrowVisible);
910 910 m_radialAxis->setLinePen(*m_arrowPen);
911 911 m_radialAxis->setLineVisible(m_arrowVisible);
912 912 }
913 913
914 914 void MainWindow::angularRangeChanged(qreal min, qreal max)
915 915 {
916 if (!qFuzzyCompare(ui->angularMinSpin->value(), min))
916 if (!qFuzzyCompare(qreal(ui->angularMinSpin->value()), min))
917 917 ui->angularMinSpin->setValue(min);
918 if (!qFuzzyCompare(ui->angularMaxSpin->value(), max))
918 if (!qFuzzyCompare(qreal(ui->angularMaxSpin->value()), max))
919 919 ui->angularMaxSpin->setValue(max);
920 920 }
921 921
922 922 void MainWindow::radialRangeChanged(qreal min, qreal max)
923 923 {
924 if (!qFuzzyCompare(ui->radialMinSpin->value(), min))
924 if (!qFuzzyCompare(qreal(ui->radialMinSpin->value()), min))
925 925 ui->radialMinSpin->setValue(min);
926 if (!qFuzzyCompare(ui->radialMaxSpin->value(), max))
926 if (!qFuzzyCompare(qreal(ui->radialMaxSpin->value()), max))
927 927 ui->radialMaxSpin->setValue(max);
928 928 }
929 929
930 930 void MainWindow::angularAxisIndexChanged(int index)
931 931 {
932 932 switch (index) {
933 933 case 0:
934 934 setAngularAxis(AxisModeNone);
935 935 break;
936 936 case 1:
937 937 setAngularAxis(AxisModeValue);
938 938 break;
939 939 case 2:
940 940 setAngularAxis(AxisModeLogValue);
941 941 break;
942 942 case 3:
943 943 setAngularAxis(AxisModeDateTime);
944 944 break;
945 945 case 4:
946 946 setAngularAxis(AxisModeCategory);
947 947 break;
948 948 default:
949 949 qWarning("Invalid Index!");
950 950 }
951 951 }
952 952
953 953 void MainWindow::radialAxisIndexChanged(int index)
954 954 {
955 955 switch (index) {
956 956 case 0:
957 957 setRadialAxis(AxisModeNone);
958 958 break;
959 959 case 1:
960 960 setRadialAxis(AxisModeValue);
961 961 break;
962 962 case 2:
963 963 setRadialAxis(AxisModeLogValue);
964 964 break;
965 965 case 3:
966 966 setRadialAxis(AxisModeDateTime);
967 967 break;
968 968 case 4:
969 969 setRadialAxis(AxisModeCategory);
970 970 break;
971 971 default:
972 972 qWarning("Invalid Index!");
973 973 }
974 974 }
975 975
976 976 void MainWindow::logBaseChanged(double value)
977 977 {
978 978 m_base = value;
979 979 if (m_angularAxisMode == AxisModeLogValue)
980 980 static_cast<QLogValueAxis *>(m_angularAxis)->setBase(m_base);
981 981 if (m_radialAxisMode == AxisModeLogValue)
982 982 static_cast<QLogValueAxis *>(m_radialAxis)->setBase(m_base);
983 983 }
984 984
985 985 void MainWindow::niceNumbersChecked()
986 986 {
987 987 if (ui->niceNumbersCheckBox->isChecked())
988 988 applyRanges();
989 989 }
990 990
991 991 void MainWindow::dateFormatEdited(const QString &text)
992 992 {
993 993 m_dateFormat = text;
994 994 if (m_angularAxisMode == AxisModeDateTime)
995 995 static_cast<QDateTimeAxis *>(m_angularAxis)->setFormat(m_dateFormat);
996 996 if (m_radialAxisMode == AxisModeDateTime)
997 997 static_cast<QDateTimeAxis *>(m_radialAxis)->setFormat(m_dateFormat);
998 998 }
999 999
1000 1000 void MainWindow::moreCategoriesChecked()
1001 1001 {
1002 1002 applyCategories();
1003 1003 m_moreCategories = ui->moreCategoriesCheckBox->isChecked();
1004 1004 }
1005 1005
1006 1006 void MainWindow::series1CheckBoxChecked()
1007 1007 {
1008 1008 if (ui->series1checkBox->isChecked())
1009 1009 m_series1->setVisible(true);
1010 1010 else
1011 1011 m_series1->setVisible(false);
1012 1012 }
1013 1013
1014 1014 void MainWindow::series2CheckBoxChecked()
1015 1015 {
1016 1016 if (ui->series2checkBox->isChecked())
1017 1017 m_series2->setVisible(true);
1018 1018 else
1019 1019 m_series2->setVisible(false);
1020 1020 }
1021 1021
1022 1022 void MainWindow::series3CheckBoxChecked()
1023 1023 {
1024 1024 if (ui->series3checkBox->isChecked())
1025 1025 m_series3->setVisible(true);
1026 1026 else
1027 1027 m_series3->setVisible(false);
1028 1028 }
1029 1029
1030 1030 void MainWindow::series4CheckBoxChecked()
1031 1031 {
1032 1032 if (ui->series4checkBox->isChecked())
1033 1033 m_series4->setVisible(true);
1034 1034 else
1035 1035 m_series4->setVisible(false);
1036 1036 }
1037 1037
1038 1038 void MainWindow::series5CheckBoxChecked()
1039 1039 {
1040 1040 if (ui->series5checkBox->isChecked())
1041 1041 m_series5->setVisible(true);
1042 1042 else
1043 1043 m_series5->setVisible(false);
1044 1044 }
1045 1045
1046 1046 void MainWindow::series6CheckBoxChecked()
1047 1047 {
1048 1048 if (ui->series6checkBox->isChecked())
1049 1049 m_series6->setVisible(true);
1050 1050 else
1051 1051 m_series6->setVisible(false);
1052 1052 }
1053 1053
1054 1054 void MainWindow::series7CheckBoxChecked()
1055 1055 {
1056 1056 if (ui->series7checkBox->isChecked())
1057 1057 m_series7->setVisible(true);
1058 1058 else
1059 1059 m_series7->setVisible(false);
1060 1060 }
1061 1061
1062 1062 void MainWindow::themeIndexChanged(int index)
1063 1063 {
1064 1064 m_chart->setTheme(QChart::ChartTheme(index));
1065 1065 }
1066 1066
1067 1067 void MainWindow::seriesHovered(QPointF point, bool state)
1068 1068 {
1069 1069 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1070 1070 if (series) {
1071 1071 if (state) {
1072 1072 QString str("'%3' - %1 x %2");
1073 1073 ui->hoverLabel->setText(str.arg(point.x()).arg(point.y()).arg(series->name()));
1074 1074 } else {
1075 1075 ui->hoverLabel->setText("No hover");
1076 1076 }
1077 1077 } else {
1078 1078 qDebug() << "seriesHovered - invalid sender!";
1079 1079 }
1080 1080 }
1081 1081
1082 1082 void MainWindow::seriesClicked(const QPointF &point)
1083 1083 {
1084 1084 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
1085 1085 if (series) {
1086 1086 QString str("'%3' clicked at: %1 x %2");
1087 1087 m_angularTitle = str.arg(point.x()).arg(point.y()).arg(series->name());
1088 1088 m_angularAxis->setTitleText(m_angularTitle);
1089 1089 } else {
1090 1090 qDebug() << "seriesClicked - invalid sender!";
1091 1091 }
1092 1092 }
1093 1093
1094 1094 void MainWindow::backgroundIndexChanged(int index)
1095 1095 {
1096 1096 delete m_backgroundBrush;
1097 1097 delete m_backgroundPen;
1098 1098
1099 1099 switch (index) {
1100 1100 case 0:
1101 1101 m_backgroundBrush = new QBrush(Qt::white);
1102 1102 m_backgroundPen = new QPen(Qt::NoPen);
1103 1103 break;
1104 1104 case 1:
1105 1105 m_backgroundBrush = new QBrush(Qt::blue);
1106 1106 m_backgroundPen = new QPen(Qt::NoPen);
1107 1107 break;
1108 1108 case 2:
1109 1109 m_backgroundBrush = new QBrush(Qt::yellow);
1110 1110 m_backgroundPen = new QPen(Qt::black, 2);
1111 1111 break;
1112 1112 default:
1113 1113 break;
1114 1114 }
1115 1115 m_chart->setBackgroundBrush(*m_backgroundBrush);
1116 1116 m_chart->setBackgroundPen(*m_backgroundPen);
1117 1117 }
1118 1118
1119 1119 void MainWindow::plotAreaIndexChanged(int index)
1120 1120 {
1121 1121 delete m_plotAreaBackgroundBrush;
1122 1122 delete m_plotAreaBackgroundPen;
1123 1123
1124 1124 switch (index) {
1125 1125 case 0:
1126 1126 m_plotAreaBackgroundBrush = new QBrush(Qt::green);
1127 1127 m_plotAreaBackgroundPen = new QPen(Qt::green);
1128 1128 m_chart->setPlotAreaBackgroundVisible(false);
1129 1129 break;
1130 1130 case 1:
1131 1131 m_plotAreaBackgroundBrush = new QBrush(Qt::magenta);
1132 1132 m_plotAreaBackgroundPen = new QPen(Qt::NoPen);
1133 1133 m_chart->setPlotAreaBackgroundVisible(true);
1134 1134 break;
1135 1135 case 2:
1136 1136 m_plotAreaBackgroundBrush = new QBrush(Qt::lightGray);
1137 1137 m_plotAreaBackgroundPen = new QPen(Qt::red, 6);
1138 1138 m_chart->setPlotAreaBackgroundVisible(true);
1139 1139 break;
1140 1140 default:
1141 1141 break;
1142 1142 }
1143 1143 m_chart->setPlotAreaBackgroundBrush(*m_plotAreaBackgroundBrush);
1144 1144 m_chart->setPlotAreaBackgroundPen(*m_plotAreaBackgroundPen);
1145 1145 }
1146 1146
1147 1147 void MainWindow::applyCategories()
1148 1148 {
1149 1149 // Basic layout is three categories, extended has five
1150 1150 if (m_angularAxisMode == AxisModeCategory) {
1151 1151 QCategoryAxis *angCatAxis = static_cast<QCategoryAxis *>(m_angularAxis);
1152 1152 if (angCatAxis->count() == 0) {
1153 1153 angCatAxis->setStartValue(4000);
1154 1154 angCatAxis->append("Category A", 7000);
1155 1155 angCatAxis->append("Category B", 12000);
1156 1156 angCatAxis->append("Category C", 17000);
1157 1157 }
1158 1158 if (angCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1159 1159 angCatAxis->setStartValue(1000);
1160 1160 angCatAxis->replaceLabel("Category A", "Cat A");
1161 1161 angCatAxis->replaceLabel("Category B", "Cat B");
1162 1162 angCatAxis->replaceLabel("Category C", "Cat C");
1163 1163 angCatAxis->append("Cat D", 22000);
1164 1164 angCatAxis->append("Cat E", 28000);
1165 1165 } else if (angCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1166 1166 angCatAxis->setStartValue(4000);
1167 1167 angCatAxis->replaceLabel("Cat A", "Category A");
1168 1168 angCatAxis->replaceLabel("Cat B", "Category B");
1169 1169 angCatAxis->replaceLabel("Cat C", "Category C");
1170 1170 angCatAxis->remove("Cat D");
1171 1171 angCatAxis->remove("Cat E");
1172 1172 }
1173 1173 }
1174 1174
1175 1175 if (m_radialAxisMode == AxisModeCategory) {
1176 1176 QCategoryAxis *radCatAxis = static_cast<QCategoryAxis *>(m_radialAxis);
1177 1177 if (radCatAxis->count() == 0) {
1178 1178 radCatAxis->setStartValue(2000);
1179 1179 radCatAxis->append("Category 1", 4000);
1180 1180 radCatAxis->append("Category 2", 9000);
1181 1181 radCatAxis->append("Category 3", 14000);
1182 1182 }
1183 1183 if (radCatAxis->count() == 3 && ui->moreCategoriesCheckBox->isChecked()) {
1184 1184 radCatAxis->setStartValue(1000);
1185 1185 radCatAxis->replaceLabel("Category 1", "Cat 1");
1186 1186 radCatAxis->replaceLabel("Category 2", "Cat 2");
1187 1187 radCatAxis->replaceLabel("Category 3", "Cat 3");
1188 1188 radCatAxis->append("Cat 4", 16500);
1189 1189 radCatAxis->append("Cat 5", 19000);
1190 1190 } else if (radCatAxis->count() == 5 && !ui->moreCategoriesCheckBox->isChecked()) {
1191 1191 radCatAxis->setStartValue(2000);
1192 1192 radCatAxis->replaceLabel("Cat 1", "Category 1");
1193 1193 radCatAxis->replaceLabel("Cat 2", "Category 2");
1194 1194 radCatAxis->replaceLabel("Cat 3", "Category 3");
1195 1195 radCatAxis->remove("Cat 4");
1196 1196 radCatAxis->remove("Cat 5");
1197 1197 }
1198 1198 }
1199 1199 }
General Comments 0
You need to be logged in to leave comments. Login now