@@ -1,54 +1,54 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #include "drilldownchart.h" |
|
20 | #include "drilldownchart.h" | |
21 | #include "drilldownslice.h" |
|
21 | #include "drilldownslice.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
23 | QTCOMMERCIALCHART_USE_NAMESPACE | |
24 |
|
24 | |||
25 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
25 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
26 | :QChart(parent, wFlags), |
|
26 | :QChart(parent, wFlags), | |
27 | m_currentSeries(0) |
|
27 | m_currentSeries(0) | |
28 | { |
|
28 | { | |
29 |
|
29 | |||
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | DrilldownChart::~DrilldownChart() |
|
32 | DrilldownChart::~DrilldownChart() | |
33 | { |
|
33 | { | |
34 |
|
34 | |||
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | void DrilldownChart::changeSeries(QSeries* series) |
|
37 | void DrilldownChart::changeSeries(QAbstractSeries* series) | |
38 | { |
|
38 | { | |
39 | // NOTE: if the series is owned by the chart it will be deleted |
|
39 | // NOTE: if the series is owned by the chart it will be deleted | |
40 | // here the "window" owns the series... |
|
40 | // here the "window" owns the series... | |
41 | if (m_currentSeries) |
|
41 | if (m_currentSeries) | |
42 | removeSeries(m_currentSeries); |
|
42 | removeSeries(m_currentSeries); | |
43 | m_currentSeries = series; |
|
43 | m_currentSeries = series; | |
44 | addSeries(series); |
|
44 | addSeries(series); | |
45 | setTitle(series->name()); |
|
45 | setTitle(series->name()); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | void DrilldownChart::handleSliceClicked(QPieSlice* slice) |
|
48 | void DrilldownChart::handleSliceClicked(QPieSlice* slice) | |
49 | { |
|
49 | { | |
50 | DrilldownSlice* drilldownSlice = static_cast<DrilldownSlice*>(slice); |
|
50 | DrilldownSlice* drilldownSlice = static_cast<DrilldownSlice*>(slice); | |
51 | changeSeries(drilldownSlice->drilldownSeries()); |
|
51 | changeSeries(drilldownSlice->drilldownSeries()); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | #include "moc_drilldownchart.cpp" |
|
54 | #include "moc_drilldownchart.cpp" |
@@ -1,47 +1,47 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #ifndef DRILLDOWNCHART_H |
|
20 | #ifndef DRILLDOWNCHART_H | |
21 | #define DRILLDOWNCHART_H |
|
21 | #define DRILLDOWNCHART_H | |
22 |
|
22 | |||
23 | #include <QChart> |
|
23 | #include <QChart> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 | class QSeries; |
|
26 | class QAbstractSeries; | |
27 | class QPieSlice; |
|
27 | class QPieSlice; | |
28 | QTCOMMERCIALCHART_END_NAMESPACE |
|
28 | QTCOMMERCIALCHART_END_NAMESPACE | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | QTCOMMERCIALCHART_USE_NAMESPACE | |
31 |
|
31 | |||
32 | class DrilldownChart : public QChart |
|
32 | class DrilldownChart : public QChart | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 | public: |
|
35 | public: | |
36 | explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
36 | explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
37 | ~DrilldownChart(); |
|
37 | ~DrilldownChart(); | |
38 | void changeSeries(QSeries* series); |
|
38 | void changeSeries(QAbstractSeries* series); | |
39 |
|
39 | |||
40 | public Q_SLOTS: |
|
40 | public Q_SLOTS: | |
41 | void handleSliceClicked(QPieSlice* slice); |
|
41 | void handleSliceClicked(QPieSlice* slice); | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | QSeries* m_currentSeries; |
|
44 | QAbstractSeries* m_currentSeries; | |
45 | }; |
|
45 | }; | |
46 |
|
46 | |||
47 | #endif // DRILLDOWNCHART_H |
|
47 | #endif // DRILLDOWNCHART_H |
@@ -1,70 +1,70 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "drilldownslice.h" |
|
21 | #include "drilldownslice.h" | |
22 |
|
22 | |||
23 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
23 | QTCOMMERCIALCHART_USE_NAMESPACE | |
24 |
|
24 | |||
25 | DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QSeries* drilldownSeries) |
|
25 | DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QAbstractSeries* drilldownSeries) | |
26 | :m_drilldownSeries(drilldownSeries), |
|
26 | :m_drilldownSeries(drilldownSeries), | |
27 | m_prefix(prefix) |
|
27 | m_prefix(prefix) | |
28 | { |
|
28 | { | |
29 | setValue(value); |
|
29 | setValue(value); | |
30 | updateLabel(); |
|
30 | updateLabel(); | |
31 | setLabelFont(QFont("Arial", 8)); |
|
31 | setLabelFont(QFont("Arial", 8)); | |
32 | connect(this, SIGNAL(changed()), this, SLOT(updateLabel())); |
|
32 | connect(this, SIGNAL(changed()), this, SLOT(updateLabel())); | |
33 | connect(this, SIGNAL(hoverEnter()), this, SLOT(showHighlight())); |
|
33 | connect(this, SIGNAL(hoverEnter()), this, SLOT(showHighlight())); | |
34 | connect(this, SIGNAL(hoverLeave()), this, SLOT(hideHighlight())); |
|
34 | connect(this, SIGNAL(hoverLeave()), this, SLOT(hideHighlight())); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | DrilldownSlice::~DrilldownSlice() |
|
37 | DrilldownSlice::~DrilldownSlice() | |
38 | { |
|
38 | { | |
39 |
|
39 | |||
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | QSeries* DrilldownSlice::drilldownSeries() const |
|
42 | QAbstractSeries* DrilldownSlice::drilldownSeries() const | |
43 | { |
|
43 | { | |
44 | return m_drilldownSeries; |
|
44 | return m_drilldownSeries; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void DrilldownSlice::updateLabel() |
|
47 | void DrilldownSlice::updateLabel() | |
48 | { |
|
48 | { | |
49 | QString label = m_prefix; |
|
49 | QString label = m_prefix; | |
50 | label += " $"; |
|
50 | label += " $"; | |
51 | label += QString::number(this->value()); |
|
51 | label += QString::number(this->value()); | |
52 | label += ", "; |
|
52 | label += ", "; | |
53 | label += QString::number(this->percentage()*100, 'f', 1); |
|
53 | label += QString::number(this->percentage()*100, 'f', 1); | |
54 | label += "%"; |
|
54 | label += "%"; | |
55 | setLabel(label); |
|
55 | setLabel(label); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void DrilldownSlice::showHighlight() |
|
58 | void DrilldownSlice::showHighlight() | |
59 | { |
|
59 | { | |
60 | setExploded(); |
|
60 | setExploded(); | |
61 | setLabelVisible(); |
|
61 | setLabelVisible(); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void DrilldownSlice::hideHighlight() |
|
64 | void DrilldownSlice::hideHighlight() | |
65 | { |
|
65 | { | |
66 | setExploded(false); |
|
66 | setExploded(false); | |
67 | setLabelVisible(false); |
|
67 | setLabelVisible(false); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | #include "moc_drilldownslice.cpp" |
|
70 | #include "moc_drilldownslice.cpp" |
@@ -1,50 +1,50 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #ifndef DRILLDOWNSLICE_H |
|
20 | #ifndef DRILLDOWNSLICE_H | |
21 | #define DRILLDOWNSLICE_H |
|
21 | #define DRILLDOWNSLICE_H | |
22 |
|
22 | |||
23 | #include <QPieSlice> |
|
23 | #include <QPieSlice> | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 | class QSeries; |
|
26 | class QAbstractSeries; | |
27 | QTCOMMERCIALCHART_END_NAMESPACE |
|
27 | QTCOMMERCIALCHART_END_NAMESPACE | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | class DrilldownSlice : public QPieSlice |
|
31 | class DrilldownSlice : public QPieSlice | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public: |
|
35 | public: | |
36 | DrilldownSlice(qreal value, QString prefix, QSeries* drilldownSeries); |
|
36 | DrilldownSlice(qreal value, QString prefix, QAbstractSeries* drilldownSeries); | |
37 | virtual ~DrilldownSlice(); |
|
37 | virtual ~DrilldownSlice(); | |
38 | QSeries* drilldownSeries() const; |
|
38 | QAbstractSeries* drilldownSeries() const; | |
39 |
|
39 | |||
40 | public Q_SLOTS: |
|
40 | public Q_SLOTS: | |
41 | void updateLabel(); |
|
41 | void updateLabel(); | |
42 | void showHighlight(); |
|
42 | void showHighlight(); | |
43 | void hideHighlight(); |
|
43 | void hideHighlight(); | |
44 |
|
44 | |||
45 | private: |
|
45 | private: | |
46 | QSeries* m_drilldownSeries; |
|
46 | QAbstractSeries* m_drilldownSeries; | |
47 | QString m_prefix; |
|
47 | QString m_prefix; | |
48 | }; |
|
48 | }; | |
49 |
|
49 | |||
50 | #endif // DRILLDOWNSLICE_H |
|
50 | #endif // DRILLDOWNSLICE_H |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartview.h" |
|
21 | #include "chartview.h" | |
22 | #include <QLineSeries> |
|
22 | #include <QLineSeries> | |
23 | #include <QScatterSeries> |
|
23 | #include <QScatterSeries> | |
24 | #include <QSplineSeries> |
|
24 | #include <QSplineSeries> | |
25 | #include <QAreaSeries> |
|
25 | #include <QAreaSeries> | |
26 | #include <QTime> |
|
26 | #include <QTime> | |
27 |
|
27 | |||
28 | ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), |
|
28 | ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), | |
29 | m_index(-1),m_chart(chart) |
|
29 | m_index(-1),m_chart(chart) | |
30 | { |
|
30 | { | |
31 | m_chart->setTitle("Charts presenter"); |
|
31 | m_chart->setTitle("Charts presenter"); | |
32 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); |
|
32 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); | |
33 | m_timer.setInterval(3000); |
|
33 | m_timer.setInterval(3000); | |
34 |
|
34 | |||
35 | //![1] |
|
35 | //![1] | |
36 | QLineSeries* series0 = new QLineSeries(); |
|
36 | QLineSeries* series0 = new QLineSeries(); | |
37 | QPen blue(Qt::blue); |
|
37 | QPen blue(Qt::blue); | |
38 | blue.setWidth(3); |
|
38 | blue.setWidth(3); | |
39 | series0->setPen(blue); |
|
39 | series0->setPen(blue); | |
40 |
|
40 | |||
41 | QScatterSeries* series1 = new QScatterSeries(); |
|
41 | QScatterSeries* series1 = new QScatterSeries(); | |
42 | QPen red(Qt::red); |
|
42 | QPen red(Qt::red); | |
43 | red.setWidth(3); |
|
43 | red.setWidth(3); | |
44 | series1->setPen(red); |
|
44 | series1->setPen(red); | |
45 | series1->setBrush(Qt::white); |
|
45 | series1->setBrush(Qt::white); | |
46 |
|
46 | |||
47 | QSplineSeries* series2 = new QSplineSeries(); |
|
47 | QSplineSeries* series2 = new QSplineSeries(); | |
48 | QPen green(Qt::green); |
|
48 | QPen green(Qt::green); | |
49 | green.setWidth(3); |
|
49 | green.setWidth(3); | |
50 | series2->setPen(green); |
|
50 | series2->setPen(green); | |
51 |
|
51 | |||
52 | QAreaSeries* series3 = new QAreaSeries(series0); |
|
52 | QAreaSeries* series3 = new QAreaSeries(series0); | |
53 | QPen yellow(Qt::black); |
|
53 | QPen yellow(Qt::black); | |
54 | yellow.setWidth(3); |
|
54 | yellow.setWidth(3); | |
55 | series3->setPen(yellow); |
|
55 | series3->setPen(yellow); | |
56 | series3->setBrush(Qt::yellow); |
|
56 | series3->setBrush(Qt::yellow); | |
57 | //![1] |
|
57 | //![1] | |
58 |
|
58 | |||
59 | //![2] |
|
59 | //![2] | |
60 | int numPoints = 10; |
|
60 | int numPoints = 10; | |
61 |
|
61 | |||
62 | for (int x = 0; x <= numPoints; ++x) { |
|
62 | for (int x = 0; x <= numPoints; ++x) { | |
63 | qreal y = qrand() % 100; |
|
63 | qreal y = qrand() % 100; | |
64 | series0->append(x,y); |
|
64 | series0->append(x,y); | |
65 | series1->append(x,y); |
|
65 | series1->append(x,y); | |
66 | series2->append(x,y); |
|
66 | series2->append(x,y); | |
67 | } |
|
67 | } | |
68 | //![2] |
|
68 | //![2] | |
69 |
|
69 | |||
70 | //![3] |
|
70 | //![3] | |
71 | m_series<<series0; |
|
71 | m_series<<series0; | |
72 | m_titles<< m_chart->title()+": LineChart"; |
|
72 | m_titles<< m_chart->title()+": LineChart"; | |
73 | m_series<<series1; |
|
73 | m_series<<series1; | |
74 | m_titles<< m_chart->title()+": ScatterChart"; |
|
74 | m_titles<< m_chart->title()+": ScatterChart"; | |
75 | m_series<<series2; |
|
75 | m_series<<series2; | |
76 | m_titles<< m_chart->title()+": SplineChart"; |
|
76 | m_titles<< m_chart->title()+": SplineChart"; | |
77 | m_series<<series3; |
|
77 | m_series<<series3; | |
78 | m_titles<< m_chart->title()+": AreaChart"; |
|
78 | m_titles<< m_chart->title()+": AreaChart"; | |
79 | //![3] |
|
79 | //![3] | |
80 |
|
80 | |||
81 | //![4] |
|
81 | //![4] | |
82 | foreach (QSeries* series, m_series) { |
|
82 | foreach (QAbstractSeries* series, m_series) { | |
83 | QObject::connect(series,SIGNAL(clicked(QPointF)),this,SLOT(handlePointClicked(QPointF))); |
|
83 | QObject::connect(series,SIGNAL(clicked(QPointF)),this,SLOT(handlePointClicked(QPointF))); | |
84 | } |
|
84 | } | |
85 | //![4] |
|
85 | //![4] | |
86 | m_timer.start(); |
|
86 | m_timer.start(); | |
87 | handleTimeout(); |
|
87 | handleTimeout(); | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | ChartView::~ChartView() |
|
90 | ChartView::~ChartView() | |
91 | { |
|
91 | { | |
92 | if(m_series.size()==0) return; |
|
92 | if(m_series.size()==0) return; | |
93 | m_chart->removeSeries(m_series.at(m_index)); |
|
93 | m_chart->removeSeries(m_series.at(m_index)); | |
94 | m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone |
|
94 | m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone | |
95 | qDeleteAll(m_series); |
|
95 | qDeleteAll(m_series); | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | //![5] |
|
98 | //![5] | |
99 | void ChartView::handleTimeout() |
|
99 | void ChartView::handleTimeout() | |
100 | { |
|
100 | { | |
101 | if(m_series.size()==0) return; |
|
101 | if(m_series.size()==0) return; | |
102 | if(m_index>=0) |
|
102 | if(m_index>=0) | |
103 | m_chart->removeSeries(m_series.at(m_index)); |
|
103 | m_chart->removeSeries(m_series.at(m_index)); | |
104 | m_index++; |
|
104 | m_index++; | |
105 | m_index=m_index%m_series.size(); |
|
105 | m_index=m_index%m_series.size(); | |
106 | m_chart->addSeries(m_series.at(m_index)); |
|
106 | m_chart->addSeries(m_series.at(m_index)); | |
107 | m_chart->setTitle(m_titles.at(m_index)); |
|
107 | m_chart->setTitle(m_titles.at(m_index)); | |
108 | } |
|
108 | } | |
109 | //![5] |
|
109 | //![5] | |
110 |
|
110 | |||
111 | //![6] |
|
111 | //![6] | |
112 | void ChartView::handlePointClicked(const QPointF& point) |
|
112 | void ChartView::handlePointClicked(const QPointF& point) | |
113 | { |
|
113 | { | |
114 | m_chart->setTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y())); |
|
114 | m_chart->setTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y())); | |
115 | } |
|
115 | } | |
116 | //![6] |
|
116 | //![6] |
@@ -1,50 +1,50 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef CHARTVIEW_H_ |
|
21 | #ifndef CHARTVIEW_H_ | |
22 | #define CHARTVIEW_H_ |
|
22 | #define CHARTVIEW_H_ | |
23 |
|
23 | |||
24 | #include <QChartView> |
|
24 | #include <QChartView> | |
25 | #include <QTimer> |
|
25 | #include <QTimer> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | //![1] |
|
29 | //![1] | |
30 | class ChartView: public QChartView |
|
30 | class ChartView: public QChartView | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | ChartView(QChart* chart,QWidget* parent = 0); |
|
34 | ChartView(QChart* chart,QWidget* parent = 0); | |
35 | virtual ~ChartView(); |
|
35 | virtual ~ChartView(); | |
36 |
|
36 | |||
37 | public slots: |
|
37 | public slots: | |
38 | void handleTimeout(); |
|
38 | void handleTimeout(); | |
39 | void handlePointClicked(const QPointF& point); |
|
39 | void handlePointClicked(const QPointF& point); | |
40 |
|
40 | |||
41 | private: |
|
41 | private: | |
42 | QTimer m_timer; |
|
42 | QTimer m_timer; | |
43 | QList<QSeries*> m_series; |
|
43 | QList<QAbstractSeries *> m_series; | |
44 | QStringList m_titles; |
|
44 | QStringList m_titles; | |
45 | int m_index; |
|
45 | int m_index; | |
46 | QChart *m_chart; |
|
46 | QChart *m_chart; | |
47 | }; |
|
47 | }; | |
48 | //![1] |
|
48 | //![1] | |
49 |
|
49 | |||
50 | #endif /* CHARTVIEW_H_ */ |
|
50 | #endif /* CHARTVIEW_H_ */ |
@@ -1,50 +1,50 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "drilldownchart.h" |
|
21 | #include "drilldownchart.h" | |
22 | #include <QChartAxis> |
|
22 | #include <QChartAxis> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
24 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
25 | |||
26 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
26 | DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
27 | : QChart(parent, wFlags) |
|
27 | : QChart(parent, wFlags) | |
28 | ,m_currentSeries(0) |
|
28 | ,m_currentSeries(0) | |
29 | { |
|
29 | { | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 |
void DrilldownChart::changeSeries(QSeries* |
|
32 | void DrilldownChart::changeSeries(QAbstractSeries *series) | |
33 | { |
|
33 | { | |
34 | if (m_currentSeries) |
|
34 | if (m_currentSeries) | |
35 | removeSeries(m_currentSeries); |
|
35 | removeSeries(m_currentSeries); | |
36 | m_currentSeries = series; |
|
36 | m_currentSeries = series; | |
37 | addSeries(series); |
|
37 | addSeries(series); | |
38 | setTitle(series->name()); |
|
38 | setTitle(series->name()); | |
39 | axisY()->setNiceNumbersEnabled(true); |
|
39 | axisY()->setNiceNumbersEnabled(true); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void DrilldownChart::handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button) |
|
42 | void DrilldownChart::handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button) | |
43 | { |
|
43 | { | |
44 | Q_UNUSED(barset) |
|
44 | Q_UNUSED(barset) | |
45 | Q_UNUSED(button) |
|
45 | Q_UNUSED(button) | |
46 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); |
|
46 | DrilldownBarSeries* series = static_cast<DrilldownBarSeries*> (sender()); | |
47 | changeSeries(series->drilldownSeries(category)); |
|
47 | changeSeries(series->drilldownSeries(category)); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | #include "moc_drilldownchart.cpp" |
|
50 | #include "moc_drilldownchart.cpp" |
@@ -1,46 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DRILLDOWNCHART_H |
|
21 | #ifndef DRILLDOWNCHART_H | |
22 | #define DRILLDOWNCHART_H |
|
22 | #define DRILLDOWNCHART_H | |
23 |
|
23 | |||
24 | #include <QChart> |
|
24 | #include <QChart> | |
25 | #include "drilldownseries.h" |
|
25 | #include "drilldownseries.h" | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | //! [2] |
|
29 | //! [2] | |
30 | class DrilldownChart : public QChart |
|
30 | class DrilldownChart : public QChart | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
34 | explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
35 |
|
35 | |||
36 |
void changeSeries(QSeries* |
|
36 | void changeSeries(QAbstractSeries *series); | |
37 |
|
37 | |||
38 | public Q_SLOTS: |
|
38 | public Q_SLOTS: | |
39 | void handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
39 | void handleClicked(QBarSet *barset, QString category, Qt::MouseButtons button); | |
40 |
|
40 | |||
41 | private: |
|
41 | private: | |
42 | QSeries* m_currentSeries; |
|
42 | QAbstractSeries* m_currentSeries; | |
43 | }; |
|
43 | }; | |
44 | //! [2] |
|
44 | //! [2] | |
45 |
|
45 | |||
46 | #endif // DRILLDOWNCHART_H |
|
46 | #endif // DRILLDOWNCHART_H |
@@ -1,70 +1,70 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativeareaseries.h" |
|
21 | #include "declarativeareaseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
28 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |
29 | QAreaSeries(new QLineSeries(parent), new QLineSeries(parent)) |
|
29 | QAreaSeries(new QLineSeries(parent), new QLineSeries(parent)) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QSeries *DeclarativeAreaSeries::series() |
|
33 | QAbstractSeries *DeclarativeAreaSeries::series() | |
34 | { |
|
34 | { | |
35 | return this; |
|
35 | return this; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::points() |
|
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::points() | |
39 | { |
|
39 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendPoints); |
|
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendPoints); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::lowerPoints() |
|
43 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeAreaSeries::lowerPoints() | |
44 | { |
|
44 | { | |
45 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendLowerPoints); |
|
45 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeAreaSeries::appendLowerPoints); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | void DeclarativeAreaSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
48 | void DeclarativeAreaSeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
49 | DeclarativeXyPoint *element) |
|
49 | DeclarativeXyPoint *element) | |
50 | { |
|
50 | { | |
51 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); |
|
51 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); | |
52 | if (series) { |
|
52 | if (series) { | |
53 | QLineSeries *upper = series->upperSeries(); |
|
53 | QLineSeries *upper = series->upperSeries(); | |
54 | upper->append(element->x(), element->y()); |
|
54 | upper->append(element->x(), element->y()); | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void DeclarativeAreaSeries::appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
58 | void DeclarativeAreaSeries::appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
59 | DeclarativeXyPoint *element) |
|
59 | DeclarativeXyPoint *element) | |
60 | { |
|
60 | { | |
61 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); |
|
61 | QAreaSeries *series = qobject_cast<QAreaSeries *>(list->object); | |
62 | if (series) { |
|
62 | if (series) { | |
63 | QLineSeries *lower = series->lowerSeries(); |
|
63 | QLineSeries *lower = series->lowerSeries(); | |
64 | lower->append(element->x(), element->y()); |
|
64 | lower->append(element->x(), element->y()); | |
65 | } |
|
65 | } | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | #include "moc_declarativeareaseries.cpp" |
|
68 | #include "moc_declarativeareaseries.cpp" | |
69 |
|
69 | |||
70 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,53 +1,53 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVEAREASERIES_H |
|
21 | #ifndef DECLARATIVEAREASERIES_H | |
22 | #define DECLARATIVEAREASERIES_H |
|
22 | #define DECLARATIVEAREASERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qareaseries.h" |
|
25 | #include "qareaseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | class DeclarativeAreaSeries : public QAreaSeries, public DeclarativeXySeries |
|
30 | class DeclarativeAreaSeries : public QAreaSeries, public DeclarativeXySeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) |
|
33 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints READ lowerPoints) |
|
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints READ lowerPoints) | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeAreaSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QSeries *series(); |
|
40 | QAbstractSeries *series(); | |
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints(); |
|
42 | QDeclarativeListProperty<DeclarativeXyPoint> lowerPoints(); | |
43 |
|
43 | |||
44 | public Q_SLOTS: |
|
44 | public Q_SLOTS: | |
45 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
45 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
46 | DeclarativeXyPoint *element); |
|
46 | DeclarativeXyPoint *element); | |
47 | static void appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
47 | static void appendLowerPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
48 | DeclarativeXyPoint *element); |
|
48 | DeclarativeXyPoint *element); | |
49 | }; |
|
49 | }; | |
50 |
|
50 | |||
51 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | QTCOMMERCIALCHART_END_NAMESPACE | |
52 |
|
52 | |||
53 | #endif // DECLARATIVEAREASERIES_H |
|
53 | #endif // DECLARATIVEAREASERIES_H |
@@ -1,45 +1,45 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativelineseries.h" |
|
21 | #include "declarativelineseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qlineseries.h" |
|
24 | #include "qlineseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : |
|
28 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |
29 | QLineSeries(parent) |
|
29 | QLineSeries(parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QSeries *DeclarativeLineSeries::series() |
|
33 | QAbstractSeries *DeclarativeLineSeries::series() | |
34 | { |
|
34 | { | |
35 | return this; |
|
35 | return this; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::points() |
|
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeLineSeries::points() | |
39 | { |
|
39 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | #include "moc_declarativelineseries.cpp" |
|
43 | #include "moc_declarativelineseries.cpp" | |
44 |
|
44 | |||
45 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,46 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVELINESERIES_H |
|
21 | #ifndef DECLARATIVELINESERIES_H | |
22 | #define DECLARATIVELINESERIES_H |
|
22 | #define DECLARATIVELINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qlineseries.h" |
|
25 | #include "qlineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries |
|
31 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) |
|
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QSeries *series(); |
|
40 | QAbstractSeries *series(); | |
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
42 | }; | |
43 |
|
43 | |||
44 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
45 |
|
45 | |||
46 | #endif // DECLARATIVELINESERIES_H |
|
46 | #endif // DECLARATIVELINESERIES_H |
@@ -1,45 +1,45 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativescatterseries.h" |
|
21 | #include "declarativescatterseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 | #include "qscatterseries.h" |
|
24 | #include "qscatterseries.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
28 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
29 | QScatterSeries(parent) |
|
29 | QScatterSeries(parent) | |
30 | { |
|
30 | { | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | QSeries *DeclarativeScatterSeries::series() |
|
33 | QAbstractSeries *DeclarativeScatterSeries::series() | |
34 | { |
|
34 | { | |
35 | return this; |
|
35 | return this; | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() |
|
38 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeScatterSeries::points() | |
39 | { |
|
39 | { | |
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
40 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | #include "moc_declarativescatterseries.cpp" |
|
43 | #include "moc_declarativescatterseries.cpp" | |
44 |
|
44 | |||
45 | QTCOMMERCIALCHART_END_NAMESPACE |
|
45 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,46 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESCATTERSERIES_H |
|
21 | #ifndef DECLARATIVESCATTERSERIES_H | |
22 | #define DECLARATIVESCATTERSERIES_H |
|
22 | #define DECLARATIVESCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qscatterseries.h" |
|
25 | #include "qscatterseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries |
|
31 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) |
|
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QSeries *series(); |
|
40 | QAbstractSeries *series(); | |
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
42 | }; | |
43 |
|
43 | |||
44 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
45 |
|
45 | |||
46 | #endif // DECLARATIVESCATTERSERIES_H |
|
46 | #endif // DECLARATIVESCATTERSERIES_H |
@@ -1,44 +1,44 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "declarativesplineseries.h" |
|
21 | #include "declarativesplineseries.h" | |
22 | #include "declarativechart.h" |
|
22 | #include "declarativechart.h" | |
23 | #include "qchart.h" |
|
23 | #include "qchart.h" | |
24 |
|
24 | |||
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
26 |
|
26 | |||
27 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
|
27 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |
28 | QSplineSeries(parent) |
|
28 | QSplineSeries(parent) | |
29 | { |
|
29 | { | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | QSeries *DeclarativeSplineSeries::series() |
|
32 | QAbstractSeries *DeclarativeSplineSeries::series() | |
33 | { |
|
33 | { | |
34 | return this; |
|
34 | return this; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeSplineSeries::points() |
|
37 | QDeclarativeListProperty<DeclarativeXyPoint> DeclarativeSplineSeries::points() | |
38 | { |
|
38 | { | |
39 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); |
|
39 | return QDeclarativeListProperty<DeclarativeXyPoint>(this, 0, &DeclarativeXySeries::appendPoints); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | #include "moc_declarativesplineseries.cpp" |
|
42 | #include "moc_declarativesplineseries.cpp" | |
43 |
|
43 | |||
44 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,46 +1,46 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVESPLINESERIES_H |
|
21 | #ifndef DECLARATIVESPLINESERIES_H | |
22 | #define DECLARATIVESPLINESERIES_H |
|
22 | #define DECLARATIVESPLINESERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qsplineseries.h" |
|
25 | #include "qsplineseries.h" | |
26 | #include "declarativexyseries.h" |
|
26 | #include "declarativexyseries.h" | |
27 | #include <QDeclarativeParserStatus> |
|
27 | #include <QDeclarativeParserStatus> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries |
|
31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) |
|
34 | Q_PROPERTY(QDeclarativeListProperty<DeclarativeXyPoint> points READ points) | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
37 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | QSeries *series(); |
|
40 | QAbstractSeries *series(); | |
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); |
|
41 | QDeclarativeListProperty<DeclarativeXyPoint> points(); | |
42 | }; |
|
42 | }; | |
43 |
|
43 | |||
44 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | QTCOMMERCIALCHART_END_NAMESPACE | |
45 |
|
45 | |||
46 | #endif // DECLARATIVESPLINESERIES_H |
|
46 | #endif // DECLARATIVESPLINESERIES_H |
@@ -1,60 +1,60 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | //#include "DeclarativeXySeries.h" |
|
21 | //#include "DeclarativeXySeries.h" | |
22 | #include "declarativexyseries.h" |
|
22 | #include "declarativexyseries.h" | |
23 | #include "qxyseries.h" |
|
23 | #include "qxyseries.h" | |
24 | #include "declarativechart.h" |
|
24 | #include "declarativechart.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | DeclarativeXySeries::DeclarativeXySeries() |
|
28 | DeclarativeXySeries::DeclarativeXySeries() | |
29 | { |
|
29 | { | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | DeclarativeXySeries::~DeclarativeXySeries() |
|
32 | DeclarativeXySeries::~DeclarativeXySeries() | |
33 | { |
|
33 | { | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | void DeclarativeXySeries::classBegin() |
|
36 | void DeclarativeXySeries::classBegin() | |
37 | { |
|
37 | { | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | void DeclarativeXySeries::componentComplete() |
|
40 | void DeclarativeXySeries::componentComplete() | |
41 | { |
|
41 | { | |
42 | QSeries *thisObj = reinterpret_cast<QSeries *>(series()); |
|
42 | QAbstractSeries *thisObj = reinterpret_cast<QAbstractSeries *>(series()); | |
43 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(thisObj->parent()); |
|
43 | DeclarativeChart *declarativeChart = qobject_cast<DeclarativeChart *>(thisObj->parent()); | |
44 |
|
44 | |||
45 | if (declarativeChart) { |
|
45 | if (declarativeChart) { | |
46 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); |
|
46 | QChart *chart = qobject_cast<QChart *>(declarativeChart->m_chart); | |
47 | Q_ASSERT(chart); |
|
47 | Q_ASSERT(chart); | |
48 | chart->addSeries(thisObj); |
|
48 | chart->addSeries(thisObj); | |
49 | } |
|
49 | } | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
52 | void DeclarativeXySeries::appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
53 | DeclarativeXyPoint *element) |
|
53 | DeclarativeXyPoint *element) | |
54 | { |
|
54 | { | |
55 | QXYSeries *series = qobject_cast<QXYSeries *>(list->object); |
|
55 | QXYSeries *series = qobject_cast<QXYSeries *>(list->object); | |
56 | if (series) |
|
56 | if (series) | |
57 | series->append(element->x(), element->y()); |
|
57 | series->append(element->x(), element->y()); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | QTCOMMERCIALCHART_END_NAMESPACE |
|
60 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,57 +1,57 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef DECLARATIVE_XY_SERIES_H |
|
21 | #ifndef DECLARATIVE_XY_SERIES_H | |
22 | #define DECLARATIVE_XY_SERIES_H |
|
22 | #define DECLARATIVE_XY_SERIES_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "declarativexypoint.h" |
|
25 | #include "declarativexypoint.h" | |
26 | #include <QDeclarativeParserStatus> |
|
26 | #include <QDeclarativeParserStatus> | |
27 | #include <QDeclarativeListProperty> |
|
27 | #include <QDeclarativeListProperty> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QChart; |
|
31 | class QChart; | |
32 | class QSeries; |
|
32 | class QAbstractSeries; | |
33 |
|
33 | |||
34 | class DeclarativeXySeries : public QDeclarativeParserStatus |
|
34 | class DeclarativeXySeries : public QDeclarativeParserStatus | |
35 | { |
|
35 | { | |
36 | Q_INTERFACES(QDeclarativeParserStatus) |
|
36 | Q_INTERFACES(QDeclarativeParserStatus) | |
37 |
|
37 | |||
38 | public: |
|
38 | public: | |
39 | explicit DeclarativeXySeries(); |
|
39 | explicit DeclarativeXySeries(); | |
40 | ~DeclarativeXySeries(); |
|
40 | ~DeclarativeXySeries(); | |
41 |
|
41 | |||
42 | public: // from QDeclarativeParserStatus |
|
42 | public: // from QDeclarativeParserStatus | |
43 | virtual void classBegin(); |
|
43 | virtual void classBegin(); | |
44 | virtual void componentComplete(); |
|
44 | virtual void componentComplete(); | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 | virtual QSeries *series() = 0; |
|
47 | virtual QAbstractSeries *series() = 0; | |
48 | virtual QDeclarativeListProperty<DeclarativeXyPoint> points() = 0; |
|
48 | virtual QDeclarativeListProperty<DeclarativeXyPoint> points() = 0; | |
49 |
|
49 | |||
50 | public Q_SLOTS: |
|
50 | public Q_SLOTS: | |
51 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, |
|
51 | static void appendPoints(QDeclarativeListProperty<DeclarativeXyPoint> *list, | |
52 | DeclarativeXyPoint *element); |
|
52 | DeclarativeXyPoint *element); | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 | QTCOMMERCIALCHART_END_NAMESPACE |
|
55 | QTCOMMERCIALCHART_END_NAMESPACE | |
56 |
|
56 | |||
57 | #endif // DECLARATIVE_XY_SERIES_H |
|
57 | #endif // DECLARATIVE_XY_SERIES_H |
@@ -1,282 +1,282 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qareaseries.h" |
|
21 | #include "qareaseries.h" | |
22 | #include "qareaseries_p.h" |
|
22 | #include "qareaseries_p.h" | |
23 | #include "qlineseries.h" |
|
23 | #include "qlineseries.h" | |
24 | #include "areachartitem_p.h" |
|
24 | #include "areachartitem_p.h" | |
25 | #include "legendmarker_p.h" |
|
25 | #include "legendmarker_p.h" | |
26 | #include "domain_p.h" |
|
26 | #include "domain_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QAreaSeries |
|
34 | \class QAreaSeries | |
35 | \brief The QAreaSeries class is used for making area charts. |
|
35 | \brief The QAreaSeries class is used for making area charts. | |
36 |
|
36 | |||
37 | \mainclass |
|
37 | \mainclass | |
38 |
|
38 | |||
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line |
|
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line | |
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. |
|
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. | |
42 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases |
|
42 | In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. |
|
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
44 |
|
44 | |||
45 | \image areachart.png |
|
45 | \image areachart.png | |
46 |
|
46 | |||
47 | Creating basic area chart is simple: |
|
47 | Creating basic area chart is simple: | |
48 | \code |
|
48 | \code | |
49 | QLineSeries* lineSeries = new QLineSeries(); |
|
49 | QLineSeries* lineSeries = new QLineSeries(); | |
50 | series->append(0, 6); |
|
50 | series->append(0, 6); | |
51 | series->append(2, 4); |
|
51 | series->append(2, 4); | |
52 | QAreaSeries* areaSeries = new QAreaSeries(lineSeries); |
|
52 | QAreaSeries* areaSeries = new QAreaSeries(lineSeries); | |
53 | ... |
|
53 | ... | |
54 | chartView->addSeries(areaSeries); |
|
54 | chartView->addSeries(areaSeries); | |
55 | \endcode |
|
55 | \endcode | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn virtual QSeriesType QAreaSeries::type() const |
|
59 | \fn virtual QSeriesType QAreaSeries::type() const | |
60 | \brief Returns type of series. |
|
60 | \brief Returns type of series. | |
61 | \sa QSeries, QSeriesType |
|
61 | \sa QAbstractSeries, QSeriesType | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \fn QLineSeries* QAreaSeries::upperSeries() const |
|
65 | \fn QLineSeries* QAreaSeries::upperSeries() const | |
66 | \brief Returns upperSeries used to define one of area boundaries. |
|
66 | \brief Returns upperSeries used to define one of area boundaries. | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \fn QLineSeries* QAreaSeries::lowerSeries() const |
|
70 | \fn QLineSeries* QAreaSeries::lowerSeries() const | |
71 | \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries |
|
71 | \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries | |
72 | this function return Null pointer. |
|
72 | this function return Null pointer. | |
73 | */ |
|
73 | */ | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | \fn QPen QAreaSeries::pen() const |
|
76 | \fn QPen QAreaSeries::pen() const | |
77 | \brief Returns the pen used to draw line for this series. |
|
77 | \brief Returns the pen used to draw line for this series. | |
78 | \sa setPen() |
|
78 | \sa setPen() | |
79 | */ |
|
79 | */ | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | \fn QPen QAreaSeries::brush() const |
|
82 | \fn QPen QAreaSeries::brush() const | |
83 | \brief Returns the brush used to draw line for this series. |
|
83 | \brief Returns the brush used to draw line for this series. | |
84 | \sa setBrush() |
|
84 | \sa setBrush() | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | \fn bool QAreaSeries::pointsVisible() const |
|
88 | \fn bool QAreaSeries::pointsVisible() const | |
89 | \brief Returns if the points are drawn for this series. |
|
89 | \brief Returns if the points are drawn for this series. | |
90 | \sa setPointsVisible() |
|
90 | \sa setPointsVisible() | |
91 | */ |
|
91 | */ | |
92 |
|
92 | |||
93 | /*! |
|
93 | /*! | |
94 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
94 | \fn void QAreaSeries::clicked(const QPointF& point) | |
95 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
95 | \brief Signal is emitted when user clicks the \a point on area chart. | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \fn void QAreaSeries::selected() |
|
99 | \fn void QAreaSeries::selected() | |
100 |
|
100 | |||
101 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
101 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
102 | implemented by the user of QAreaSeries API. |
|
102 | implemented by the user of QAreaSeries API. | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \fn void QAreaSeriesPrivate::updated() |
|
106 | \fn void QAreaSeriesPrivate::updated() | |
107 | \brief \internal |
|
107 | \brief \internal | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
111 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
112 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
112 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
113 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
113 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
114 | */ |
|
114 | */ | |
115 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
115 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
116 | : QSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) |
|
116 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) | |
117 | { |
|
117 | { | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
121 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
122 | and are deleted when mentioned object are destroyed. |
|
122 | and are deleted when mentioned object are destroyed. | |
123 | */ |
|
123 | */ | |
124 | QAreaSeries::~QAreaSeries() |
|
124 | QAreaSeries::~QAreaSeries() | |
125 | { |
|
125 | { | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 |
|
128 | |||
129 | QSeries::QSeriesType QAreaSeries::type() const |
|
129 | QAbstractSeries::QSeriesType QAreaSeries::type() const | |
130 | { |
|
130 | { | |
131 | return QSeries::SeriesTypeArea; |
|
131 | return QAbstractSeries::SeriesTypeArea; | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | QLineSeries* QAreaSeries::upperSeries() const |
|
134 | QLineSeries* QAreaSeries::upperSeries() const | |
135 | { |
|
135 | { | |
136 | Q_D(const QAreaSeries); |
|
136 | Q_D(const QAreaSeries); | |
137 | return d->m_upperSeries; |
|
137 | return d->m_upperSeries; | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | QLineSeries* QAreaSeries::lowerSeries() const |
|
140 | QLineSeries* QAreaSeries::lowerSeries() const | |
141 | { |
|
141 | { | |
142 | Q_D(const QAreaSeries); |
|
142 | Q_D(const QAreaSeries); | |
143 | return d->m_lowerSeries; |
|
143 | return d->m_lowerSeries; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | Sets \a pen used for drawing area outline. |
|
147 | Sets \a pen used for drawing area outline. | |
148 | */ |
|
148 | */ | |
149 | void QAreaSeries::setPen(const QPen &pen) |
|
149 | void QAreaSeries::setPen(const QPen &pen) | |
150 | { |
|
150 | { | |
151 | Q_D(QAreaSeries); |
|
151 | Q_D(QAreaSeries); | |
152 | if (d->m_pen != pen) { |
|
152 | if (d->m_pen != pen) { | |
153 | d->m_pen = pen; |
|
153 | d->m_pen = pen; | |
154 | emit d->updated(); |
|
154 | emit d->updated(); | |
155 | } |
|
155 | } | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | QPen QAreaSeries::pen() const |
|
158 | QPen QAreaSeries::pen() const | |
159 | { |
|
159 | { | |
160 | Q_D(const QAreaSeries); |
|
160 | Q_D(const QAreaSeries); | |
161 | return d->m_pen; |
|
161 | return d->m_pen; | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Sets \a brush used for filling the area. |
|
165 | Sets \a brush used for filling the area. | |
166 | */ |
|
166 | */ | |
167 | void QAreaSeries::setBrush(const QBrush &brush) |
|
167 | void QAreaSeries::setBrush(const QBrush &brush) | |
168 | { |
|
168 | { | |
169 | Q_D(QAreaSeries); |
|
169 | Q_D(QAreaSeries); | |
170 | if (d->m_brush != brush) { |
|
170 | if (d->m_brush != brush) { | |
171 | d->m_brush = brush; |
|
171 | d->m_brush = brush; | |
172 | emit d->updated(); |
|
172 | emit d->updated(); | |
173 | } |
|
173 | } | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 | QBrush QAreaSeries::brush() const |
|
176 | QBrush QAreaSeries::brush() const | |
177 | { |
|
177 | { | |
178 | Q_D(const QAreaSeries); |
|
178 | Q_D(const QAreaSeries); | |
179 | return d->m_brush; |
|
179 | return d->m_brush; | |
180 | } |
|
180 | } | |
181 | /*! |
|
181 | /*! | |
182 | Sets if data points are \a visible and should be drawn on line. |
|
182 | Sets if data points are \a visible and should be drawn on line. | |
183 | */ |
|
183 | */ | |
184 | void QAreaSeries::setPointsVisible(bool visible) |
|
184 | void QAreaSeries::setPointsVisible(bool visible) | |
185 | { |
|
185 | { | |
186 | Q_D(QAreaSeries); |
|
186 | Q_D(QAreaSeries); | |
187 | if (d->m_pointsVisible != visible) { |
|
187 | if (d->m_pointsVisible != visible) { | |
188 | d->m_pointsVisible = visible; |
|
188 | d->m_pointsVisible = visible; | |
189 | emit d->updated(); |
|
189 | emit d->updated(); | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | bool QAreaSeries::pointsVisible() const |
|
193 | bool QAreaSeries::pointsVisible() const | |
194 | { |
|
194 | { | |
195 | Q_D(const QAreaSeries); |
|
195 | Q_D(const QAreaSeries); | |
196 | return d->m_pointsVisible; |
|
196 | return d->m_pointsVisible; | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | bool QAreaSeries::setModel(QAbstractItemModel* model) |
|
199 | bool QAreaSeries::setModel(QAbstractItemModel* model) | |
200 | { |
|
200 | { | |
201 | Q_UNUSED(model); |
|
201 | Q_UNUSED(model); | |
202 | qWarning()<<"Not implemented"; |
|
202 | qWarning()<<"Not implemented"; | |
203 | return false; |
|
203 | return false; | |
204 | } |
|
204 | } | |
205 |
|
205 | |||
206 | QAbstractItemModel* QAreaSeries::model() const |
|
206 | QAbstractItemModel* QAreaSeries::model() const | |
207 | { |
|
207 | { | |
208 | return 0; |
|
208 | return 0; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
211 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
212 |
|
212 | |||
213 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : |
|
213 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : | |
214 | QSeriesPrivate(q), |
|
214 | QAbstractSeriesPrivate(q), | |
215 | m_upperSeries(upperSeries), |
|
215 | m_upperSeries(upperSeries), | |
216 | m_lowerSeries(lowerSeries), |
|
216 | m_lowerSeries(lowerSeries), | |
217 | m_pointsVisible(false) |
|
217 | m_pointsVisible(false) | |
218 | { |
|
218 | { | |
219 | } |
|
219 | } | |
220 |
|
220 | |||
221 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) |
|
221 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |
222 | { |
|
222 | { | |
223 | Q_Q(QAreaSeries); |
|
223 | Q_Q(QAreaSeries); | |
224 |
|
224 | |||
225 | qreal minX(domain.minX()); |
|
225 | qreal minX(domain.minX()); | |
226 | qreal minY(domain.minY()); |
|
226 | qreal minY(domain.minY()); | |
227 | qreal maxX(domain.maxX()); |
|
227 | qreal maxX(domain.maxX()); | |
228 | qreal maxY(domain.maxY()); |
|
228 | qreal maxY(domain.maxY()); | |
229 | int tickXCount(domain.tickXCount()); |
|
229 | int tickXCount(domain.tickXCount()); | |
230 | int tickYCount(domain.tickYCount()); |
|
230 | int tickYCount(domain.tickYCount()); | |
231 |
|
231 | |||
232 | QLineSeries* upperSeries = q->upperSeries(); |
|
232 | QLineSeries* upperSeries = q->upperSeries(); | |
233 | QLineSeries* lowerSeries = q->lowerSeries(); |
|
233 | QLineSeries* lowerSeries = q->lowerSeries(); | |
234 |
|
234 | |||
235 | for (int i = 0; i < upperSeries->count(); i++) |
|
235 | for (int i = 0; i < upperSeries->count(); i++) | |
236 | { |
|
236 | { | |
237 | qreal x = upperSeries->x(i); |
|
237 | qreal x = upperSeries->x(i); | |
238 | qreal y = upperSeries->y(i); |
|
238 | qreal y = upperSeries->y(i); | |
239 | minX = qMin(minX, x); |
|
239 | minX = qMin(minX, x); | |
240 | minY = qMin(minY, y); |
|
240 | minY = qMin(minY, y); | |
241 | maxX = qMax(maxX, x); |
|
241 | maxX = qMax(maxX, x); | |
242 | maxY = qMax(maxY, y); |
|
242 | maxY = qMax(maxY, y); | |
243 | } |
|
243 | } | |
244 | if(lowerSeries) { |
|
244 | if(lowerSeries) { | |
245 | for (int i = 0; i < lowerSeries->count(); i++) |
|
245 | for (int i = 0; i < lowerSeries->count(); i++) | |
246 | { |
|
246 | { | |
247 | qreal x = lowerSeries->x(i); |
|
247 | qreal x = lowerSeries->x(i); | |
248 | qreal y = lowerSeries->y(i); |
|
248 | qreal y = lowerSeries->y(i); | |
249 | minX = qMin(minX, x); |
|
249 | minX = qMin(minX, x); | |
250 | minY = qMin(minY, y); |
|
250 | minY = qMin(minY, y); | |
251 | maxX = qMax(maxX, x); |
|
251 | maxX = qMax(maxX, x); | |
252 | maxY = qMax(maxY, y); |
|
252 | maxY = qMax(maxY, y); | |
253 | }} |
|
253 | }} | |
254 |
|
254 | |||
255 | domain.setRangeX(minX,maxX,tickXCount); |
|
255 | domain.setRangeX(minX,maxX,tickXCount); | |
256 | domain.setRangeY(minY,maxY,tickYCount); |
|
256 | domain.setRangeY(minY,maxY,tickYCount); | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
259 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
260 | { |
|
260 | { | |
261 | Q_Q(QAreaSeries); |
|
261 | Q_Q(QAreaSeries); | |
262 |
|
262 | |||
263 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
263 | AreaChartItem* area = new AreaChartItem(q,presenter); | |
264 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
264 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
265 | presenter->animator()->addAnimation(area->upperLineItem()); |
|
265 | presenter->animator()->addAnimation(area->upperLineItem()); | |
266 | if(q->lowerSeries()) presenter->animator()->addAnimation(area->lowerLineItem()); |
|
266 | if(q->lowerSeries()) presenter->animator()->addAnimation(area->lowerLineItem()); | |
267 | } |
|
267 | } | |
268 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
268 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
269 | return area; |
|
269 | return area; | |
270 | } |
|
270 | } | |
271 |
|
271 | |||
272 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) |
|
272 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |
273 | { |
|
273 | { | |
274 | Q_Q(QAreaSeries); |
|
274 | Q_Q(QAreaSeries); | |
275 | QList<LegendMarker*> list; |
|
275 | QList<LegendMarker*> list; | |
276 | return list << new AreaLegendMarker(q,legend); |
|
276 | return list << new AreaLegendMarker(q,legend); | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | #include "moc_qareaseries.cpp" |
|
279 | #include "moc_qareaseries.cpp" | |
280 | #include "moc_qareaseries_p.cpp" |
|
280 | #include "moc_qareaseries_p.cpp" | |
281 |
|
281 | |||
282 | QTCOMMERCIALCHART_END_NAMESPACE |
|
282 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,71 +1,71 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QAREASERIES_H |
|
21 | #ifndef QAREASERIES_H | |
22 | #define QAREASERIES_H |
|
22 | #define QAREASERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QLineSeries; |
|
30 | class QLineSeries; | |
31 | class QAreaSeriesPrivate; |
|
31 | class QAreaSeriesPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries |
|
33 | class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QAbstractSeries | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | public: |
|
36 | public: | |
37 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); |
|
37 | explicit QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0); | |
38 | ~QAreaSeries(); |
|
38 | ~QAreaSeries(); | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | QSeries::QSeriesType type() const; |
|
41 | QAbstractSeries::QSeriesType type() const; | |
42 |
|
42 | |||
43 | QLineSeries* upperSeries() const; |
|
43 | QLineSeries* upperSeries() const; | |
44 | QLineSeries* lowerSeries() const; |
|
44 | QLineSeries* lowerSeries() const; | |
45 |
|
45 | |||
46 | void setPen(const QPen &pen); |
|
46 | void setPen(const QPen &pen); | |
47 | QPen pen() const; |
|
47 | QPen pen() const; | |
48 |
|
48 | |||
49 | void setBrush(const QBrush &brush); |
|
49 | void setBrush(const QBrush &brush); | |
50 | QBrush brush() const; |
|
50 | QBrush brush() const; | |
51 |
|
51 | |||
52 | void setPointsVisible(bool visible = true); |
|
52 | void setPointsVisible(bool visible = true); | |
53 | bool pointsVisible() const; |
|
53 | bool pointsVisible() const; | |
54 |
|
54 | |||
55 | bool setModel(QAbstractItemModel* model); |
|
55 | bool setModel(QAbstractItemModel* model); | |
56 | QAbstractItemModel* model() const; |
|
56 | QAbstractItemModel* model() const; | |
57 |
|
57 | |||
58 | Q_SIGNALS: |
|
58 | Q_SIGNALS: | |
59 | void clicked(const QPointF &point); |
|
59 | void clicked(const QPointF &point); | |
60 | void selected(); |
|
60 | void selected(); | |
61 |
|
61 | |||
62 | private: |
|
62 | private: | |
63 | Q_DECLARE_PRIVATE(QAreaSeries); |
|
63 | Q_DECLARE_PRIVATE(QAreaSeries); | |
64 | Q_DISABLE_COPY(QAreaSeries); |
|
64 | Q_DISABLE_COPY(QAreaSeries); | |
65 | friend class AreaLegendMarker; |
|
65 | friend class AreaLegendMarker; | |
66 | friend class AreaChartItem; |
|
66 | friend class AreaChartItem; | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
70 |
|
70 | |||
71 | #endif |
|
71 | #endif |
@@ -1,65 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QAREASERIES_P_H |
|
30 | #ifndef QAREASERIES_P_H | |
31 | #define QAREASERIES_P_H |
|
31 | #define QAREASERIES_P_H | |
32 |
|
32 | |||
33 | #include "qseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QAreaSeries; |
|
37 | class QAreaSeries; | |
38 |
|
38 | |||
39 | class QAreaSeriesPrivate: public QSeriesPrivate |
|
39 | class QAreaSeriesPrivate: public QAbstractSeriesPrivate | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q); |
|
44 | QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q); | |
45 |
|
45 | |||
46 | void scaleDomain(Domain& domain); |
|
46 | void scaleDomain(Domain& domain); | |
47 | Chart* createGraphics(ChartPresenter* presenter); |
|
47 | Chart* createGraphics(ChartPresenter* presenter); | |
48 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
48 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
49 |
|
49 | |||
50 | Q_SIGNALS: |
|
50 | Q_SIGNALS: | |
51 | void updated(); |
|
51 | void updated(); | |
52 |
|
52 | |||
53 | protected: |
|
53 | protected: | |
54 | QBrush m_brush; |
|
54 | QBrush m_brush; | |
55 | QPen m_pen; |
|
55 | QPen m_pen; | |
56 | QLineSeries* m_upperSeries; |
|
56 | QLineSeries* m_upperSeries; | |
57 | QLineSeries* m_lowerSeries; |
|
57 | QLineSeries* m_lowerSeries; | |
58 | bool m_pointsVisible; |
|
58 | bool m_pointsVisible; | |
59 | private: |
|
59 | private: | |
60 | Q_DECLARE_PUBLIC(QAreaSeries); |
|
60 | Q_DECLARE_PUBLIC(QAreaSeries); | |
61 | }; |
|
61 | }; | |
62 |
|
62 | |||
63 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | QTCOMMERCIALCHART_END_NAMESPACE | |
64 |
|
64 | |||
65 | #endif |
|
65 | #endif |
@@ -1,78 +1,78 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef BARCHARTMODEL_H |
|
21 | #ifndef BARCHARTMODEL_H | |
22 | #define BARCHARTMODEL_H |
|
22 | #define BARCHARTMODEL_H | |
23 |
|
23 | |||
24 | #include <QObject> |
|
24 | #include <QObject> | |
25 | #include <QStringList> |
|
25 | #include <QStringList> | |
26 | #include "qchartglobal.h" |
|
26 | #include "qchartglobal.h" | |
27 | #include <qseries.h> |
|
27 | #include <qabstractseries.h> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | // Model for bar chart. Internal class. |
|
31 | // Model for bar chart. Internal class. | |
32 | // TODO: Implement as QAbstractItemModel? |
|
32 | // TODO: Implement as QAbstractItemModel? | |
33 |
|
33 | |||
34 | class QBarSet; |
|
34 | class QBarSet; | |
35 |
|
35 | |||
36 | class BarChartModel : public QObject //, public QAbstractItemModel |
|
36 | class BarChartModel : public QObject //, public QAbstractItemModel | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 | public: |
|
39 | public: | |
40 | explicit BarChartModel(QStringList categories, QObject *parent = 0); |
|
40 | explicit BarChartModel(QStringList categories, QObject *parent = 0); | |
41 |
|
41 | |||
42 | QStringList category(); |
|
42 | QStringList category(); | |
43 | void appendBarSet(QBarSet *set); |
|
43 | void appendBarSet(QBarSet *set); | |
44 | void removeBarSet(QBarSet *set); |
|
44 | void removeBarSet(QBarSet *set); | |
45 | void insertBarSet(int i, QBarSet *set); |
|
45 | void insertBarSet(int i, QBarSet *set); | |
46 | void insertCategory(int i, QString category); |
|
46 | void insertCategory(int i, QString category); | |
47 | void removeCategory(int i); |
|
47 | void removeCategory(int i); | |
48 | QBarSet *barsetAt(int index) const; |
|
48 | QBarSet *barsetAt(int index) const; | |
49 | QList<QBarSet *> barSets() const; |
|
49 | QList<QBarSet *> barSets() const; | |
50 |
|
50 | |||
51 | int barsetCount() const; // Number of sets in model |
|
51 | int barsetCount() const; // Number of sets in model | |
52 | int categoryCount() const; // Number of categories |
|
52 | int categoryCount() const; // Number of categories | |
53 |
|
53 | |||
54 | qreal max() const; // Maximum value of all sets |
|
54 | qreal max() const; // Maximum value of all sets | |
55 | qreal min() const; // Minimum value of all sets |
|
55 | qreal min() const; // Minimum value of all sets | |
56 | qreal valueAt(int set, int category) const; |
|
56 | qreal valueAt(int set, int category) const; | |
57 | qreal percentageAt(int set, int category) const; |
|
57 | qreal percentageAt(int set, int category) const; | |
58 |
|
58 | |||
59 | qreal categorySum(int category) const; |
|
59 | qreal categorySum(int category) const; | |
60 | qreal absoluteCategorySum(int category) const; |
|
60 | qreal absoluteCategorySum(int category) const; | |
61 | qreal maxCategorySum() const; // returns maximum sum of sets in all categories. |
|
61 | qreal maxCategorySum() const; // returns maximum sum of sets in all categories. | |
62 |
|
62 | |||
63 | QString categoryName(int category); |
|
63 | QString categoryName(int category); | |
64 |
|
64 | |||
65 | Q_SIGNALS: |
|
65 | Q_SIGNALS: | |
66 | void modelUpdated(); |
|
66 | void modelUpdated(); | |
67 |
|
67 | |||
68 | public Q_SLOTS: |
|
68 | public Q_SLOTS: | |
69 |
|
69 | |||
70 | private: |
|
70 | private: | |
71 |
|
71 | |||
72 | QList<QBarSet *> m_dataModel; |
|
72 | QList<QBarSet *> m_dataModel; | |
73 | QStringList m_category; |
|
73 | QStringList m_category; | |
74 | }; |
|
74 | }; | |
75 |
|
75 | |||
76 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE | |
77 |
|
77 | |||
78 | #endif // BARCHARTMODEL_H |
|
78 | #endif // BARCHARTMODEL_H |
@@ -1,526 +1,527 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qbarseries.h" |
|
21 | #include "qbarseries.h" | |
22 | #include "qbarseries_p.h" |
|
22 | #include "qbarseries_p.h" | |
23 | #include "qbarset.h" |
|
23 | #include "qbarset.h" | |
24 | #include "qbarset_p.h" |
|
24 | #include "qbarset_p.h" | |
25 | #include "barchartmodel_p.h" |
|
25 | #include "barchartmodel_p.h" | |
26 | #include "domain_p.h" |
|
26 | #include "domain_p.h" | |
27 | #include "legendmarker_p.h" |
|
27 | #include "legendmarker_p.h" | |
28 | #include "chartdataset_p.h" |
|
28 | #include "chartdataset_p.h" | |
29 | #include "charttheme_p.h" |
|
29 | #include "charttheme_p.h" | |
30 | #include "chartanimator_p.h" |
|
30 | #include "chartanimator_p.h" | |
31 |
|
31 | |||
32 | #include <QAbstractItemModel> |
|
32 | #include <QAbstractItemModel> | |
33 | #include <QModelIndex> |
|
33 | #include <QModelIndex> | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | /*! |
|
37 | /*! | |
38 | \class QBarSeries |
|
38 | \class QBarSeries | |
39 | \brief part of QtCommercial chart API. |
|
39 | \brief part of QtCommercial chart API. | |
40 |
|
40 | |||
41 | QBarSeries represents a series of data shown as bars. One QBarSeries can contain multiple |
|
41 | QBarSeries represents a series of data shown as bars. One QBarSeries can contain multiple | |
42 | QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined |
|
42 | QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined | |
43 | by QStringList. |
|
43 | by QStringList. | |
44 |
|
44 | |||
45 | \mainclass |
|
45 | \mainclass | |
46 |
|
46 | |||
47 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries |
|
47 | \sa QBarSet, QStackedBarSeries, QPercentBarSeries | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \fn void QBarSeries::clicked(QBarSet *barset, QString category, Qt::MouseButtons button) |
|
51 | \fn void QBarSeries::clicked(QBarSet *barset, QString category, Qt::MouseButtons button) | |
52 |
|
52 | |||
53 | The signal is emitted if the user clicks with a mouse \a button on top of QBarSet \a barset of category \a category |
|
53 | The signal is emitted if the user clicks with a mouse \a button on top of QBarSet \a barset of category \a category | |
54 | contained by the series. |
|
54 | contained by the series. | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \fn void QBarSeries::selected() |
|
58 | \fn void QBarSeries::selected() | |
59 |
|
59 | |||
60 | The signal is emitted if the user selects/deselects the series. The logic for storing selections should be |
|
60 | The signal is emitted if the user selects/deselects the series. The logic for storing selections should be | |
61 | implemented by the user of QBarSeries API. |
|
61 | implemented by the user of QBarSeries API. | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) |
|
65 | \fn void QBarSeries::hovered(QBarSet* barset, bool status) | |
66 |
|
66 | |||
67 | The signal is emitted if mouse is hovered on top of series. |
|
67 | The signal is emitted if mouse is hovered on top of series. | |
68 | Parameter \a barset is the pointer of barset, where hover happened. |
|
68 | Parameter \a barset is the pointer of barset, where hover happened. | |
69 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. |
|
69 | Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series. | |
70 | */ |
|
70 | */ | |
71 |
|
71 | |||
72 | /*! |
|
72 | /*! | |
73 | Constructs empty QBarSeries. Parameter \a categories defines the categories for chart. |
|
73 | Constructs empty QBarSeries. Parameter \a categories defines the categories for chart. | |
74 | QBarSeries is QObject which is a child of a \a parent. |
|
74 | QBarSeries is QObject which is a child of a \a parent. | |
75 | */ |
|
75 | */ | |
76 | QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : |
|
76 | QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : | |
77 | QSeries(*new QBarSeriesPrivate(categories, this),parent) |
|
77 | QAbstractSeries(*new QBarSeriesPrivate(categories, this),parent) | |
78 | { |
|
78 | { | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | /*! |
|
81 | /*! | |
82 | Destructs barseries and owned barsets. |
|
82 | Destructs barseries and owned barsets. | |
83 | */ |
|
83 | */ | |
84 | QBarSeries::~QBarSeries() |
|
84 | QBarSeries::~QBarSeries() | |
85 | { |
|
85 | { | |
86 | // NOTE: d_ptr destroyed by QObject |
|
86 | // NOTE: d_ptr destroyed by QObject | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \internal |
|
90 | \internal | |
91 | */ |
|
91 | */ | |
92 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : |
|
92 | QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) : | |
93 | QSeries(d,parent) |
|
93 | QAbstractSeries(d,parent) | |
94 | { |
|
94 | { | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | /*! |
|
97 | /*! | |
98 | Returns the type of series. Derived classes override this. |
|
98 | Returns the type of series. Derived classes override this. | |
99 | */ |
|
99 | */ | |
100 | QSeries::QSeriesType QBarSeries::type() const |
|
100 | QAbstractSeries::QSeriesType QBarSeries::type() const | |
101 | { |
|
101 | { | |
102 | return QSeries::SeriesTypeBar; |
|
102 | return QAbstractSeries::SeriesTypeBar; | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | Adds a set of bars to series. Takes ownership of \a set. |
|
106 | Adds a set of bars to series. Takes ownership of \a set. | |
107 | Connects the clicked(QString, Qt::MouseButtons) signal |
|
107 | Connects the clicked(QString, Qt::MouseButtons) signal | |
108 | of \a set to this series |
|
108 | of \a set to this series | |
109 | */ |
|
109 | */ | |
110 | void QBarSeries::appendBarSet(QBarSet *set) |
|
110 | void QBarSeries::appendBarSet(QBarSet *set) | |
111 | { |
|
111 | { | |
112 | Q_D(QBarSeries); |
|
112 | Q_D(QBarSeries); | |
113 | d->m_internalModel->appendBarSet(set); |
|
113 | d->m_internalModel->appendBarSet(set); | |
114 | QObject::connect(set->d_ptr.data(), SIGNAL(valueChanged()), d, SLOT(barsetChanged())); |
|
114 | QObject::connect(set->d_ptr.data(), SIGNAL(valueChanged()), d, SLOT(barsetChanged())); | |
115 | emit d->restructuredBars(); |
|
115 | emit d->restructuredBars(); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | /*! |
|
118 | /*! | |
119 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. |
|
119 | Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set. | |
120 | Disconnects the clicked(QString, Qt::MouseButtons) signal |
|
120 | Disconnects the clicked(QString, Qt::MouseButtons) signal | |
121 | of \a set from this series |
|
121 | of \a set from this series | |
122 | */ |
|
122 | */ | |
123 | void QBarSeries::removeBarSet(QBarSet *set) |
|
123 | void QBarSeries::removeBarSet(QBarSet *set) | |
124 | { |
|
124 | { | |
125 | Q_D(QBarSeries); |
|
125 | Q_D(QBarSeries); | |
126 | d->m_internalModel->removeBarSet(set); |
|
126 | d->m_internalModel->removeBarSet(set); | |
127 | emit d->restructuredBars(); |
|
127 | emit d->restructuredBars(); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | Adds a list of barsets to series. Takes ownership of \a sets. |
|
131 | Adds a list of barsets to series. Takes ownership of \a sets. | |
132 | Connects the clicked(QString, Qt::MouseButtons) signals |
|
132 | Connects the clicked(QString, Qt::MouseButtons) signals | |
133 | of \a sets to this series |
|
133 | of \a sets to this series | |
134 | */ |
|
134 | */ | |
135 | void QBarSeries::appendBarSets(QList<QBarSet* > sets) |
|
135 | void QBarSeries::appendBarSets(QList<QBarSet* > sets) | |
136 | { |
|
136 | { | |
137 | Q_D(QBarSeries); |
|
137 | Q_D(QBarSeries); | |
138 | foreach (QBarSet* barset, sets) { |
|
138 | foreach (QBarSet* barset, sets) { | |
139 | d->m_internalModel->appendBarSet(barset); |
|
139 | d->m_internalModel->appendBarSet(barset); | |
140 | QObject::connect(barset, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); |
|
140 | QObject::connect(barset, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); | |
141 | } |
|
141 | } | |
142 | emit d->restructuredBars(); |
|
142 | emit d->restructuredBars(); | |
143 |
|
143 | |||
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets. |
|
147 | Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets. | |
148 | Disconnects the clicked(QString, Qt::MouseButtons) signal |
|
148 | Disconnects the clicked(QString, Qt::MouseButtons) signal | |
149 | of \a sets from this series |
|
149 | of \a sets from this series | |
150 | */ |
|
150 | */ | |
151 | void QBarSeries::removeBarSets(QList<QBarSet* > sets) |
|
151 | void QBarSeries::removeBarSets(QList<QBarSet* > sets) | |
152 | { |
|
152 | { | |
153 | Q_D(QBarSeries); |
|
153 | Q_D(QBarSeries); | |
154 |
|
154 | |||
155 | foreach (QBarSet* barset, sets) { |
|
155 | foreach (QBarSet* barset, sets) { | |
156 | d->m_internalModel->removeBarSet(barset); |
|
156 | d->m_internalModel->removeBarSet(barset); | |
157 | } |
|
157 | } | |
158 | emit d->restructuredBars(); |
|
158 | emit d->restructuredBars(); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | Inserts new \a set on the \a i position. |
|
162 | Inserts new \a set on the \a i position. | |
163 | The barset that is currently at this postion is moved to postion i + 1 |
|
163 | The barset that is currently at this postion is moved to postion i + 1 | |
164 | */ |
|
164 | */ | |
165 | void QBarSeries::insertBarSet(int i, QBarSet *set) |
|
165 | void QBarSeries::insertBarSet(int i, QBarSet *set) | |
166 | { |
|
166 | { | |
167 | Q_D(QBarSeries); |
|
167 | Q_D(QBarSeries); | |
168 | d->m_internalModel->insertBarSet(i, set); |
|
168 | d->m_internalModel->insertBarSet(i, set); | |
169 | emit d->barsetChanged(); |
|
169 | emit d->barsetChanged(); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | Inserts new \a category on the \a i position. |
|
173 | Inserts new \a category on the \a i position. | |
174 | The category that is currently at this postion is moved to postion i + 1 |
|
174 | The category that is currently at this postion is moved to postion i + 1 | |
175 | \sa removeCategory() |
|
175 | \sa removeCategory() | |
176 | */ |
|
176 | */ | |
177 | void QBarSeries::insertCategory(int i, QString category) |
|
177 | void QBarSeries::insertCategory(int i, QString category) | |
178 | { |
|
178 | { | |
179 | Q_D(QBarSeries); |
|
179 | Q_D(QBarSeries); | |
180 | d->m_internalModel->insertCategory(i, category); |
|
180 | d->m_internalModel->insertCategory(i, category); | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | /*! |
|
183 | /*! | |
184 | Removes the category specified by \a i |
|
184 | Removes the category specified by \a i | |
185 | \sa insertCategory() |
|
185 | \sa insertCategory() | |
186 | */ |
|
186 | */ | |
187 | void QBarSeries::removeCategory(int i) |
|
187 | void QBarSeries::removeCategory(int i) | |
188 | { |
|
188 | { | |
189 | Q_D(QBarSeries); |
|
189 | Q_D(QBarSeries); | |
190 | d->m_internalModel->removeCategory(i); |
|
190 | d->m_internalModel->removeCategory(i); | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | /*! |
|
193 | /*! | |
194 | Returns number of sets in series. |
|
194 | Returns number of sets in series. | |
195 | */ |
|
195 | */ | |
196 | int QBarSeries::barsetCount() const |
|
196 | int QBarSeries::barsetCount() const | |
197 | { |
|
197 | { | |
198 | Q_D(const QBarSeries); |
|
198 | Q_D(const QBarSeries); | |
199 | return d->m_internalModel->barsetCount(); |
|
199 | return d->m_internalModel->barsetCount(); | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | /*! |
|
202 | /*! | |
203 | Returns number of categories in series |
|
203 | Returns number of categories in series | |
204 | */ |
|
204 | */ | |
205 | int QBarSeries::categoryCount() const |
|
205 | int QBarSeries::categoryCount() const | |
206 | { |
|
206 | { | |
207 | Q_D(const QBarSeries); |
|
207 | Q_D(const QBarSeries); | |
208 | return d->m_internalModel->categoryCount(); |
|
208 | return d->m_internalModel->categoryCount(); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Returns a list of sets in series. Keeps ownership of sets. |
|
212 | Returns a list of sets in series. Keeps ownership of sets. | |
213 | */ |
|
213 | */ | |
214 | QList<QBarSet*> QBarSeries::barSets() const |
|
214 | QList<QBarSet*> QBarSeries::barSets() const | |
215 | { |
|
215 | { | |
216 | Q_D(const QBarSeries); |
|
216 | Q_D(const QBarSeries); | |
217 | return d->m_internalModel->barSets(); |
|
217 | return d->m_internalModel->barSets(); | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | /*! |
|
220 | /*! | |
221 | \fn bool QBarSeries::setModel(QAbstractItemModel *model) |
|
221 | \fn bool QBarSeries::setModel(QAbstractItemModel *model) | |
222 | Sets the \a model to be used as a data source |
|
222 | Sets the \a model to be used as a data source | |
223 | */ |
|
223 | */ | |
224 | bool QBarSeries::setModel(QAbstractItemModel *model) |
|
224 | bool QBarSeries::setModel(QAbstractItemModel *model) | |
225 | { |
|
225 | { | |
226 | Q_D(QBarSeries); |
|
226 | Q_D(QBarSeries); | |
227 | return d->setModel(model); |
|
227 | return d->setModel(model); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | /*! |
|
230 | /*! | |
231 | \fn bool QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation) |
|
231 | \fn bool QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation) | |
232 | Sets column/row specified by \a categories to be used as a list of bar series categories. |
|
232 | Sets column/row specified by \a categories to be used as a list of bar series categories. | |
233 | Parameter \a bottomBoundry indicates the column/row where the first bar set is located in the model. |
|
233 | Parameter \a bottomBoundry indicates the column/row where the first bar set is located in the model. | |
234 | Parameter \a topBoundry indicates the column/row where the last bar set is located in the model. |
|
234 | Parameter \a topBoundry indicates the column/row where the last bar set is located in the model. | |
235 | All the columns/rows inbetween those two values are also used as data for bar sets. |
|
235 | All the columns/rows inbetween those two values are also used as data for bar sets. | |
236 | The \a orientation parameter specifies whether the data is in columns or in rows. |
|
236 | The \a orientation parameter specifies whether the data is in columns or in rows. | |
237 | */ |
|
237 | */ | |
238 | void QBarSeries::setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation) |
|
238 | void QBarSeries::setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation) | |
239 | { |
|
239 | { | |
240 | Q_D(QBarSeries); |
|
240 | Q_D(QBarSeries); | |
241 | d->setModelMapping(categories,bottomBoundary,topBoundary,orientation); |
|
241 | d->setModelMapping(categories,bottomBoundary,topBoundary,orientation); | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | Returns the bar categories of the series. |
|
245 | Returns the bar categories of the series. | |
246 | */ |
|
246 | */ | |
247 | QBarCategories QBarSeries::categories() const |
|
247 | QBarCategories QBarSeries::categories() const | |
248 | { |
|
248 | { | |
249 | Q_D(const QBarSeries); |
|
249 | Q_D(const QBarSeries); | |
250 |
|
250 | |||
251 | QBarCategories categories; |
|
251 | QBarCategories categories; | |
252 | int count = d->m_internalModel->categoryCount(); |
|
252 | int count = d->m_internalModel->categoryCount(); | |
253 | for (int i=1; i <= count; i++) { |
|
253 | for (int i=1; i <= count; i++) { | |
254 | categories.insert(i, d->m_internalModel->categoryName(i - 1)); |
|
254 | categories.insert(i, d->m_internalModel->categoryName(i - 1)); | |
255 | } |
|
255 | } | |
256 | return categories; |
|
256 | return categories; | |
257 |
|
257 | |||
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | /*! |
|
260 | /*! | |
261 | Sets the visibility of labels in series to \a visible |
|
261 | Sets the visibility of labels in series to \a visible | |
262 | */ |
|
262 | */ | |
263 | void QBarSeries::setLabelsVisible(bool visible) |
|
263 | void QBarSeries::setLabelsVisible(bool visible) | |
264 | { |
|
264 | { | |
265 | foreach (QBarSet* s, barSets()) { |
|
265 | foreach (QBarSet* s, barSets()) { | |
266 | s->setLabelsVisible(visible); |
|
266 | s->setLabelsVisible(visible); | |
267 | } |
|
267 | } | |
268 | } |
|
268 | } | |
269 |
|
269 | |||
270 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
270 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
271 |
|
271 | |||
272 |
QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) : |
|
272 | QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) : | |
|
273 | QAbstractSeriesPrivate(q), | |||
273 | m_internalModel(new BarChartModel(categories,this)), |
|
274 | m_internalModel(new BarChartModel(categories,this)), | |
274 | m_model(0), |
|
275 | m_model(0), | |
275 | m_mapCategories(-1), |
|
276 | m_mapCategories(-1), | |
276 | m_mapBarBottom(-1), |
|
277 | m_mapBarBottom(-1), | |
277 | m_mapBarTop(-1), |
|
278 | m_mapBarTop(-1), | |
278 | m_mapFirst(0), |
|
279 | m_mapFirst(0), | |
279 | m_mapCount(0), |
|
280 | m_mapCount(0), | |
280 | m_mapOrientation(Qt::Vertical) |
|
281 | m_mapOrientation(Qt::Vertical) | |
281 | { |
|
282 | { | |
282 | } |
|
283 | } | |
283 |
|
284 | |||
284 | QBarSet* QBarSeriesPrivate::barsetAt(int index) |
|
285 | QBarSet* QBarSeriesPrivate::barsetAt(int index) | |
285 | { |
|
286 | { | |
286 | return m_internalModel->barsetAt(index); |
|
287 | return m_internalModel->barsetAt(index); | |
287 | } |
|
288 | } | |
288 |
|
289 | |||
289 | QString QBarSeriesPrivate::categoryName(int category) |
|
290 | QString QBarSeriesPrivate::categoryName(int category) | |
290 | { |
|
291 | { | |
291 | return m_internalModel->categoryName(category); |
|
292 | return m_internalModel->categoryName(category); | |
292 | } |
|
293 | } | |
293 |
|
294 | |||
294 | qreal QBarSeriesPrivate::min() |
|
295 | qreal QBarSeriesPrivate::min() | |
295 | { |
|
296 | { | |
296 | return m_internalModel->min(); |
|
297 | return m_internalModel->min(); | |
297 | } |
|
298 | } | |
298 |
|
299 | |||
299 | qreal QBarSeriesPrivate::max() |
|
300 | qreal QBarSeriesPrivate::max() | |
300 | { |
|
301 | { | |
301 | return m_internalModel->max(); |
|
302 | return m_internalModel->max(); | |
302 | } |
|
303 | } | |
303 |
|
304 | |||
304 | qreal QBarSeriesPrivate::valueAt(int set, int category) |
|
305 | qreal QBarSeriesPrivate::valueAt(int set, int category) | |
305 | { |
|
306 | { | |
306 | return m_internalModel->valueAt(set, category); |
|
307 | return m_internalModel->valueAt(set, category); | |
307 | } |
|
308 | } | |
308 |
|
309 | |||
309 | qreal QBarSeriesPrivate::percentageAt(int set, int category) |
|
310 | qreal QBarSeriesPrivate::percentageAt(int set, int category) | |
310 | { |
|
311 | { | |
311 | return m_internalModel->percentageAt(set, category); |
|
312 | return m_internalModel->percentageAt(set, category); | |
312 | } |
|
313 | } | |
313 |
|
314 | |||
314 | qreal QBarSeriesPrivate::categorySum(int category) |
|
315 | qreal QBarSeriesPrivate::categorySum(int category) | |
315 | { |
|
316 | { | |
316 | return m_internalModel->categorySum(category); |
|
317 | return m_internalModel->categorySum(category); | |
317 | } |
|
318 | } | |
318 |
|
319 | |||
319 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) |
|
320 | qreal QBarSeriesPrivate::absoluteCategorySum(int category) | |
320 | { |
|
321 | { | |
321 | return m_internalModel->absoluteCategorySum(category); |
|
322 | return m_internalModel->absoluteCategorySum(category); | |
322 | } |
|
323 | } | |
323 |
|
324 | |||
324 | qreal QBarSeriesPrivate::maxCategorySum() |
|
325 | qreal QBarSeriesPrivate::maxCategorySum() | |
325 | { |
|
326 | { | |
326 | return m_internalModel->maxCategorySum(); |
|
327 | return m_internalModel->maxCategorySum(); | |
327 | } |
|
328 | } | |
328 |
|
329 | |||
329 | BarChartModel& QBarSeriesPrivate::modelInternal() |
|
330 | BarChartModel& QBarSeriesPrivate::modelInternal() | |
330 | { |
|
331 | { | |
331 | return *m_internalModel; |
|
332 | return *m_internalModel; | |
332 | } |
|
333 | } | |
333 |
|
334 | |||
334 | bool QBarSeriesPrivate::setModel(QAbstractItemModel *model) |
|
335 | bool QBarSeriesPrivate::setModel(QAbstractItemModel *model) | |
335 | { |
|
336 | { | |
336 | // disconnect signals from old model |
|
337 | // disconnect signals from old model | |
337 | if(m_model) |
|
338 | if(m_model) | |
338 | { |
|
339 | { | |
339 | disconnect(m_model, 0, this, 0); |
|
340 | disconnect(m_model, 0, this, 0); | |
340 | m_mapCategories = -1; |
|
341 | m_mapCategories = -1; | |
341 | m_mapBarBottom = -1; |
|
342 | m_mapBarBottom = -1; | |
342 | m_mapBarTop = -1; |
|
343 | m_mapBarTop = -1; | |
343 | m_mapFirst = 0; |
|
344 | m_mapFirst = 0; | |
344 | m_mapCount = 0; |
|
345 | m_mapCount = 0; | |
345 | m_mapOrientation = Qt::Vertical; |
|
346 | m_mapOrientation = Qt::Vertical; | |
346 | } |
|
347 | } | |
347 |
|
348 | |||
348 | // set new model |
|
349 | // set new model | |
349 | if(model) |
|
350 | if(model) | |
350 | { |
|
351 | { | |
351 | m_model = model; |
|
352 | m_model = model; | |
352 | return true; |
|
353 | return true; | |
353 | } |
|
354 | } | |
354 | else |
|
355 | else | |
355 | { |
|
356 | { | |
356 | m_model = 0; |
|
357 | m_model = 0; | |
357 | return false; |
|
358 | return false; | |
358 | } |
|
359 | } | |
359 | } |
|
360 | } | |
360 |
|
361 | |||
361 | void QBarSeriesPrivate::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation) |
|
362 | void QBarSeriesPrivate::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation) | |
362 | { |
|
363 | { | |
363 | Q_Q(QBarSeries); |
|
364 | Q_Q(QBarSeries); | |
364 |
|
365 | |||
365 | if (m_model == 0) |
|
366 | if (m_model == 0) | |
366 | return; |
|
367 | return; | |
367 |
|
368 | |||
368 | m_mapCategories = categories; |
|
369 | m_mapCategories = categories; | |
369 | m_mapBarBottom = bottomBoundry; |
|
370 | m_mapBarBottom = bottomBoundry; | |
370 | m_mapBarTop = topBoundry; |
|
371 | m_mapBarTop = topBoundry; | |
371 | // m_mapFirst = 1; |
|
372 | // m_mapFirst = 1; | |
372 | m_mapOrientation = orientation; |
|
373 | m_mapOrientation = orientation; | |
373 |
|
374 | |||
374 | // connect the signals |
|
375 | // connect the signals | |
375 | if (m_mapOrientation == Qt::Vertical) { |
|
376 | if (m_mapOrientation == Qt::Vertical) { | |
376 | m_mapCount = m_model->rowCount() - m_mapFirst; |
|
377 | m_mapCount = m_model->rowCount() - m_mapFirst; | |
377 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
|
378 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), | |
378 | this, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
379 | this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
379 | connect(m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), |
|
380 | connect(m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), | |
380 | this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
381 | this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
381 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), |
|
382 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), | |
382 | this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
383 | this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
383 | } else { |
|
384 | } else { | |
384 | m_mapCount = m_model->columnCount() - m_mapFirst; |
|
385 | m_mapCount = m_model->columnCount() - m_mapFirst; | |
385 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
|
386 | connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), | |
386 | this, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
387 | this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
387 | connect(m_model,SIGNAL(columnsInserted(QModelIndex,int,int)), |
|
388 | connect(m_model,SIGNAL(columnsInserted(QModelIndex,int,int)), | |
388 | this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
389 | this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
389 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), |
|
390 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), | |
390 | this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
391 | this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
391 | } |
|
392 | } | |
392 |
|
393 | |||
393 | // create the initial bars |
|
394 | // create the initial bars | |
394 | delete m_internalModel; |
|
395 | delete m_internalModel; | |
395 | if (m_mapOrientation == Qt::Vertical) { |
|
396 | if (m_mapOrientation == Qt::Vertical) { | |
396 | QStringList categories; |
|
397 | QStringList categories; | |
397 | for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) |
|
398 | for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) | |
398 | categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString(); |
|
399 | categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString(); | |
399 | m_internalModel = new BarChartModel(categories, this); |
|
400 | m_internalModel = new BarChartModel(categories, this); | |
400 |
|
401 | |||
401 | for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { |
|
402 | for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { | |
402 | QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1)); |
|
403 | QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1)); | |
403 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) |
|
404 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) | |
404 | *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble(); |
|
405 | *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble(); | |
405 | q->appendBarSet(barSet); |
|
406 | q->appendBarSet(barSet); | |
406 | } |
|
407 | } | |
407 | } else { |
|
408 | } else { | |
408 | QStringList categories; |
|
409 | QStringList categories; | |
409 | for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) |
|
410 | for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) | |
410 | categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString(); |
|
411 | categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString(); | |
411 | m_internalModel = new BarChartModel(categories, this); |
|
412 | m_internalModel = new BarChartModel(categories, this); | |
412 |
|
413 | |||
413 | for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { |
|
414 | for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { | |
414 | QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1)); |
|
415 | QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1)); | |
415 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) |
|
416 | for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) | |
416 | *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble(); |
|
417 | *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble(); | |
417 | q->appendBarSet(barSet); |
|
418 | q->appendBarSet(barSet); | |
418 | } |
|
419 | } | |
419 | } |
|
420 | } | |
420 | } |
|
421 | } | |
421 |
|
422 | |||
422 | void QBarSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
423 | void QBarSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
423 | { |
|
424 | { | |
424 | Q_UNUSED(bottomRight) |
|
425 | Q_UNUSED(bottomRight) | |
425 |
|
426 | |||
426 | if (m_mapOrientation == Qt::Vertical) |
|
427 | if (m_mapOrientation == Qt::Vertical) | |
427 | { |
|
428 | { | |
428 | // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries |
|
429 | // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries | |
429 | if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop && topLeft.row() >= m_mapFirst && topLeft.row() < m_mapFirst + m_mapCount) |
|
430 | if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop && topLeft.row() >= m_mapFirst && topLeft.row() < m_mapFirst + m_mapCount) | |
430 | barsetAt(topLeft.column() - m_mapBarBottom)->setValue(topLeft.row() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
431 | barsetAt(topLeft.column() - m_mapBarBottom)->setValue(topLeft.row() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
431 | } |
|
432 | } | |
432 | else |
|
433 | else | |
433 | { |
|
434 | { | |
434 | // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries |
|
435 | // model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries | |
435 | if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop && topLeft.column() >= m_mapFirst && topLeft.column() < m_mapFirst + m_mapCount) |
|
436 | if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop && topLeft.column() >= m_mapFirst && topLeft.column() < m_mapFirst + m_mapCount) | |
436 | barsetAt(topLeft.row() - m_mapBarBottom)->setValue(topLeft.column() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
437 | barsetAt(topLeft.row() - m_mapBarBottom)->setValue(topLeft.column() - m_mapFirst, m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
437 | } |
|
438 | } | |
438 | } |
|
439 | } | |
439 |
|
440 | |||
440 | void QBarSeriesPrivate::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/) |
|
441 | void QBarSeriesPrivate::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/) | |
441 | { |
|
442 | { | |
442 | Q_Q(QBarSeries); |
|
443 | Q_Q(QBarSeries); | |
443 |
|
444 | |||
444 | if (m_mapOrientation == Qt::Vertical) { |
|
445 | if (m_mapOrientation == Qt::Vertical) { | |
445 | q->insertCategory(start - m_mapFirst, QString("Row: %1").arg(start + 1)); |
|
446 | q->insertCategory(start - m_mapFirst, QString("Row: %1").arg(start + 1)); | |
446 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { |
|
447 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { | |
447 | barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble()); |
|
448 | barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble()); | |
448 | } |
|
449 | } | |
449 | } else { |
|
450 | } else { | |
450 | q->insertCategory(start - m_mapFirst, QString("Column: %1").arg(start + 1)); |
|
451 | q->insertCategory(start - m_mapFirst, QString("Column: %1").arg(start + 1)); | |
451 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { |
|
452 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { | |
452 | barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble()); |
|
453 | barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble()); | |
453 | } |
|
454 | } | |
454 | } |
|
455 | } | |
455 | emit restructuredBars(); |
|
456 | emit restructuredBars(); | |
456 | } |
|
457 | } | |
457 |
|
458 | |||
458 | void QBarSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) |
|
459 | void QBarSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |
459 | { |
|
460 | { | |
460 | Q_Q(QBarSeries); |
|
461 | Q_Q(QBarSeries); | |
461 | Q_UNUSED(parent) |
|
462 | Q_UNUSED(parent) | |
462 | Q_UNUSED(end) |
|
463 | Q_UNUSED(end) | |
463 |
|
464 | |||
464 | q->removeCategory(start - m_mapFirst); |
|
465 | q->removeCategory(start - m_mapFirst); | |
465 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) |
|
466 | for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) | |
466 | { |
|
467 | { | |
467 | barsetAt(i)->removeValue(start - m_mapFirst); |
|
468 | barsetAt(i)->removeValue(start - m_mapFirst); | |
468 | } |
|
469 | } | |
469 | emit restructuredBars(); |
|
470 | emit restructuredBars(); | |
470 | } |
|
471 | } | |
471 |
|
472 | |||
472 | void QBarSeriesPrivate::barsetChanged() |
|
473 | void QBarSeriesPrivate::barsetChanged() | |
473 | { |
|
474 | { | |
474 | emit updatedBars(); |
|
475 | emit updatedBars(); | |
475 | } |
|
476 | } | |
476 |
|
477 | |||
477 | void QBarSeriesPrivate::scaleDomain(Domain& domain) |
|
478 | void QBarSeriesPrivate::scaleDomain(Domain& domain) | |
478 | { |
|
479 | { | |
479 | qreal minX(domain.minX()); |
|
480 | qreal minX(domain.minX()); | |
480 | qreal minY(domain.minY()); |
|
481 | qreal minY(domain.minY()); | |
481 | qreal maxX(domain.maxX()); |
|
482 | qreal maxX(domain.maxX()); | |
482 | qreal maxY(domain.maxY()); |
|
483 | qreal maxY(domain.maxY()); | |
483 | int tickXCount(domain.tickXCount()); |
|
484 | int tickXCount(domain.tickXCount()); | |
484 | int tickYCount(domain.tickYCount()); |
|
485 | int tickYCount(domain.tickYCount()); | |
485 |
|
486 | |||
486 | qreal x = m_internalModel->categoryCount(); |
|
487 | qreal x = m_internalModel->categoryCount(); | |
487 | qreal y = max(); |
|
488 | qreal y = max(); | |
488 | minX = qMin(minX, x); |
|
489 | minX = qMin(minX, x); | |
489 | minY = qMin(minY, y); |
|
490 | minY = qMin(minY, y); | |
490 | maxX = qMax(maxX, x); |
|
491 | maxX = qMax(maxX, x); | |
491 | maxY = qMax(maxY, y); |
|
492 | maxY = qMax(maxY, y); | |
492 | tickXCount = x+1; |
|
493 | tickXCount = x+1; | |
493 |
|
494 | |||
494 | domain.setRangeX(minX,maxX,tickXCount); |
|
495 | domain.setRangeX(minX,maxX,tickXCount); | |
495 | domain.setRangeY(minY,maxY,tickYCount); |
|
496 | domain.setRangeY(minY,maxY,tickYCount); | |
496 | } |
|
497 | } | |
497 |
|
498 | |||
498 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
499 | Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
499 | { |
|
500 | { | |
500 | Q_Q(QBarSeries); |
|
501 | Q_Q(QBarSeries); | |
501 |
|
502 | |||
502 | BarChartItem* bar = new BarChartItem(q,presenter); |
|
503 | BarChartItem* bar = new BarChartItem(q,presenter); | |
503 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
504 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
504 | presenter->animator()->addAnimation(bar); |
|
505 | presenter->animator()->addAnimation(bar); | |
505 | } |
|
506 | } | |
506 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
507 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
507 | return bar; |
|
508 | return bar; | |
508 |
|
509 | |||
509 | } |
|
510 | } | |
510 |
|
511 | |||
511 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) |
|
512 | QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) | |
512 | { |
|
513 | { | |
513 | Q_Q(QBarSeries); |
|
514 | Q_Q(QBarSeries); | |
514 | QList<LegendMarker*> markers; |
|
515 | QList<LegendMarker*> markers; | |
515 | foreach(QBarSet* set, q->barSets()) { |
|
516 | foreach(QBarSet* set, q->barSets()) { | |
516 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); |
|
517 | BarLegendMarker* marker = new BarLegendMarker(q,set,legend); | |
517 | markers << marker; |
|
518 | markers << marker; | |
518 | } |
|
519 | } | |
519 |
|
520 | |||
520 | return markers; |
|
521 | return markers; | |
521 | } |
|
522 | } | |
522 |
|
523 | |||
523 | #include "moc_qbarseries.cpp" |
|
524 | #include "moc_qbarseries.cpp" | |
524 | #include "moc_qbarseries_p.cpp" |
|
525 | #include "moc_qbarseries_p.cpp" | |
525 |
|
526 | |||
526 | QTCOMMERCIALCHART_END_NAMESPACE |
|
527 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,82 +1,82 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef BARSERIES_H |
|
21 | #ifndef BARSERIES_H | |
22 | #define BARSERIES_H |
|
22 | #define BARSERIES_H | |
23 |
|
23 | |||
24 | #include <qseries.h> |
|
24 | #include <qabstractseries.h> | |
25 | #include <QStringList> |
|
25 | #include <QStringList> | |
26 |
|
26 | |||
27 | class QModelIndex; |
|
27 | class QModelIndex; | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | typedef QStringList QBarCategories; |
|
31 | typedef QStringList QBarCategories; | |
32 |
|
32 | |||
33 | class QBarSet; |
|
33 | class QBarSet; | |
34 | class BarChartModel; |
|
34 | class BarChartModel; | |
35 | class BarCategory; |
|
35 | class BarCategory; | |
36 | class QBarSeriesPrivate; |
|
36 | class QBarSeriesPrivate; | |
37 |
|
37 | |||
38 | // Container for series |
|
38 | // Container for series | |
39 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries |
|
39 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QAbstractSeries | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 | public: |
|
42 | public: | |
43 | explicit QBarSeries(QBarCategories categories, QObject *parent = 0); |
|
43 | explicit QBarSeries(QBarCategories categories, QObject *parent = 0); | |
44 | virtual ~QBarSeries(); |
|
44 | virtual ~QBarSeries(); | |
45 |
|
45 | |||
46 | QSeries::QSeriesType type() const; |
|
46 | QAbstractSeries::QSeriesType type() const; | |
47 |
|
47 | |||
48 | void appendBarSet(QBarSet *set); // Takes ownership of set |
|
48 | void appendBarSet(QBarSet *set); // Takes ownership of set | |
49 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set |
|
49 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |
50 | void appendBarSets(QList<QBarSet* > sets); |
|
50 | void appendBarSets(QList<QBarSet* > sets); | |
51 | void removeBarSets(QList<QBarSet* > sets); |
|
51 | void removeBarSets(QList<QBarSet* > sets); | |
52 | void insertBarSet(int i, QBarSet *set); |
|
52 | void insertBarSet(int i, QBarSet *set); | |
53 | void insertCategory(int i, QString category); |
|
53 | void insertCategory(int i, QString category); | |
54 | void removeCategory(int i); |
|
54 | void removeCategory(int i); | |
55 | int barsetCount() const; |
|
55 | int barsetCount() const; | |
56 | int categoryCount() const; |
|
56 | int categoryCount() const; | |
57 | QList<QBarSet*> barSets() const; |
|
57 | QList<QBarSet*> barSets() const; | |
58 | QBarCategories categories() const; |
|
58 | QBarCategories categories() const; | |
59 |
|
59 | |||
60 | void setLabelsVisible(bool visible = true); |
|
60 | void setLabelsVisible(bool visible = true); | |
61 |
|
61 | |||
62 | bool setModel(QAbstractItemModel *model); |
|
62 | bool setModel(QAbstractItemModel *model); | |
63 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
63 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |
64 |
|
64 | |||
65 | protected: |
|
65 | protected: | |
66 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); |
|
66 | explicit QBarSeries(QBarSeriesPrivate &d,QObject *parent = 0); | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
69 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); | |
70 | void selected(); |
|
70 | void selected(); | |
71 | void hovered(QBarSet* barset, bool status); |
|
71 | void hovered(QBarSet* barset, bool status); | |
72 |
|
72 | |||
73 | protected: |
|
73 | protected: | |
74 | Q_DECLARE_PRIVATE(QBarSeries) |
|
74 | Q_DECLARE_PRIVATE(QBarSeries) | |
75 | friend class BarChartItem; |
|
75 | friend class BarChartItem; | |
76 | friend class PercentBarChartItem; |
|
76 | friend class PercentBarChartItem; | |
77 | friend class StackedBarChartItem; |
|
77 | friend class StackedBarChartItem; | |
78 | }; |
|
78 | }; | |
79 |
|
79 | |||
80 | QTCOMMERCIALCHART_END_NAMESPACE |
|
80 | QTCOMMERCIALCHART_END_NAMESPACE | |
81 |
|
81 | |||
82 | #endif // BARSERIES_H |
|
82 | #endif // BARSERIES_H |
@@ -1,66 +1,66 | |||||
1 | #ifndef QBARSERIES_P_H |
|
1 | #ifndef QBARSERIES_P_H | |
2 | #define QBARSERIES_P_H |
|
2 | #define QBARSERIES_P_H | |
3 |
|
3 | |||
4 | #include "qbarseries.h" |
|
4 | #include "qbarseries.h" | |
5 | #include "qseries_p.h" |
|
5 | #include "qabstractseries_p.h" | |
6 | #include <QStringList> |
|
6 | #include <QStringList> | |
7 | #include <QSeries> |
|
7 | #include <QAbstractSeries> | |
8 |
|
8 | |||
9 | class QModelIndex; |
|
9 | class QModelIndex; | |
10 |
|
10 | |||
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
12 |
|
12 | |||
13 | // Container for series |
|
13 | // Container for series | |
14 | class QBarSeriesPrivate : public QSeriesPrivate |
|
14 | class QBarSeriesPrivate : public QAbstractSeriesPrivate | |
15 | { |
|
15 | { | |
16 | Q_OBJECT |
|
16 | Q_OBJECT | |
17 | public: |
|
17 | public: | |
18 | QBarSeriesPrivate(QBarCategories categories, QBarSeries *parent); |
|
18 | QBarSeriesPrivate(QBarCategories categories, QBarSeries *parent); | |
19 |
|
19 | |||
20 | void scaleDomain(Domain& domain); |
|
20 | void scaleDomain(Domain& domain); | |
21 | Chart* createGraphics(ChartPresenter* presenter); |
|
21 | Chart* createGraphics(ChartPresenter* presenter); | |
22 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
22 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
23 |
|
23 | |||
24 | bool setModel(QAbstractItemModel *model); |
|
24 | bool setModel(QAbstractItemModel *model); | |
25 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); |
|
25 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); | |
26 |
|
26 | |||
27 | QBarSet* barsetAt(int index); |
|
27 | QBarSet* barsetAt(int index); | |
28 | QString categoryName(int category); |
|
28 | QString categoryName(int category); | |
29 | qreal min(); |
|
29 | qreal min(); | |
30 | qreal max(); |
|
30 | qreal max(); | |
31 | qreal valueAt(int set, int category); |
|
31 | qreal valueAt(int set, int category); | |
32 | qreal percentageAt(int set, int category); |
|
32 | qreal percentageAt(int set, int category); | |
33 | qreal categorySum(int category); |
|
33 | qreal categorySum(int category); | |
34 | qreal absoluteCategorySum(int category); |
|
34 | qreal absoluteCategorySum(int category); | |
35 | qreal maxCategorySum(); |
|
35 | qreal maxCategorySum(); | |
36 | BarChartModel& modelInternal(); |
|
36 | BarChartModel& modelInternal(); | |
37 |
|
37 | |||
38 | Q_SIGNALS: |
|
38 | Q_SIGNALS: | |
39 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); |
|
39 | void clicked(QBarSet *barset, QString category, Qt::MouseButtons button); | |
40 | void selected(); |
|
40 | void selected(); | |
41 | void updatedBars(); |
|
41 | void updatedBars(); | |
42 | void restructuredBars(); |
|
42 | void restructuredBars(); | |
43 |
|
43 | |||
44 | private Q_SLOTS: |
|
44 | private Q_SLOTS: | |
45 | // slots for updating bars when data in model changes |
|
45 | // slots for updating bars when data in model changes | |
46 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
46 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
47 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
47 | void modelDataAdded(QModelIndex parent, int start, int end); | |
48 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
48 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
49 | void barsetChanged(); |
|
49 | void barsetChanged(); | |
50 |
|
50 | |||
51 | protected: |
|
51 | protected: | |
52 | BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good. |
|
52 | BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good. | |
53 | QAbstractItemModel* m_model; |
|
53 | QAbstractItemModel* m_model; | |
54 | int m_mapCategories; |
|
54 | int m_mapCategories; | |
55 | int m_mapBarBottom; |
|
55 | int m_mapBarBottom; | |
56 | int m_mapBarTop; |
|
56 | int m_mapBarTop; | |
57 | int m_mapFirst; |
|
57 | int m_mapFirst; | |
58 | int m_mapCount; |
|
58 | int m_mapCount; | |
59 | Qt::Orientation m_mapOrientation; |
|
59 | Qt::Orientation m_mapOrientation; | |
60 | private: |
|
60 | private: | |
61 | Q_DECLARE_PUBLIC(QBarSeries) |
|
61 | Q_DECLARE_PUBLIC(QBarSeries) | |
62 | }; |
|
62 | }; | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | QTCOMMERCIALCHART_END_NAMESPACE | |
65 |
|
65 | |||
66 | #endif // QBARSERIESPRIVATE_P_H |
|
66 | #endif // QBARSERIESPRIVATE_P_H |
@@ -1,108 +1,108 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qpercentbarseries.h" |
|
21 | #include "qpercentbarseries.h" | |
22 | #include "qpercentbarseries_p.h" |
|
22 | #include "qpercentbarseries_p.h" | |
23 | #include "percentbarchartitem_p.h" |
|
23 | #include "percentbarchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \class QPercentBarSeries |
|
32 | \class QPercentBarSeries | |
33 | \brief part of QtCommercial chart API. |
|
33 | \brief part of QtCommercial chart API. | |
34 |
|
34 | |||
35 | QPercentBarSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage |
|
35 | QPercentBarSeries represents a series of data shown as bars. Each bar of QBarSet is shown as percentage | |
36 | of all bars in category. One QPercentBarSeries can contain multiple QBarSet data sets. |
|
36 | of all bars in category. One QPercentBarSeries can contain multiple QBarSet data sets. | |
37 | QBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
37 | QBarSeries groups the data from sets to categories, which are defined by QStringList. | |
38 |
|
38 | |||
39 | \mainclass |
|
39 | \mainclass | |
40 |
|
40 | |||
41 | \sa QBarSet, QStackedBarSeries, QBarSeries |
|
41 | \sa QBarSet, QStackedBarSeries, QBarSeries | |
42 | */ |
|
42 | */ | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | \fn virtual QSeriesType QPercentBarSeries::type() const |
|
45 | \fn virtual QSeriesType QPercentBarSeries::type() const | |
46 | \brief Returns type of series. |
|
46 | \brief Returns type of series. | |
47 | \sa QSeries, QSeriesType |
|
47 | \sa QAbstractSeries, QSeriesType | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | Constructs empty QPercentBarSeries. Parameter \a categories defines the categories for chart. |
|
51 | Constructs empty QPercentBarSeries. Parameter \a categories defines the categories for chart. | |
52 | QPercentBarSeries is QObject which is a child of a \a parent. |
|
52 | QPercentBarSeries is QObject which is a child of a \a parent. | |
53 | */ |
|
53 | */ | |
54 | QPercentBarSeries::QPercentBarSeries(QBarCategories categories, QObject *parent) |
|
54 | QPercentBarSeries::QPercentBarSeries(QBarCategories categories, QObject *parent) | |
55 | : QBarSeries(*new QPercentBarSeriesPrivate(categories,this), parent) |
|
55 | : QBarSeries(*new QPercentBarSeriesPrivate(categories,this), parent) | |
56 | { |
|
56 | { | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QSeries::QSeriesType QPercentBarSeries::type() const |
|
59 | QAbstractSeries::QSeriesType QPercentBarSeries::type() const | |
60 | { |
|
60 | { | |
61 | return QSeries::SeriesTypePercentBar; |
|
61 | return QAbstractSeries::SeriesTypePercentBar; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
64 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
65 |
|
65 | |||
66 | QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QBarCategories categories, QPercentBarSeries *q) : QBarSeriesPrivate(categories,q) |
|
66 | QPercentBarSeriesPrivate::QPercentBarSeriesPrivate(QBarCategories categories, QPercentBarSeries *q) : QBarSeriesPrivate(categories,q) | |
67 | { |
|
67 | { | |
68 |
|
68 | |||
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void QPercentBarSeriesPrivate::scaleDomain(Domain& domain) |
|
71 | void QPercentBarSeriesPrivate::scaleDomain(Domain& domain) | |
72 | { |
|
72 | { | |
73 | Q_Q(QPercentBarSeries); |
|
73 | Q_Q(QPercentBarSeries); | |
74 | qreal minX(domain.minX()); |
|
74 | qreal minX(domain.minX()); | |
75 | qreal minY(domain.minY()); |
|
75 | qreal minY(domain.minY()); | |
76 | qreal maxX(domain.maxX()); |
|
76 | qreal maxX(domain.maxX()); | |
77 | qreal maxY(domain.maxY()); |
|
77 | qreal maxY(domain.maxY()); | |
78 | int tickXCount(domain.tickXCount()); |
|
78 | int tickXCount(domain.tickXCount()); | |
79 | int tickYCount(domain.tickYCount()); |
|
79 | int tickYCount(domain.tickYCount()); | |
80 |
|
80 | |||
81 | qreal x = q->categoryCount(); |
|
81 | qreal x = q->categoryCount(); | |
82 | minX = qMin(minX, x); |
|
82 | minX = qMin(minX, x); | |
83 | maxX = qMax(maxX, x); |
|
83 | maxX = qMax(maxX, x); | |
84 | minY = 0; |
|
84 | minY = 0; | |
85 | maxY = 100; |
|
85 | maxY = 100; | |
86 | tickXCount = x+1; |
|
86 | tickXCount = x+1; | |
87 |
|
87 | |||
88 | domain.setRangeX(minX,maxX,tickXCount); |
|
88 | domain.setRangeX(minX,maxX,tickXCount); | |
89 | domain.setRangeY(minY,maxY,tickYCount); |
|
89 | domain.setRangeY(minY,maxY,tickYCount); | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 |
|
92 | |||
93 | Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
93 | Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
94 | { |
|
94 | { | |
95 | Q_Q(QPercentBarSeries); |
|
95 | Q_Q(QPercentBarSeries); | |
96 |
|
96 | |||
97 | PercentBarChartItem* bar = new PercentBarChartItem(q,presenter); |
|
97 | PercentBarChartItem* bar = new PercentBarChartItem(q,presenter); | |
98 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
98 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
99 | presenter->animator()->addAnimation(bar); |
|
99 | presenter->animator()->addAnimation(bar); | |
100 | } |
|
100 | } | |
101 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
101 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
102 | return bar; |
|
102 | return bar; | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | #include "moc_qpercentbarseries.cpp" |
|
105 | #include "moc_qpercentbarseries.cpp" | |
106 |
|
106 | |||
107 | QTCOMMERCIALCHART_END_NAMESPACE |
|
107 | QTCOMMERCIALCHART_END_NAMESPACE | |
108 |
|
108 |
@@ -1,44 +1,44 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef PERCENTBARSERIES_H |
|
21 | #ifndef PERCENTBARSERIES_H | |
22 | #define PERCENTBARSERIES_H |
|
22 | #define PERCENTBARSERIES_H | |
23 |
|
23 | |||
24 | #include <QStringList> |
|
24 | #include <QStringList> | |
25 | #include <qbarseries.h> |
|
25 | #include <qbarseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QPercentBarSeriesPrivate; |
|
29 | class QPercentBarSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | public: |
|
34 | public: | |
35 | explicit QPercentBarSeries(QBarCategories categories, QObject *parent = 0); |
|
35 | explicit QPercentBarSeries(QBarCategories categories, QObject *parent = 0); | |
36 | QSeries::QSeriesType type() const; |
|
36 | QAbstractSeries::QSeriesType type() const; | |
37 | private: |
|
37 | private: | |
38 | Q_DECLARE_PRIVATE(QPercentBarSeries) |
|
38 | Q_DECLARE_PRIVATE(QPercentBarSeries) | |
39 | Q_DISABLE_COPY(QPercentBarSeries) |
|
39 | Q_DISABLE_COPY(QPercentBarSeries) | |
40 | }; |
|
40 | }; | |
41 |
|
41 | |||
42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
42 | QTCOMMERCIALCHART_END_NAMESPACE | |
43 |
|
43 | |||
44 | #endif // PERCENTBARSERIES_H |
|
44 | #endif // PERCENTBARSERIES_H |
@@ -1,108 +1,108 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qstackedbarseries.h" |
|
21 | #include "qstackedbarseries.h" | |
22 | #include "qstackedbarseries_p.h" |
|
22 | #include "qstackedbarseries_p.h" | |
23 | #include "stackedbarchartitem_p.h" |
|
23 | #include "stackedbarchartitem_p.h" | |
24 | #include "barchartmodel_p.h" |
|
24 | #include "barchartmodel_p.h" | |
25 | #include "chartdataset_p.h" |
|
25 | #include "chartdataset_p.h" | |
26 | #include "charttheme_p.h" |
|
26 | #include "charttheme_p.h" | |
27 | #include "chartanimator_p.h" |
|
27 | #include "chartanimator_p.h" | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | /*! |
|
31 | /*! | |
32 | \class QStackedBarSeries |
|
32 | \class QStackedBarSeries | |
33 | \brief part of QtCommercial chart API. |
|
33 | \brief part of QtCommercial chart API. | |
34 |
|
34 | |||
35 | QStackedBarSeries represents a series of data shown as bars. All bars in same category are |
|
35 | QStackedBarSeries represents a series of data shown as bars. All bars in same category are | |
36 | stacked on top of each other. One QStackedBarSeries can contain multiple QBarSet data sets. |
|
36 | stacked on top of each other. One QStackedBarSeries can contain multiple QBarSet data sets. | |
37 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. |
|
37 | QStackedBarSeries groups the data from sets to categories, which are defined by QStringList. | |
38 |
|
38 | |||
39 | \mainclass |
|
39 | \mainclass | |
40 |
|
40 | |||
41 | \sa QBarSet, QPercentBarSeries, QBarSeries |
|
41 | \sa QBarSet, QPercentBarSeries, QBarSeries | |
42 | */ |
|
42 | */ | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | \fn virtual QSeriesType QStackedBarSeries::type() const |
|
45 | \fn virtual QSeriesType QStackedBarSeries::type() const | |
46 | \brief Returns type of series. |
|
46 | \brief Returns type of series. | |
47 |
\sa QSeries |
|
47 | \sa QSeriesType | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | Constructs empty QStackedBarSeries. Parameter \a categories defines the categories for chart. |
|
51 | Constructs empty QStackedBarSeries. Parameter \a categories defines the categories for chart. | |
52 | QStackedBarSeries is QObject which is a child of a \a parent. |
|
52 | QStackedBarSeries is QObject which is a child of a \a parent. | |
53 | */ |
|
53 | */ | |
54 | QStackedBarSeries::QStackedBarSeries(QBarCategories categories, QObject *parent) |
|
54 | QStackedBarSeries::QStackedBarSeries(QBarCategories categories, QObject *parent) | |
55 | : QBarSeries(*new QStackedBarSeriesPrivate(categories,this), parent) |
|
55 | : QBarSeries(*new QStackedBarSeriesPrivate(categories,this), parent) | |
56 | { |
|
56 | { | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | QSeries::QSeriesType QStackedBarSeries::type() const |
|
59 | QAbstractSeries::QSeriesType QStackedBarSeries::type() const | |
60 | { |
|
60 | { | |
61 | return QSeries::SeriesTypeStackedBar; |
|
61 | return QAbstractSeries::SeriesTypeStackedBar; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
64 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
65 |
|
65 | |||
66 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QBarCategories categories, QStackedBarSeries *q) : QBarSeriesPrivate(categories,q) |
|
66 | QStackedBarSeriesPrivate::QStackedBarSeriesPrivate(QBarCategories categories, QStackedBarSeries *q) : QBarSeriesPrivate(categories,q) | |
67 | { |
|
67 | { | |
68 |
|
68 | |||
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void QStackedBarSeriesPrivate::scaleDomain(Domain& domain) |
|
71 | void QStackedBarSeriesPrivate::scaleDomain(Domain& domain) | |
72 | { |
|
72 | { | |
73 | qreal minX(domain.minX()); |
|
73 | qreal minX(domain.minX()); | |
74 | qreal minY(domain.minY()); |
|
74 | qreal minY(domain.minY()); | |
75 | qreal maxX(domain.maxX()); |
|
75 | qreal maxX(domain.maxX()); | |
76 | qreal maxY(domain.maxY()); |
|
76 | qreal maxY(domain.maxY()); | |
77 | int tickXCount(domain.tickXCount()); |
|
77 | int tickXCount(domain.tickXCount()); | |
78 | int tickYCount(domain.tickYCount()); |
|
78 | int tickYCount(domain.tickYCount()); | |
79 |
|
79 | |||
80 | qreal x = m_internalModel->categoryCount(); |
|
80 | qreal x = m_internalModel->categoryCount(); | |
81 | qreal y = maxCategorySum(); |
|
81 | qreal y = maxCategorySum(); | |
82 | minX = qMin(minX, x); |
|
82 | minX = qMin(minX, x); | |
83 | minY = qMin(minY, y); |
|
83 | minY = qMin(minY, y); | |
84 | maxX = qMax(maxX, x); |
|
84 | maxX = qMax(maxX, x); | |
85 | maxY = qMax(maxY, y); |
|
85 | maxY = qMax(maxY, y); | |
86 | tickXCount = x+1; |
|
86 | tickXCount = x+1; | |
87 |
|
87 | |||
88 | domain.setRangeX(minX,maxX,tickXCount); |
|
88 | domain.setRangeX(minX,maxX,tickXCount); | |
89 | domain.setRangeY(minY,maxY,tickYCount); |
|
89 | domain.setRangeY(minY,maxY,tickYCount); | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 |
|
92 | |||
93 | Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
93 | Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
94 | { |
|
94 | { | |
95 | Q_Q(QStackedBarSeries); |
|
95 | Q_Q(QStackedBarSeries); | |
96 |
|
96 | |||
97 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); |
|
97 | StackedBarChartItem* bar = new StackedBarChartItem(q,presenter); | |
98 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
98 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
99 | presenter->animator()->addAnimation(bar); |
|
99 | presenter->animator()->addAnimation(bar); | |
100 | } |
|
100 | } | |
101 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
101 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
102 | return bar; |
|
102 | return bar; | |
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | #include "moc_qstackedbarseries.cpp" |
|
105 | #include "moc_qstackedbarseries.cpp" | |
106 |
|
106 | |||
107 | QTCOMMERCIALCHART_END_NAMESPACE |
|
107 | QTCOMMERCIALCHART_END_NAMESPACE | |
108 |
|
108 |
@@ -1,44 +1,44 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef STACKEDBARSERIES_H |
|
21 | #ifndef STACKEDBARSERIES_H | |
22 | #define STACKEDBARSERIES_H |
|
22 | #define STACKEDBARSERIES_H | |
23 |
|
23 | |||
24 | #include <QStringList> |
|
24 | #include <QStringList> | |
25 | #include <qbarseries.h> |
|
25 | #include <qbarseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QStackedBarSeriesPrivate; |
|
29 | class QStackedBarSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | public: |
|
34 | public: | |
35 | explicit QStackedBarSeries(QBarCategories categories, QObject *parent = 0); |
|
35 | explicit QStackedBarSeries(QBarCategories categories, QObject *parent = 0); | |
36 | QSeries::QSeriesType type() const; |
|
36 | QAbstractSeries::QSeriesType type() const; | |
37 | private: |
|
37 | private: | |
38 | Q_DECLARE_PRIVATE(QStackedBarSeries) |
|
38 | Q_DECLARE_PRIVATE(QStackedBarSeries) | |
39 | Q_DISABLE_COPY(QStackedBarSeries) |
|
39 | Q_DISABLE_COPY(QStackedBarSeries) | |
40 | }; |
|
40 | }; | |
41 |
|
41 | |||
42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
42 | QTCOMMERCIALCHART_END_NAMESPACE | |
43 |
|
43 | |||
44 | #endif // STACKEDBARSERIES_H |
|
44 | #endif // STACKEDBARSERIES_H |
@@ -1,252 +1,252 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchartaxis.h" |
|
22 | #include "qchartaxis.h" | |
23 | #include "qchartaxis_p.h" |
|
23 | #include "qchartaxis_p.h" | |
24 | #include "qseries_p.h" |
|
24 | #include "qabstractseries_p.h" | |
25 | #include "qbarseries.h" |
|
25 | #include "qbarseries.h" | |
26 | #include "qstackedbarseries.h" |
|
26 | #include "qstackedbarseries.h" | |
27 | #include "qpercentbarseries.h" |
|
27 | #include "qpercentbarseries.h" | |
28 | #include "qpieseries.h" |
|
28 | #include "qpieseries.h" | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), |
|
32 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), | |
33 | m_axisX(new QChartAxis(this)), |
|
33 | m_axisX(new QChartAxis(this)), | |
34 | m_axisY(new QChartAxis(this)), |
|
34 | m_axisY(new QChartAxis(this)), | |
35 | m_domainIndex(0), |
|
35 | m_domainIndex(0), | |
36 | m_axisXInitialized(false) |
|
36 | m_axisXInitialized(false) | |
37 | { |
|
37 | { | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | ChartDataSet::~ChartDataSet() |
|
40 | ChartDataSet::~ChartDataSet() | |
41 | { |
|
41 | { | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) |
|
44 | void ChartDataSet::addSeries(QAbstractSeries* series, QChartAxis *axisY) | |
45 | { |
|
45 | { | |
46 | if(axisY==0) axisY = m_axisY; |
|
46 | if(axisY==0) axisY = m_axisY; | |
47 |
|
47 | |||
48 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
48 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
49 |
|
49 | |||
50 | if(axis) { |
|
50 | if(axis) { | |
51 | qWarning() << "Can not add series. Series already on the chart"; |
|
51 | qWarning() << "Can not add series. Series already on the chart"; | |
52 | return; |
|
52 | return; | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | series->setParent(this); // take ownership |
|
55 | series->setParent(this); // take ownership | |
56 | axisY->setParent(this); // take ownership |
|
56 | axisY->setParent(this); // take ownership | |
57 |
|
57 | |||
58 | Domain* domain = m_axisDomainMap.value(axisY); |
|
58 | Domain* domain = m_axisDomainMap.value(axisY); | |
59 |
|
59 | |||
60 | if(!domain) { |
|
60 | if(!domain) { | |
61 | domain = new Domain(axisY); |
|
61 | domain = new Domain(axisY); | |
62 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
62 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
63 | QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); |
|
63 | QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
64 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
64 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
65 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX()->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
65 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX()->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
66 | //initialize |
|
66 | //initialize | |
67 | m_axisDomainMap.insert(axisY,domain); |
|
67 | m_axisDomainMap.insert(axisY,domain); | |
68 | emit axisAdded(axisY,domain); |
|
68 | emit axisAdded(axisY,domain); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | if(!m_axisXInitialized){ |
|
71 | if(!m_axisXInitialized){ | |
72 | emit axisAdded(axisX(),domain); |
|
72 | emit axisAdded(axisX(),domain); | |
73 | m_axisXInitialized=true; |
|
73 | m_axisXInitialized=true; | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | series->d_ptr->scaleDomain(*domain); |
|
76 | series->d_ptr->scaleDomain(*domain); | |
77 |
|
77 | |||
78 | if(series->type() == QSeries::SeriesTypeBar || series->type() == QSeries::SeriesTypeStackedBar || series->type() == QSeries::SeriesTypePercentBar) |
|
78 | if(series->type() == QAbstractSeries::SeriesTypeBar | |
79 | { |
|
79 | || series->type() == QAbstractSeries::SeriesTypeStackedBar | |
|
80 | || series->type() == QAbstractSeries::SeriesTypePercentBar) { | |||
80 | QBarSeries* barSeries = static_cast<QBarSeries*>(series); |
|
81 | QBarSeries* barSeries = static_cast<QBarSeries*>(series); | |
81 | setupCategories(barSeries); |
|
82 | setupCategories(barSeries); | |
82 | } |
|
83 | } | |
83 |
|
84 | |||
84 |
if (series->type()== QSeries::SeriesTypePie && |
|
85 | if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisMap.count() == 0) { | |
85 | { |
|
|||
86 | axisX()->hide(); |
|
86 | axisX()->hide(); | |
87 | this->axisY()->hide(); |
|
87 | this->axisY()->hide(); | |
88 | } |
|
88 | } | |
89 |
|
89 | |||
90 | m_seriesAxisMap.insert(series,axisY); |
|
90 | m_seriesAxisMap.insert(series,axisY); | |
91 |
|
91 | |||
92 | QMapIterator<int, QSeries*> i(m_indexSeriesMap); |
|
92 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
93 |
|
93 | |||
94 | int key=0; |
|
94 | int key=0; | |
95 | while (i.hasNext()) { |
|
95 | while (i.hasNext()) { | |
96 | i.next(); |
|
96 | i.next(); | |
97 | if(i.key()!=key) { |
|
97 | if(i.key()!=key) { | |
98 | break; |
|
98 | break; | |
99 | } |
|
99 | } | |
100 | key++; |
|
100 | key++; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | m_indexSeriesMap.insert(key,series); |
|
103 | m_indexSeriesMap.insert(key,series); | |
104 |
|
104 | |||
105 | emit seriesAdded(series,domain); |
|
105 | emit seriesAdded(series,domain); | |
106 |
|
106 | |||
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | QChartAxis* ChartDataSet::removeSeries(QSeries* series) |
|
109 | QChartAxis* ChartDataSet::removeSeries(QAbstractSeries* series) | |
110 | { |
|
110 | { | |
111 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
111 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
112 |
|
112 | |||
113 | if(!axis){ |
|
113 | if(!axis){ | |
114 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
114 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
115 | return 0; |
|
115 | return 0; | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | emit seriesRemoved(series); |
|
118 | emit seriesRemoved(series); | |
119 |
|
119 | |||
120 | m_seriesAxisMap.remove(series); |
|
120 | m_seriesAxisMap.remove(series); | |
121 | int key = seriesIndex(series); |
|
121 | int key = seriesIndex(series); | |
122 | Q_ASSERT(key!=-1); |
|
122 | Q_ASSERT(key!=-1); | |
123 |
|
123 | |||
124 | m_indexSeriesMap.remove(key); |
|
124 | m_indexSeriesMap.remove(key); | |
125 | series->setParent(0); |
|
125 | series->setParent(0); | |
126 |
|
126 | |||
127 | QList<QChartAxis*> axes = m_seriesAxisMap.values(); |
|
127 | QList<QChartAxis*> axes = m_seriesAxisMap.values(); | |
128 |
|
128 | |||
129 | int i = axes.indexOf(axis); |
|
129 | int i = axes.indexOf(axis); | |
130 |
|
130 | |||
131 | if(i==-1){ |
|
131 | if(i==-1){ | |
132 | Domain* domain = m_axisDomainMap.take(axis); |
|
132 | Domain* domain = m_axisDomainMap.take(axis); | |
133 | emit axisRemoved(axis); |
|
133 | emit axisRemoved(axis); | |
134 | if(axis!=axisY()){ |
|
134 | if(axis!=axisY()){ | |
135 | axis->setParent(0); |
|
135 | axis->setParent(0); | |
136 | } |
|
136 | } | |
137 | delete domain; |
|
137 | delete domain; | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | if(m_seriesAxisMap.values().size()==0) |
|
140 | if(m_seriesAxisMap.values().size()==0) | |
141 | { |
|
141 | { | |
142 | m_axisXInitialized=false; |
|
142 | m_axisXInitialized=false; | |
143 | emit axisRemoved(axisX()); |
|
143 | emit axisRemoved(axisX()); | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | return axis; |
|
146 | return axis; | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | void ChartDataSet::removeAllSeries() |
|
149 | void ChartDataSet::removeAllSeries() | |
150 | { |
|
150 | { | |
151 | QList<QSeries*> series = m_seriesAxisMap.keys(); |
|
151 | QList<QAbstractSeries*> series = m_seriesAxisMap.keys(); | |
152 | QList<QChartAxis*> axes; |
|
152 | QList<QChartAxis*> axes; | |
153 |
foreach(QSeries* |
|
153 | foreach(QAbstractSeries *s , series) { | |
154 | QChartAxis* axis = removeSeries(s); |
|
154 | QChartAxis* axis = removeSeries(s); | |
155 | if(axis==axisY()) continue; |
|
155 | if(axis==axisY()) continue; | |
156 | int i = axes.indexOf(axis); |
|
156 | int i = axes.indexOf(axis); | |
157 | if(i==-1){ |
|
157 | if(i==-1){ | |
158 | axes<<axis; |
|
158 | axes<<axis; | |
159 | } |
|
159 | } | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | Q_ASSERT(m_seriesAxisMap.count()==0); |
|
162 | Q_ASSERT(m_seriesAxisMap.count()==0); | |
163 | Q_ASSERT(m_axisDomainMap.count()==0); |
|
163 | Q_ASSERT(m_axisDomainMap.count()==0); | |
164 |
|
164 | |||
165 | qDeleteAll(series); |
|
165 | qDeleteAll(series); | |
166 | qDeleteAll(axes); |
|
166 | qDeleteAll(axes); | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | void ChartDataSet::setupCategories(QBarSeries* series) |
|
169 | void ChartDataSet::setupCategories(QBarSeries* series) | |
170 | { |
|
170 | { | |
171 | QChartAxisCategories* categories = axisX()->categories(); |
|
171 | QChartAxisCategories* categories = axisX()->categories(); | |
172 | categories->clear(); |
|
172 | categories->clear(); | |
173 | categories->insert(series->categories()); |
|
173 | categories->insert(series->categories()); | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
176 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
177 | { |
|
177 | { | |
178 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
178 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); | |
179 | while (i.hasNext()) { |
|
179 | while (i.hasNext()) { | |
180 | i.next(); |
|
180 | i.next(); | |
181 | i.value()->zoomIn(rect,size); |
|
181 | i.value()->zoomIn(rect,size); | |
182 | } |
|
182 | } | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
185 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
186 | { |
|
186 | { | |
187 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
187 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); | |
188 | while (i.hasNext()) { |
|
188 | while (i.hasNext()) { | |
189 | i.next(); |
|
189 | i.next(); | |
190 | i.value()->zoomOut(rect,size); |
|
190 | i.value()->zoomOut(rect,size); | |
191 | } |
|
191 | } | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | int ChartDataSet::seriesCount(QSeries::QSeriesType type) |
|
194 | int ChartDataSet::seriesCount(QAbstractSeries::QSeriesType type) | |
195 | { |
|
195 | { | |
196 | int count=0; |
|
196 | int count=0; | |
197 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); |
|
197 | QMapIterator<QAbstractSeries*, QChartAxis*> i(m_seriesAxisMap); | |
198 | while (i.hasNext()) { |
|
198 | while (i.hasNext()) { | |
199 | i.next(); |
|
199 | i.next(); | |
200 | if(i.key()->type()==type) count++; |
|
200 | if(i.key()->type()==type) count++; | |
201 | } |
|
201 | } | |
202 | return count; |
|
202 | return count; | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | int ChartDataSet::seriesIndex(QSeries *series) |
|
205 | int ChartDataSet::seriesIndex(QAbstractSeries *series) | |
206 | { |
|
206 | { | |
207 | QMapIterator<int, QSeries*> i(m_indexSeriesMap); |
|
207 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
208 | while (i.hasNext()) { |
|
208 | while (i.hasNext()) { | |
209 | i.next(); |
|
209 | i.next(); | |
210 | if (i.value() == series) |
|
210 | if (i.value() == series) | |
211 | return i.key(); |
|
211 | return i.key(); | |
212 | } |
|
212 | } | |
213 | return -1; |
|
213 | return -1; | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 |
QChartAxis* ChartDataSet::axisY(QSeries* |
|
216 | QChartAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |
217 | { |
|
217 | { | |
218 | if(series == 0) return m_axisY; |
|
218 | if(series == 0) return m_axisY; | |
219 | return m_seriesAxisMap.value(series); |
|
219 | return m_seriesAxisMap.value(series); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 |
Domain* ChartDataSet::domain(QSeries* |
|
222 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
223 | { |
|
223 | { | |
224 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
224 | QChartAxis* axis = m_seriesAxisMap.value(series); | |
225 | if(axis){ |
|
225 | if(axis){ | |
226 | return m_axisDomainMap.value(axis); |
|
226 | return m_axisDomainMap.value(axis); | |
227 | }else |
|
227 | }else | |
228 | return 0; |
|
228 | return 0; | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | Domain* ChartDataSet::domain(QChartAxis* axis) const |
|
231 | Domain* ChartDataSet::domain(QChartAxis* axis) const | |
232 | { |
|
232 | { | |
233 | if(!axis || axis==axisX()) { |
|
233 | if(!axis || axis==axisX()) { | |
234 | return m_axisDomainMap.value(axisY()); |
|
234 | return m_axisDomainMap.value(axisY()); | |
235 | } |
|
235 | } | |
236 | else { |
|
236 | else { | |
237 | return m_axisDomainMap.value(axis); |
|
237 | return m_axisDomainMap.value(axis); | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size) |
|
241 | void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size) | |
242 | { |
|
242 | { | |
243 | QMapIterator<QChartAxis*, Domain*> i( m_axisDomainMap); |
|
243 | QMapIterator<QChartAxis*, Domain*> i( m_axisDomainMap); | |
244 | while (i.hasNext()) { |
|
244 | while (i.hasNext()) { | |
245 | i.next(); |
|
245 | i.next(); | |
246 | i.value()->move(dx,dy,size); |
|
246 | i.value()->move(dx,dy,size); | |
247 | } |
|
247 | } | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | #include "moc_chartdataset_p.cpp" |
|
250 | #include "moc_chartdataset_p.cpp" | |
251 |
|
251 | |||
252 | QTCOMMERCIALCHART_END_NAMESPACE |
|
252 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,90 +1,90 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTDATASET_P_H |
|
30 | #ifndef CHARTDATASET_P_H | |
31 | #define CHARTDATASET_P_H |
|
31 | #define CHARTDATASET_P_H | |
32 |
|
32 | |||
33 | #include "qseries.h" |
|
33 | #include "qabstractseries.h" | |
34 | #include "domain_p.h" |
|
34 | #include "domain_p.h" | |
35 | #include <QVector> |
|
35 | #include <QVector> | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class QChartAxis; |
|
39 | class QChartAxis; | |
40 | class QBarSeries; |
|
40 | class QBarSeries; | |
41 |
|
41 | |||
42 | class ChartDataSet : public QObject |
|
42 | class ChartDataSet : public QObject | |
43 | { |
|
43 | { | |
44 | Q_OBJECT |
|
44 | Q_OBJECT | |
45 | public: |
|
45 | public: | |
46 | ChartDataSet(QObject* parent=0); |
|
46 | ChartDataSet(QObject* parent=0); | |
47 | virtual ~ChartDataSet(); |
|
47 | virtual ~ChartDataSet(); | |
48 |
|
48 | |||
49 | void addSeries(QSeries* series,QChartAxis *axisY = 0); |
|
49 | void addSeries(QAbstractSeries* series,QChartAxis *axisY = 0); | |
50 | QChartAxis* removeSeries(QSeries* series); |
|
50 | QChartAxis* removeSeries(QAbstractSeries* series); | |
51 | void removeAllSeries(); |
|
51 | void removeAllSeries(); | |
52 |
|
52 | |||
53 | void zoomInDomain(const QRectF& rect, const QSizeF& size); |
|
53 | void zoomInDomain(const QRectF& rect, const QSizeF& size); | |
54 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); |
|
54 | void zoomOutDomain(const QRectF& rect, const QSizeF& size); | |
55 | void scrollDomain(int dx,int dy,const QSizeF& size); |
|
55 | void scrollDomain(int dx,int dy,const QSizeF& size); | |
56 |
|
56 | |||
57 | int seriesCount(QSeries::QSeriesType type); |
|
57 | int seriesCount(QAbstractSeries::QSeriesType type); | |
58 | int seriesIndex(QSeries *series); |
|
58 | int seriesIndex(QAbstractSeries *series); | |
59 |
|
59 | |||
60 | Domain* domain(QSeries* series) const; |
|
60 | Domain* domain(QAbstractSeries* series) const; | |
61 | Domain* domain(QChartAxis* axis) const; |
|
61 | Domain* domain(QChartAxis* axis) const; | |
62 |
|
62 | |||
63 | QChartAxis* axisX() const { return m_axisX; } |
|
63 | QChartAxis* axisX() const { return m_axisX; } | |
64 |
QChartAxis* axisY(QSeries* |
|
64 | QChartAxis* axisY(QAbstractSeries *series = 0) const; | |
65 |
|
65 | |||
66 | Q_SIGNALS: |
|
66 | Q_SIGNALS: | |
67 | void seriesAdded(QSeries* series,Domain* domain); |
|
67 | void seriesAdded(QAbstractSeries* series, Domain* domain); | |
68 | void seriesRemoved(QSeries* series); |
|
68 | void seriesRemoved(QAbstractSeries* series); | |
69 | void axisAdded(QChartAxis* axis,Domain* domain); |
|
69 | void axisAdded(QChartAxis* axis,Domain* domain); | |
70 | void axisRemoved(QChartAxis* axis); |
|
70 | void axisRemoved(QChartAxis* axis); | |
71 |
|
71 | |||
72 | private: |
|
72 | private: | |
73 | QStringList createLabels(QChartAxis* axis,qreal min, qreal max); |
|
73 | QStringList createLabels(QChartAxis* axis,qreal min, qreal max); | |
74 | void calculateDomain(QSeries* series,Domain* domain); |
|
74 | void calculateDomain(QAbstractSeries* series,Domain* domain); | |
75 | void setupCategories(QBarSeries* series); |
|
75 | void setupCategories(QBarSeries* series); | |
76 |
|
76 | |||
77 | private: |
|
77 | private: | |
78 | QMap<QSeries*, QChartAxis*> m_seriesAxisMap; |
|
78 | QMap<QAbstractSeries *, QChartAxis *> m_seriesAxisMap; | |
79 | QMap<QChartAxis*, Domain*> m_axisDomainMap; |
|
79 | QMap<QChartAxis*, Domain *> m_axisDomainMap; | |
80 | QMap<int,QSeries*> m_indexSeriesMap; |
|
80 | QMap<int, QAbstractSeries *> m_indexSeriesMap; | |
81 | QChartAxis* m_axisX; |
|
81 | QChartAxis* m_axisX; | |
82 | QChartAxis* m_axisY; |
|
82 | QChartAxis* m_axisY; | |
83 |
|
83 | |||
84 | int m_domainIndex; |
|
84 | int m_domainIndex; | |
85 | bool m_axisXInitialized; |
|
85 | bool m_axisXInitialized; | |
86 | }; |
|
86 | }; | |
87 |
|
87 | |||
88 | QTCOMMERCIALCHART_END_NAMESPACE |
|
88 | QTCOMMERCIALCHART_END_NAMESPACE | |
89 |
|
89 | |||
90 | #endif /* CHARTENGINE_P_H_ */ |
|
90 | #endif /* CHARTENGINE_P_H_ */ |
@@ -1,401 +1,401 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 | #include "chartpresenter_p.h" |
|
20 | #include "chartpresenter_p.h" | |
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "qchartaxis.h" |
|
23 | #include "qchartaxis.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 | #include "qseries_p.h" |
|
27 | #include "qabstractseries_p.h" | |
28 | #include "qareaseries.h" |
|
28 | #include "qareaseries.h" | |
29 | #include "axis_p.h" |
|
29 | #include "axis_p.h" | |
30 | #include "areachartitem_p.h" |
|
30 | #include "areachartitem_p.h" | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), |
|
34 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | |
35 | m_chart(chart), |
|
35 | m_chart(chart), | |
36 | m_animator(0), |
|
36 | m_animator(0), | |
37 | m_dataset(dataset), |
|
37 | m_dataset(dataset), | |
38 | m_chartTheme(0), |
|
38 | m_chartTheme(0), | |
39 | m_chartRect(QRectF(QPoint(0,0),m_chart->size())), |
|
39 | m_chartRect(QRectF(QPoint(0,0),m_chart->size())), | |
40 | m_options(QChart::NoAnimation), |
|
40 | m_options(QChart::NoAnimation), | |
41 | m_minLeftMargin(0), |
|
41 | m_minLeftMargin(0), | |
42 | m_minBottomMargin(0), |
|
42 | m_minBottomMargin(0), | |
43 | m_backgroundItem(0), |
|
43 | m_backgroundItem(0), | |
44 | m_titleItem(0), |
|
44 | m_titleItem(0), | |
45 | m_marginBig(60), |
|
45 | m_marginBig(60), | |
46 | m_marginSmall(20), |
|
46 | m_marginSmall(20), | |
47 | m_marginTiny(10), |
|
47 | m_marginTiny(10), | |
48 | m_chartMargins(QRect(m_marginBig,m_marginBig,0,0)) |
|
48 | m_chartMargins(QRect(m_marginBig,m_marginBig,0,0)) | |
49 | { |
|
49 | { | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | ChartPresenter::~ChartPresenter() |
|
52 | ChartPresenter::~ChartPresenter() | |
53 | { |
|
53 | { | |
54 | delete m_chartTheme; |
|
54 | delete m_chartTheme; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | void ChartPresenter::setGeometry(const QRectF& rect) |
|
57 | void ChartPresenter::setGeometry(const QRectF& rect) | |
58 | { |
|
58 | { | |
59 | m_rect = rect; |
|
59 | m_rect = rect; | |
60 | Q_ASSERT(m_rect.isValid()); |
|
60 | Q_ASSERT(m_rect.isValid()); | |
61 | updateLayout(); |
|
61 | updateLayout(); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width) |
|
64 | void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width) | |
65 | { |
|
65 | { | |
66 | switch(axis->axisType()){ |
|
66 | switch(axis->axisType()){ | |
67 | case Axis::X_AXIS: |
|
67 | case Axis::X_AXIS: | |
68 | { |
|
68 | { | |
69 | if(width>m_chartRect.width()+ m_chartMargins.left()) { |
|
69 | if(width>m_chartRect.width()+ m_chartMargins.left()) { | |
70 | m_minLeftMargin= width - m_chartRect.width(); |
|
70 | m_minLeftMargin= width - m_chartRect.width(); | |
71 | updateLayout(); |
|
71 | updateLayout(); | |
72 | } |
|
72 | } | |
73 | break; |
|
73 | break; | |
74 | } |
|
74 | } | |
75 | case Axis::Y_AXIS: |
|
75 | case Axis::Y_AXIS: | |
76 | { |
|
76 | { | |
77 |
|
77 | |||
78 | if(m_minLeftMargin!=width){ |
|
78 | if(m_minLeftMargin!=width){ | |
79 | m_minLeftMargin= width; |
|
79 | m_minLeftMargin= width; | |
80 | updateLayout(); |
|
80 | updateLayout(); | |
81 | } |
|
81 | } | |
82 | break; |
|
82 | break; | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | } |
|
85 | } | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height) |
|
88 | void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height) | |
89 | { |
|
89 | { | |
90 | switch(axis->axisType()){ |
|
90 | switch(axis->axisType()){ | |
91 | case Axis::X_AXIS: |
|
91 | case Axis::X_AXIS: | |
92 | { |
|
92 | { | |
93 | if(m_minBottomMargin!=height) { |
|
93 | if(m_minBottomMargin!=height) { | |
94 | m_minBottomMargin= height; |
|
94 | m_minBottomMargin= height; | |
95 | updateLayout(); |
|
95 | updateLayout(); | |
96 | } |
|
96 | } | |
97 | break; |
|
97 | break; | |
98 | } |
|
98 | } | |
99 | case Axis::Y_AXIS: |
|
99 | case Axis::Y_AXIS: | |
100 | { |
|
100 | { | |
101 |
|
101 | |||
102 | if(height>m_chartMargins.bottom()+m_chartRect.height()){ |
|
102 | if(height>m_chartMargins.bottom()+m_chartRect.height()){ | |
103 | m_minBottomMargin= height - m_chartRect.height(); |
|
103 | m_minBottomMargin= height - m_chartRect.height(); | |
104 | updateLayout(); |
|
104 | updateLayout(); | |
105 | } |
|
105 | } | |
106 | break; |
|
106 | break; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | } |
|
109 | } | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain) |
|
112 | void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain) | |
113 | { |
|
113 | { | |
114 | Axis* item = new Axis(axis,this,axis==m_dataset->axisX()?Axis::X_AXIS : Axis::Y_AXIS); |
|
114 | Axis* item = new Axis(axis,this,axis==m_dataset->axisX()?Axis::X_AXIS : Axis::Y_AXIS); | |
115 |
|
115 | |||
116 | if(m_options.testFlag(QChart::GridAxisAnimations)){ |
|
116 | if(m_options.testFlag(QChart::GridAxisAnimations)){ | |
117 | m_animator->addAnimation(item); |
|
117 | m_animator->addAnimation(item); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | if(axis==m_dataset->axisX()){ |
|
120 | if(axis==m_dataset->axisX()){ | |
121 | m_chartTheme->decorate(axis,true); |
|
121 | m_chartTheme->decorate(axis,true); | |
122 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
122 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | |
123 | //initialize |
|
123 | //initialize | |
124 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); |
|
124 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); | |
125 |
|
125 | |||
126 | } |
|
126 | } | |
127 | else{ |
|
127 | else{ | |
128 | m_chartTheme->decorate(axis,false); |
|
128 | m_chartTheme->decorate(axis,false); | |
129 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
129 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | |
130 | //initialize |
|
130 | //initialize | |
131 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); |
|
131 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
134 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); | |
135 | //initialize |
|
135 | //initialize | |
136 | item->handleGeometryChanged(m_chartRect); |
|
136 | item->handleGeometryChanged(m_chartRect); | |
137 | m_axisItems.insert(axis, item); |
|
137 | m_axisItems.insert(axis, item); | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) |
|
140 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) | |
141 | { |
|
141 | { | |
142 | Axis* item = m_axisItems.take(axis); |
|
142 | Axis* item = m_axisItems.take(axis); | |
143 | Q_ASSERT(item); |
|
143 | Q_ASSERT(item); | |
144 | if(m_animator) m_animator->removeAnimation(item); |
|
144 | if(m_animator) m_animator->removeAnimation(item); | |
145 | delete item; |
|
145 | delete item; | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 |
|
148 | |||
149 | void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) |
|
149 | void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain) | |
150 | { |
|
150 | { | |
151 | Chart *item = series->d_ptr->createGraphics(this); |
|
151 | Chart *item = series->d_ptr->createGraphics(this); | |
152 | Q_ASSERT(item); |
|
152 | Q_ASSERT(item); | |
153 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
153 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); | |
154 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
154 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | |
155 | //initialize |
|
155 | //initialize | |
156 | item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); |
|
156 | item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); | |
157 | if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect); |
|
157 | if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect); | |
158 | m_chartItems.insert(series,item); |
|
158 | m_chartItems.insert(series,item); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | void ChartPresenter::handleSeriesRemoved(QSeries* series) |
|
161 | void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series) | |
162 | { |
|
162 | { | |
163 | Chart* item = m_chartItems.take(series); |
|
163 | Chart* item = m_chartItems.take(series); | |
164 | Q_ASSERT(item); |
|
164 | Q_ASSERT(item); | |
165 | if(m_animator) { |
|
165 | if(m_animator) { | |
166 | //small hack to handle area animations |
|
166 | //small hack to handle area animations | |
167 | if(series->type()==QSeries::SeriesTypeArea){ |
|
167 | if(series->type() == QAbstractSeries::SeriesTypeArea){ | |
168 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); |
|
168 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | |
169 | AreaChartItem* area = static_cast<AreaChartItem*>(item); |
|
169 | AreaChartItem* area = static_cast<AreaChartItem*>(item); | |
170 | m_animator->removeAnimation(area->upperLineItem()); |
|
170 | m_animator->removeAnimation(area->upperLineItem()); | |
171 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); |
|
171 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); | |
172 | }else |
|
172 | }else | |
173 | m_animator->removeAnimation(item); |
|
173 | m_animator->removeAnimation(item); | |
174 | } |
|
174 | } | |
175 | delete item; |
|
175 | delete item; | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) |
|
178 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) | |
179 | { |
|
179 | { | |
180 | if(m_chartTheme && m_chartTheme->id() == theme) return; |
|
180 | if(m_chartTheme && m_chartTheme->id() == theme) return; | |
181 | delete m_chartTheme; |
|
181 | delete m_chartTheme; | |
182 | m_chartTheme = ChartTheme::createTheme(theme); |
|
182 | m_chartTheme = ChartTheme::createTheme(theme); | |
183 | m_chartTheme->setForced(force); |
|
183 | m_chartTheme->setForced(force); | |
184 | m_chartTheme->decorate(m_chart); |
|
184 | m_chartTheme->decorate(m_chart); | |
185 | m_chartTheme->decorate(m_chart->legend()); |
|
185 | m_chartTheme->decorate(m_chart->legend()); | |
186 | resetAllElements(); |
|
186 | resetAllElements(); | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | QChart::ChartTheme ChartPresenter::theme() |
|
189 | QChart::ChartTheme ChartPresenter::theme() | |
190 | { |
|
190 | { | |
191 | return m_chartTheme->id(); |
|
191 | return m_chartTheme->id(); | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) |
|
194 | void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | |
195 | { |
|
195 | { | |
196 | if(m_options!=options) { |
|
196 | if(m_options!=options) { | |
197 |
|
197 | |||
198 | m_options=options; |
|
198 | m_options=options; | |
199 |
|
199 | |||
200 | if(m_options!=QChart::NoAnimation && !m_animator) { |
|
200 | if(m_options!=QChart::NoAnimation && !m_animator) { | |
201 | m_animator= new ChartAnimator(this); |
|
201 | m_animator= new ChartAnimator(this); | |
202 | } |
|
202 | } | |
203 | resetAllElements(); |
|
203 | resetAllElements(); | |
204 | } |
|
204 | } | |
205 |
|
205 | |||
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | void ChartPresenter::resetAllElements() |
|
208 | void ChartPresenter::resetAllElements() | |
209 | { |
|
209 | { | |
210 | QList<QChartAxis*> axisList = m_axisItems.uniqueKeys(); |
|
210 | QList<QChartAxis *> axisList = m_axisItems.uniqueKeys(); | |
211 | QList<QSeries*> seriesList = m_chartItems.uniqueKeys(); |
|
211 | QList<QAbstractSeries *> seriesList = m_chartItems.uniqueKeys(); | |
212 |
|
212 | |||
213 |
foreach(QChartAxis* |
|
213 | foreach(QChartAxis *axis, axisList) { | |
214 | handleAxisRemoved(axis); |
|
214 | handleAxisRemoved(axis); | |
215 | handleAxisAdded(axis,m_dataset->domain(axis)); |
|
215 | handleAxisAdded(axis,m_dataset->domain(axis)); | |
216 | } |
|
216 | } | |
217 |
foreach(QSeries* |
|
217 | foreach(QAbstractSeries *series, seriesList) { | |
218 | handleSeriesRemoved(series); |
|
218 | handleSeriesRemoved(series); | |
219 | handleSeriesAdded(series,m_dataset->domain(series)); |
|
219 | handleSeriesAdded(series,m_dataset->domain(series)); | |
220 | } |
|
220 | } | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | void ChartPresenter::zoomIn() |
|
223 | void ChartPresenter::zoomIn() | |
224 | { |
|
224 | { | |
225 | QRectF rect = chartGeometry(); |
|
225 | QRectF rect = chartGeometry(); | |
226 | rect.setWidth(rect.width()/2); |
|
226 | rect.setWidth(rect.width()/2); | |
227 | rect.setHeight(rect.height()/2); |
|
227 | rect.setHeight(rect.height()/2); | |
228 | rect.moveCenter(chartGeometry().center()); |
|
228 | rect.moveCenter(chartGeometry().center()); | |
229 | zoomIn(rect); |
|
229 | zoomIn(rect); | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | void ChartPresenter::zoomIn(const QRectF& rect) |
|
232 | void ChartPresenter::zoomIn(const QRectF& rect) | |
233 | { |
|
233 | { | |
234 | QRectF r = rect.normalized(); |
|
234 | QRectF r = rect.normalized(); | |
235 | r.translate(-m_chartMargins.topLeft()); |
|
235 | r.translate(-m_chartMargins.topLeft()); | |
236 | if(m_animator) { |
|
236 | if(m_animator) { | |
237 |
|
237 | |||
238 | QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height()); |
|
238 | QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height()); | |
239 | m_animator->setState(ChartAnimator::ZoomInState,point); |
|
239 | m_animator->setState(ChartAnimator::ZoomInState,point); | |
240 | } |
|
240 | } | |
241 | m_dataset->zoomInDomain(r,chartGeometry().size()); |
|
241 | m_dataset->zoomInDomain(r,chartGeometry().size()); | |
242 | if(m_animator) { |
|
242 | if(m_animator) { | |
243 | m_animator->setState(ChartAnimator::ShowState); |
|
243 | m_animator->setState(ChartAnimator::ShowState); | |
244 | } |
|
244 | } | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | void ChartPresenter::zoomOut() |
|
247 | void ChartPresenter::zoomOut() | |
248 | { |
|
248 | { | |
249 | if(m_animator) |
|
249 | if(m_animator) | |
250 | { |
|
250 | { | |
251 | m_animator->setState(ChartAnimator::ZoomOutState); |
|
251 | m_animator->setState(ChartAnimator::ZoomOutState); | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | QSizeF size = chartGeometry().size(); |
|
254 | QSizeF size = chartGeometry().size(); | |
255 | QRectF rect = chartGeometry(); |
|
255 | QRectF rect = chartGeometry(); | |
256 | rect.translate(-m_chartMargins.topLeft()); |
|
256 | rect.translate(-m_chartMargins.topLeft()); | |
257 | m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); |
|
257 | m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size); | |
258 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); |
|
258 | //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size()); | |
259 |
|
259 | |||
260 | if(m_animator){ |
|
260 | if(m_animator){ | |
261 | m_animator->setState(ChartAnimator::ShowState); |
|
261 | m_animator->setState(ChartAnimator::ShowState); | |
262 | } |
|
262 | } | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | void ChartPresenter::scroll(int dx,int dy) |
|
265 | void ChartPresenter::scroll(int dx,int dy) | |
266 | { |
|
266 | { | |
267 | if(m_animator){ |
|
267 | if(m_animator){ | |
268 | if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF()); |
|
268 | if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF()); | |
269 | if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF()); |
|
269 | if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF()); | |
270 | if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF()); |
|
270 | if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF()); | |
271 | if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF()); |
|
271 | if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF()); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | m_dataset->scrollDomain(dx,dy,chartGeometry().size()); |
|
274 | m_dataset->scrollDomain(dx,dy,chartGeometry().size()); | |
275 |
|
275 | |||
276 | if(m_animator){ |
|
276 | if(m_animator){ | |
277 | m_animator->setState(ChartAnimator::ShowState); |
|
277 | m_animator->setState(ChartAnimator::ShowState); | |
278 | } |
|
278 | } | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | QChart::AnimationOptions ChartPresenter::animationOptions() const |
|
281 | QChart::AnimationOptions ChartPresenter::animationOptions() const | |
282 | { |
|
282 | { | |
283 | return m_options; |
|
283 | return m_options; | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void ChartPresenter::updateLayout() |
|
286 | void ChartPresenter::updateLayout() | |
287 | { |
|
287 | { | |
288 | if (!m_rect.isValid()) return; |
|
288 | if (!m_rect.isValid()) return; | |
289 |
|
289 | |||
290 | // recalculate title size |
|
290 | // recalculate title size | |
291 |
|
291 | |||
292 | QSize titleSize; |
|
292 | QSize titleSize; | |
293 | int titlePadding=0; |
|
293 | int titlePadding=0; | |
294 |
|
294 | |||
295 | if (m_titleItem) { |
|
295 | if (m_titleItem) { | |
296 | titleSize= m_titleItem->boundingRect().size().toSize(); |
|
296 | titleSize= m_titleItem->boundingRect().size().toSize(); | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | //defaults |
|
299 | //defaults | |
300 | m_chartMargins = QRect(QPoint(m_minLeftMargin>m_marginBig?m_minLeftMargin:m_marginBig,m_marginBig),QPoint(m_marginBig,m_minBottomMargin>m_marginBig?m_minBottomMargin:m_marginBig)); |
|
300 | m_chartMargins = QRect(QPoint(m_minLeftMargin>m_marginBig?m_minLeftMargin:m_marginBig,m_marginBig),QPoint(m_marginBig,m_minBottomMargin>m_marginBig?m_minBottomMargin:m_marginBig)); | |
301 | titlePadding = m_chartMargins.top()/2; |
|
301 | titlePadding = m_chartMargins.top()/2; | |
302 |
|
302 | |||
303 | QLegend* legend = m_chart->d_ptr->m_legend; |
|
303 | QLegend* legend = m_chart->d_ptr->m_legend; | |
304 |
|
304 | |||
305 | // recalculate legend position |
|
305 | // recalculate legend position | |
306 | if (legend->isAttachedToChart() && legend->isEnabled()) { |
|
306 | if (legend->isAttachedToChart() && legend->isEnabled()) { | |
307 |
|
307 | |||
308 | QRect legendRect; |
|
308 | QRect legendRect; | |
309 |
|
309 | |||
310 | // Reserve some space for legend |
|
310 | // Reserve some space for legend | |
311 | switch (legend->alignment()) { |
|
311 | switch (legend->alignment()) { | |
312 |
|
312 | |||
313 | case QLegend::AlignmentTop: { |
|
313 | case QLegend::AlignmentTop: { | |
314 | int ledgendSize = legend->minHeight(); |
|
314 | int ledgendSize = legend->minHeight(); | |
315 | int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny; |
|
315 | int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny; | |
316 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); |
|
316 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); | |
317 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny)); |
|
317 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny)); | |
318 | titlePadding = m_marginTiny + m_marginTiny; |
|
318 | titlePadding = m_marginTiny + m_marginTiny; | |
319 | break; |
|
319 | break; | |
320 | } |
|
320 | } | |
321 | case QLegend::AlignmentBottom: { |
|
321 | case QLegend::AlignmentBottom: { | |
322 | int ledgendSize = legend->minHeight(); |
|
322 | int ledgendSize = legend->minHeight(); | |
323 | int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin; |
|
323 | int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin; | |
324 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding)); |
|
324 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding)); | |
325 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall)); |
|
325 | m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall)); | |
326 | titlePadding = m_chartMargins.top()/2; |
|
326 | titlePadding = m_chartMargins.top()/2; | |
327 | break; |
|
327 | break; | |
328 | } |
|
328 | } | |
329 | case QLegend::AlignmentLeft: { |
|
329 | case QLegend::AlignmentLeft: { | |
330 | int ledgendSize = legend->minWidth(); |
|
330 | int ledgendSize = legend->minWidth(); | |
331 | int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin; |
|
331 | int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin; | |
332 | m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); |
|
332 | m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom())); | |
333 | m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom())); |
|
333 | m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom())); | |
334 | titlePadding = m_chartMargins.top()/2; |
|
334 | titlePadding = m_chartMargins.top()/2; | |
335 | break; |
|
335 | break; | |
336 | } |
|
336 | } | |
337 | case QLegend::AlignmentRight: { |
|
337 | case QLegend::AlignmentRight: { | |
338 | int ledgendSize = legend->minWidth(); |
|
338 | int ledgendSize = legend->minWidth(); | |
339 | int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny; |
|
339 | int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny; | |
340 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom())); |
|
340 | m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom())); | |
341 | m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom())); |
|
341 | m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom())); | |
342 | titlePadding = m_chartMargins.top()/2; |
|
342 | titlePadding = m_chartMargins.top()/2; | |
343 | break; |
|
343 | break; | |
344 | } |
|
344 | } | |
345 | default: { |
|
345 | default: { | |
346 | break; |
|
346 | break; | |
347 | } |
|
347 | } | |
348 | } |
|
348 | } | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | if(m_rect.width()<2*(m_chartMargins.top()+m_chartMargins.bottom()) || m_rect.height()< 2*(m_chartMargins.top() + m_chartMargins.bottom())) |
|
351 | if(m_rect.width()<2*(m_chartMargins.top()+m_chartMargins.bottom()) || m_rect.height()< 2*(m_chartMargins.top() + m_chartMargins.bottom())) | |
352 | { |
|
352 | { | |
353 | m_chart->setMinimumSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom())); |
|
353 | m_chart->setMinimumSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom())); | |
354 | return; |
|
354 | return; | |
355 | } |
|
355 | } | |
356 |
|
356 | |||
357 |
|
357 | |||
358 | // recalculate title position |
|
358 | // recalculate title position | |
359 | if (m_titleItem) { |
|
359 | if (m_titleItem) { | |
360 | QPointF center = m_rect.center() -m_titleItem->boundingRect().center(); |
|
360 | QPointF center = m_rect.center() -m_titleItem->boundingRect().center(); | |
361 | m_titleItem->setPos(center.x(),titlePadding); |
|
361 | m_titleItem->setPos(center.x(),titlePadding); | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | //recalculate background gradient |
|
364 | //recalculate background gradient | |
365 | if (m_backgroundItem) { |
|
365 | if (m_backgroundItem) { | |
366 | m_backgroundItem->setRect(m_rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny)); |
|
366 | m_backgroundItem->setRect(m_rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny)); | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 |
|
369 | |||
370 | QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom()); |
|
370 | QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom()); | |
371 |
|
371 | |||
372 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); |
|
372 | legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom())); | |
373 |
|
373 | |||
374 | if(m_chartRect!=chartRect){ |
|
374 | if(m_chartRect!=chartRect){ | |
375 | m_chartRect=chartRect; |
|
375 | m_chartRect=chartRect; | |
376 | emit geometryChanged(m_chartRect); |
|
376 | emit geometryChanged(m_chartRect); | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 |
|
379 | |||
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | void ChartPresenter::createChartBackgroundItem() |
|
382 | void ChartPresenter::createChartBackgroundItem() | |
383 | { |
|
383 | { | |
384 | if (!m_backgroundItem) { |
|
384 | if (!m_backgroundItem) { | |
385 | m_backgroundItem = new ChartBackground(rootItem()); |
|
385 | m_backgroundItem = new ChartBackground(rootItem()); | |
386 | m_backgroundItem->setPen(Qt::NoPen); |
|
386 | m_backgroundItem->setPen(Qt::NoPen); | |
387 | m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); |
|
387 | m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); | |
388 | } |
|
388 | } | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | void ChartPresenter::createChartTitleItem() |
|
391 | void ChartPresenter::createChartTitleItem() | |
392 | { |
|
392 | { | |
393 | if (!m_titleItem) { |
|
393 | if (!m_titleItem) { | |
394 | m_titleItem = new QGraphicsSimpleTextItem(rootItem()); |
|
394 | m_titleItem = new QGraphicsSimpleTextItem(rootItem()); | |
395 | m_titleItem->setZValue(ChartPresenter::BackgroundZValue); |
|
395 | m_titleItem->setZValue(ChartPresenter::BackgroundZValue); | |
396 | } |
|
396 | } | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | #include "moc_chartpresenter_p.cpp" |
|
399 | #include "moc_chartpresenter_p.cpp" | |
400 |
|
400 | |||
401 | QTCOMMERCIALCHART_END_NAMESPACE |
|
401 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,125 +1,125 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef CHARTPRESENTER_H |
|
21 | #ifndef CHARTPRESENTER_H | |
22 | #define CHARTPRESENTER_H |
|
22 | #define CHARTPRESENTER_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "chartbackground_p.h" //TODO fix me |
|
25 | #include "chartbackground_p.h" //TODO fix me | |
26 | #include "qchart.h" //becouse of QChart::ChartThemeId //TODO |
|
26 | #include "qchart.h" //becouse of QChart::ChartThemeId //TODO | |
27 | #include "qchartaxis.h" |
|
27 | #include "qchartaxis.h" | |
28 | #include <QRectF> |
|
28 | #include <QRectF> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class Chart; |
|
32 | class Chart; | |
33 | class QSeries; |
|
33 | class QAbstractSeries; | |
34 | class ChartDataSet; |
|
34 | class ChartDataSet; | |
35 | class Domain; |
|
35 | class Domain; | |
36 | class Axis; |
|
36 | class Axis; | |
37 | class ChartTheme; |
|
37 | class ChartTheme; | |
38 | class ChartAnimator; |
|
38 | class ChartAnimator; | |
39 |
|
39 | |||
40 | class ChartPresenter: public QObject |
|
40 | class ChartPresenter: public QObject | |
41 | { |
|
41 | { | |
42 | Q_OBJECT |
|
42 | Q_OBJECT | |
43 | public: |
|
43 | public: | |
44 | enum ZValues { |
|
44 | enum ZValues { | |
45 | BackgroundZValue = -1, |
|
45 | BackgroundZValue = -1, | |
46 | ShadesZValue, |
|
46 | ShadesZValue, | |
47 | GridZValue, |
|
47 | GridZValue, | |
48 | LineChartZValue, |
|
48 | LineChartZValue, | |
49 | BarSeriesZValue, |
|
49 | BarSeriesZValue, | |
50 | ScatterSeriesZValue, |
|
50 | ScatterSeriesZValue, | |
51 | PieSeriesZValue, |
|
51 | PieSeriesZValue, | |
52 | AxisZValue, |
|
52 | AxisZValue, | |
53 | LegendZValue |
|
53 | LegendZValue | |
54 | }; |
|
54 | }; | |
55 |
|
55 | |||
56 | ChartPresenter(QChart* chart,ChartDataSet *dataset); |
|
56 | ChartPresenter(QChart* chart,ChartDataSet *dataset); | |
57 | virtual ~ChartPresenter(); |
|
57 | virtual ~ChartPresenter(); | |
58 |
|
58 | |||
59 | ChartAnimator* animator() const { return m_animator; } |
|
59 | ChartAnimator* animator() const { return m_animator; } | |
60 | ChartTheme *chartTheme() const { return m_chartTheme; } |
|
60 | ChartTheme *chartTheme() const { return m_chartTheme; } | |
61 | ChartDataSet *dataSet() const { return m_dataset; } |
|
61 | ChartDataSet *dataSet() const { return m_dataset; } | |
62 | QGraphicsItem* rootItem() const { return m_chart; } |
|
62 | QGraphicsItem* rootItem() const { return m_chart; } | |
63 |
|
63 | |||
64 | void setTheme(QChart::ChartTheme theme,bool force = true); |
|
64 | void setTheme(QChart::ChartTheme theme,bool force = true); | |
65 | QChart::ChartTheme theme(); |
|
65 | QChart::ChartTheme theme(); | |
66 |
|
66 | |||
67 | void setAnimationOptions(QChart::AnimationOptions options); |
|
67 | void setAnimationOptions(QChart::AnimationOptions options); | |
68 | QChart::AnimationOptions animationOptions() const; |
|
68 | QChart::AnimationOptions animationOptions() const; | |
69 |
|
69 | |||
70 | void zoomIn(); |
|
70 | void zoomIn(); | |
71 | void zoomIn(const QRectF& rect); |
|
71 | void zoomIn(const QRectF& rect); | |
72 | void zoomOut(); |
|
72 | void zoomOut(); | |
73 | void scroll(int dx,int dy); |
|
73 | void scroll(int dx,int dy); | |
74 |
|
74 | |||
75 | void setGeometry(const QRectF& rect); |
|
75 | void setGeometry(const QRectF& rect); | |
76 | QRectF chartGeometry() const { return m_chartRect; } |
|
76 | QRectF chartGeometry() const { return m_chartRect; } | |
77 |
|
77 | |||
78 | void setMinimumMarginHeight(Axis* axis, qreal height); |
|
78 | void setMinimumMarginHeight(Axis* axis, qreal height); | |
79 | void setMinimumMarginWidth(Axis* axis, qreal width); |
|
79 | void setMinimumMarginWidth(Axis* axis, qreal width); | |
80 | qreal minimumLeftMargin() const { return m_minLeftMargin; } |
|
80 | qreal minimumLeftMargin() const { return m_minLeftMargin; } | |
81 | qreal minimumBottomMargin() const { return m_minBottomMargin; } |
|
81 | qreal minimumBottomMargin() const { return m_minBottomMargin; } | |
82 |
|
82 | |||
83 | public: //TODO: fix me |
|
83 | public: //TODO: fix me | |
84 | void resetAllElements(); |
|
84 | void resetAllElements(); | |
85 | void createChartBackgroundItem(); |
|
85 | void createChartBackgroundItem(); | |
86 | void createChartTitleItem(); |
|
86 | void createChartTitleItem(); | |
87 | QRectF margins() const { return m_chartMargins;} |
|
87 | QRectF margins() const { return m_chartMargins;} | |
88 |
|
88 | |||
89 | public Q_SLOTS: |
|
89 | public Q_SLOTS: | |
90 | void handleSeriesAdded(QSeries* series,Domain* domain); |
|
90 | void handleSeriesAdded(QAbstractSeries* series,Domain* domain); | |
91 | void handleSeriesRemoved(QSeries* series); |
|
91 | void handleSeriesRemoved(QAbstractSeries* series); | |
92 | void handleAxisAdded(QChartAxis* axis,Domain* domain); |
|
92 | void handleAxisAdded(QChartAxis* axis,Domain* domain); | |
93 | void handleAxisRemoved(QChartAxis* axis); |
|
93 | void handleAxisRemoved(QChartAxis* axis); | |
94 | void updateLayout(); |
|
94 | void updateLayout(); | |
95 |
|
95 | |||
96 | Q_SIGNALS: |
|
96 | Q_SIGNALS: | |
97 | void geometryChanged(const QRectF& rect); |
|
97 | void geometryChanged(const QRectF& rect); | |
98 |
|
98 | |||
99 |
|
99 | |||
100 | private: |
|
100 | private: | |
101 | QChart* m_chart; |
|
101 | QChart* m_chart; | |
102 | ChartAnimator* m_animator; |
|
102 | ChartAnimator* m_animator; | |
103 | ChartDataSet* m_dataset; |
|
103 | ChartDataSet* m_dataset; | |
104 | ChartTheme *m_chartTheme; |
|
104 | ChartTheme *m_chartTheme; | |
105 | QMap<QSeries*,Chart*> m_chartItems; |
|
105 | QMap<QAbstractSeries *, Chart *> m_chartItems; | |
106 | QMap<QChartAxis*,Axis*> m_axisItems; |
|
106 | QMap<QChartAxis *, Axis *> m_axisItems; | |
107 | QRectF m_rect; |
|
107 | QRectF m_rect; | |
108 | QRectF m_chartRect; |
|
108 | QRectF m_chartRect; | |
109 | QChart::AnimationOptions m_options; |
|
109 | QChart::AnimationOptions m_options; | |
110 | qreal m_minLeftMargin; |
|
110 | qreal m_minLeftMargin; | |
111 | qreal m_minBottomMargin; |
|
111 | qreal m_minBottomMargin; | |
112 | public: //TODO: fixme |
|
112 | public: //TODO: fixme | |
113 | ChartBackground* m_backgroundItem; |
|
113 | ChartBackground* m_backgroundItem; | |
114 | QGraphicsSimpleTextItem* m_titleItem; |
|
114 | QGraphicsSimpleTextItem* m_titleItem; | |
115 | int m_marginBig; |
|
115 | int m_marginBig; | |
116 | int m_marginSmall; |
|
116 | int m_marginSmall; | |
117 | int m_marginTiny; |
|
117 | int m_marginTiny; | |
118 | QRectF m_chartMargins; |
|
118 | QRectF m_chartMargins; | |
119 | QRectF m_legendMargins; |
|
119 | QRectF m_legendMargins; | |
120 |
|
120 | |||
121 | }; |
|
121 | }; | |
122 |
|
122 | |||
123 | QTCOMMERCIALCHART_END_NAMESPACE |
|
123 | QTCOMMERCIALCHART_END_NAMESPACE | |
124 |
|
124 | |||
125 | #endif /* CHARTPRESENTER_H_ */ |
|
125 | #endif /* CHARTPRESENTER_H_ */ |
@@ -1,102 +1,101 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef CHARTTHEME_H |
|
21 | #ifndef CHARTTHEME_H | |
22 | #define CHARTTHEME_H |
|
22 | #define CHARTTHEME_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include "qchart.h" |
|
25 | #include "qchart.h" | |
26 | #include <QColor> |
|
26 | #include <QColor> | |
27 | #include <QGradientStops> |
|
27 | #include <QGradientStops> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class ChartItem; |
|
31 | class ChartItem; | |
32 | class QSeries; |
|
|||
33 | class LineChartItem; |
|
32 | class LineChartItem; | |
34 | class QLineSeries; |
|
33 | class QLineSeries; | |
35 | class BarChartItem; |
|
34 | class BarChartItem; | |
36 | class QBarSeries; |
|
35 | class QBarSeries; | |
37 | class StackedBarChartItem; |
|
36 | class StackedBarChartItem; | |
38 | class QStackedBarSeries; |
|
37 | class QStackedBarSeries; | |
39 | class QPercentBarSeries; |
|
38 | class QPercentBarSeries; | |
40 | class PercentBarChartItem; |
|
39 | class PercentBarChartItem; | |
41 | class QScatterSeries; |
|
40 | class QScatterSeries; | |
42 | class ScatterChartItem; |
|
41 | class ScatterChartItem; | |
43 | class PieChartItem; |
|
42 | class PieChartItem; | |
44 | class QPieSeries; |
|
43 | class QPieSeries; | |
45 | class SplineChartItem; |
|
44 | class SplineChartItem; | |
46 | class QSplineSeries; |
|
45 | class QSplineSeries; | |
47 | class AreaChartItem; |
|
46 | class AreaChartItem; | |
48 | class QAreaSeries; |
|
47 | class QAreaSeries; | |
49 |
|
48 | |||
50 | class ChartTheme |
|
49 | class ChartTheme | |
51 | { |
|
50 | { | |
52 | public: |
|
51 | public: | |
53 | enum BackgroundShadesMode { |
|
52 | enum BackgroundShadesMode { | |
54 | BackgroundShadesNone = 0, |
|
53 | BackgroundShadesNone = 0, | |
55 | BackgroundShadesVertical, |
|
54 | BackgroundShadesVertical, | |
56 | BackgroundShadesHorizontal, |
|
55 | BackgroundShadesHorizontal, | |
57 | BackgroundShadesBoth |
|
56 | BackgroundShadesBoth | |
58 | }; |
|
57 | }; | |
59 |
|
58 | |||
60 | protected: |
|
59 | protected: | |
61 | explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeLight); |
|
60 | explicit ChartTheme(QChart::ChartTheme id = QChart::ChartThemeLight); | |
62 | public: |
|
61 | public: | |
63 | static ChartTheme *createTheme(QChart::ChartTheme theme); |
|
62 | static ChartTheme *createTheme(QChart::ChartTheme theme); | |
64 | QChart::ChartTheme id() const {return m_id;} |
|
63 | QChart::ChartTheme id() const {return m_id;} | |
65 | void decorate(QChart *chart); |
|
64 | void decorate(QChart *chart); | |
66 | void decorate(QLegend *legend); |
|
65 | void decorate(QLegend *legend); | |
67 | void decorate(QBarSeries *series, int index); |
|
66 | void decorate(QBarSeries *series, int index); | |
68 | void decorate(QLineSeries *series, int index); |
|
67 | void decorate(QLineSeries *series, int index); | |
69 | void decorate(QAreaSeries *series, int index); |
|
68 | void decorate(QAreaSeries *series, int index); | |
70 | void decorate(QScatterSeries *series, int index); |
|
69 | void decorate(QScatterSeries *series, int index); | |
71 | void decorate(QPieSeries *series, int index); |
|
70 | void decorate(QPieSeries *series, int index); | |
72 | void decorate(QSplineSeries *series, int index); |
|
71 | void decorate(QSplineSeries *series, int index); | |
73 | void decorate(QChartAxis *axis, bool axisX); |
|
72 | void decorate(QChartAxis *axis, bool axisX); | |
74 | void setForced(bool enabled); |
|
73 | void setForced(bool enabled); | |
75 | bool isForced() { return m_force; } |
|
74 | bool isForced() { return m_force; } | |
76 |
|
75 | |||
77 | public: // utils |
|
76 | public: // utils | |
78 | void generateSeriesGradients(); |
|
77 | void generateSeriesGradients(); | |
79 | static QColor colorAt(const QColor &start, const QColor &end, qreal pos); |
|
78 | static QColor colorAt(const QColor &start, const QColor &end, qreal pos); | |
80 | static QColor colorAt(const QGradient &gradient, qreal pos); |
|
79 | static QColor colorAt(const QGradient &gradient, qreal pos); | |
81 |
|
80 | |||
82 | protected: |
|
81 | protected: | |
83 | QChart::ChartTheme m_id; |
|
82 | QChart::ChartTheme m_id; | |
84 | QList<QColor> m_seriesColors; |
|
83 | QList<QColor> m_seriesColors; | |
85 | QList<QGradient> m_seriesGradients; |
|
84 | QList<QGradient> m_seriesGradients; | |
86 | QLinearGradient m_chartBackgroundGradient; |
|
85 | QLinearGradient m_chartBackgroundGradient; | |
87 |
|
86 | |||
88 | QFont m_masterFont; |
|
87 | QFont m_masterFont; | |
89 | QFont m_labelFont; |
|
88 | QFont m_labelFont; | |
90 | QBrush m_titleBrush; |
|
89 | QBrush m_titleBrush; | |
91 | QPen m_axisLinePen; |
|
90 | QPen m_axisLinePen; | |
92 | QBrush m_axisLabelBrush; |
|
91 | QBrush m_axisLabelBrush; | |
93 | QPen m_backgroundShadesPen; |
|
92 | QPen m_backgroundShadesPen; | |
94 | QBrush m_backgroundShadesBrush; |
|
93 | QBrush m_backgroundShadesBrush; | |
95 | BackgroundShadesMode m_backgroundShades; |
|
94 | BackgroundShadesMode m_backgroundShades; | |
96 | QPen m_gridLinePen; |
|
95 | QPen m_gridLinePen; | |
97 | bool m_force; |
|
96 | bool m_force; | |
98 | }; |
|
97 | }; | |
99 |
|
98 | |||
100 | QTCOMMERCIALCHART_END_NAMESPACE |
|
99 | QTCOMMERCIALCHART_END_NAMESPACE | |
101 |
|
100 | |||
102 | #endif // CHARTTHEME_H |
|
101 | #endif // CHARTTHEME_H |
@@ -1,194 +1,194 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "legendmarker_p.h" |
|
21 | #include "legendmarker_p.h" | |
22 | #include "qxyseries.h" |
|
22 | #include "qxyseries.h" | |
23 | #include "qxyseries_p.h" |
|
23 | #include "qxyseries_p.h" | |
24 | #include "qlegend.h" |
|
24 | #include "qlegend.h" | |
25 | #include "qbarseries.h" |
|
25 | #include "qbarseries.h" | |
26 | #include "qpieseries.h" |
|
26 | #include "qpieseries.h" | |
27 | #include "qpieslice.h" |
|
27 | #include "qpieslice.h" | |
28 | #include "qbarset.h" |
|
28 | #include "qbarset.h" | |
29 | #include "qbarset_p.h" |
|
29 | #include "qbarset_p.h" | |
30 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
31 | #include "qareaseries_p.h" |
|
31 | #include "qareaseries_p.h" | |
32 | #include <QPainter> |
|
32 | #include <QPainter> | |
33 | #include <QGraphicsSceneEvent> |
|
33 | #include <QGraphicsSceneEvent> | |
34 | #include <QGraphicsSimpleTextItem> |
|
34 | #include <QGraphicsSimpleTextItem> | |
35 |
|
35 | |||
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
37 |
|
37 | |||
38 |
LegendMarker::LegendMarker(QSeries* |
|
38 | LegendMarker::LegendMarker(QAbstractSeries *series, QLegend *legend) : QGraphicsObject(legend), | |
39 | m_series(series), |
|
39 | m_series(series), | |
40 | m_markerRect(0,0,10.0,10.0), |
|
40 | m_markerRect(0,0,10.0,10.0), | |
41 | m_boundingRect(0,0,0,0), |
|
41 | m_boundingRect(0,0,0,0), | |
42 | m_legend(legend), |
|
42 | m_legend(legend), | |
43 | m_textItem(new QGraphicsSimpleTextItem(this)), |
|
43 | m_textItem(new QGraphicsSimpleTextItem(this)), | |
44 | m_rectItem(new QGraphicsRectItem(this)) |
|
44 | m_rectItem(new QGraphicsRectItem(this)) | |
45 | { |
|
45 | { | |
46 | //setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); |
|
46 | //setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); | |
47 | m_rectItem->setRect(m_markerRect); |
|
47 | m_rectItem->setRect(m_markerRect); | |
48 | updateLayout(); |
|
48 | updateLayout(); | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void LegendMarker::setPen(const QPen &pen) |
|
51 | void LegendMarker::setPen(const QPen &pen) | |
52 | { |
|
52 | { | |
53 | m_textItem->setPen(pen); |
|
53 | m_textItem->setPen(pen); | |
54 | updateLayout(); |
|
54 | updateLayout(); | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | QPen LegendMarker::pen() const |
|
57 | QPen LegendMarker::pen() const | |
58 | { |
|
58 | { | |
59 | return m_textItem->pen(); |
|
59 | return m_textItem->pen(); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | void LegendMarker::setBrush(const QBrush &brush) |
|
62 | void LegendMarker::setBrush(const QBrush &brush) | |
63 | { |
|
63 | { | |
64 | m_rectItem->setBrush(brush); |
|
64 | m_rectItem->setBrush(brush); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | QBrush LegendMarker::brush() const |
|
67 | QBrush LegendMarker::brush() const | |
68 | { |
|
68 | { | |
69 | return m_rectItem->brush(); |
|
69 | return m_rectItem->brush(); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | void LegendMarker::setLabel(const QString name) |
|
72 | void LegendMarker::setLabel(const QString name) | |
73 | { |
|
73 | { | |
74 | m_textItem->setText(name); |
|
74 | m_textItem->setText(name); | |
75 | updateLayout(); |
|
75 | updateLayout(); | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | void LegendMarker::setSize(const QSize& size) |
|
78 | void LegendMarker::setSize(const QSize& size) | |
79 | { |
|
79 | { | |
80 | m_markerRect = QRectF(0,0,size.width(),size.height()); |
|
80 | m_markerRect = QRectF(0,0,size.width(),size.height()); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | QString LegendMarker::label() const |
|
83 | QString LegendMarker::label() const | |
84 | { |
|
84 | { | |
85 | return m_textItem->text(); |
|
85 | return m_textItem->text(); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
88 | void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
89 | { |
|
89 | { | |
90 | Q_UNUSED(option) |
|
90 | Q_UNUSED(option) | |
91 | Q_UNUSED(widget) |
|
91 | Q_UNUSED(widget) | |
92 | Q_UNUSED(painter) |
|
92 | Q_UNUSED(painter) | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | QRectF LegendMarker::boundingRect() const |
|
95 | QRectF LegendMarker::boundingRect() const | |
96 | { |
|
96 | { | |
97 | return m_boundingRect; |
|
97 | return m_boundingRect; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void LegendMarker::updateLayout() |
|
100 | void LegendMarker::updateLayout() | |
101 | { |
|
101 | { | |
102 |
|
102 | |||
103 | static const qreal margin = 2; |
|
103 | static const qreal margin = 2; | |
104 | static const qreal space = 4; |
|
104 | static const qreal space = 4; | |
105 |
|
105 | |||
106 | const QRectF& textRect = m_textItem->boundingRect(); |
|
106 | const QRectF& textRect = m_textItem->boundingRect(); | |
107 | prepareGeometryChange(); |
|
107 | prepareGeometryChange(); | |
108 | m_boundingRect = QRectF(0,0,m_markerRect.width() + 2*margin + space + textRect.width(),qMax(m_markerRect.height()+2*margin,textRect.height()+2*margin)); |
|
108 | m_boundingRect = QRectF(0,0,m_markerRect.width() + 2*margin + space + textRect.width(),qMax(m_markerRect.height()+2*margin,textRect.height()+2*margin)); | |
109 | m_textItem->setPos(m_markerRect.width() + space + margin,m_boundingRect.height()/2 - textRect.height()/2); |
|
109 | m_textItem->setPos(m_markerRect.width() + space + margin,m_boundingRect.height()/2 - textRect.height()/2); | |
110 | m_rectItem->setPos(margin,m_boundingRect.height()/2 - m_markerRect.height()/2); |
|
110 | m_rectItem->setPos(margin,m_boundingRect.height()/2 - m_markerRect.height()/2); | |
111 |
|
111 | |||
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 | void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
114 | void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
115 | { |
|
115 | { | |
116 | QGraphicsObject::mousePressEvent(event); |
|
116 | QGraphicsObject::mousePressEvent(event); | |
117 | emit selected(); |
|
117 | emit selected(); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
121 |
|
121 | |||
122 | AreaLegendMarker::AreaLegendMarker(QAreaSeries *series,QLegend *legend) : LegendMarker(series,legend), |
|
122 | AreaLegendMarker::AreaLegendMarker(QAreaSeries *series,QLegend *legend) : LegendMarker(series,legend), | |
123 | m_series(series) |
|
123 | m_series(series) | |
124 | { |
|
124 | { | |
125 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
125 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
126 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); |
|
126 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); | |
127 | updated(); |
|
127 | updated(); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | void AreaLegendMarker::updated() |
|
130 | void AreaLegendMarker::updated() | |
131 | { |
|
131 | { | |
132 | setBrush(m_series->brush()); |
|
132 | setBrush(m_series->brush()); | |
133 | setLabel(m_series->name()); |
|
133 | setLabel(m_series->name()); | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
136 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
137 |
|
137 | |||
138 | BarLegendMarker::BarLegendMarker(QBarSeries *barseries,QBarSet *barset, QLegend *legend) : LegendMarker(barseries,legend), |
|
138 | BarLegendMarker::BarLegendMarker(QBarSeries *barseries,QBarSet *barset, QLegend *legend) : LegendMarker(barseries,legend), | |
139 | m_barset(barset) |
|
139 | m_barset(barset) | |
140 | { |
|
140 | { | |
141 | QObject::connect(this, SIGNAL(selected()),barseries, SIGNAL(selected())); |
|
141 | QObject::connect(this, SIGNAL(selected()),barseries, SIGNAL(selected())); | |
142 | QObject::connect(barset->d_ptr.data(), SIGNAL(valueChanged()), this, SLOT(updated())); |
|
142 | QObject::connect(barset->d_ptr.data(), SIGNAL(valueChanged()), this, SLOT(updated())); | |
143 | updated(); |
|
143 | updated(); | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | void BarLegendMarker::updated() |
|
146 | void BarLegendMarker::updated() | |
147 | { |
|
147 | { | |
148 | setBrush(m_barset->brush()); |
|
148 | setBrush(m_barset->brush()); | |
149 | setLabel(m_barset->name()); |
|
149 | setLabel(m_barset->name()); | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
153 |
|
153 | |||
154 | PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarker(series,legend), |
|
154 | PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarker(series,legend), | |
155 | m_pieslice(pieslice) |
|
155 | m_pieslice(pieslice) | |
156 | { |
|
156 | { | |
157 | QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL(selected())); |
|
157 | QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL(selected())); | |
158 | QObject::connect(pieslice, SIGNAL(changed()), this, SLOT(updated())); |
|
158 | QObject::connect(pieslice, SIGNAL(changed()), this, SLOT(updated())); | |
159 | updated(); |
|
159 | updated(); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void PieLegendMarker::updated() |
|
162 | void PieLegendMarker::updated() | |
163 | { |
|
163 | { | |
164 | setBrush(m_pieslice->brush()); |
|
164 | setBrush(m_pieslice->brush()); | |
165 | setLabel(m_pieslice->label()); |
|
165 | setLabel(m_pieslice->label()); | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
168 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
169 |
|
169 | |||
170 | XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) : LegendMarker(series,legend), |
|
170 | XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) : LegendMarker(series,legend), | |
171 | m_series(series) |
|
171 | m_series(series) | |
172 | { |
|
172 | { | |
173 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
173 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
174 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); |
|
174 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); | |
175 | updated(); |
|
175 | updated(); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | void XYLegendMarker::updated() |
|
178 | void XYLegendMarker::updated() | |
179 | { |
|
179 | { | |
180 | setLabel(m_series->name()); |
|
180 | setLabel(m_series->name()); | |
181 |
|
181 | |||
182 | if(m_series->type()== QSeries::SeriesTypeScatter) |
|
182 | if(m_series->type()== QAbstractSeries::SeriesTypeScatter) | |
183 | { |
|
183 | { | |
184 | setBrush(m_series->brush()); |
|
184 | setBrush(m_series->brush()); | |
185 |
|
185 | |||
186 | } |
|
186 | } | |
187 | else { |
|
187 | else { | |
188 | setBrush(QBrush(m_series->pen().color())); |
|
188 | setBrush(QBrush(m_series->pen().color())); | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | #include "moc_legendmarker_p.cpp" |
|
192 | #include "moc_legendmarker_p.cpp" | |
193 |
|
193 | |||
194 | QTCOMMERCIALCHART_END_NAMESPACE |
|
194 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,128 +1,128 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef LEGENDMARKER_P_H |
|
21 | #ifndef LEGENDMARKER_P_H | |
22 | #define LEGENDMARKER_P_H |
|
22 | #define LEGENDMARKER_P_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QGraphicsObject> |
|
25 | #include <QGraphicsObject> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QPen> |
|
27 | #include <QPen> | |
28 | #include <QGraphicsSimpleTextItem> |
|
28 | #include <QGraphicsSimpleTextItem> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSeries; |
|
32 | class QAbstractSeries; | |
33 | class QAreaSeries; |
|
33 | class QAreaSeries; | |
34 | class QXYSeries; |
|
34 | class QXYSeries; | |
35 | class QBarSet; |
|
35 | class QBarSet; | |
36 | class QBarSeries; |
|
36 | class QBarSeries; | |
37 | class QPieSlice; |
|
37 | class QPieSlice; | |
38 | class QLegend; |
|
38 | class QLegend; | |
39 | class QPieSeries; |
|
39 | class QPieSeries; | |
40 |
|
40 | |||
41 | class LegendMarker : public QGraphicsObject |
|
41 | class LegendMarker : public QGraphicsObject | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 |
explicit LegendMarker(QSeries* |
|
46 | explicit LegendMarker(QAbstractSeries *m_series, QLegend *parent); | |
47 |
|
47 | |||
48 | void setPen(const QPen &pen); |
|
48 | void setPen(const QPen &pen); | |
49 | QPen pen() const; |
|
49 | QPen pen() const; | |
50 | void setBrush(const QBrush &brush); |
|
50 | void setBrush(const QBrush &brush); | |
51 | QBrush brush() const; |
|
51 | QBrush brush() const; | |
52 |
|
52 | |||
53 | void setSize(const QSize& size); |
|
53 | void setSize(const QSize& size); | |
54 |
|
54 | |||
55 | void setLabel(const QString label); |
|
55 | void setLabel(const QString label); | |
56 | QString label() const; |
|
56 | QString label() const; | |
57 |
|
57 | |||
58 |
QSeries* |
|
58 | QAbstractSeries *series() const { return m_series;} | |
59 |
|
59 | |||
60 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
60 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
61 |
|
61 | |||
62 | QRectF boundingRect() const; |
|
62 | QRectF boundingRect() const; | |
63 |
|
63 | |||
64 | void updateLayout(); |
|
64 | void updateLayout(); | |
65 |
|
65 | |||
66 | protected: |
|
66 | protected: | |
67 | // From QGraphicsObject |
|
67 | // From QGraphicsObject | |
68 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
68 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
69 |
|
69 | |||
70 | Q_SIGNALS: |
|
70 | Q_SIGNALS: | |
71 | void selected(); |
|
71 | void selected(); | |
72 |
|
72 | |||
73 | public Q_SLOTS: |
|
73 | public Q_SLOTS: | |
74 | virtual void updated() = 0; |
|
74 | virtual void updated() = 0; | |
75 |
|
75 | |||
76 | protected: |
|
76 | protected: | |
77 |
QSeries* |
|
77 | QAbstractSeries *m_series; | |
78 | QRectF m_markerRect; |
|
78 | QRectF m_markerRect; | |
79 | QRectF m_boundingRect; |
|
79 | QRectF m_boundingRect; | |
80 | QLegend* m_legend; |
|
80 | QLegend* m_legend; | |
81 | QGraphicsSimpleTextItem *m_textItem; |
|
81 | QGraphicsSimpleTextItem *m_textItem; | |
82 | QGraphicsRectItem *m_rectItem; |
|
82 | QGraphicsRectItem *m_rectItem; | |
83 |
|
83 | |||
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
87 | class XYLegendMarker : public LegendMarker |
|
87 | class XYLegendMarker : public LegendMarker | |
88 | { |
|
88 | { | |
89 | public: |
|
89 | public: | |
90 | XYLegendMarker(QXYSeries *series, QLegend *legend); |
|
90 | XYLegendMarker(QXYSeries *series, QLegend *legend); | |
91 | protected: |
|
91 | protected: | |
92 | void updated(); |
|
92 | void updated(); | |
93 | private: |
|
93 | private: | |
94 | QXYSeries *m_series; |
|
94 | QXYSeries *m_series; | |
95 | }; |
|
95 | }; | |
96 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
96 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
97 | class AreaLegendMarker : public LegendMarker |
|
97 | class AreaLegendMarker : public LegendMarker | |
98 | { |
|
98 | { | |
99 | public: |
|
99 | public: | |
100 | AreaLegendMarker(QAreaSeries *series, QLegend *legend); |
|
100 | AreaLegendMarker(QAreaSeries *series, QLegend *legend); | |
101 | protected: |
|
101 | protected: | |
102 | void updated(); |
|
102 | void updated(); | |
103 | private: |
|
103 | private: | |
104 | QAreaSeries *m_series; |
|
104 | QAreaSeries *m_series; | |
105 | }; |
|
105 | }; | |
106 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
106 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
107 | class BarLegendMarker : public LegendMarker |
|
107 | class BarLegendMarker : public LegendMarker | |
108 | { |
|
108 | { | |
109 | public: |
|
109 | public: | |
110 | BarLegendMarker(QBarSeries *barseries, QBarSet *barset,QLegend *legend); |
|
110 | BarLegendMarker(QBarSeries *barseries, QBarSet *barset,QLegend *legend); | |
111 | protected: |
|
111 | protected: | |
112 | void updated(); |
|
112 | void updated(); | |
113 | private: |
|
113 | private: | |
114 | QBarSet *m_barset; |
|
114 | QBarSet *m_barset; | |
115 | }; |
|
115 | }; | |
116 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
116 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
117 | class PieLegendMarker : public LegendMarker |
|
117 | class PieLegendMarker : public LegendMarker | |
118 | { |
|
118 | { | |
119 | public: |
|
119 | public: | |
120 | PieLegendMarker(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); |
|
120 | PieLegendMarker(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); | |
121 | protected: |
|
121 | protected: | |
122 | void updated(); |
|
122 | void updated(); | |
123 | private: |
|
123 | private: | |
124 | QPieSlice *m_pieslice; |
|
124 | QPieSlice *m_pieslice; | |
125 | }; |
|
125 | }; | |
126 |
|
126 | |||
127 | QTCOMMERCIALCHART_END_NAMESPACE |
|
127 | QTCOMMERCIALCHART_END_NAMESPACE | |
128 | #endif // LEGENDMARKER_P_H |
|
128 | #endif // LEGENDMARKER_P_H |
@@ -1,451 +1,451 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qlegend.h" |
|
21 | #include "qlegend.h" | |
22 | #include "qlegend_p.h" |
|
22 | #include "qlegend_p.h" | |
23 | #include "qseries.h" |
|
23 | #include "qabstractseries.h" | |
24 | #include "qseries_p.h" |
|
24 | #include "qabstractseries_p.h" | |
25 | #include "qchart_p.h" |
|
25 | #include "qchart_p.h" | |
26 |
|
26 | |||
27 | #include "legendmarker_p.h" |
|
27 | #include "legendmarker_p.h" | |
28 | #include "qxyseries.h" |
|
28 | #include "qxyseries.h" | |
29 | #include "qlineseries.h" |
|
29 | #include "qlineseries.h" | |
30 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
31 | #include "qscatterseries.h" |
|
31 | #include "qscatterseries.h" | |
32 | #include "qsplineseries.h" |
|
32 | #include "qsplineseries.h" | |
33 | #include "qbarseries.h" |
|
33 | #include "qbarseries.h" | |
34 | #include "qstackedbarseries.h" |
|
34 | #include "qstackedbarseries.h" | |
35 | #include "qpercentbarseries.h" |
|
35 | #include "qpercentbarseries.h" | |
36 | #include "qbarset.h" |
|
36 | #include "qbarset.h" | |
37 | #include "qpieseries.h" |
|
37 | #include "qpieseries.h" | |
38 | #include "qpieslice.h" |
|
38 | #include "qpieslice.h" | |
39 | #include "chartpresenter_p.h" |
|
39 | #include "chartpresenter_p.h" | |
40 | #include <QPainter> |
|
40 | #include <QPainter> | |
41 | #include <QPen> |
|
41 | #include <QPen> | |
42 | #include <QTimer> |
|
42 | #include <QTimer> | |
43 |
|
43 | |||
44 | #include <QGraphicsSceneEvent> |
|
44 | #include <QGraphicsSceneEvent> | |
45 |
|
45 | |||
46 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
46 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \class QLegend |
|
49 | \class QLegend | |
50 | \brief part of QtCommercial chart API. |
|
50 | \brief part of QtCommercial chart API. | |
51 |
|
51 | |||
52 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when |
|
52 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when | |
53 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and |
|
53 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and | |
54 | handle the drawing manually. |
|
54 | handle the drawing manually. | |
55 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. |
|
55 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. | |
56 |
|
56 | |||
57 | \mainclass |
|
57 | \mainclass | |
58 |
|
58 | |||
59 | \sa QChart, QSeries |
|
59 | \sa QChart, QAbstractSeries | |
60 | */ |
|
60 | */ | |
61 |
|
61 | |||
62 | /*! |
|
62 | /*! | |
63 | \enum QLegend::Alignment |
|
63 | \enum QLegend::Alignment | |
64 |
|
64 | |||
65 | This enum describes the possible position for legend inside chart. |
|
65 | This enum describes the possible position for legend inside chart. | |
66 |
|
66 | |||
67 | \value AlignmentTop |
|
67 | \value AlignmentTop | |
68 | \value AlignmentBottom |
|
68 | \value AlignmentBottom | |
69 | \value AlignmentLeft |
|
69 | \value AlignmentLeft | |
70 | \value AlignmentRight |
|
70 | \value AlignmentRight | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \fn qreal QLegend::minWidth() const |
|
74 | \fn qreal QLegend::minWidth() const | |
75 | Returns minimum width of the legend |
|
75 | Returns minimum width of the legend | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \fn qreal QLegend::minHeight() const |
|
79 | \fn qreal QLegend::minHeight() const | |
80 | Returns minimum height of the legend |
|
80 | Returns minimum height of the legend | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | Constructs the legend object and sets the parent to \a parent |
|
84 | Constructs the legend object and sets the parent to \a parent | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), |
|
87 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), | |
88 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,this)) |
|
88 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,this)) | |
89 | { |
|
89 | { | |
90 | setZValue(ChartPresenter::LegendZValue); |
|
90 | setZValue(ChartPresenter::LegendZValue); | |
91 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
91 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
92 | setEnabled(false); // By default legend is disabled |
|
92 | setEnabled(false); // By default legend is disabled | |
93 | setVisible(false); |
|
93 | setVisible(false); | |
94 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
94 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries *, Domain *)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries *,Domain*))); | |
95 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QSeries*))); |
|
95 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries *)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries *))); | |
96 | } |
|
96 | } | |
97 |
|
97 | |||
98 | QLegend::~QLegend() |
|
98 | QLegend::~QLegend() | |
99 | { |
|
99 | { | |
100 |
|
100 | |||
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | Paints the legend to given \a painter. Paremeters \a option and \a widget arent used. |
|
104 | Paints the legend to given \a painter. Paremeters \a option and \a widget arent used. | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
107 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
108 | { |
|
108 | { | |
109 | Q_UNUSED(option) |
|
109 | Q_UNUSED(option) | |
110 | Q_UNUSED(widget) |
|
110 | Q_UNUSED(widget) | |
111 | if(!d_ptr->m_backgroundVisible) return; |
|
111 | if(!d_ptr->m_backgroundVisible) return; | |
112 |
|
112 | |||
113 | painter->setOpacity(opacity()); |
|
113 | painter->setOpacity(opacity()); | |
114 | painter->setPen(d_ptr->m_pen); |
|
114 | painter->setPen(d_ptr->m_pen); | |
115 | painter->setBrush(d_ptr->m_brush); |
|
115 | painter->setBrush(d_ptr->m_brush); | |
116 | painter->drawRect(boundingRect()); |
|
116 | painter->drawRect(boundingRect()); | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
120 | Bounding rect of legend. |
|
120 | Bounding rect of legend. | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | QRectF QLegend::boundingRect() const |
|
123 | QRectF QLegend::boundingRect() const | |
124 | { |
|
124 | { | |
125 | return d_ptr->m_rect; |
|
125 | return d_ptr->m_rect; | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Sets the \a brush of legend. Brush affects the background of legend. |
|
129 | Sets the \a brush of legend. Brush affects the background of legend. | |
130 | */ |
|
130 | */ | |
131 | void QLegend::setBrush(const QBrush &brush) |
|
131 | void QLegend::setBrush(const QBrush &brush) | |
132 | { |
|
132 | { | |
133 | if (d_ptr->m_brush != brush) { |
|
133 | if (d_ptr->m_brush != brush) { | |
134 | d_ptr->m_brush = brush; |
|
134 | d_ptr->m_brush = brush; | |
135 | update(); |
|
135 | update(); | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | /*! |
|
139 | /*! | |
140 | Returns the brush used by legend. |
|
140 | Returns the brush used by legend. | |
141 | */ |
|
141 | */ | |
142 | QBrush QLegend::brush() const |
|
142 | QBrush QLegend::brush() const | |
143 | { |
|
143 | { | |
144 | return d_ptr->m_brush; |
|
144 | return d_ptr->m_brush; | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | /*! |
|
147 | /*! | |
148 | Sets the \a pen of legend. Pen affects the legend borders. |
|
148 | Sets the \a pen of legend. Pen affects the legend borders. | |
149 | */ |
|
149 | */ | |
150 | void QLegend::setPen(const QPen &pen) |
|
150 | void QLegend::setPen(const QPen &pen) | |
151 | { |
|
151 | { | |
152 | if (d_ptr->m_pen != pen) { |
|
152 | if (d_ptr->m_pen != pen) { | |
153 | d_ptr->m_pen = pen; |
|
153 | d_ptr->m_pen = pen; | |
154 | update(); |
|
154 | update(); | |
155 | } |
|
155 | } | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | Returns the pen used by legend |
|
159 | Returns the pen used by legend | |
160 | */ |
|
160 | */ | |
161 |
|
161 | |||
162 | QPen QLegend::pen() const |
|
162 | QPen QLegend::pen() const | |
163 | { |
|
163 | { | |
164 | return d_ptr->m_pen; |
|
164 | return d_ptr->m_pen; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | /*! |
|
167 | /*! | |
168 | Sets the \a alignment for legend. Legend tries to paint itself on the defined position in chart. |
|
168 | Sets the \a alignment for legend. Legend tries to paint itself on the defined position in chart. | |
169 | \sa QLegend::Alignment |
|
169 | \sa QLegend::Alignment | |
170 | */ |
|
170 | */ | |
171 | void QLegend::setAlignment(QLegend::Alignments alignment) |
|
171 | void QLegend::setAlignment(QLegend::Alignments alignment) | |
172 | { |
|
172 | { | |
173 | if(d_ptr->m_alignment!=alignment && d_ptr->m_attachedToChart) { |
|
173 | if(d_ptr->m_alignment!=alignment && d_ptr->m_attachedToChart) { | |
174 | d_ptr->m_alignment = alignment; |
|
174 | d_ptr->m_alignment = alignment; | |
175 | d_ptr->updateLayout(); |
|
175 | d_ptr->updateLayout(); | |
176 | } |
|
176 | } | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | Returns the preferred layout for legend |
|
180 | Returns the preferred layout for legend | |
181 | */ |
|
181 | */ | |
182 | QLegend::Alignments QLegend::alignment() const |
|
182 | QLegend::Alignments QLegend::alignment() const | |
183 | { |
|
183 | { | |
184 | return d_ptr->m_alignment; |
|
184 | return d_ptr->m_alignment; | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | Detaches the legend from chart. Chart won't change layout of the legend. |
|
188 | Detaches the legend from chart. Chart won't change layout of the legend. | |
189 | */ |
|
189 | */ | |
190 | void QLegend::detachFromChart() |
|
190 | void QLegend::detachFromChart() | |
191 | { |
|
191 | { | |
192 | d_ptr->m_attachedToChart = false; |
|
192 | d_ptr->m_attachedToChart = false; | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Attaches the legend to chart. Chart may change layout of the legend. |
|
196 | Attaches the legend to chart. Chart may change layout of the legend. | |
197 | */ |
|
197 | */ | |
198 | void QLegend::attachToChart() |
|
198 | void QLegend::attachToChart() | |
199 | { |
|
199 | { | |
200 | d_ptr->m_attachedToChart = true; |
|
200 | d_ptr->m_attachedToChart = true; | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | Returns true, if legend is attached to chart. |
|
204 | Returns true, if legend is attached to chart. | |
205 | */ |
|
205 | */ | |
206 | bool QLegend::isAttachedToChart() |
|
206 | bool QLegend::isAttachedToChart() | |
207 | { |
|
207 | { | |
208 | return d_ptr->m_attachedToChart; |
|
208 | return d_ptr->m_attachedToChart; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | void QLegend::setOffset(const QPointF& point) |
|
211 | void QLegend::setOffset(const QPointF& point) | |
212 | { |
|
212 | { | |
213 | d_ptr->setOffset(point.x(),point.y()); |
|
213 | d_ptr->setOffset(point.x(),point.y()); | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | QPointF QLegend::offset() const |
|
216 | QPointF QLegend::offset() const | |
217 | { |
|
217 | { | |
218 | return QPointF(d_ptr->m_offsetX,d_ptr->m_offsetY); |
|
218 | return QPointF(d_ptr->m_offsetX,d_ptr->m_offsetY); | |
219 | } |
|
219 | } | |
220 |
|
220 | |||
221 | /*! |
|
221 | /*! | |
222 | Sets the visibility of legend background to \a visible |
|
222 | Sets the visibility of legend background to \a visible | |
223 | */ |
|
223 | */ | |
224 | void QLegend::setBackgroundVisible(bool visible) |
|
224 | void QLegend::setBackgroundVisible(bool visible) | |
225 | { |
|
225 | { | |
226 | if(d_ptr->m_backgroundVisible!=visible) |
|
226 | if(d_ptr->m_backgroundVisible!=visible) | |
227 | { |
|
227 | { | |
228 | d_ptr->m_backgroundVisible=visible; |
|
228 | d_ptr->m_backgroundVisible=visible; | |
229 | update(); |
|
229 | update(); | |
230 | } |
|
230 | } | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | /*! |
|
233 | /*! | |
234 | Returns the visibility of legend background |
|
234 | Returns the visibility of legend background | |
235 | */ |
|
235 | */ | |
236 | bool QLegend::isBackgroundVisible() const |
|
236 | bool QLegend::isBackgroundVisible() const | |
237 | { |
|
237 | { | |
238 | return d_ptr->m_backgroundVisible; |
|
238 | return d_ptr->m_backgroundVisible; | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | /*! |
|
241 | /*! | |
242 | \internal \a event see QGraphicsWidget for details |
|
242 | \internal \a event see QGraphicsWidget for details | |
243 | */ |
|
243 | */ | |
244 | void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
244 | void QLegend::resizeEvent(QGraphicsSceneResizeEvent *event) | |
245 | { |
|
245 | { | |
246 | const QRectF& rect = QRectF(QPoint(0,0),event->newSize()); |
|
246 | const QRectF& rect = QRectF(QPoint(0,0),event->newSize()); | |
247 | QGraphicsWidget::resizeEvent(event); |
|
247 | QGraphicsWidget::resizeEvent(event); | |
248 | if(d_ptr->m_rect != rect) { |
|
248 | if(d_ptr->m_rect != rect) { | |
249 | d_ptr->m_rect = rect; |
|
249 | d_ptr->m_rect = rect; | |
250 | d_ptr->updateLayout(); |
|
250 | d_ptr->updateLayout(); | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | /*! |
|
254 | /*! | |
255 | \internal \a event see QGraphicsWidget for details |
|
255 | \internal \a event see QGraphicsWidget for details | |
256 | */ |
|
256 | */ | |
257 | void QLegend::hideEvent(QHideEvent *event) |
|
257 | void QLegend::hideEvent(QHideEvent *event) | |
258 | { |
|
258 | { | |
259 | QGraphicsWidget::hideEvent(event); |
|
259 | QGraphicsWidget::hideEvent(event); | |
260 | setEnabled(false); |
|
260 | setEnabled(false); | |
261 | d_ptr->updateLayout(); |
|
261 | d_ptr->updateLayout(); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | /*! |
|
264 | /*! | |
265 | \internal \a event see QGraphicsWidget for details |
|
265 | \internal \a event see QGraphicsWidget for details | |
266 | */ |
|
266 | */ | |
267 | void QLegend::showEvent(QShowEvent *event) |
|
267 | void QLegend::showEvent(QShowEvent *event) | |
268 | { |
|
268 | { | |
269 | QGraphicsWidget::showEvent(event); |
|
269 | QGraphicsWidget::showEvent(event); | |
270 | setEnabled(true); |
|
270 | setEnabled(true); | |
271 | d_ptr->updateLayout(); |
|
271 | d_ptr->updateLayout(); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | qreal QLegend::minWidth() const |
|
274 | qreal QLegend::minWidth() const | |
275 | { |
|
275 | { | |
276 | return d_ptr->m_minWidth; |
|
276 | return d_ptr->m_minWidth; | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | qreal QLegend::minHeight() const |
|
279 | qreal QLegend::minHeight() const | |
280 | { |
|
280 | { | |
281 | return d_ptr->m_minHeight; |
|
281 | return d_ptr->m_minHeight; | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
284 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
285 |
|
285 | |||
286 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter,QLegend *q): |
|
286 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter,QLegend *q): | |
287 | q_ptr(q), |
|
287 | q_ptr(q), | |
288 | m_presenter(presenter), |
|
288 | m_presenter(presenter), | |
289 | m_markers(new QGraphicsItemGroup(q)), |
|
289 | m_markers(new QGraphicsItemGroup(q)), | |
290 | m_alignment(QLegend::AlignmentTop), |
|
290 | m_alignment(QLegend::AlignmentTop), | |
291 | m_offsetX(0), |
|
291 | m_offsetX(0), | |
292 | m_offsetY(0), |
|
292 | m_offsetY(0), | |
293 | m_minWidth(0), |
|
293 | m_minWidth(0), | |
294 | m_minHeight(0), |
|
294 | m_minHeight(0), | |
295 | m_width(0), |
|
295 | m_width(0), | |
296 | m_height(0), |
|
296 | m_height(0), | |
297 | m_attachedToChart(true), |
|
297 | m_attachedToChart(true), | |
298 | m_backgroundVisible(false) |
|
298 | m_backgroundVisible(false) | |
299 | { |
|
299 | { | |
300 |
|
300 | |||
301 | } |
|
301 | } | |
302 |
|
302 | |||
303 | QLegendPrivate::~QLegendPrivate() |
|
303 | QLegendPrivate::~QLegendPrivate() | |
304 | { |
|
304 | { | |
305 |
|
305 | |||
306 | } |
|
306 | } | |
307 |
|
307 | |||
308 | void QLegendPrivate::setOffset(qreal x, qreal y) |
|
308 | void QLegendPrivate::setOffset(qreal x, qreal y) | |
309 | { |
|
309 | { | |
310 |
|
310 | |||
311 | switch(m_alignment) { |
|
311 | switch(m_alignment) { | |
312 |
|
312 | |||
313 | case QLegend::AlignmentTop: |
|
313 | case QLegend::AlignmentTop: | |
314 | case QLegend::AlignmentBottom: { |
|
314 | case QLegend::AlignmentBottom: { | |
315 | if(m_width<=m_rect.width()) return; |
|
315 | if(m_width<=m_rect.width()) return; | |
316 |
|
316 | |||
317 | if (x != m_offsetX) { |
|
317 | if (x != m_offsetX) { | |
318 | m_offsetX = qBound(qreal(0), x, m_width - m_rect.width()); |
|
318 | m_offsetX = qBound(qreal(0), x, m_width - m_rect.width()); | |
319 | m_markers->setPos(-m_offsetX,m_rect.top()); |
|
319 | m_markers->setPos(-m_offsetX,m_rect.top()); | |
320 | } |
|
320 | } | |
321 | break; |
|
321 | break; | |
322 | } |
|
322 | } | |
323 | case QLegend::AlignmentLeft: |
|
323 | case QLegend::AlignmentLeft: | |
324 | case QLegend::AlignmentRight: { |
|
324 | case QLegend::AlignmentRight: { | |
325 |
|
325 | |||
326 | if(m_height<=m_rect.height()) return; |
|
326 | if(m_height<=m_rect.height()) return; | |
327 |
|
327 | |||
328 | if (y != m_offsetY) { |
|
328 | if (y != m_offsetY) { | |
329 | m_offsetY = qBound(qreal(0), y, m_height - m_rect.height()); |
|
329 | m_offsetY = qBound(qreal(0), y, m_height - m_rect.height()); | |
330 | m_markers->setPos(m_rect.left(),-m_offsetY); |
|
330 | m_markers->setPos(m_rect.left(),-m_offsetY); | |
331 | } |
|
331 | } | |
332 | break; |
|
332 | break; | |
333 | } |
|
333 | } | |
334 | } |
|
334 | } | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 |
|
337 | |||
338 | void QLegendPrivate::updateLayout() |
|
338 | void QLegendPrivate::updateLayout() | |
339 | { |
|
339 | { | |
340 | m_offsetX=0; |
|
340 | m_offsetX=0; | |
341 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
341 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
342 |
|
342 | |||
343 | if(items.isEmpty()) return; |
|
343 | if(items.isEmpty()) return; | |
344 |
|
344 | |||
345 | m_minWidth=0; |
|
345 | m_minWidth=0; | |
346 | m_minHeight=0; |
|
346 | m_minHeight=0; | |
347 |
|
347 | |||
348 | switch(m_alignment) { |
|
348 | switch(m_alignment) { | |
349 |
|
349 | |||
350 | case QLegend::AlignmentTop: |
|
350 | case QLegend::AlignmentTop: | |
351 | case QLegend::AlignmentBottom: { |
|
351 | case QLegend::AlignmentBottom: { | |
352 | QPointF point = m_rect.topLeft(); |
|
352 | QPointF point = m_rect.topLeft(); | |
353 | m_width = 0; |
|
353 | m_width = 0; | |
354 | foreach (QGraphicsItem *item, items) { |
|
354 | foreach (QGraphicsItem *item, items) { | |
355 | item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2); |
|
355 | item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2); | |
356 | const QRectF& rect = item->boundingRect(); |
|
356 | const QRectF& rect = item->boundingRect(); | |
357 | qreal w = rect.width(); |
|
357 | qreal w = rect.width(); | |
358 | m_minWidth=qMax(m_minWidth,w); |
|
358 | m_minWidth=qMax(m_minWidth,w); | |
359 | m_minHeight=qMax(m_minHeight,rect.height()); |
|
359 | m_minHeight=qMax(m_minHeight,rect.height()); | |
360 | m_width+=w; |
|
360 | m_width+=w; | |
361 | point.setX(point.x() + w); |
|
361 | point.setX(point.x() + w); | |
362 | } |
|
362 | } | |
363 | if(m_width<m_rect.width()) { |
|
363 | if(m_width<m_rect.width()) { | |
364 | m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top()); |
|
364 | m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top()); | |
365 | } |
|
365 | } | |
366 | else { |
|
366 | else { | |
367 | m_markers->setPos(m_rect.topLeft()); |
|
367 | m_markers->setPos(m_rect.topLeft()); | |
368 | } |
|
368 | } | |
369 | m_height=m_minHeight; |
|
369 | m_height=m_minHeight; | |
370 | } |
|
370 | } | |
371 | break; |
|
371 | break; | |
372 | case QLegend::AlignmentLeft: |
|
372 | case QLegend::AlignmentLeft: | |
373 | case QLegend::AlignmentRight: { |
|
373 | case QLegend::AlignmentRight: { | |
374 | QPointF point = m_rect.topLeft(); |
|
374 | QPointF point = m_rect.topLeft(); | |
375 | m_height = 0; |
|
375 | m_height = 0; | |
376 | foreach (QGraphicsItem *item, items) { |
|
376 | foreach (QGraphicsItem *item, items) { | |
377 | item->setPos(point); |
|
377 | item->setPos(point); | |
378 | const QRectF& rect = item->boundingRect(); |
|
378 | const QRectF& rect = item->boundingRect(); | |
379 | qreal h = rect.height(); |
|
379 | qreal h = rect.height(); | |
380 | m_minWidth=qMax(m_minWidth,rect.width()); |
|
380 | m_minWidth=qMax(m_minWidth,rect.width()); | |
381 | m_minHeight=qMax(m_minHeight,h); |
|
381 | m_minHeight=qMax(m_minHeight,h); | |
382 | m_height+=h; |
|
382 | m_height+=h; | |
383 | point.setY(point.y() + h); |
|
383 | point.setY(point.y() + h); | |
384 | } |
|
384 | } | |
385 | if(m_height<m_rect.height()) { |
|
385 | if(m_height<m_rect.height()) { | |
386 | m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2); |
|
386 | m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2); | |
387 | } |
|
387 | } | |
388 | else { |
|
388 | else { | |
389 | m_markers->setPos(m_rect.topLeft()); |
|
389 | m_markers->setPos(m_rect.topLeft()); | |
390 | } |
|
390 | } | |
391 | m_width=m_minWidth; |
|
391 | m_width=m_minWidth; | |
392 | } |
|
392 | } | |
393 | break; |
|
393 | break; | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | m_presenter->updateLayout(); |
|
396 | m_presenter->updateLayout(); | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | void QLegendPrivate::handleSeriesAdded(QSeries *series, Domain *domain) |
|
399 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
400 | { |
|
400 | { | |
401 | Q_UNUSED(domain) |
|
401 | Q_UNUSED(domain) | |
402 |
|
402 | |||
403 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); |
|
403 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); | |
404 | foreach(LegendMarker* marker , markers) |
|
404 | foreach(LegendMarker* marker , markers) | |
405 | m_markers->addToGroup(marker); |
|
405 | m_markers->addToGroup(marker); | |
406 |
|
406 | |||
407 | if(series->type()==QSeries::SeriesTypePie) |
|
407 | if(series->type() == QAbstractSeries::SeriesTypePie) | |
408 | { |
|
408 | { | |
409 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
409 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
410 | QObject::connect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); |
|
410 | QObject::connect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
411 | QObject::connect(pieSeries,SIGNAL(removed(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); |
|
411 | QObject::connect(pieSeries,SIGNAL(removed(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | updateLayout(); |
|
414 | updateLayout(); | |
415 | } |
|
415 | } | |
416 |
|
416 | |||
417 | void QLegendPrivate::handleSeriesRemoved(QSeries *series) |
|
417 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |
418 | { |
|
418 | { | |
419 |
|
419 | |||
420 | QList<QGraphicsItem *> items = m_markers->childItems(); |
|
420 | QList<QGraphicsItem *> items = m_markers->childItems(); | |
421 |
|
421 | |||
422 | foreach (QGraphicsItem *markers, items) { |
|
422 | foreach (QGraphicsItem *markers, items) { | |
423 | LegendMarker *marker = static_cast<LegendMarker*>(markers); |
|
423 | LegendMarker *marker = static_cast<LegendMarker*>(markers); | |
424 | if (marker->series() == series) { |
|
424 | if (marker->series() == series) { | |
425 | delete marker; |
|
425 | delete marker; | |
426 | } |
|
426 | } | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | if(series->type()==QSeries::SeriesTypePie) |
|
429 | if(series->type() == QAbstractSeries::SeriesTypePie) | |
430 | { |
|
430 | { | |
431 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
431 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
432 | QObject::disconnect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); |
|
432 | QObject::disconnect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
433 | QObject::disconnect(pieSeries,SIGNAL(removed(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); |
|
433 | QObject::disconnect(pieSeries,SIGNAL(removed(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | updateLayout(); |
|
436 | updateLayout(); | |
437 | } |
|
437 | } | |
438 |
|
438 | |||
439 | void QLegendPrivate::handleUpdateSeries() |
|
439 | void QLegendPrivate::handleUpdateSeries() | |
440 | { |
|
440 | { | |
441 | //TODO: reimplement to be optimal |
|
441 | //TODO: reimplement to be optimal | |
442 | QSeries* series = qobject_cast<QSeries *> (sender()); |
|
442 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); | |
443 | Q_ASSERT(series); |
|
443 | Q_ASSERT(series); | |
444 | handleSeriesRemoved(series); |
|
444 | handleSeriesRemoved(series); | |
445 | handleSeriesAdded(series,0); |
|
445 | handleSeriesAdded(series,0); | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | #include "moc_qlegend.cpp" |
|
448 | #include "moc_qlegend.cpp" | |
449 | #include "moc_qlegend_p.cpp" |
|
449 | #include "moc_qlegend_p.cpp" | |
450 |
|
450 | |||
451 | QTCOMMERCIALCHART_END_NAMESPACE |
|
451 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,104 +1,102 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QLEGEND_H |
|
21 | #ifndef QLEGEND_H | |
22 | #define QLEGEND_H |
|
22 | #define QLEGEND_H | |
23 |
|
23 | |||
24 | #include <QChartGlobal> |
|
24 | #include <QChartGlobal> | |
25 | #include <QGraphicsWidget> |
|
25 | #include <QGraphicsWidget> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class Domain; |
|
31 | class Domain; | |
32 | class LegendMarker; |
|
32 | class LegendMarker; | |
33 | class QPieSlice; |
|
33 | class QPieSlice; | |
34 | class QXYSeries; |
|
34 | class QXYSeries; | |
35 | class QBarSet; |
|
35 | class QBarSet; | |
36 | class QBarSeries; |
|
36 | class QBarSeries; | |
37 | class QPieSeries; |
|
37 | class QPieSeries; | |
38 | class QAreaSeries; |
|
38 | class QAreaSeries; | |
39 | class LegendScrollButton; |
|
39 | class LegendScrollButton; | |
40 | class QSeries; |
|
|||
41 |
|
||||
42 | class QChart; |
|
40 | class QChart; | |
43 | class QLegendPrivate; |
|
41 | class QLegendPrivate; | |
44 |
|
42 | |||
45 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget |
|
43 | class QTCOMMERCIALCHART_EXPORT QLegend : public QGraphicsWidget | |
46 | { |
|
44 | { | |
47 | Q_OBJECT |
|
45 | Q_OBJECT | |
48 | public: |
|
46 | public: | |
49 |
|
47 | |||
50 | // We only support these alignments (for now) |
|
48 | // We only support these alignments (for now) | |
51 | enum Alignment { |
|
49 | enum Alignment { | |
52 | AlignmentTop = Qt::AlignTop, |
|
50 | AlignmentTop = Qt::AlignTop, | |
53 | AlignmentBottom = Qt::AlignBottom, |
|
51 | AlignmentBottom = Qt::AlignBottom, | |
54 | AlignmentLeft = Qt::AlignLeft, |
|
52 | AlignmentLeft = Qt::AlignLeft, | |
55 | AlignmentRight = Qt::AlignRight |
|
53 | AlignmentRight = Qt::AlignRight | |
56 | }; |
|
54 | }; | |
57 |
|
55 | |||
58 | Q_DECLARE_FLAGS(Alignments, Alignment) |
|
56 | Q_DECLARE_FLAGS(Alignments, Alignment) | |
59 |
|
57 | |||
60 | private: |
|
58 | private: | |
61 | explicit QLegend(QChart *chart); |
|
59 | explicit QLegend(QChart *chart); | |
62 |
|
60 | |||
63 | public: |
|
61 | public: | |
64 | ~QLegend(); |
|
62 | ~QLegend(); | |
65 |
|
63 | |||
66 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
64 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
67 | QRectF boundingRect() const; |
|
65 | QRectF boundingRect() const; | |
68 |
|
66 | |||
69 | void setBrush(const QBrush &brush); |
|
67 | void setBrush(const QBrush &brush); | |
70 | QBrush brush() const; |
|
68 | QBrush brush() const; | |
71 |
|
69 | |||
72 | void setPen(const QPen &pen); |
|
70 | void setPen(const QPen &pen); | |
73 | QPen pen() const; |
|
71 | QPen pen() const; | |
74 |
|
72 | |||
75 | void setAlignment(QLegend::Alignments alignment); |
|
73 | void setAlignment(QLegend::Alignments alignment); | |
76 | QLegend::Alignments alignment() const; |
|
74 | QLegend::Alignments alignment() const; | |
77 |
|
75 | |||
78 | void detachFromChart(); |
|
76 | void detachFromChart(); | |
79 | void attachToChart(); |
|
77 | void attachToChart(); | |
80 | bool isAttachedToChart(); |
|
78 | bool isAttachedToChart(); | |
81 |
|
79 | |||
82 | qreal minWidth() const; |
|
80 | qreal minWidth() const; | |
83 | qreal minHeight() const; |
|
81 | qreal minHeight() const; | |
84 |
|
82 | |||
85 | void setBackgroundVisible(bool visible = true); |
|
83 | void setBackgroundVisible(bool visible = true); | |
86 | bool isBackgroundVisible() const; |
|
84 | bool isBackgroundVisible() const; | |
87 |
|
85 | |||
88 | void setOffset(const QPointF& point); |
|
86 | void setOffset(const QPointF& point); | |
89 | QPointF offset() const; |
|
87 | QPointF offset() const; | |
90 |
|
88 | |||
91 | protected: |
|
89 | protected: | |
92 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
90 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
93 | void hideEvent(QHideEvent *event); |
|
91 | void hideEvent(QHideEvent *event); | |
94 | void showEvent(QShowEvent *event); |
|
92 | void showEvent(QShowEvent *event); | |
95 |
|
93 | |||
96 | private: |
|
94 | private: | |
97 | QScopedPointer<QLegendPrivate> d_ptr; |
|
95 | QScopedPointer<QLegendPrivate> d_ptr; | |
98 | Q_DISABLE_COPY(QLegend); |
|
96 | Q_DISABLE_COPY(QLegend); | |
99 | friend class LegendScroller; |
|
97 | friend class LegendScroller; | |
100 | }; |
|
98 | }; | |
101 |
|
99 | |||
102 | QTCOMMERCIALCHART_END_NAMESPACE |
|
100 | QTCOMMERCIALCHART_END_NAMESPACE | |
103 |
|
101 | |||
104 | #endif // QLEGEND_H |
|
102 | #endif // QLEGEND_H |
@@ -1,77 +1,78 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QLEGEND_P_H |
|
30 | #ifndef QLEGEND_P_H | |
31 | #define QLEGEND_P_H |
|
31 | #define QLEGEND_P_H | |
32 |
|
32 | |||
33 | #include "qlegend.h" |
|
33 | #include "qlegend.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class ChartPresenter; |
|
37 | class ChartPresenter; | |
|
38 | class QAbstractSeries; | |||
38 |
|
39 | |||
39 | class QLegendPrivate : public QObject |
|
40 | class QLegendPrivate : public QObject | |
40 | { |
|
41 | { | |
41 | Q_OBJECT |
|
42 | Q_OBJECT | |
42 | public: |
|
43 | public: | |
43 | QLegendPrivate(ChartPresenter *chart,QLegend *q); |
|
44 | QLegendPrivate(ChartPresenter *chart,QLegend *q); | |
44 | ~QLegendPrivate(); |
|
45 | ~QLegendPrivate(); | |
45 |
|
46 | |||
46 | void setOffset(qreal x, qreal y); |
|
47 | void setOffset(qreal x, qreal y); | |
47 | void updateLayout(); |
|
48 | void updateLayout(); | |
48 |
|
49 | |||
49 | public Q_SLOTS: |
|
50 | public Q_SLOTS: | |
50 | void handleSeriesAdded(QSeries *series, Domain *domain); |
|
51 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); | |
51 | void handleSeriesRemoved(QSeries *series); |
|
52 | void handleSeriesRemoved(QAbstractSeries *series); | |
52 | void handleUpdateSeries(); //TODO remove this function |
|
53 | void handleUpdateSeries(); //TODO remove this function | |
53 |
|
54 | |||
54 | private: |
|
55 | private: | |
55 | QLegend *q_ptr; |
|
56 | QLegend *q_ptr; | |
56 | ChartPresenter *m_presenter; |
|
57 | ChartPresenter *m_presenter; | |
57 | QGraphicsItemGroup* m_markers; |
|
58 | QGraphicsItemGroup* m_markers; | |
58 | QLegend::Alignments m_alignment; |
|
59 | QLegend::Alignments m_alignment; | |
59 | QBrush m_brush; |
|
60 | QBrush m_brush; | |
60 | QPen m_pen; |
|
61 | QPen m_pen; | |
61 | QRectF m_rect; |
|
62 | QRectF m_rect; | |
62 | qreal m_offsetX; |
|
63 | qreal m_offsetX; | |
63 | qreal m_offsetY; |
|
64 | qreal m_offsetY; | |
64 | qreal m_minWidth; |
|
65 | qreal m_minWidth; | |
65 | qreal m_minHeight; |
|
66 | qreal m_minHeight; | |
66 | qreal m_width; |
|
67 | qreal m_width; | |
67 | qreal m_height; |
|
68 | qreal m_height; | |
68 | bool m_attachedToChart; |
|
69 | bool m_attachedToChart; | |
69 | bool m_backgroundVisible; |
|
70 | bool m_backgroundVisible; | |
70 |
|
71 | |||
71 | friend class QLegend; |
|
72 | friend class QLegend; | |
72 |
|
73 | |||
73 | }; |
|
74 | }; | |
74 |
|
75 | |||
75 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE | |
76 |
|
77 | |||
77 | #endif |
|
78 | #endif |
@@ -1,116 +1,116 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qlineseries.h" |
|
21 | #include "qlineseries.h" | |
22 | #include "qlineseries_p.h" |
|
22 | #include "qlineseries_p.h" | |
23 | #include "linechartitem_p.h" |
|
23 | #include "linechartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 | \class QLineSeries |
|
31 | \class QLineSeries | |
32 | \brief The QLineSeries class is used for making line charts. |
|
32 | \brief The QLineSeries class is used for making line charts. | |
33 |
|
33 | |||
34 | \mainclass |
|
34 | \mainclass | |
35 |
|
35 | |||
36 | A line chart is used to show information as a series of data points |
|
36 | A line chart is used to show information as a series of data points | |
37 | connected by straight lines. |
|
37 | connected by straight lines. | |
38 |
|
38 | |||
39 | \image linechart.png |
|
39 | \image linechart.png | |
40 |
|
40 | |||
41 | Creating basic line chart is simple: |
|
41 | Creating basic line chart is simple: | |
42 | \code |
|
42 | \code | |
43 | QLineSeries* series = new QLineSeries(); |
|
43 | QLineSeries* series = new QLineSeries(); | |
44 | series->append(0, 6); |
|
44 | series->append(0, 6); | |
45 | series->append(2, 4); |
|
45 | series->append(2, 4); | |
46 | ... |
|
46 | ... | |
47 | chartView->addSeries(series); |
|
47 | chartView->addSeries(series); | |
48 | \endcode |
|
48 | \endcode | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn virtual QSeriesType QLineSeries::type() const |
|
52 | \fn virtual QSeriesType QLineSeries::type() const | |
53 | \brief Returns type of series. |
|
53 | \brief Returns type of series. | |
54 | \sa QSeries, QSeriesType |
|
54 | \sa QAbstractSeries, QSeriesType | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | Constructs empty series object which is a child of \a parent. |
|
58 | Constructs empty series object which is a child of \a parent. | |
59 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
59 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
60 | */ |
|
60 | */ | |
61 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent) |
|
61 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent) | |
62 | { |
|
62 | { | |
63 |
|
63 | |||
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | \internal |
|
67 | \internal | |
68 | */ |
|
68 | */ | |
69 | QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent) |
|
69 | QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent) | |
70 | { |
|
70 | { | |
71 |
|
71 | |||
72 | } |
|
72 | } | |
73 | /*! |
|
73 | /*! | |
74 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
74 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
75 | and are deleted when mentioned object are destroyed. |
|
75 | and are deleted when mentioned object are destroyed. | |
76 | */ |
|
76 | */ | |
77 | QLineSeries::~QLineSeries() |
|
77 | QLineSeries::~QLineSeries() | |
78 | { |
|
78 | { | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | QSeries::QSeriesType QLineSeries::type() const |
|
81 | QAbstractSeries::QSeriesType QLineSeries::type() const | |
82 | { |
|
82 | { | |
83 | return QSeries::SeriesTypeLine; |
|
83 | return QAbstractSeries::SeriesTypeLine; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | /* |
|
86 | /* | |
87 | QDebug operator<< (QDebug debug, const QLineSeries series) |
|
87 | QDebug operator<< (QDebug debug, const QLineSeries series) | |
88 | { |
|
88 | { | |
89 | Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size()); |
|
89 | Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size()); | |
90 | int size = series.d_func()->m_x.size(); |
|
90 | int size = series.d_func()->m_x.size(); | |
91 | for (int i=0; i<size; i++) { |
|
91 | for (int i=0; i<size; i++) { | |
92 | debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") "; |
|
92 | debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") "; | |
93 | } |
|
93 | } | |
94 | return debug.space(); |
|
94 | return debug.space(); | |
95 | } |
|
95 | } | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
99 |
|
99 | |||
100 | QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q) |
|
100 | QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q) | |
101 | { |
|
101 | { | |
102 |
|
102 | |||
103 | }; |
|
103 | }; | |
104 |
|
104 | |||
105 | Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
105 | Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
106 | { |
|
106 | { | |
107 | Q_Q(QLineSeries); |
|
107 | Q_Q(QLineSeries); | |
108 | LineChartItem* line = new LineChartItem(q,presenter); |
|
108 | LineChartItem* line = new LineChartItem(q,presenter); | |
109 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
109 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
110 | presenter->animator()->addAnimation(line); |
|
110 | presenter->animator()->addAnimation(line); | |
111 | } |
|
111 | } | |
112 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
112 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
113 | return line; |
|
113 | return line; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
116 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,52 +1,52 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QLINESERIES_H |
|
21 | #ifndef QLINESERIES_H | |
22 | #define QLINESERIES_H |
|
22 | #define QLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | class QLineSeriesPrivate; |
|
30 | class QLineSeriesPrivate; | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries |
|
32 | class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries | |
33 | { |
|
33 | { | |
34 | public: |
|
34 | public: | |
35 | explicit QLineSeries(QObject *parent = 0); |
|
35 | explicit QLineSeries(QObject *parent = 0); | |
36 | ~QLineSeries(); |
|
36 | ~QLineSeries(); | |
37 |
|
37 | |||
38 | QSeries::QSeriesType type() const; |
|
38 | QAbstractSeries::QSeriesType type() const; | |
39 |
|
39 | |||
40 | protected: |
|
40 | protected: | |
41 | QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0); |
|
41 | QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0); | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | Q_DECLARE_PRIVATE(QLineSeries); |
|
44 | Q_DECLARE_PRIVATE(QLineSeries); | |
45 | Q_DISABLE_COPY(QLineSeries); |
|
45 | Q_DISABLE_COPY(QLineSeries); | |
46 | friend class LineChartItem; |
|
46 | friend class LineChartItem; | |
47 |
|
47 | |||
48 | }; |
|
48 | }; | |
49 |
|
49 | |||
50 | QTCOMMERCIALCHART_END_NAMESPACE |
|
50 | QTCOMMERCIALCHART_END_NAMESPACE | |
51 |
|
51 | |||
52 | #endif |
|
52 | #endif |
@@ -1,738 +1,738 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qpieseries.h" |
|
21 | #include "qpieseries.h" | |
22 | #include "qpieseries_p.h" |
|
22 | #include "qpieseries_p.h" | |
23 | #include "qpieslice.h" |
|
23 | #include "qpieslice.h" | |
24 | #include "pieslicedata_p.h" |
|
24 | #include "pieslicedata_p.h" | |
25 | #include "chartdataset_p.h" |
|
25 | #include "chartdataset_p.h" | |
26 | #include "charttheme_p.h" |
|
26 | #include "charttheme_p.h" | |
27 | #include "chartanimator_p.h" |
|
27 | #include "chartanimator_p.h" | |
28 | #include "legendmarker_p.h" |
|
28 | #include "legendmarker_p.h" | |
29 | #include <QAbstractItemModel> |
|
29 | #include <QAbstractItemModel> | |
30 | #include <QDebug> |
|
30 | #include <QDebug> | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | /*! |
|
34 | /*! | |
35 | \class QPieSeries |
|
35 | \class QPieSeries | |
36 | \brief Pie series API for QtCommercial Charts |
|
36 | \brief Pie series API for QtCommercial Charts | |
37 |
|
37 | |||
38 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. |
|
38 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. | |
39 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
39 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. | |
40 | The actual slice size is determined by that relative value. |
|
40 | The actual slice size is determined by that relative value. | |
41 |
|
41 | |||
42 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 |
|
42 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 | |
43 | These relate to the actual chart rectangle. |
|
43 | These relate to the actual chart rectangle. | |
44 |
|
44 | |||
45 | By default the pie is defined as a full pie but it can also be a partial pie. |
|
45 | By default the pie is defined as a full pie but it can also be a partial pie. | |
46 | This can be done by setting a starting angle and angle span to the series. |
|
46 | This can be done by setting a starting angle and angle span to the series. | |
47 | Full pie is 360 degrees where 0 is at 12 a'clock. |
|
47 | Full pie is 360 degrees where 0 is at 12 a'clock. | |
48 | */ |
|
48 | */ | |
49 |
|
49 | |||
50 | /*! |
|
50 | /*! | |
51 | \property QPieSeries::horizontalPosition |
|
51 | \property QPieSeries::horizontalPosition | |
52 | \brief Defines the horizontal position of the pie. |
|
52 | \brief Defines the horizontal position of the pie. | |
53 |
|
53 | |||
54 | The value is a relative value to the chart rectangle where: |
|
54 | The value is a relative value to the chart rectangle where: | |
55 |
|
55 | |||
56 | \list |
|
56 | \list | |
57 | \o 0.0 is the absolute left. |
|
57 | \o 0.0 is the absolute left. | |
58 | \o 1.0 is the absolute right. |
|
58 | \o 1.0 is the absolute right. | |
59 | \endlist |
|
59 | \endlist | |
60 |
|
60 | |||
61 | Default value is 0.5 (center). |
|
61 | Default value is 0.5 (center). | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \property QPieSeries::verticalPosition |
|
65 | \property QPieSeries::verticalPosition | |
66 | \brief Defines the vertical position of the pie. |
|
66 | \brief Defines the vertical position of the pie. | |
67 |
|
67 | |||
68 | The value is a relative value to the chart rectangle where: |
|
68 | The value is a relative value to the chart rectangle where: | |
69 |
|
69 | |||
70 | \list |
|
70 | \list | |
71 | \o 0.0 is the absolute top. |
|
71 | \o 0.0 is the absolute top. | |
72 | \o 1.0 is the absolute bottom. |
|
72 | \o 1.0 is the absolute bottom. | |
73 | \endlist |
|
73 | \endlist | |
74 |
|
74 | |||
75 | Default value is 0.5 (center). |
|
75 | Default value is 0.5 (center). | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \property QPieSeries::size |
|
79 | \property QPieSeries::size | |
80 | \brief Defines the pie size. |
|
80 | \brief Defines the pie size. | |
81 |
|
81 | |||
82 | The value is a relative value to the chart rectangle where: |
|
82 | The value is a relative value to the chart rectangle where: | |
83 |
|
83 | |||
84 | \list |
|
84 | \list | |
85 | \o 0.0 is the minimum size (pie not drawn). |
|
85 | \o 0.0 is the minimum size (pie not drawn). | |
86 | \o 1.0 is the maximum size that can fit the chart. |
|
86 | \o 1.0 is the maximum size that can fit the chart. | |
87 | \endlist |
|
87 | \endlist | |
88 |
|
88 | |||
89 | Default value is 0.7. |
|
89 | Default value is 0.7. | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | /*! |
|
92 | /*! | |
93 | \property QPieSeries::startAngle |
|
93 | \property QPieSeries::startAngle | |
94 | \brief Defines the starting angle of the pie. |
|
94 | \brief Defines the starting angle of the pie. | |
95 |
|
95 | |||
96 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
96 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
97 |
|
97 | |||
98 | Default is value is 0. |
|
98 | Default is value is 0. | |
99 | */ |
|
99 | */ | |
100 |
|
100 | |||
101 | /*! |
|
101 | /*! | |
102 | \property QPieSeries::endAngle |
|
102 | \property QPieSeries::endAngle | |
103 | \brief Defines the ending angle of the pie. |
|
103 | \brief Defines the ending angle of the pie. | |
104 |
|
104 | |||
105 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
105 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
106 |
|
106 | |||
107 | Default is value is 360. |
|
107 | Default is value is 360. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | Constructs a series object which is a child of \a parent. |
|
112 | Constructs a series object which is a child of \a parent. | |
113 | */ |
|
113 | */ | |
114 | QPieSeries::QPieSeries(QObject *parent) : |
|
114 | QPieSeries::QPieSeries(QObject *parent) : | |
115 | QSeries(*new QPieSeriesPrivate(this),parent) |
|
115 | QAbstractSeries(*new QPieSeriesPrivate(this),parent) | |
116 | { |
|
116 | { | |
117 |
|
117 | |||
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Destroys the series and its slices. |
|
121 | Destroys the series and its slices. | |
122 | */ |
|
122 | */ | |
123 | QPieSeries::~QPieSeries() |
|
123 | QPieSeries::~QPieSeries() | |
124 | { |
|
124 | { | |
125 | // NOTE: d_prt destroyed by QObject |
|
125 | // NOTE: d_prt destroyed by QObject | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Returns QChartSeries::SeriesTypePie. |
|
129 | Returns QChartSeries::SeriesTypePie. | |
130 | */ |
|
130 | */ | |
131 | QSeries::QSeriesType QPieSeries::type() const |
|
131 | QAbstractSeries::QSeriesType QPieSeries::type() const | |
132 | { |
|
132 | { | |
133 | return QSeries::SeriesTypePie; |
|
133 | return QAbstractSeries::SeriesTypePie; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | /*! |
|
136 | /*! | |
137 | Sets an array of \a slices to the series replacing the existing slices. |
|
137 | Sets an array of \a slices to the series replacing the existing slices. | |
138 | Slice ownership is passed to the series. |
|
138 | Slice ownership is passed to the series. | |
139 | */ |
|
139 | */ | |
140 | void QPieSeries::replace(QList<QPieSlice*> slices) |
|
140 | void QPieSeries::replace(QList<QPieSlice*> slices) | |
141 | { |
|
141 | { | |
142 | clear(); |
|
142 | clear(); | |
143 | append(slices); |
|
143 | append(slices); | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | Appends an array of \a slices to the series. |
|
147 | Appends an array of \a slices to the series. | |
148 | Slice ownership is passed to the series. |
|
148 | Slice ownership is passed to the series. | |
149 | */ |
|
149 | */ | |
150 | void QPieSeries::append(QList<QPieSlice*> slices) |
|
150 | void QPieSeries::append(QList<QPieSlice*> slices) | |
151 | { |
|
151 | { | |
152 | Q_D(QPieSeries); |
|
152 | Q_D(QPieSeries); | |
153 |
|
153 | |||
154 | foreach (QPieSlice* s, slices) { |
|
154 | foreach (QPieSlice* s, slices) { | |
155 | s->setParent(this); |
|
155 | s->setParent(this); | |
156 | d->m_slices << s; |
|
156 | d->m_slices << s; | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | d->updateDerivativeData(); |
|
159 | d->updateDerivativeData(); | |
160 |
|
160 | |||
161 | foreach (QPieSlice* s, slices) { |
|
161 | foreach (QPieSlice* s, slices) { | |
162 | connect(s, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
162 | connect(s, SIGNAL(changed()), d, SLOT(sliceChanged())); | |
163 | connect(s, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); |
|
163 | connect(s, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); | |
164 | connect(s, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); |
|
164 | connect(s, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); | |
165 | connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); |
|
165 | connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | emit added(slices); |
|
168 | emit added(slices); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Appends a single \a slice to the series. |
|
172 | Appends a single \a slice to the series. | |
173 | Slice ownership is passed to the series. |
|
173 | Slice ownership is passed to the series. | |
174 | */ |
|
174 | */ | |
175 | void QPieSeries::append(QPieSlice* slice) |
|
175 | void QPieSeries::append(QPieSlice* slice) | |
176 | { |
|
176 | { | |
177 | append(QList<QPieSlice*>() << slice); |
|
177 | append(QList<QPieSlice*>() << slice); | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | /*! |
|
180 | /*! | |
181 | Appends a single \a slice to the series and returns a reference to the series. |
|
181 | Appends a single \a slice to the series and returns a reference to the series. | |
182 | Slice ownership is passed to the series. |
|
182 | Slice ownership is passed to the series. | |
183 | */ |
|
183 | */ | |
184 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) |
|
184 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) | |
185 | { |
|
185 | { | |
186 | append(slice); |
|
186 | append(slice); | |
187 | return *this; |
|
187 | return *this; | |
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 |
|
190 | |||
191 | /*! |
|
191 | /*! | |
192 | Appends a single slice to the series with give \a value and \a name. |
|
192 | Appends a single slice to the series with give \a value and \a name. | |
193 | Slice ownership is passed to the series. |
|
193 | Slice ownership is passed to the series. | |
194 | */ |
|
194 | */ | |
195 | QPieSlice* QPieSeries::append(qreal value, QString name) |
|
195 | QPieSlice* QPieSeries::append(qreal value, QString name) | |
196 | { |
|
196 | { | |
197 | QPieSlice* slice = new QPieSlice(value, name); |
|
197 | QPieSlice* slice = new QPieSlice(value, name); | |
198 | append(slice); |
|
198 | append(slice); | |
199 | return slice; |
|
199 | return slice; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | /*! |
|
202 | /*! | |
203 | Inserts a single \a slice to the series before the slice at \a index position. |
|
203 | Inserts a single \a slice to the series before the slice at \a index position. | |
204 | Slice ownership is passed to the series. |
|
204 | Slice ownership is passed to the series. | |
205 | */ |
|
205 | */ | |
206 | void QPieSeries::insert(int index, QPieSlice* slice) |
|
206 | void QPieSeries::insert(int index, QPieSlice* slice) | |
207 | { |
|
207 | { | |
208 | Q_D(QPieSeries); |
|
208 | Q_D(QPieSeries); | |
209 | Q_ASSERT(index <= d->m_slices.count()); |
|
209 | Q_ASSERT(index <= d->m_slices.count()); | |
210 | slice->setParent(this); |
|
210 | slice->setParent(this); | |
211 | d->m_slices.insert(index, slice); |
|
211 | d->m_slices.insert(index, slice); | |
212 |
|
212 | |||
213 | d->updateDerivativeData(); |
|
213 | d->updateDerivativeData(); | |
214 |
|
214 | |||
215 | connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
215 | connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged())); | |
216 | connect(slice, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); |
|
216 | connect(slice, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); | |
217 | connect(slice, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); |
|
217 | connect(slice, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); | |
218 | connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); |
|
218 | connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
219 |
|
219 | |||
220 | emit added(QList<QPieSlice*>() << slice); |
|
220 | emit added(QList<QPieSlice*>() << slice); | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | /*! |
|
223 | /*! | |
224 | Removes a single \a slice from the series and deletes the slice. |
|
224 | Removes a single \a slice from the series and deletes the slice. | |
225 |
|
225 | |||
226 | Do not reference the pointer after this call. |
|
226 | Do not reference the pointer after this call. | |
227 | */ |
|
227 | */ | |
228 | void QPieSeries::remove(QPieSlice* slice) |
|
228 | void QPieSeries::remove(QPieSlice* slice) | |
229 | { |
|
229 | { | |
230 | Q_D(QPieSeries); |
|
230 | Q_D(QPieSeries); | |
231 | if (!d->m_slices.removeOne(slice)) { |
|
231 | if (!d->m_slices.removeOne(slice)) { | |
232 | Q_ASSERT(0); // TODO: how should this be reported? |
|
232 | Q_ASSERT(0); // TODO: how should this be reported? | |
233 | return; |
|
233 | return; | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | d->updateDerivativeData(); |
|
236 | d->updateDerivativeData(); | |
237 |
|
237 | |||
238 | emit removed(QList<QPieSlice*>() << slice); |
|
238 | emit removed(QList<QPieSlice*>() << slice); | |
239 |
|
239 | |||
240 | delete slice; |
|
240 | delete slice; | |
241 | slice = 0; |
|
241 | slice = 0; | |
242 | } |
|
242 | } | |
243 |
|
243 | |||
244 | /*! |
|
244 | /*! | |
245 | Clears all slices from the series. |
|
245 | Clears all slices from the series. | |
246 | */ |
|
246 | */ | |
247 | void QPieSeries::clear() |
|
247 | void QPieSeries::clear() | |
248 | { |
|
248 | { | |
249 | Q_D(QPieSeries); |
|
249 | Q_D(QPieSeries); | |
250 | if (d->m_slices.count() == 0) |
|
250 | if (d->m_slices.count() == 0) | |
251 | return; |
|
251 | return; | |
252 |
|
252 | |||
253 | QList<QPieSlice*> slices = d->m_slices; |
|
253 | QList<QPieSlice*> slices = d->m_slices; | |
254 | foreach (QPieSlice* s, d->m_slices) { |
|
254 | foreach (QPieSlice* s, d->m_slices) { | |
255 | d->m_slices.removeOne(s); |
|
255 | d->m_slices.removeOne(s); | |
256 | delete s; |
|
256 | delete s; | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 | d->updateDerivativeData(); |
|
259 | d->updateDerivativeData(); | |
260 |
|
260 | |||
261 | emit removed(slices); |
|
261 | emit removed(slices); | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 | /*! |
|
264 | /*! | |
265 | returns the number of the slices in this series. |
|
265 | returns the number of the slices in this series. | |
266 | */ |
|
266 | */ | |
267 | int QPieSeries::count() const |
|
267 | int QPieSeries::count() const | |
268 | { |
|
268 | { | |
269 | Q_D(const QPieSeries); |
|
269 | Q_D(const QPieSeries); | |
270 | return d->m_slices.count(); |
|
270 | return d->m_slices.count(); | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | /*! |
|
273 | /*! | |
274 | Returns true is the series is empty. |
|
274 | Returns true is the series is empty. | |
275 | */ |
|
275 | */ | |
276 | bool QPieSeries::isEmpty() const |
|
276 | bool QPieSeries::isEmpty() const | |
277 | { |
|
277 | { | |
278 | Q_D(const QPieSeries); |
|
278 | Q_D(const QPieSeries); | |
279 | return d->m_slices.isEmpty(); |
|
279 | return d->m_slices.isEmpty(); | |
280 | } |
|
280 | } | |
281 |
|
281 | |||
282 | /*! |
|
282 | /*! | |
283 | Returns a list of slices that belong to this series. |
|
283 | Returns a list of slices that belong to this series. | |
284 | */ |
|
284 | */ | |
285 | QList<QPieSlice*> QPieSeries::slices() const |
|
285 | QList<QPieSlice*> QPieSeries::slices() const | |
286 | { |
|
286 | { | |
287 | Q_D(const QPieSeries); |
|
287 | Q_D(const QPieSeries); | |
288 | return d->m_slices; |
|
288 | return d->m_slices; | |
289 | } |
|
289 | } | |
290 |
|
290 | |||
291 | void QPieSeries::setHorizontalPosition(qreal relativePosition) |
|
291 | void QPieSeries::setHorizontalPosition(qreal relativePosition) | |
292 | { |
|
292 | { | |
293 | Q_D(QPieSeries); |
|
293 | Q_D(QPieSeries); | |
294 | if (d->setRealValue(d->m_pieRelativeHorPos, relativePosition, 1.0)) |
|
294 | if (d->setRealValue(d->m_pieRelativeHorPos, relativePosition, 1.0)) | |
295 | emit piePositionChanged(); |
|
295 | emit piePositionChanged(); | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
298 | void QPieSeries::setVerticalPosition(qreal relativePosition) | |
299 | { |
|
299 | { | |
300 | Q_D(QPieSeries); |
|
300 | Q_D(QPieSeries); | |
301 | if (d->setRealValue(d->m_pieRelativeVerPos, relativePosition, 1.0)) |
|
301 | if (d->setRealValue(d->m_pieRelativeVerPos, relativePosition, 1.0)) | |
302 | emit piePositionChanged(); |
|
302 | emit piePositionChanged(); | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | qreal QPieSeries::horizontalPosition() const |
|
305 | qreal QPieSeries::horizontalPosition() const | |
306 | { |
|
306 | { | |
307 | Q_D(const QPieSeries); |
|
307 | Q_D(const QPieSeries); | |
308 | return d->m_pieRelativeHorPos; |
|
308 | return d->m_pieRelativeHorPos; | |
309 | } |
|
309 | } | |
310 |
|
310 | |||
311 | qreal QPieSeries::verticalPosition() const |
|
311 | qreal QPieSeries::verticalPosition() const | |
312 | { |
|
312 | { | |
313 | Q_D(const QPieSeries); |
|
313 | Q_D(const QPieSeries); | |
314 | return d->m_pieRelativeVerPos; |
|
314 | return d->m_pieRelativeVerPos; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | void QPieSeries::setPieSize(qreal relativeSize) |
|
317 | void QPieSeries::setPieSize(qreal relativeSize) | |
318 | { |
|
318 | { | |
319 | Q_D(QPieSeries); |
|
319 | Q_D(QPieSeries); | |
320 | if (d->setRealValue(d->m_pieRelativeSize, relativeSize, 1.0)) |
|
320 | if (d->setRealValue(d->m_pieRelativeSize, relativeSize, 1.0)) | |
321 | emit pieSizeChanged(); |
|
321 | emit pieSizeChanged(); | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | qreal QPieSeries::pieSize() const |
|
324 | qreal QPieSeries::pieSize() const | |
325 | { |
|
325 | { | |
326 | Q_D(const QPieSeries); |
|
326 | Q_D(const QPieSeries); | |
327 | return d->m_pieRelativeSize; |
|
327 | return d->m_pieRelativeSize; | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 |
|
330 | |||
331 | void QPieSeries::setPieStartAngle(qreal angle) |
|
331 | void QPieSeries::setPieStartAngle(qreal angle) | |
332 | { |
|
332 | { | |
333 | Q_D(QPieSeries); |
|
333 | Q_D(QPieSeries); | |
334 | if (d->setRealValue(d->m_pieStartAngle, angle, d->m_pieEndAngle)) |
|
334 | if (d->setRealValue(d->m_pieStartAngle, angle, d->m_pieEndAngle)) | |
335 | d->updateDerivativeData(); |
|
335 | d->updateDerivativeData(); | |
336 | } |
|
336 | } | |
337 |
|
337 | |||
338 | qreal QPieSeries::pieStartAngle() const |
|
338 | qreal QPieSeries::pieStartAngle() const | |
339 | { |
|
339 | { | |
340 | Q_D(const QPieSeries); |
|
340 | Q_D(const QPieSeries); | |
341 | return d->m_pieStartAngle; |
|
341 | return d->m_pieStartAngle; | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | /*! |
|
344 | /*! | |
345 | Sets the end angle of the pie. |
|
345 | Sets the end angle of the pie. | |
346 |
|
346 | |||
347 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
347 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
348 |
|
348 | |||
349 | \a angle must be greater than start angle. |
|
349 | \a angle must be greater than start angle. | |
350 |
|
350 | |||
351 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
351 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() | |
352 | */ |
|
352 | */ | |
353 | void QPieSeries::setPieEndAngle(qreal angle) |
|
353 | void QPieSeries::setPieEndAngle(qreal angle) | |
354 | { |
|
354 | { | |
355 | Q_D(QPieSeries); |
|
355 | Q_D(QPieSeries); | |
356 |
|
356 | |||
357 | if (d->setRealValue(d->m_pieEndAngle, angle, 360.0, d->m_pieStartAngle)) |
|
357 | if (d->setRealValue(d->m_pieEndAngle, angle, 360.0, d->m_pieStartAngle)) | |
358 | d->updateDerivativeData(); |
|
358 | d->updateDerivativeData(); | |
359 | } |
|
359 | } | |
360 |
|
360 | |||
361 | /*! |
|
361 | /*! | |
362 | Returns the end angle of the pie. |
|
362 | Returns the end angle of the pie. | |
363 |
|
363 | |||
364 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
364 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
365 |
|
365 | |||
366 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
366 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() | |
367 | */ |
|
367 | */ | |
368 | qreal QPieSeries::pieEndAngle() const |
|
368 | qreal QPieSeries::pieEndAngle() const | |
369 | { |
|
369 | { | |
370 | Q_D(const QPieSeries); |
|
370 | Q_D(const QPieSeries); | |
371 | return d->m_pieEndAngle; |
|
371 | return d->m_pieEndAngle; | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | /*! |
|
374 | /*! | |
375 | Sets the all the slice labels \a visible or invisible. |
|
375 | Sets the all the slice labels \a visible or invisible. | |
376 |
|
376 | |||
377 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
377 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() | |
378 | */ |
|
378 | */ | |
379 | void QPieSeries::setLabelsVisible(bool visible) |
|
379 | void QPieSeries::setLabelsVisible(bool visible) | |
380 | { |
|
380 | { | |
381 | Q_D(QPieSeries); |
|
381 | Q_D(QPieSeries); | |
382 | foreach (QPieSlice* s, d->m_slices) |
|
382 | foreach (QPieSlice* s, d->m_slices) | |
383 | s->setLabelVisible(visible); |
|
383 | s->setLabelVisible(visible); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | /*! |
|
386 | /*! | |
387 | Returns the sum of all slice values in this series. |
|
387 | Returns the sum of all slice values in this series. | |
388 |
|
388 | |||
389 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() |
|
389 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() | |
390 | */ |
|
390 | */ | |
391 | qreal QPieSeries::sum() const |
|
391 | qreal QPieSeries::sum() const | |
392 | { |
|
392 | { | |
393 | Q_D(const QPieSeries); |
|
393 | Q_D(const QPieSeries); | |
394 | return d->m_sum; |
|
394 | return d->m_sum; | |
395 | } |
|
395 | } | |
396 |
|
396 | |||
397 | /*! |
|
397 | /*! | |
398 | \fn void QPieSeries::clicked(QPieSlice* slice, Qt::MouseButtons buttons) |
|
398 | \fn void QPieSeries::clicked(QPieSlice* slice, Qt::MouseButtons buttons) | |
399 |
|
399 | |||
400 | This signal is emitted when a \a slice has been clicked with mouse \a buttons. |
|
400 | This signal is emitted when a \a slice has been clicked with mouse \a buttons. | |
401 |
|
401 | |||
402 | \sa QPieSlice::clicked() |
|
402 | \sa QPieSlice::clicked() | |
403 | */ |
|
403 | */ | |
404 |
|
404 | |||
405 | /*! |
|
405 | /*! | |
406 | \fn void QPieSeries::hoverEnter(QPieSlice* slice) |
|
406 | \fn void QPieSeries::hoverEnter(QPieSlice* slice) | |
407 |
|
407 | |||
408 | This signal is emitted when user has hovered over a \a slice. |
|
408 | This signal is emitted when user has hovered over a \a slice. | |
409 |
|
409 | |||
410 | \sa QPieSlice::hoverEnter() |
|
410 | \sa QPieSlice::hoverEnter() | |
411 | */ |
|
411 | */ | |
412 |
|
412 | |||
413 | /*! |
|
413 | /*! | |
414 | \fn void QPieSeries::hoverLeave(QPieSlice* slice) |
|
414 | \fn void QPieSeries::hoverLeave(QPieSlice* slice) | |
415 |
|
415 | |||
416 | This signal is emitted when user has hovered away from a \a slice. |
|
416 | This signal is emitted when user has hovered away from a \a slice. | |
417 |
|
417 | |||
418 | \sa QPieSlice::hoverLeave() |
|
418 | \sa QPieSlice::hoverLeave() | |
419 | */ |
|
419 | */ | |
420 |
|
420 | |||
421 | /*! |
|
421 | /*! | |
422 | \fn void QPieSeries::added(QList<QPieSlice*> slices) |
|
422 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |
423 |
|
423 | |||
424 | This signal is emitted when \a slices has been added to the series. |
|
424 | This signal is emitted when \a slices has been added to the series. | |
425 |
|
425 | |||
426 | \sa append(), insert() |
|
426 | \sa append(), insert() | |
427 | */ |
|
427 | */ | |
428 |
|
428 | |||
429 | /*! |
|
429 | /*! | |
430 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) |
|
430 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |
431 |
|
431 | |||
432 | This signal is emitted when \a slices has been removed from the series. |
|
432 | This signal is emitted when \a slices has been removed from the series. | |
433 |
|
433 | |||
434 | \sa remove(), clear() |
|
434 | \sa remove(), clear() | |
435 | */ |
|
435 | */ | |
436 |
|
436 | |||
437 | /*! |
|
437 | /*! | |
438 | \fn void QPieSeries::piePositionChanged() |
|
438 | \fn void QPieSeries::piePositionChanged() | |
439 |
|
439 | |||
440 | This signal is emitted when pie position has changed. |
|
440 | This signal is emitted when pie position has changed. | |
441 |
|
441 | |||
442 | \sa verticalPosition(), setVerticalPosition(), horizontalPosition(), setHorizontalPosition() |
|
442 | \sa verticalPosition(), setVerticalPosition(), horizontalPosition(), setHorizontalPosition() | |
443 | */ |
|
443 | */ | |
444 |
|
444 | |||
445 | /*! |
|
445 | /*! | |
446 | \fn void QPieSeries::pieSizeChanged() |
|
446 | \fn void QPieSeries::pieSizeChanged() | |
447 |
|
447 | |||
448 | This signal is emitted when pie size has changed. |
|
448 | This signal is emitted when pie size has changed. | |
449 |
|
449 | |||
450 | \sa pieSize(), setPieSize() |
|
450 | \sa pieSize(), setPieSize() | |
451 | */ |
|
451 | */ | |
452 |
|
452 | |||
453 | /*! |
|
453 | /*! | |
454 | \fn bool QPieSeries::setModel(QAbstractItemModel *model) |
|
454 | \fn bool QPieSeries::setModel(QAbstractItemModel *model) | |
455 | Sets the \a model to be used as a data source |
|
455 | Sets the \a model to be used as a data source | |
456 | */ |
|
456 | */ | |
457 | bool QPieSeries::setModel(QAbstractItemModel* model) |
|
457 | bool QPieSeries::setModel(QAbstractItemModel* model) | |
458 | { |
|
458 | { | |
459 | Q_D(QPieSeries); |
|
459 | Q_D(QPieSeries); | |
460 | // disconnect signals from old model |
|
460 | // disconnect signals from old model | |
461 | if(d->m_model) |
|
461 | if(d->m_model) | |
462 | { |
|
462 | { | |
463 | disconnect(d->m_model, 0, this, 0); |
|
463 | disconnect(d->m_model, 0, this, 0); | |
464 | d->m_mapValues = -1; |
|
464 | d->m_mapValues = -1; | |
465 | d->m_mapLabels = -1; |
|
465 | d->m_mapLabels = -1; | |
466 | d->m_mapOrientation = Qt::Vertical; |
|
466 | d->m_mapOrientation = Qt::Vertical; | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | // set new model |
|
469 | // set new model | |
470 | if(model) |
|
470 | if(model) | |
471 | { |
|
471 | { | |
472 | d->m_model = model; |
|
472 | d->m_model = model; | |
473 | return true; |
|
473 | return true; | |
474 | } |
|
474 | } | |
475 | else |
|
475 | else | |
476 | { |
|
476 | { | |
477 | d->m_model = 0; |
|
477 | d->m_model = 0; | |
478 | return false; |
|
478 | return false; | |
479 | } |
|
479 | } | |
480 | } |
|
480 | } | |
481 |
|
481 | |||
482 | /*! |
|
482 | /*! | |
483 | \fn bool QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) |
|
483 | \fn bool QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) | |
484 | Sets column/row specified by \a modelValuesLine to be used as a list of pie slice values for the pie. |
|
484 | Sets column/row specified by \a modelValuesLine to be used as a list of pie slice values for the pie. | |
485 | Parameter \a modelValuesLine indicates the column/row where the values for the pie slices are located in the model. |
|
485 | Parameter \a modelValuesLine indicates the column/row where the values for the pie slices are located in the model. | |
486 | Parameter \a modelLabelsLine indicates the column/row where the labels for the pie slices are located in the model. |
|
486 | Parameter \a modelLabelsLine indicates the column/row where the labels for the pie slices are located in the model. | |
487 | The \a orientation parameter specifies whether the data is in columns or in rows. |
|
487 | The \a orientation parameter specifies whether the data is in columns or in rows. | |
488 | */ |
|
488 | */ | |
489 | void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) |
|
489 | void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) | |
490 | { |
|
490 | { | |
491 | Q_D(QPieSeries); |
|
491 | Q_D(QPieSeries); | |
492 |
|
492 | |||
493 | if (d->m_model == 0) |
|
493 | if (d->m_model == 0) | |
494 | return; |
|
494 | return; | |
495 |
|
495 | |||
496 | d->m_mapValues = modelValuesLine; |
|
496 | d->m_mapValues = modelValuesLine; | |
497 | d->m_mapLabels = modelLabelsLine; |
|
497 | d->m_mapLabels = modelLabelsLine; | |
498 | d->m_mapOrientation = orientation; |
|
498 | d->m_mapOrientation = orientation; | |
499 |
|
499 | |||
500 | // connect the signals |
|
500 | // connect the signals | |
501 | if (d->m_mapOrientation == Qt::Vertical) { |
|
501 | if (d->m_mapOrientation == Qt::Vertical) { | |
502 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
502 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
503 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
503 | connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); | |
504 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
504 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
505 | } else { |
|
505 | } else { | |
506 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
506 | connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
507 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
507 | connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); | |
508 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
508 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
509 | } |
|
509 | } | |
510 |
|
510 | |||
511 | // create the initial slices set |
|
511 | // create the initial slices set | |
512 | if (d->m_mapOrientation == Qt::Vertical) { |
|
512 | if (d->m_mapOrientation == Qt::Vertical) { | |
513 | for (int i = 0; i < d->m_model->rowCount(); i++) |
|
513 | for (int i = 0; i < d->m_model->rowCount(); i++) | |
514 | append(d->m_model->data(d->m_model->index(i, d->m_mapValues), Qt::DisplayRole).toDouble(), d->m_model->data(d->m_model->index(i, d->m_mapLabels), Qt::DisplayRole).toString()); |
|
514 | append(d->m_model->data(d->m_model->index(i, d->m_mapValues), Qt::DisplayRole).toDouble(), d->m_model->data(d->m_model->index(i, d->m_mapLabels), Qt::DisplayRole).toString()); | |
515 | } else { |
|
515 | } else { | |
516 | for (int i = 0; i < d->m_model->columnCount(); i++) |
|
516 | for (int i = 0; i < d->m_model->columnCount(); i++) | |
517 | append(d->m_model->data(d->m_model->index(d->m_mapValues, i), Qt::DisplayRole).toDouble(), d->m_model->data(d->m_model->index(d->m_mapLabels, i), Qt::DisplayRole).toString()); |
|
517 | append(d->m_model->data(d->m_model->index(d->m_mapValues, i), Qt::DisplayRole).toDouble(), d->m_model->data(d->m_model->index(d->m_mapLabels, i), Qt::DisplayRole).toString()); | |
518 | } |
|
518 | } | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
521 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
522 |
|
522 | |||
523 |
|
523 | |||
524 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) |
|
524 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : | |
525 |
|
|
525 | QAbstractSeriesPrivate(parent), | |
526 | m_pieRelativeHorPos(0.5), |
|
526 | m_pieRelativeHorPos(0.5), | |
527 | m_pieRelativeVerPos(0.5), |
|
527 | m_pieRelativeVerPos(0.5), | |
528 | m_pieRelativeSize(0.7), |
|
528 | m_pieRelativeSize(0.7), | |
529 | m_pieStartAngle(0), |
|
529 | m_pieStartAngle(0), | |
530 | m_pieEndAngle(360), |
|
530 | m_pieEndAngle(360), | |
531 | m_sum(0), |
|
531 | m_sum(0), | |
532 | m_mapValues(0), |
|
532 | m_mapValues(0), | |
533 | m_mapLabels(0), |
|
533 | m_mapLabels(0), | |
534 | m_mapOrientation(Qt::Horizontal) |
|
534 | m_mapOrientation(Qt::Horizontal) | |
535 | { |
|
535 | { | |
536 |
|
536 | |||
537 | } |
|
537 | } | |
538 |
|
538 | |||
539 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
539 | QPieSeriesPrivate::~QPieSeriesPrivate() | |
540 | { |
|
540 | { | |
541 |
|
541 | |||
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | void QPieSeriesPrivate::updateDerivativeData() |
|
544 | void QPieSeriesPrivate::updateDerivativeData() | |
545 | { |
|
545 | { | |
546 | m_sum = 0; |
|
546 | m_sum = 0; | |
547 |
|
547 | |||
548 | // nothing to do? |
|
548 | // nothing to do? | |
549 | if (m_slices.count() == 0) |
|
549 | if (m_slices.count() == 0) | |
550 | return; |
|
550 | return; | |
551 |
|
551 | |||
552 | // calculate sum of all slices |
|
552 | // calculate sum of all slices | |
553 | foreach (QPieSlice* s, m_slices) |
|
553 | foreach (QPieSlice* s, m_slices) | |
554 | m_sum += s->value(); |
|
554 | m_sum += s->value(); | |
555 |
|
555 | |||
556 | // nothing to show.. |
|
556 | // nothing to show.. | |
557 | if (qFuzzyIsNull(m_sum)) |
|
557 | if (qFuzzyIsNull(m_sum)) | |
558 | return; |
|
558 | return; | |
559 |
|
559 | |||
560 | // update slice attributes |
|
560 | // update slice attributes | |
561 | qreal sliceAngle = m_pieStartAngle; |
|
561 | qreal sliceAngle = m_pieStartAngle; | |
562 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
562 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; | |
563 | QVector<QPieSlice*> changed; |
|
563 | QVector<QPieSlice*> changed; | |
564 | foreach (QPieSlice* s, m_slices) { |
|
564 | foreach (QPieSlice* s, m_slices) { | |
565 |
|
565 | |||
566 | PieSliceData data = PieSliceData::data(s); |
|
566 | PieSliceData data = PieSliceData::data(s); | |
567 | data.m_percentage = s->value() / m_sum; |
|
567 | data.m_percentage = s->value() / m_sum; | |
568 | data.m_angleSpan = pieSpan * data.m_percentage; |
|
568 | data.m_angleSpan = pieSpan * data.m_percentage; | |
569 | data.m_startAngle = sliceAngle; |
|
569 | data.m_startAngle = sliceAngle; | |
570 | sliceAngle += data.m_angleSpan; |
|
570 | sliceAngle += data.m_angleSpan; | |
571 |
|
571 | |||
572 | if (PieSliceData::data(s) != data) { |
|
572 | if (PieSliceData::data(s) != data) { | |
573 | PieSliceData::data(s) = data; |
|
573 | PieSliceData::data(s) = data; | |
574 | changed << s; |
|
574 | changed << s; | |
575 | } |
|
575 | } | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | // emit signals |
|
578 | // emit signals | |
579 | foreach (QPieSlice* s, changed) |
|
579 | foreach (QPieSlice* s, changed) | |
580 | PieSliceData::data(s).emitChangedSignal(s); |
|
580 | PieSliceData::data(s).emitChangedSignal(s); | |
581 | } |
|
581 | } | |
582 |
|
582 | |||
583 | void QPieSeriesPrivate::sliceChanged() |
|
583 | void QPieSeriesPrivate::sliceChanged() | |
584 | { |
|
584 | { | |
585 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
585 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
586 | updateDerivativeData(); |
|
586 | updateDerivativeData(); | |
587 | } |
|
587 | } | |
588 |
|
588 | |||
589 | void QPieSeriesPrivate::sliceClicked(Qt::MouseButtons buttons) |
|
589 | void QPieSeriesPrivate::sliceClicked(Qt::MouseButtons buttons) | |
590 | { |
|
590 | { | |
591 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
591 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
592 | Q_ASSERT(m_slices.contains(slice)); |
|
592 | Q_ASSERT(m_slices.contains(slice)); | |
593 | Q_Q(QPieSeries); |
|
593 | Q_Q(QPieSeries); | |
594 | emit q->clicked(slice, buttons); |
|
594 | emit q->clicked(slice, buttons); | |
595 | } |
|
595 | } | |
596 |
|
596 | |||
597 | void QPieSeriesPrivate::sliceHoverEnter() |
|
597 | void QPieSeriesPrivate::sliceHoverEnter() | |
598 | { |
|
598 | { | |
599 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
599 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
600 | Q_ASSERT(m_slices.contains(slice)); |
|
600 | Q_ASSERT(m_slices.contains(slice)); | |
601 | Q_Q(QPieSeries); |
|
601 | Q_Q(QPieSeries); | |
602 | emit q->hoverEnter(slice); |
|
602 | emit q->hoverEnter(slice); | |
603 | } |
|
603 | } | |
604 |
|
604 | |||
605 | void QPieSeriesPrivate::sliceHoverLeave() |
|
605 | void QPieSeriesPrivate::sliceHoverLeave() | |
606 | { |
|
606 | { | |
607 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
607 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
608 | Q_ASSERT(m_slices.contains(slice)); |
|
608 | Q_ASSERT(m_slices.contains(slice)); | |
609 | Q_Q(QPieSeries); |
|
609 | Q_Q(QPieSeries); | |
610 | emit q->hoverLeave(slice); |
|
610 | emit q->hoverLeave(slice); | |
611 | } |
|
611 | } | |
612 |
|
612 | |||
613 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
613 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
614 | { |
|
614 | { | |
615 | Q_UNUSED(bottomRight) |
|
615 | Q_UNUSED(bottomRight) | |
616 |
|
616 | |||
617 | if (m_mapOrientation == Qt::Vertical) |
|
617 | if (m_mapOrientation == Qt::Vertical) | |
618 | { |
|
618 | { | |
619 | if (topLeft.column() == m_mapValues) |
|
619 | if (topLeft.column() == m_mapValues) | |
620 | if (m_mapValues == m_mapLabels) |
|
620 | if (m_mapValues == m_mapLabels) | |
621 | { |
|
621 | { | |
622 | m_slices.at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
622 | m_slices.at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
623 | m_slices.at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
623 | m_slices.at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
624 | } |
|
624 | } | |
625 | else |
|
625 | else | |
626 | { |
|
626 | { | |
627 | m_slices.at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
627 | m_slices.at(topLeft.row())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
628 | } |
|
628 | } | |
629 | else if (topLeft.column() == m_mapLabels) |
|
629 | else if (topLeft.column() == m_mapLabels) | |
630 | m_slices.at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
630 | m_slices.at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
631 | } |
|
631 | } | |
632 | else |
|
632 | else | |
633 | { |
|
633 | { | |
634 | if (topLeft.row() == m_mapValues) |
|
634 | if (topLeft.row() == m_mapValues) | |
635 | if (m_mapValues == m_mapLabels) |
|
635 | if (m_mapValues == m_mapLabels) | |
636 | { |
|
636 | { | |
637 | m_slices.at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
637 | m_slices.at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
638 | m_slices.at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
638 | m_slices.at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
639 | } |
|
639 | } | |
640 | else |
|
640 | else | |
641 | { |
|
641 | { | |
642 | m_slices.at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
642 | m_slices.at(topLeft.column())->setValue(m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
643 | } |
|
643 | } | |
644 | else if (topLeft.row() == m_mapLabels) |
|
644 | else if (topLeft.row() == m_mapLabels) | |
645 | m_slices.at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
645 | m_slices.at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString()); | |
646 | } |
|
646 | } | |
647 | } |
|
647 | } | |
648 |
|
648 | |||
649 | void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end) |
|
649 | void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end) | |
650 | { |
|
650 | { | |
651 | Q_UNUSED(parent) |
|
651 | Q_UNUSED(parent) | |
652 | Q_UNUSED(end) |
|
652 | Q_UNUSED(end) | |
653 | Q_Q(QPieSeries); |
|
653 | Q_Q(QPieSeries); | |
654 |
|
654 | |||
655 | QPieSlice* newSlice = new QPieSlice; |
|
655 | QPieSlice* newSlice = new QPieSlice; | |
656 | newSlice->setLabelVisible(true); |
|
656 | newSlice->setLabelVisible(true); | |
657 | if (m_mapOrientation == Qt::Vertical) |
|
657 | if (m_mapOrientation == Qt::Vertical) | |
658 | { |
|
658 | { | |
659 | newSlice->setValue(m_model->data(m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble()); |
|
659 | newSlice->setValue(m_model->data(m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble()); | |
660 | newSlice->setLabel(m_model->data(m_model->index(start, m_mapLabels), Qt::DisplayRole).toString()); |
|
660 | newSlice->setLabel(m_model->data(m_model->index(start, m_mapLabels), Qt::DisplayRole).toString()); | |
661 | } |
|
661 | } | |
662 | else |
|
662 | else | |
663 | { |
|
663 | { | |
664 | newSlice->setValue(m_model->data(m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble()); |
|
664 | newSlice->setValue(m_model->data(m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble()); | |
665 | newSlice->setLabel(m_model->data(m_model->index(m_mapLabels, start), Qt::DisplayRole).toString()); |
|
665 | newSlice->setLabel(m_model->data(m_model->index(m_mapLabels, start), Qt::DisplayRole).toString()); | |
666 | } |
|
666 | } | |
667 |
|
667 | |||
668 | q->insert(start, newSlice); |
|
668 | q->insert(start, newSlice); | |
669 | } |
|
669 | } | |
670 |
|
670 | |||
671 | void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) |
|
671 | void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |
672 | { |
|
672 | { | |
673 | Q_UNUSED(parent) |
|
673 | Q_UNUSED(parent) | |
674 | Q_UNUSED(end) |
|
674 | Q_UNUSED(end) | |
675 | Q_Q(QPieSeries); |
|
675 | Q_Q(QPieSeries); | |
676 | q->remove(m_slices.at(start)); |
|
676 | q->remove(m_slices.at(start)); | |
677 | } |
|
677 | } | |
678 |
|
678 | |||
679 | bool QPieSeriesPrivate::setRealValue(qreal &value, qreal newValue, qreal max, qreal min) |
|
679 | bool QPieSeriesPrivate::setRealValue(qreal &value, qreal newValue, qreal max, qreal min) | |
680 | { |
|
680 | { | |
681 | // Remove rounding errors |
|
681 | // Remove rounding errors | |
682 | qreal roundedValue = newValue; |
|
682 | qreal roundedValue = newValue; | |
683 | if (qFuzzyIsNull(min) && qFuzzyIsNull(newValue)) |
|
683 | if (qFuzzyIsNull(min) && qFuzzyIsNull(newValue)) | |
684 | roundedValue = 0.0; |
|
684 | roundedValue = 0.0; | |
685 | else if (qFuzzyCompare(newValue, max)) |
|
685 | else if (qFuzzyCompare(newValue, max)) | |
686 | roundedValue = max; |
|
686 | roundedValue = max; | |
687 | else if (qFuzzyCompare(newValue, min)) |
|
687 | else if (qFuzzyCompare(newValue, min)) | |
688 | roundedValue = min; |
|
688 | roundedValue = min; | |
689 |
|
689 | |||
690 | // Check if the position is valid after removing the rounding errors |
|
690 | // Check if the position is valid after removing the rounding errors | |
691 | if (roundedValue < min || roundedValue > max) { |
|
691 | if (roundedValue < min || roundedValue > max) { | |
692 | qWarning("QPieSeries: Illegal value"); |
|
692 | qWarning("QPieSeries: Illegal value"); | |
693 | return false; |
|
693 | return false; | |
694 | } |
|
694 | } | |
695 |
|
695 | |||
696 | if (!qFuzzyIsNull(value - roundedValue)) { |
|
696 | if (!qFuzzyIsNull(value - roundedValue)) { | |
697 | value = roundedValue; |
|
697 | value = roundedValue; | |
698 | return true; |
|
698 | return true; | |
699 | } |
|
699 | } | |
700 |
|
700 | |||
701 | // The change was so small it is considered a rounding error |
|
701 | // The change was so small it is considered a rounding error | |
702 | return false; |
|
702 | return false; | |
703 | } |
|
703 | } | |
704 |
|
704 | |||
705 | void QPieSeriesPrivate::scaleDomain(Domain& domain) |
|
705 | void QPieSeriesPrivate::scaleDomain(Domain& domain) | |
706 | { |
|
706 | { | |
707 | Q_UNUSED(domain); |
|
707 | Q_UNUSED(domain); | |
708 | #ifndef QT_NO_DEBUG |
|
708 | #ifndef QT_NO_DEBUG | |
709 | qWarning() << __FILE__<<__FUNCTION__<<"not implemented"; |
|
709 | qWarning() << __FILE__<<__FUNCTION__<<"not implemented"; | |
710 | #endif |
|
710 | #endif | |
711 | } |
|
711 | } | |
712 |
|
712 | |||
713 | Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
713 | Chart* QPieSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
714 | { |
|
714 | { | |
715 | Q_Q(QPieSeries); |
|
715 | Q_Q(QPieSeries); | |
716 | PieChartItem* pie = new PieChartItem(q,presenter); |
|
716 | PieChartItem* pie = new PieChartItem(q,presenter); | |
717 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
717 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
718 | presenter->animator()->addAnimation(pie); |
|
718 | presenter->animator()->addAnimation(pie); | |
719 | } |
|
719 | } | |
720 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
720 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
721 | return pie; |
|
721 | return pie; | |
722 | } |
|
722 | } | |
723 |
|
723 | |||
724 | QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) |
|
724 | QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) | |
725 | { |
|
725 | { | |
726 | Q_Q(QPieSeries); |
|
726 | Q_Q(QPieSeries); | |
727 | QList<LegendMarker*> markers; |
|
727 | QList<LegendMarker*> markers; | |
728 | foreach(QPieSlice* slice, q->slices()) { |
|
728 | foreach(QPieSlice* slice, q->slices()) { | |
729 | PieLegendMarker* marker = new PieLegendMarker(q,slice,legend); |
|
729 | PieLegendMarker* marker = new PieLegendMarker(q,slice,legend); | |
730 | markers << marker; |
|
730 | markers << marker; | |
731 | } |
|
731 | } | |
732 | return markers; |
|
732 | return markers; | |
733 | } |
|
733 | } | |
734 |
|
734 | |||
735 | #include "moc_qpieseries.cpp" |
|
735 | #include "moc_qpieseries.cpp" | |
736 | #include "moc_qpieseries_p.cpp" |
|
736 | #include "moc_qpieseries_p.cpp" | |
737 |
|
737 | |||
738 | QTCOMMERCIALCHART_END_NAMESPACE |
|
738 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,101 +1,101 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef PIESERIES_H |
|
21 | #ifndef PIESERIES_H | |
22 | #define PIESERIES_H |
|
22 | #define PIESERIES_H | |
23 |
|
23 | |||
24 | #include <qseries.h> |
|
24 | #include <qabstractseries.h> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 | class QPieSeriesPrivate; |
|
27 | class QPieSeriesPrivate; | |
28 | class QPieSlice; |
|
28 | class QPieSlice; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries |
|
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QAbstractSeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) |
|
33 | Q_PROPERTY(qreal horizontalPosition READ horizontalPosition WRITE setHorizontalPosition) | |
34 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) |
|
34 | Q_PROPERTY(qreal verticalPosition READ verticalPosition WRITE setVerticalPosition) | |
35 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) |
|
35 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) | |
36 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) |
|
36 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) | |
37 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) |
|
37 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | explicit QPieSeries(QObject *parent = 0); |
|
40 | explicit QPieSeries(QObject *parent = 0); | |
41 | virtual ~QPieSeries(); |
|
41 | virtual ~QPieSeries(); | |
42 |
|
42 | |||
43 | public: // from QChartSeries |
|
43 | public: // from QChartSeries | |
44 | QSeriesType type() const; |
|
44 | QSeriesType type() const; | |
45 |
|
45 | |||
46 | public: |
|
46 | public: | |
47 |
|
47 | |||
48 | // slice setters |
|
48 | // slice setters | |
49 | void append(QPieSlice* slice); |
|
49 | void append(QPieSlice* slice); | |
50 | void append(QList<QPieSlice*> slices); |
|
50 | void append(QList<QPieSlice*> slices); | |
51 | void insert(int index, QPieSlice* slice); |
|
51 | void insert(int index, QPieSlice* slice); | |
52 | void replace(QList<QPieSlice*> slices); |
|
52 | void replace(QList<QPieSlice*> slices); | |
53 | void remove(QPieSlice* slice); |
|
53 | void remove(QPieSlice* slice); | |
54 | void clear(); |
|
54 | void clear(); | |
55 |
|
55 | |||
56 | // slice getters |
|
56 | // slice getters | |
57 | QList<QPieSlice*> slices() const; |
|
57 | QList<QPieSlice*> slices() const; | |
58 |
|
58 | |||
59 | // calculated data |
|
59 | // calculated data | |
60 | int count() const; |
|
60 | int count() const; | |
61 | bool isEmpty() const; |
|
61 | bool isEmpty() const; | |
62 | qreal sum() const; |
|
62 | qreal sum() const; | |
63 |
|
63 | |||
64 | // pie customization |
|
64 | // pie customization | |
65 | void setHorizontalPosition(qreal relativePosition); |
|
65 | void setHorizontalPosition(qreal relativePosition); | |
66 | qreal horizontalPosition() const; |
|
66 | qreal horizontalPosition() const; | |
67 | void setVerticalPosition(qreal relativePosition); |
|
67 | void setVerticalPosition(qreal relativePosition); | |
68 | qreal verticalPosition() const; |
|
68 | qreal verticalPosition() const; | |
69 | void setPieSize(qreal relativeSize); |
|
69 | void setPieSize(qreal relativeSize); | |
70 | qreal pieSize() const; |
|
70 | qreal pieSize() const; | |
71 | void setPieStartAngle(qreal startAngle); |
|
71 | void setPieStartAngle(qreal startAngle); | |
72 | qreal pieStartAngle() const; |
|
72 | qreal pieStartAngle() const; | |
73 | void setPieEndAngle(qreal endAngle); |
|
73 | void setPieEndAngle(qreal endAngle); | |
74 | qreal pieEndAngle() const; |
|
74 | qreal pieEndAngle() const; | |
75 |
|
75 | |||
76 | // convenience function |
|
76 | // convenience function | |
77 | QPieSeries& operator << (QPieSlice* slice); |
|
77 | QPieSeries& operator << (QPieSlice* slice); | |
78 | QPieSlice* append(qreal value, QString name); |
|
78 | QPieSlice* append(qreal value, QString name); | |
79 | void setLabelsVisible(bool visible = true); |
|
79 | void setLabelsVisible(bool visible = true); | |
80 |
|
80 | |||
81 | // data from model |
|
81 | // data from model | |
82 | bool setModel(QAbstractItemModel* model); |
|
82 | bool setModel(QAbstractItemModel* model); | |
83 | void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); |
|
83 | void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); | |
84 |
|
84 | |||
85 | Q_SIGNALS: |
|
85 | Q_SIGNALS: | |
86 | void clicked(QPieSlice* slice, Qt::MouseButtons buttons); |
|
86 | void clicked(QPieSlice* slice, Qt::MouseButtons buttons); | |
87 | void hoverEnter(QPieSlice* slice); |
|
87 | void hoverEnter(QPieSlice* slice); | |
88 | void hoverLeave(QPieSlice* slice); |
|
88 | void hoverLeave(QPieSlice* slice); | |
89 | void added(QList<QPieSlice*> slices); |
|
89 | void added(QList<QPieSlice*> slices); | |
90 | void removed(QList<QPieSlice*> slices); |
|
90 | void removed(QList<QPieSlice*> slices); | |
91 | void piePositionChanged(); |
|
91 | void piePositionChanged(); | |
92 | void pieSizeChanged(); |
|
92 | void pieSizeChanged(); | |
93 |
|
93 | |||
94 | private: |
|
94 | private: | |
95 | Q_DECLARE_PRIVATE(QPieSeries) |
|
95 | Q_DECLARE_PRIVATE(QPieSeries) | |
96 | Q_DISABLE_COPY(QPieSeries) |
|
96 | Q_DISABLE_COPY(QPieSeries) | |
97 | }; |
|
97 | }; | |
98 |
|
98 | |||
99 | QTCOMMERCIALCHART_END_NAMESPACE |
|
99 | QTCOMMERCIALCHART_END_NAMESPACE | |
100 |
|
100 | |||
101 | #endif // PIESERIES_H |
|
101 | #endif // PIESERIES_H |
@@ -1,74 +1,74 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QPIESERIES_P_H |
|
21 | #ifndef QPIESERIES_P_H | |
22 | #define QPIESERIES_P_H |
|
22 | #define QPIESERIES_P_H | |
23 |
|
23 | |||
24 | #include "qpieseries.h" |
|
24 | #include "qpieseries.h" | |
25 | #include "qseries_p.h" |
|
25 | #include "qabstractseries_p.h" | |
26 |
|
26 | |||
27 | class QModelIndex; |
|
27 | class QModelIndex; | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QPieSeriesPrivate : public QSeriesPrivate |
|
31 | class QPieSeriesPrivate : public QAbstractSeriesPrivate | |
32 | { |
|
32 | { | |
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 |
|
34 | |||
35 | public: |
|
35 | public: | |
36 | QPieSeriesPrivate(QPieSeries *parent); |
|
36 | QPieSeriesPrivate(QPieSeries *parent); | |
37 | ~QPieSeriesPrivate(); |
|
37 | ~QPieSeriesPrivate(); | |
38 |
|
38 | |||
39 | void scaleDomain(Domain& domain); |
|
39 | void scaleDomain(Domain& domain); | |
40 | Chart* createGraphics(ChartPresenter* presenter); |
|
40 | Chart* createGraphics(ChartPresenter* presenter); | |
41 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
41 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
42 |
|
42 | |||
43 | void updateDerivativeData(); |
|
43 | void updateDerivativeData(); | |
44 |
|
44 | |||
45 | public Q_SLOTS: |
|
45 | public Q_SLOTS: | |
46 | void sliceChanged(); |
|
46 | void sliceChanged(); | |
47 | void sliceClicked(Qt::MouseButtons buttons); |
|
47 | void sliceClicked(Qt::MouseButtons buttons); | |
48 | void sliceHoverEnter(); |
|
48 | void sliceHoverEnter(); | |
49 | void sliceHoverLeave(); |
|
49 | void sliceHoverLeave(); | |
50 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
50 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
51 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
51 | void modelDataAdded(QModelIndex parent, int start, int end); | |
52 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
52 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
53 | bool setRealValue(qreal &value, qreal newValue, qreal max, qreal min = 0.0); |
|
53 | bool setRealValue(qreal &value, qreal newValue, qreal max, qreal min = 0.0); | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | QList<QPieSlice*> m_slices; |
|
56 | QList<QPieSlice*> m_slices; | |
57 | qreal m_pieRelativeHorPos; |
|
57 | qreal m_pieRelativeHorPos; | |
58 | qreal m_pieRelativeVerPos; |
|
58 | qreal m_pieRelativeVerPos; | |
59 | qreal m_pieRelativeSize; |
|
59 | qreal m_pieRelativeSize; | |
60 | qreal m_pieStartAngle; |
|
60 | qreal m_pieStartAngle; | |
61 | qreal m_pieEndAngle; |
|
61 | qreal m_pieEndAngle; | |
62 | qreal m_sum; |
|
62 | qreal m_sum; | |
63 |
|
63 | |||
64 | // model map |
|
64 | // model map | |
65 | int m_mapValues; |
|
65 | int m_mapValues; | |
66 | int m_mapLabels; |
|
66 | int m_mapLabels; | |
67 | Qt::Orientation m_mapOrientation; |
|
67 | Qt::Orientation m_mapOrientation; | |
68 | private: |
|
68 | private: | |
69 | Q_DECLARE_PUBLIC(QPieSeries) |
|
69 | Q_DECLARE_PUBLIC(QPieSeries) | |
70 | }; |
|
70 | }; | |
71 |
|
71 | |||
72 | QTCOMMERCIALCHART_END_NAMESPACE |
|
72 | QTCOMMERCIALCHART_END_NAMESPACE | |
73 |
|
73 | |||
74 | #endif // QPIESERIES_P_H |
|
74 | #endif // QPIESERIES_P_H |
@@ -1,133 +1,133 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qseries.h" |
|
21 | #include "qabstractseries.h" | |
22 | #include "qseries_p.h" |
|
22 | #include "qabstractseries_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QSeries |
|
27 | \class QAbstractSeries | |
28 | \brief Base class for all QtCommercial Chart series. |
|
28 | \brief Base class for all QtCommercial Chart series. | |
29 | \mainclass |
|
29 | \mainclass | |
30 |
|
30 | |||
31 | Usually you use the series type specific inherited classes instead of the base class. |
|
31 | Usually you use the series type specific inherited classes instead of the base class. | |
32 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QBarSeries, QStackedBarSeries, |
|
32 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QBarSeries, QStackedBarSeries, | |
33 | QPercentBarSeries, QPieSeries |
|
33 | QPercentBarSeries, QPieSeries | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \enum QSeries::QSeriesType |
|
37 | \enum QAbstractSeries::QSeriesType | |
38 |
|
38 | |||
39 | The type of the series object. |
|
39 | The type of the series object. | |
40 |
|
40 | |||
41 | \value SeriesTypeLine |
|
41 | \value SeriesTypeLine | |
42 | \value SeriesTypeArea |
|
42 | \value SeriesTypeArea | |
43 | \value SeriesTypeBar |
|
43 | \value SeriesTypeBar | |
44 | \value SeriesTypeStackedBar |
|
44 | \value SeriesTypeStackedBar | |
45 | \value SeriesTypePercentBar |
|
45 | \value SeriesTypePercentBar | |
46 | \value SeriesTypePie |
|
46 | \value SeriesTypePie | |
47 | \value SeriesTypeScatter |
|
47 | \value SeriesTypeScatter | |
48 | \value SeriesTypeSpline |
|
48 | \value SeriesTypeSpline | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn QSeriesType QSeries::type() const |
|
52 | \fn QSeriesType QAbstractSeries::type() const | |
53 | \brief The type of the series. |
|
53 | \brief The type of the series. | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \fn bool QSeries::setModel(QAbstractItemModel *model) |
|
57 | \fn bool QAbstractSeries::setModel(QAbstractItemModel *model) | |
58 | \brief Use the \a model to provide data for the series. The model overrides possible user data |
|
58 | \brief Use the \a model to provide data for the series. The model overrides possible user data | |
59 | set with QChartSeries type specific data setters. For example if you call both |
|
59 | set with QChartSeries type specific data setters. For example if you call both | |
60 | QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is |
|
60 | QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is | |
61 | used by the series. Returns true if the model is valid for the series. |
|
61 | used by the series. Returns true if the model is valid for the series. | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \property QSeries::name |
|
65 | \property QAbstractSeries::name | |
66 | \brief name of the series property |
|
66 | \brief name of the series property | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \fn void QSeries::setName(const QString& name) |
|
70 | \fn void QAbstractSeries::setName(const QString& name) | |
71 | \brief Sets a \a name for the series. |
|
71 | \brief Sets a \a name for the series. | |
72 |
|
72 | |||
73 | The name of a series is shown in the legend for QXYSeries. |
|
73 | The name of a series is shown in the legend for QXYSeries. | |
74 | \sa QChart::setTitle() |
|
74 | \sa QChart::setTitle() | |
75 | \sa QPieSlice::setLabel() |
|
75 | \sa QPieSlice::setLabel() | |
76 | \sa QBarSet::setName() |
|
76 | \sa QBarSet::setName() | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \internal |
|
80 | \internal | |
81 | \brief Constructs ChartSeries object with \a parent. |
|
81 | \brief Constructs ChartSeries object with \a parent. | |
82 | */ |
|
82 | */ | |
83 | QSeries::QSeries(QSeriesPrivate &d, QObject *parent) : |
|
83 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : | |
84 | QObject(parent), |
|
84 | QObject(parent), | |
85 | d_ptr(&d) |
|
85 | d_ptr(&d) | |
86 | { |
|
86 | { | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \brief Virtual destructor for the chart series. |
|
90 | \brief Virtual destructor for the chart series. | |
91 | */ |
|
91 | */ | |
92 | QSeries::~QSeries() |
|
92 | QAbstractSeries::~QAbstractSeries() | |
93 | { |
|
93 | { | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | /*! |
|
96 | /*! | |
97 | \brief Returns the pointer to the model that is used as the series data source |
|
97 | \brief Returns the pointer to the model that is used as the series data source | |
98 | */ |
|
98 | */ | |
99 | QAbstractItemModel* QSeries::model() const |
|
99 | QAbstractItemModel* QAbstractSeries::model() const | |
100 | { |
|
100 | { | |
101 | return d_ptr->m_model; |
|
101 | return d_ptr->m_model; | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void QSeries::setName(const QString& name) |
|
104 | void QAbstractSeries::setName(const QString& name) | |
105 | { |
|
105 | { | |
106 | d_ptr->m_name = name; |
|
106 | d_ptr->m_name = name; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | \brief Returns the name of the series. |
|
110 | \brief Returns the name of the series. | |
111 | \sa setName() |
|
111 | \sa setName() | |
112 | */ |
|
112 | */ | |
113 | QString QSeries::name() const |
|
113 | QString QAbstractSeries::name() const | |
114 | { |
|
114 | { | |
115 | return d_ptr->m_name; |
|
115 | return d_ptr->m_name; | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
119 |
|
119 | |||
120 | QSeriesPrivate::QSeriesPrivate(QSeries* q): q_ptr(q),m_model(0) |
|
120 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q): q_ptr(q),m_model(0) | |
121 | { |
|
121 | { | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | QSeriesPrivate::~QSeriesPrivate() |
|
124 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() | |
125 | { |
|
125 | { | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | #include "moc_qseries.cpp" |
|
128 | #include "moc_qabstractseries.cpp" | |
129 | #include "moc_qseries_p.cpp" |
|
129 | #include "moc_qabstractseries_p.cpp" | |
130 |
|
130 | |||
131 | QTCOMMERCIALCHART_END_NAMESPACE |
|
131 | QTCOMMERCIALCHART_END_NAMESPACE | |
132 |
|
132 | |||
133 |
|
133 |
@@ -1,72 +1,72 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QSERIES_H |
|
21 | #ifndef QABSTRACTSERIES_H | |
22 | #define QSERIES_H |
|
22 | #define QABSTRACTSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QObject> |
|
25 | #include <QObject> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 |
|
27 | |||
28 | class QAbstractItemModel; |
|
28 | class QAbstractItemModel; | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSeriesPrivate; |
|
32 | class QAbstractSeriesPrivate; | |
33 |
|
33 | |||
34 | class QTCOMMERCIALCHART_EXPORT QSeries : public QObject |
|
34 | class QTCOMMERCIALCHART_EXPORT QAbstractSeries : public QObject | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | Q_PROPERTY(QString name READ name WRITE setName) |
|
37 | Q_PROPERTY(QString name READ name WRITE setName) | |
38 | Q_ENUMS(QSeriesType) |
|
38 | Q_ENUMS(QSeriesType) | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | enum QSeriesType { |
|
41 | enum QSeriesType { | |
42 | SeriesTypeLine, |
|
42 | SeriesTypeLine, | |
43 | SeriesTypeArea, |
|
43 | SeriesTypeArea, | |
44 | SeriesTypeBar, |
|
44 | SeriesTypeBar, | |
45 | SeriesTypeStackedBar, |
|
45 | SeriesTypeStackedBar, | |
46 | SeriesTypePercentBar, |
|
46 | SeriesTypePercentBar, | |
47 | SeriesTypePie, |
|
47 | SeriesTypePie, | |
48 | SeriesTypeScatter, |
|
48 | SeriesTypeScatter, | |
49 | SeriesTypeSpline |
|
49 | SeriesTypeSpline | |
50 | }; |
|
50 | }; | |
51 |
|
51 | |||
52 | protected: |
|
52 | protected: | |
53 | QSeries(QSeriesPrivate &d, QObject *parent = 0); |
|
53 | QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = 0); | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | ~QSeries(); |
|
56 | ~QAbstractSeries(); | |
57 | virtual QSeriesType type() const = 0; |
|
57 | virtual QSeriesType type() const = 0; | |
58 | virtual bool setModel(QAbstractItemModel* model) = 0; |
|
58 | virtual bool setModel(QAbstractItemModel* model) = 0; | |
59 | QAbstractItemModel* model() const; |
|
59 | QAbstractItemModel* model() const; | |
60 | void setName(const QString& name); |
|
60 | void setName(const QString& name); | |
61 | QString name() const; |
|
61 | QString name() const; | |
62 |
|
62 | |||
63 | protected: |
|
63 | protected: | |
64 | QScopedPointer<QSeriesPrivate> d_ptr; |
|
64 | QScopedPointer<QAbstractSeriesPrivate> d_ptr; | |
65 | friend class ChartDataSet; |
|
65 | friend class ChartDataSet; | |
66 | friend class ChartPresenter; |
|
66 | friend class ChartPresenter; | |
67 | friend class QLegendPrivate; |
|
67 | friend class QLegendPrivate; | |
68 | }; |
|
68 | }; | |
69 |
|
69 | |||
70 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | QTCOMMERCIALCHART_END_NAMESPACE | |
71 |
|
71 | |||
72 | #endif |
|
72 | #endif |
@@ -1,66 +1,66 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QSERIES_P_H |
|
30 | #ifndef QABSTRACTSERIES_P_H | |
31 | #define QSERIES_P_H |
|
31 | #define QABSTRACTSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qseries.h" |
|
33 | #include "qabstractseries.h" | |
34 |
|
34 | |||
35 | class QAbstractItemModel; |
|
35 | class QAbstractItemModel; | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class Domain; |
|
39 | class Domain; | |
40 | class ChartPresenter; |
|
40 | class ChartPresenter; | |
41 | class Chart; |
|
41 | class Chart; | |
42 | class LegendMarker; |
|
42 | class LegendMarker; | |
43 | class QLegend; |
|
43 | class QLegend; | |
44 |
|
44 | |||
45 | class QSeriesPrivate : public QObject |
|
45 | class QAbstractSeriesPrivate : public QObject | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 | public: |
|
48 | public: | |
49 | QSeriesPrivate(QSeries *q); |
|
49 | QAbstractSeriesPrivate(QAbstractSeries *q); | |
50 | ~QSeriesPrivate(); |
|
50 | ~QAbstractSeriesPrivate(); | |
51 |
|
51 | |||
52 | virtual void scaleDomain(Domain& domain) = 0; |
|
52 | virtual void scaleDomain(Domain& domain) = 0; | |
53 | virtual Chart* createGraphics(ChartPresenter* presenter) = 0; |
|
53 | virtual Chart* createGraphics(ChartPresenter* presenter) = 0; | |
54 | virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0; |
|
54 | virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0; | |
55 |
|
55 | |||
56 | protected: |
|
56 | protected: | |
57 | QSeries *q_ptr; |
|
57 | QAbstractSeries *q_ptr; | |
58 | QAbstractItemModel *m_model; |
|
58 | QAbstractItemModel *m_model; | |
59 | QString m_name; |
|
59 | QString m_name; | |
60 |
|
60 | |||
61 | friend class QSeries; |
|
61 | friend class QAbstractSeries; | |
62 | }; |
|
62 | }; | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
64 | QTCOMMERCIALCHART_END_NAMESPACE | |
65 |
|
65 | |||
66 | #endif |
|
66 | #endif |
@@ -1,412 +1,412 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "legendscroller_p.h" |
|
23 | #include "legendscroller_p.h" | |
24 | #include "qlegend_p.h" |
|
24 | #include "qlegend_p.h" | |
25 | #include <QGraphicsScene> |
|
25 | #include <QGraphicsScene> | |
26 | #include <QGraphicsSceneResizeEvent> |
|
26 | #include <QGraphicsSceneResizeEvent> | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 | \enum QChart::ChartTheme |
|
31 | \enum QChart::ChartTheme | |
32 |
|
32 | |||
33 | This enum describes the theme used by the chart. |
|
33 | This enum describes the theme used by the chart. | |
34 |
|
34 | |||
35 | \value ChartThemeLight The default theme |
|
35 | \value ChartThemeLight The default theme | |
36 | \value ChartThemeBlueCerulean |
|
36 | \value ChartThemeBlueCerulean | |
37 | \value ChartThemeDark |
|
37 | \value ChartThemeDark | |
38 | \value ChartThemeBrownSand |
|
38 | \value ChartThemeBrownSand | |
39 | \value ChartThemeBlueNcs |
|
39 | \value ChartThemeBlueNcs | |
40 | \value ChartThemeHighContrast |
|
40 | \value ChartThemeHighContrast | |
41 | \value ChartThemeBlueIcy |
|
41 | \value ChartThemeBlueIcy | |
42 | */ |
|
42 | */ | |
43 |
|
43 | |||
44 | /*! |
|
44 | /*! | |
45 | \enum QChart::AnimationOption |
|
45 | \enum QChart::AnimationOption | |
46 |
|
46 | |||
47 | For enabling/disabling animations. Defaults to NoAnimation. |
|
47 | For enabling/disabling animations. Defaults to NoAnimation. | |
48 |
|
48 | |||
49 | \value NoAnimation |
|
49 | \value NoAnimation | |
50 | \value GridAxisAnimations |
|
50 | \value GridAxisAnimations | |
51 | \value SeriesAnimations |
|
51 | \value SeriesAnimations | |
52 | \value AllAnimations |
|
52 | \value AllAnimations | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \class QChart |
|
56 | \class QChart | |
57 | \brief QtCommercial chart API. |
|
57 | \brief QtCommercial chart API. | |
58 |
|
58 | |||
59 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
59 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
60 | representation of different types of QChartSeries and other chart related objects like |
|
60 | representation of different types of QChartSeries and other chart related objects like | |
61 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the |
|
61 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the | |
62 | convenience class QChartView instead of QChart. |
|
62 | convenience class QChartView instead of QChart. | |
63 | \sa QChartView |
|
63 | \sa QChartView | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
67 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
68 | */ |
|
68 | */ | |
69 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
69 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
70 | d_ptr(new QChartPrivate()) |
|
70 | d_ptr(new QChartPrivate()) | |
71 | { |
|
71 | { | |
72 | d_ptr->m_dataset = new ChartDataSet(this); |
|
72 | d_ptr->m_dataset = new ChartDataSet(this); | |
73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
74 | d_ptr->createConnections(); |
|
74 | d_ptr->createConnections(); | |
75 | d_ptr->m_legend = new LegendScroller(this); |
|
75 | d_ptr->m_legend = new LegendScroller(this); | |
76 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
76 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. |
|
80 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. | |
81 | */ |
|
81 | */ | |
82 | QChart::~QChart() |
|
82 | QChart::~QChart() | |
83 | { |
|
83 | { | |
84 | //delete first presenter , since this is a root of all the graphical items |
|
84 | //delete first presenter , since this is a root of all the graphical items | |
85 | delete d_ptr->m_presenter; |
|
85 | delete d_ptr->m_presenter; | |
86 | d_ptr->m_presenter=0; |
|
86 | d_ptr->m_presenter=0; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. |
|
90 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. | |
91 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
91 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
92 | the y axis). |
|
92 | the y axis). | |
93 | */ |
|
93 | */ | |
94 |
void QChart::addSeries(QSeries* |
|
94 | void QChart::addSeries(QAbstractSeries *series, QChartAxis *axisY) | |
95 | { |
|
95 | { | |
96 | Q_ASSERT(series); |
|
96 | Q_ASSERT(series); | |
97 | d_ptr->m_dataset->addSeries(series, axisY); |
|
97 | d_ptr->m_dataset->addSeries(series, axisY); | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | Removes the \a series specified in a perameter from the QChartView. |
|
101 | Removes the \a series specified in a perameter from the QChartView. | |
102 | It releses its ownership of the specified QChartSeries object. |
|
102 | It releses its ownership of the specified QChartSeries object. | |
103 | It does not delete the pointed QChartSeries data object |
|
103 | It does not delete the pointed QChartSeries data object | |
104 | \sa addSeries(), removeAllSeries() |
|
104 | \sa addSeries(), removeAllSeries() | |
105 | */ |
|
105 | */ | |
106 |
void QChart::removeSeries(QSeries* |
|
106 | void QChart::removeSeries(QAbstractSeries *series) | |
107 | { |
|
107 | { | |
108 | Q_ASSERT(series); |
|
108 | Q_ASSERT(series); | |
109 | d_ptr->m_dataset->removeSeries(series); |
|
109 | d_ptr->m_dataset->removeSeries(series); | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | Removes all the QChartSeries that have been added to the QChartView |
|
113 | Removes all the QChartSeries that have been added to the QChartView | |
114 | It also deletes the pointed QChartSeries data objects |
|
114 | It also deletes the pointed QChartSeries data objects | |
115 | \sa addSeries(), removeSeries() |
|
115 | \sa addSeries(), removeSeries() | |
116 | */ |
|
116 | */ | |
117 | void QChart::removeAllSeries() |
|
117 | void QChart::removeAllSeries() | |
118 | { |
|
118 | { | |
119 | d_ptr->m_dataset->removeAllSeries(); |
|
119 | d_ptr->m_dataset->removeAllSeries(); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | Sets the \a brush that is used for painting the background of the chart area. |
|
123 | Sets the \a brush that is used for painting the background of the chart area. | |
124 | */ |
|
124 | */ | |
125 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
125 | void QChart::setBackgroundBrush(const QBrush& brush) | |
126 | { |
|
126 | { | |
127 | //TODO: refactor me |
|
127 | //TODO: refactor me | |
128 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
128 | d_ptr->m_presenter->createChartBackgroundItem(); | |
129 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); |
|
129 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); | |
130 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
130 | d_ptr->m_presenter->m_backgroundItem->update(); | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | Gets the brush that is used for painting the background of the chart area. |
|
134 | Gets the brush that is used for painting the background of the chart area. | |
135 | */ |
|
135 | */ | |
136 | QBrush QChart::backgroundBrush() const |
|
136 | QBrush QChart::backgroundBrush() const | |
137 | { |
|
137 | { | |
138 | //TODO: refactor me |
|
138 | //TODO: refactor me | |
139 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); |
|
139 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); | |
140 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); |
|
140 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | Sets the \a pen that is used for painting the background of the chart area. |
|
144 | Sets the \a pen that is used for painting the background of the chart area. | |
145 | */ |
|
145 | */ | |
146 | void QChart::setBackgroundPen(const QPen& pen) |
|
146 | void QChart::setBackgroundPen(const QPen& pen) | |
147 | { |
|
147 | { | |
148 | //TODO: refactor me |
|
148 | //TODO: refactor me | |
149 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
149 | d_ptr->m_presenter->createChartBackgroundItem(); | |
150 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); |
|
150 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); | |
151 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
151 | d_ptr->m_presenter->m_backgroundItem->update(); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | Gets the pen that is used for painting the background of the chart area. |
|
155 | Gets the pen that is used for painting the background of the chart area. | |
156 | */ |
|
156 | */ | |
157 | QPen QChart::backgroundPen() const |
|
157 | QPen QChart::backgroundPen() const | |
158 | { |
|
158 | { | |
159 | //TODO: refactor me |
|
159 | //TODO: refactor me | |
160 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); |
|
160 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); | |
161 | return d_ptr->m_presenter->m_backgroundItem->pen(); |
|
161 | return d_ptr->m_presenter->m_backgroundItem->pen(); | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Sets the chart \a title. The description text that is drawn above the chart. |
|
165 | Sets the chart \a title. The description text that is drawn above the chart. | |
166 | */ |
|
166 | */ | |
167 | void QChart::setTitle(const QString& title) |
|
167 | void QChart::setTitle(const QString& title) | |
168 | { |
|
168 | { | |
169 | //TODO: refactor me |
|
169 | //TODO: refactor me | |
170 | d_ptr->m_presenter->createChartTitleItem(); |
|
170 | d_ptr->m_presenter->createChartTitleItem(); | |
171 | d_ptr->m_presenter->m_titleItem->setText(title); |
|
171 | d_ptr->m_presenter->m_titleItem->setText(title); | |
172 | d_ptr->m_presenter->updateLayout(); |
|
172 | d_ptr->m_presenter->updateLayout(); | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | /*! |
|
175 | /*! | |
176 | Returns the chart title. The description text that is drawn above the chart. |
|
176 | Returns the chart title. The description text that is drawn above the chart. | |
177 | */ |
|
177 | */ | |
178 | QString QChart::title() const |
|
178 | QString QChart::title() const | |
179 | { |
|
179 | { | |
180 | //TODO: refactor me |
|
180 | //TODO: refactor me | |
181 | if (d_ptr->m_presenter->m_titleItem) |
|
181 | if (d_ptr->m_presenter->m_titleItem) | |
182 | return d_ptr->m_presenter->m_titleItem->text(); |
|
182 | return d_ptr->m_presenter->m_titleItem->text(); | |
183 | else |
|
183 | else | |
184 | return QString(); |
|
184 | return QString(); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
188 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
189 | */ |
|
189 | */ | |
190 | void QChart::setTitleFont(const QFont& font) |
|
190 | void QChart::setTitleFont(const QFont& font) | |
191 | { |
|
191 | { | |
192 | //TODO: refactor me |
|
192 | //TODO: refactor me | |
193 | d_ptr->m_presenter->createChartTitleItem(); |
|
193 | d_ptr->m_presenter->createChartTitleItem(); | |
194 | d_ptr->m_presenter->m_titleItem->setFont(font); |
|
194 | d_ptr->m_presenter->m_titleItem->setFont(font); | |
195 | d_ptr->m_presenter->updateLayout(); |
|
195 | d_ptr->m_presenter->updateLayout(); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | /*! |
|
198 | /*! | |
199 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
199 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
200 | */ |
|
200 | */ | |
201 | QFont QChart::titleFont() const |
|
201 | QFont QChart::titleFont() const | |
202 | { |
|
202 | { | |
203 | if (d_ptr->m_presenter->m_titleItem) |
|
203 | if (d_ptr->m_presenter->m_titleItem) | |
204 | return d_ptr->m_presenter->m_titleItem->font(); |
|
204 | return d_ptr->m_presenter->m_titleItem->font(); | |
205 | else |
|
205 | else | |
206 | return QFont(); |
|
206 | return QFont(); | |
207 | } |
|
207 | } | |
208 |
|
208 | |||
209 | /*! |
|
209 | /*! | |
210 | Sets the \a brush used for rendering the title text. |
|
210 | Sets the \a brush used for rendering the title text. | |
211 | */ |
|
211 | */ | |
212 | void QChart::setTitleBrush(const QBrush &brush) |
|
212 | void QChart::setTitleBrush(const QBrush &brush) | |
213 | { |
|
213 | { | |
214 | //TODO: refactor me |
|
214 | //TODO: refactor me | |
215 | d_ptr->m_presenter->createChartTitleItem(); |
|
215 | d_ptr->m_presenter->createChartTitleItem(); | |
216 | d_ptr->m_presenter->m_titleItem->setBrush(brush); |
|
216 | d_ptr->m_presenter->m_titleItem->setBrush(brush); | |
217 | d_ptr->m_presenter->updateLayout(); |
|
217 | d_ptr->m_presenter->updateLayout(); | |
218 | } |
|
218 | } | |
219 |
|
219 | |||
220 | /*! |
|
220 | /*! | |
221 | Returns the brush used for rendering the title text. |
|
221 | Returns the brush used for rendering the title text. | |
222 | */ |
|
222 | */ | |
223 | QBrush QChart::titleBrush() const |
|
223 | QBrush QChart::titleBrush() const | |
224 | { |
|
224 | { | |
225 | //TODO: refactor me |
|
225 | //TODO: refactor me | |
226 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); |
|
226 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); | |
227 | return d_ptr->m_presenter->m_titleItem->brush(); |
|
227 | return d_ptr->m_presenter->m_titleItem->brush(); | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | /*! |
|
230 | /*! | |
231 | Sets the \a theme used by the chart for rendering the graphical representation of the data |
|
231 | Sets the \a theme used by the chart for rendering the graphical representation of the data | |
232 | \sa theme() |
|
232 | \sa theme() | |
233 | */ |
|
233 | */ | |
234 | void QChart::setTheme(QChart::ChartTheme theme) |
|
234 | void QChart::setTheme(QChart::ChartTheme theme) | |
235 | { |
|
235 | { | |
236 | d_ptr->m_presenter->setTheme(theme); |
|
236 | d_ptr->m_presenter->setTheme(theme); | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | /*! |
|
239 | /*! | |
240 | Returns the theme enum used by the chart. |
|
240 | Returns the theme enum used by the chart. | |
241 | \sa ChartTheme, setTheme() |
|
241 | \sa ChartTheme, setTheme() | |
242 | */ |
|
242 | */ | |
243 | QChart::ChartTheme QChart::theme() const |
|
243 | QChart::ChartTheme QChart::theme() const | |
244 | { |
|
244 | { | |
245 | return d_ptr->m_presenter->theme(); |
|
245 | return d_ptr->m_presenter->theme(); | |
246 | } |
|
246 | } | |
247 |
|
247 | |||
248 | /*! |
|
248 | /*! | |
249 | Zooms in the view by a factor of 2 |
|
249 | Zooms in the view by a factor of 2 | |
250 | */ |
|
250 | */ | |
251 | void QChart::zoomIn() |
|
251 | void QChart::zoomIn() | |
252 | { |
|
252 | { | |
253 | d_ptr->m_presenter->zoomIn(); |
|
253 | d_ptr->m_presenter->zoomIn(); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | /*! |
|
256 | /*! | |
257 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
257 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
258 | */ |
|
258 | */ | |
259 | void QChart::zoomIn(const QRectF& rect) |
|
259 | void QChart::zoomIn(const QRectF& rect) | |
260 | { |
|
260 | { | |
261 | if (!rect.isValid()) return; |
|
261 | if (!rect.isValid()) return; | |
262 | d_ptr->m_presenter->zoomIn(rect); |
|
262 | d_ptr->m_presenter->zoomIn(rect); | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 | /*! |
|
265 | /*! | |
266 | Restores the view zoom level to the previous one. |
|
266 | Restores the view zoom level to the previous one. | |
267 | */ |
|
267 | */ | |
268 | void QChart::zoomOut() |
|
268 | void QChart::zoomOut() | |
269 | { |
|
269 | { | |
270 | d_ptr->m_presenter->zoomOut(); |
|
270 | d_ptr->m_presenter->zoomOut(); | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | /*! |
|
273 | /*! | |
274 | Returns the pointer to the x axis object of the chart |
|
274 | Returns the pointer to the x axis object of the chart | |
275 | */ |
|
275 | */ | |
276 | QChartAxis* QChart::axisX() const |
|
276 | QChartAxis* QChart::axisX() const | |
277 | { |
|
277 | { | |
278 | return d_ptr->m_dataset->axisX(); |
|
278 | return d_ptr->m_dataset->axisX(); | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | /*! |
|
281 | /*! | |
282 | Returns the pointer to the y axis object of the \a series |
|
282 | Returns the pointer to the y axis object of the \a series | |
283 | If no \a series is provided then default Y axis of the chart is returned. |
|
283 | If no \a series is provided then default Y axis of the chart is returned. | |
284 | */ |
|
284 | */ | |
285 |
QChartAxis* QChart::axisY(QSeries* |
|
285 | QChartAxis* QChart::axisY(QAbstractSeries *series) const | |
286 | { |
|
286 | { | |
287 | return d_ptr->m_dataset->axisY(series); |
|
287 | return d_ptr->m_dataset->axisY(series); | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | /*! |
|
290 | /*! | |
291 | Returns the legend object of the chart. Ownership stays in chart. |
|
291 | Returns the legend object of the chart. Ownership stays in chart. | |
292 | */ |
|
292 | */ | |
293 | QLegend* QChart::legend() const |
|
293 | QLegend* QChart::legend() const | |
294 | { |
|
294 | { | |
295 | return d_ptr->m_legend; |
|
295 | return d_ptr->m_legend; | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | /*! |
|
298 | /*! | |
299 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
299 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
300 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
300 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
301 | */ |
|
301 | */ | |
302 | QRectF QChart::margins() const |
|
302 | QRectF QChart::margins() const | |
303 | { |
|
303 | { | |
304 | return d_ptr->m_presenter->margins(); |
|
304 | return d_ptr->m_presenter->margins(); | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
307 |
|
307 | |||
308 | /*! |
|
308 | /*! | |
309 | Resizes and updates the chart area using the \a event data |
|
309 | Resizes and updates the chart area using the \a event data | |
310 | */ |
|
310 | */ | |
311 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
311 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) | |
312 | { |
|
312 | { | |
313 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); |
|
313 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); | |
314 | QGraphicsWidget::resizeEvent(event); |
|
314 | QGraphicsWidget::resizeEvent(event); | |
315 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); |
|
315 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | /*! |
|
318 | /*! | |
319 | Sets animation \a options for the chart |
|
319 | Sets animation \a options for the chart | |
320 | */ |
|
320 | */ | |
321 | void QChart::setAnimationOptions(AnimationOptions options) |
|
321 | void QChart::setAnimationOptions(AnimationOptions options) | |
322 | { |
|
322 | { | |
323 | d_ptr->m_presenter->setAnimationOptions(options); |
|
323 | d_ptr->m_presenter->setAnimationOptions(options); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | /*! |
|
326 | /*! | |
327 | Returns animation options for the chart |
|
327 | Returns animation options for the chart | |
328 | */ |
|
328 | */ | |
329 | QChart::AnimationOptions QChart::animationOptions() const |
|
329 | QChart::AnimationOptions QChart::animationOptions() const | |
330 | { |
|
330 | { | |
331 | return d_ptr->m_presenter->animationOptions(); |
|
331 | return d_ptr->m_presenter->animationOptions(); | |
332 | } |
|
332 | } | |
333 |
|
333 | |||
334 | /*! |
|
334 | /*! | |
335 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks |
|
335 | Scrolls the visible area of the chart to the left by the distance between two x axis ticks | |
336 | */ |
|
336 | */ | |
337 | void QChart::scrollLeft() |
|
337 | void QChart::scrollLeft() | |
338 | { |
|
338 | { | |
339 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
339 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | /*! |
|
342 | /*! | |
343 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks |
|
343 | Scrolls the visible area of the chart to the right by the distance between two x axis ticks | |
344 | */ |
|
344 | */ | |
345 | void QChart::scrollRight() |
|
345 | void QChart::scrollRight() | |
346 | { |
|
346 | { | |
347 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
347 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | /*! |
|
350 | /*! | |
351 | Scrolls the visible area of the chart up by the distance between two y axis ticks |
|
351 | Scrolls the visible area of the chart up by the distance between two y axis ticks | |
352 | */ |
|
352 | */ | |
353 | void QChart::scrollUp() |
|
353 | void QChart::scrollUp() | |
354 | { |
|
354 | { | |
355 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
355 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | /*! |
|
358 | /*! | |
359 | Scrolls the visible area of the chart down by the distance between two y axis ticks |
|
359 | Scrolls the visible area of the chart down by the distance between two y axis ticks | |
360 | */ |
|
360 | */ | |
361 | void QChart::scrollDown() |
|
361 | void QChart::scrollDown() | |
362 | { |
|
362 | { | |
363 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
363 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 | /*! |
|
366 | /*! | |
367 | Sets the chart background visibility state to \a visible |
|
367 | Sets the chart background visibility state to \a visible | |
368 | */ |
|
368 | */ | |
369 | void QChart::setBackgroundVisible(bool visible) |
|
369 | void QChart::setBackgroundVisible(bool visible) | |
370 | { |
|
370 | { | |
371 | //TODO: refactor me |
|
371 | //TODO: refactor me | |
372 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
372 | d_ptr->m_presenter->createChartBackgroundItem(); | |
373 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); |
|
373 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | /*! |
|
376 | /*! | |
377 | Returns the chart's background visibility state |
|
377 | Returns the chart's background visibility state | |
378 | */ |
|
378 | */ | |
379 | bool QChart::isBackgroundVisible() const |
|
379 | bool QChart::isBackgroundVisible() const | |
380 | { |
|
380 | { | |
381 | //TODO: refactor me |
|
381 | //TODO: refactor me | |
382 | if (!d_ptr->m_presenter->m_backgroundItem) return false; |
|
382 | if (!d_ptr->m_presenter->m_backgroundItem) return false; | |
383 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); |
|
383 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
386 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
387 |
|
387 | |||
388 | QChartPrivate::QChartPrivate(): |
|
388 | QChartPrivate::QChartPrivate(): | |
389 | m_legend(0), |
|
389 | m_legend(0), | |
390 | m_dataset(0), |
|
390 | m_dataset(0), | |
391 | m_presenter(0) |
|
391 | m_presenter(0) | |
392 | { |
|
392 | { | |
393 |
|
393 | |||
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | QChartPrivate::~QChartPrivate() |
|
396 | QChartPrivate::~QChartPrivate() | |
397 | { |
|
397 | { | |
398 |
|
398 | |||
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | void QChartPrivate::createConnections() |
|
401 | void QChartPrivate::createConnections() | |
402 | { |
|
402 | { | |
403 |
|
403 | |||
404 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
404 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries *, Domain *)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries *, Domain *))); | |
405 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); |
|
405 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries *)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries *))); | |
406 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); |
|
406 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | |
407 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); |
|
407 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | #include "moc_qchart.cpp" |
|
410 | #include "moc_qchart.cpp" | |
411 |
|
411 | |||
412 | QTCOMMERCIALCHART_END_NAMESPACE |
|
412 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,119 +1,119 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHART_H |
|
21 | #ifndef QCHART_H | |
22 | #define QCHART_H |
|
22 | #define QCHART_H | |
23 |
|
23 | |||
24 | #include <QSeries> |
|
24 | #include <QAbstractSeries> | |
25 | #include <QLegend> |
|
25 | #include <QLegend> | |
26 | #include <QGraphicsWidget> |
|
26 | #include <QGraphicsWidget> | |
27 |
|
27 | |||
28 | class QGraphicsSceneResizeEvent; |
|
28 | class QGraphicsSceneResizeEvent; | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSeries; |
|
32 | class QAbstractSeries; | |
33 | class QChartAxis; |
|
33 | class QChartAxis; | |
34 | class QLegend; |
|
34 | class QLegend; | |
35 | struct QChartPrivate; |
|
35 | struct QChartPrivate; | |
36 |
|
36 | |||
37 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
37 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
38 | { |
|
38 | { | |
39 | Q_OBJECT |
|
39 | Q_OBJECT | |
40 | Q_ENUMS(ChartTheme) |
|
40 | Q_ENUMS(ChartTheme) | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | enum ChartTheme { |
|
43 | enum ChartTheme { | |
44 | ChartThemeLight = 0, |
|
44 | ChartThemeLight = 0, | |
45 | ChartThemeBlueCerulean, |
|
45 | ChartThemeBlueCerulean, | |
46 | ChartThemeDark, |
|
46 | ChartThemeDark, | |
47 | ChartThemeBrownSand, |
|
47 | ChartThemeBrownSand, | |
48 | ChartThemeBlueNcs, |
|
48 | ChartThemeBlueNcs, | |
49 | ChartThemeHighContrast, |
|
49 | ChartThemeHighContrast, | |
50 | ChartThemeBlueIcy |
|
50 | ChartThemeBlueIcy | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | enum AnimationOption { |
|
53 | enum AnimationOption { | |
54 | NoAnimation = 0x0, |
|
54 | NoAnimation = 0x0, | |
55 | GridAxisAnimations = 0x1, |
|
55 | GridAxisAnimations = 0x1, | |
56 | SeriesAnimations =0x2, |
|
56 | SeriesAnimations =0x2, | |
57 | AllAnimations = 0x3 |
|
57 | AllAnimations = 0x3 | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
60 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
61 |
|
61 | |||
62 | public: |
|
62 | public: | |
63 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
63 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
64 | ~QChart(); |
|
64 | ~QChart(); | |
65 |
|
65 | |||
66 | void addSeries(QSeries *series, QChartAxis *axisY = 0); |
|
66 | void addSeries(QAbstractSeries *series, QChartAxis *axisY = 0); | |
67 | void removeSeries(QSeries *series); |
|
67 | void removeSeries(QAbstractSeries *series); | |
68 | void removeAllSeries(); |
|
68 | void removeAllSeries(); | |
69 |
|
69 | |||
70 | void setTheme(QChart::ChartTheme theme); |
|
70 | void setTheme(QChart::ChartTheme theme); | |
71 | QChart::ChartTheme theme() const; |
|
71 | QChart::ChartTheme theme() const; | |
72 |
|
72 | |||
73 | void setTitle(const QString& title); |
|
73 | void setTitle(const QString& title); | |
74 | QString title() const; |
|
74 | QString title() const; | |
75 | void setTitleFont(const QFont& font); |
|
75 | void setTitleFont(const QFont& font); | |
76 | QFont titleFont() const; |
|
76 | QFont titleFont() const; | |
77 | void setTitleBrush(const QBrush &brush); |
|
77 | void setTitleBrush(const QBrush &brush); | |
78 | QBrush titleBrush() const; |
|
78 | QBrush titleBrush() const; | |
79 |
|
79 | |||
80 | void setBackgroundBrush(const QBrush &brush); |
|
80 | void setBackgroundBrush(const QBrush &brush); | |
81 | QBrush backgroundBrush() const; |
|
81 | QBrush backgroundBrush() const; | |
82 | void setBackgroundPen(const QPen &pen); |
|
82 | void setBackgroundPen(const QPen &pen); | |
83 | QPen backgroundPen() const; |
|
83 | QPen backgroundPen() const; | |
84 |
|
84 | |||
85 | void setBackgroundVisible(bool visible = true); |
|
85 | void setBackgroundVisible(bool visible = true); | |
86 | bool isBackgroundVisible() const; |
|
86 | bool isBackgroundVisible() const; | |
87 |
|
87 | |||
88 | void setAnimationOptions(AnimationOptions options); |
|
88 | void setAnimationOptions(AnimationOptions options); | |
89 | AnimationOptions animationOptions() const; |
|
89 | AnimationOptions animationOptions() const; | |
90 |
|
90 | |||
91 | void zoomIn(); |
|
91 | void zoomIn(); | |
92 | void zoomIn(const QRectF &rect); |
|
92 | void zoomIn(const QRectF &rect); | |
93 | void zoomOut(); |
|
93 | void zoomOut(); | |
94 | void scrollLeft(); |
|
94 | void scrollLeft(); | |
95 | void scrollRight(); |
|
95 | void scrollRight(); | |
96 | void scrollUp(); |
|
96 | void scrollUp(); | |
97 | void scrollDown(); |
|
97 | void scrollDown(); | |
98 |
|
98 | |||
99 | QChartAxis* axisX() const; |
|
99 | QChartAxis* axisX() const; | |
100 | QChartAxis* axisY(QSeries* series = 0) const; |
|
100 | QChartAxis* axisY(QAbstractSeries* series = 0) const; | |
101 |
|
101 | |||
102 | QLegend* legend() const; |
|
102 | QLegend* legend() const; | |
103 | QRectF margins() const; |
|
103 | QRectF margins() const; | |
104 |
|
104 | |||
105 | protected: |
|
105 | protected: | |
106 | void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
106 | void resizeEvent(QGraphicsSceneResizeEvent *event); | |
107 |
|
107 | |||
108 | protected: |
|
108 | protected: | |
109 | QScopedPointer<QChartPrivate> d_ptr; |
|
109 | QScopedPointer<QChartPrivate> d_ptr; | |
110 | friend class QLegend; |
|
110 | friend class QLegend; | |
111 | friend class ChartPresenter; |
|
111 | friend class ChartPresenter; | |
112 | Q_DISABLE_COPY(QChart) |
|
112 | Q_DISABLE_COPY(QChart) | |
113 | }; |
|
113 | }; | |
114 |
|
114 | |||
115 | QTCOMMERCIALCHART_END_NAMESPACE |
|
115 | QTCOMMERCIALCHART_END_NAMESPACE | |
116 |
|
116 | |||
117 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
117 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
118 |
|
118 | |||
119 | #endif |
|
119 | #endif |
@@ -1,71 +1,71 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QCHARTVIEW_H |
|
21 | #ifndef QCHARTVIEW_H | |
22 | #define QCHARTVIEW_H |
|
22 | #define QCHARTVIEW_H | |
23 |
|
23 | |||
24 | #include <QChartAxis> |
|
24 | #include <QChartAxis> | |
25 | #include <QSeries> |
|
25 | #include <QAbstractSeries> | |
26 | #include <QChart> |
|
26 | #include <QChart> | |
27 | #include <QGraphicsView> |
|
27 | #include <QGraphicsView> | |
28 |
|
28 | |||
29 | class QGraphicsScene; |
|
29 | class QGraphicsScene; | |
30 | class QRubberBand; |
|
30 | class QRubberBand; | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | struct QChartViewPrivate; |
|
34 | struct QChartViewPrivate; | |
35 |
|
35 | |||
36 | class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView |
|
36 | class QTCOMMERCIALCHART_EXPORT QChartView : public QGraphicsView | |
37 | { |
|
37 | { | |
38 | Q_OBJECT |
|
38 | Q_OBJECT | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 |
|
41 | |||
42 | enum RubberBand{ |
|
42 | enum RubberBand{ | |
43 | NoRubberBand = 0x0, |
|
43 | NoRubberBand = 0x0, | |
44 | VerticalRubberBand = 0x1, |
|
44 | VerticalRubberBand = 0x1, | |
45 | HorizonalRubberBand = 0x2, |
|
45 | HorizonalRubberBand = 0x2, | |
46 | RectangleRubberBand = 0x3 |
|
46 | RectangleRubberBand = 0x3 | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 | Q_DECLARE_FLAGS(RubberBands, RubberBand) |
|
49 | Q_DECLARE_FLAGS(RubberBands, RubberBand) | |
50 |
|
50 | |||
51 | explicit QChartView(QChart *chart,QWidget *parent = 0); |
|
51 | explicit QChartView(QChart *chart,QWidget *parent = 0); | |
52 | ~QChartView(); |
|
52 | ~QChartView(); | |
53 |
|
53 | |||
54 | void setRubberBand(const RubberBands& rubberBands); |
|
54 | void setRubberBand(const RubberBands& rubberBands); | |
55 | RubberBands rubberBand() const; |
|
55 | RubberBands rubberBand() const; | |
56 | QChart* chart() const; |
|
56 | QChart* chart() const; | |
57 |
|
57 | |||
58 | protected: |
|
58 | protected: | |
59 | void resizeEvent(QResizeEvent *event); |
|
59 | void resizeEvent(QResizeEvent *event); | |
60 | void mousePressEvent(QMouseEvent *event); |
|
60 | void mousePressEvent(QMouseEvent *event); | |
61 | void mouseMoveEvent(QMouseEvent *event); |
|
61 | void mouseMoveEvent(QMouseEvent *event); | |
62 | void mouseReleaseEvent(QMouseEvent *event); |
|
62 | void mouseReleaseEvent(QMouseEvent *event); | |
63 |
|
63 | |||
64 | protected: |
|
64 | protected: | |
65 | QScopedPointer<QChartViewPrivate> d_ptr; |
|
65 | QScopedPointer<QChartViewPrivate> d_ptr; | |
66 | Q_DISABLE_COPY(QChartView) |
|
66 | Q_DISABLE_COPY(QChartView) | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE | |
70 |
|
70 | |||
71 | #endif // QCHARTWIDGET_H |
|
71 | #endif // QCHARTWIDGET_H |
@@ -1,150 +1,150 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QScatterSeries |
|
29 | \class QScatterSeries | |
30 | \brief The QScatterSeries class is used for making scatter charts. |
|
30 | \brief The QScatterSeries class is used for making scatter charts. | |
31 |
|
31 | |||
32 | \mainclass |
|
32 | \mainclass | |
33 |
|
33 | |||
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
35 | and the vertical axis. |
|
35 | and the vertical axis. | |
36 |
|
36 | |||
37 | \image scatterchart.png |
|
37 | \image scatterchart.png | |
38 |
|
38 | |||
39 | Creating basic scatter chart is simple: |
|
39 | Creating basic scatter chart is simple: | |
40 | \code |
|
40 | \code | |
41 | QScatterSeries* series = new QScatterSeries(); |
|
41 | QScatterSeries* series = new QScatterSeries(); | |
42 | series->append(0, 6); |
|
42 | series->append(0, 6); | |
43 | series->append(2, 4); |
|
43 | series->append(2, 4); | |
44 | ... |
|
44 | ... | |
45 | chartView->addSeries(series); |
|
45 | chartView->addSeries(series); | |
46 | \endcode |
|
46 | \endcode | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \enum QScatterSeries::MarkerShape |
|
50 | \enum QScatterSeries::MarkerShape | |
51 |
|
51 | |||
52 | This enum describes the shape used when rendering marker items. |
|
52 | This enum describes the shape used when rendering marker items. | |
53 |
|
53 | |||
54 | \value MarkerShapeCircle |
|
54 | \value MarkerShapeCircle | |
55 | \value MarkerShapeRectangle |
|
55 | \value MarkerShapeRectangle | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn QChartSeriesType QScatterSeries::type() const |
|
59 | \fn QChartSeriesType QScatterSeries::type() const | |
60 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
60 | \brief Returns QChartSeries::SeriesTypeScatter. | |
61 | \sa QSeries, QSeriesType |
|
61 | \sa QAbstractSeries, QSeriesType | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | Constructs a series object which is a child of \a parent. |
|
67 | Constructs a series object which is a child of \a parent. | |
68 | */ |
|
68 | */ | |
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
70 | { |
|
70 | { | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
75 | */ |
|
75 | */ | |
76 | QScatterSeries::~QScatterSeries() |
|
76 | QScatterSeries::~QScatterSeries() | |
77 | { |
|
77 | { | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | QSeries::QSeriesType QScatterSeries::type() const |
|
80 | QAbstractSeries::QSeriesType QScatterSeries::type() const | |
81 | { |
|
81 | { | |
82 | return QSeries::SeriesTypeScatter; |
|
82 | return QAbstractSeries::SeriesTypeScatter; | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | Returns the shape used for drawing markers. |
|
86 | Returns the shape used for drawing markers. | |
87 | */ |
|
87 | */ | |
88 | QScatterSeries::MarkerShape QScatterSeries::shape() const |
|
88 | QScatterSeries::MarkerShape QScatterSeries::shape() const | |
89 | { |
|
89 | { | |
90 | Q_D(const QScatterSeries); |
|
90 | Q_D(const QScatterSeries); | |
91 | return d->m_shape; |
|
91 | return d->m_shape; | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
95 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
96 | is defined by chart theme setting. |
|
96 | is defined by chart theme setting. | |
97 | */ |
|
97 | */ | |
98 | void QScatterSeries::setShape(MarkerShape shape) |
|
98 | void QScatterSeries::setShape(MarkerShape shape) | |
99 | { |
|
99 | { | |
100 | Q_D(QScatterSeries); |
|
100 | Q_D(QScatterSeries); | |
101 | if (d->m_shape != shape) { |
|
101 | if (d->m_shape != shape) { | |
102 | d->m_shape = shape; |
|
102 | d->m_shape = shape; | |
103 | emit d->updated(); |
|
103 | emit d->updated(); | |
104 | } |
|
104 | } | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | Returns the size of the marker items. |
|
108 | Returns the size of the marker items. | |
109 | */ |
|
109 | */ | |
110 | qreal QScatterSeries::size() const |
|
110 | qreal QScatterSeries::size() const | |
111 | { |
|
111 | { | |
112 | Q_D(const QScatterSeries); |
|
112 | Q_D(const QScatterSeries); | |
113 | return d->m_size; |
|
113 | return d->m_size; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | Set the \a size of the marker items. The default size is 15. |
|
117 | Set the \a size of the marker items. The default size is 15. | |
118 | */ |
|
118 | */ | |
119 | void QScatterSeries::setSize(qreal size) |
|
119 | void QScatterSeries::setSize(qreal size) | |
120 | { |
|
120 | { | |
121 | Q_D(QScatterSeries); |
|
121 | Q_D(QScatterSeries); | |
122 |
|
122 | |||
123 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
123 | if (!qFuzzyIsNull(d->m_size - size)) { | |
124 | d->m_size = size; |
|
124 | d->m_size = size; | |
125 | emit d->updated(); |
|
125 | emit d->updated(); | |
126 | } |
|
126 | } | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
129 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
130 |
|
130 | |||
131 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
131 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), | |
132 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
132 | m_shape(QScatterSeries::MarkerShapeCircle), | |
133 | m_size(15.0) |
|
133 | m_size(15.0) | |
134 | { |
|
134 | { | |
135 |
|
135 | |||
136 | }; |
|
136 | }; | |
137 |
|
137 | |||
138 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
138 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
139 | { |
|
139 | { | |
140 | Q_Q(QScatterSeries); |
|
140 | Q_Q(QScatterSeries); | |
141 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
141 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
142 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
142 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
143 | presenter->animator()->addAnimation(scatter); |
|
143 | presenter->animator()->addAnimation(scatter); | |
144 | } |
|
144 | } | |
145 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
145 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
146 | return scatter; |
|
146 | return scatter; | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 |
|
149 | |||
150 | QTCOMMERCIALCHART_END_NAMESPACE |
|
150 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,60 +1,60 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QSCATTERSERIES_H |
|
21 | #ifndef QSCATTERSERIES_H | |
22 | #define QSCATTERSERIES_H |
|
22 | #define QSCATTERSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qxyseries.h> |
|
25 | #include <qxyseries.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | class QScatterSeriesPrivate; |
|
29 | class QScatterSeriesPrivate; | |
30 |
|
30 | |||
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries |
|
31 | class QTCOMMERCIALCHART_EXPORT QScatterSeries : public QXYSeries | |
32 | { |
|
32 | { | |
33 |
|
33 | |||
34 | public: |
|
34 | public: | |
35 | enum MarkerShape { |
|
35 | enum MarkerShape { | |
36 | MarkerShapeCircle, |
|
36 | MarkerShapeCircle, | |
37 | MarkerShapeRectangle |
|
37 | MarkerShapeRectangle | |
38 | }; |
|
38 | }; | |
39 |
|
39 | |||
40 | public: |
|
40 | public: | |
41 | explicit QScatterSeries(QObject *parent = 0); |
|
41 | explicit QScatterSeries(QObject *parent = 0); | |
42 | ~QScatterSeries(); |
|
42 | ~QScatterSeries(); | |
43 |
|
43 | |||
44 | QSeries::QSeriesType type() const; |
|
44 | QAbstractSeries::QSeriesType type() const; | |
45 |
|
45 | |||
46 | MarkerShape shape() const; |
|
46 | MarkerShape shape() const; | |
47 | void setShape(MarkerShape shape); |
|
47 | void setShape(MarkerShape shape); | |
48 | qreal size() const; |
|
48 | qreal size() const; | |
49 | void setSize(qreal size); |
|
49 | void setSize(qreal size); | |
50 |
|
50 | |||
51 | private: |
|
51 | private: | |
52 | Q_DECLARE_PRIVATE(QScatterSeries); |
|
52 | Q_DECLARE_PRIVATE(QScatterSeries); | |
53 | Q_DISABLE_COPY(QScatterSeries); |
|
53 | Q_DISABLE_COPY(QScatterSeries); | |
54 | friend class ScatterChartItem; |
|
54 | friend class ScatterChartItem; | |
55 |
|
55 | |||
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | QTCOMMERCIALCHART_END_NAMESPACE |
|
58 | QTCOMMERCIALCHART_END_NAMESPACE | |
59 |
|
59 | |||
60 | #endif // QSCATTERSERIES_H |
|
60 | #endif // QSCATTERSERIES_H |
@@ -1,236 +1,236 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qsplineseries.h" |
|
21 | #include "qsplineseries.h" | |
22 | #include "qsplineseries_p.h" |
|
22 | #include "qsplineseries_p.h" | |
23 | #include "splinechartitem_p.h" |
|
23 | #include "splinechartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QSplineSeries |
|
29 | \class QSplineSeries | |
30 | \brief Series type used to store data needed to draw a spline. |
|
30 | \brief Series type used to store data needed to draw a spline. | |
31 |
|
31 | |||
32 | QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline |
|
32 | QSplineSeries stores the data points along with the segment control points needed by QPainterPath to draw spline | |
33 | Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn. |
|
33 | Control points are automatically calculated when data changes. The algorithm computes the points so that the normal spline can be drawn. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \fn QSeriesType QSplineSeries::type() const |
|
37 | \fn QSeriesType QSplineSeries::type() const | |
38 | Returns the type of the series |
|
38 | Returns the type of the series | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \fn QSeriesType QSplineSeries::controlPoint(int index) const |
|
42 | \fn QSeriesType QSplineSeries::controlPoint(int index) const | |
43 | Returns the control point specified by \a index |
|
43 | Returns the control point specified by \a index | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
46 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | Constructs empty series object which is a child of \a parent. |
|
49 | Constructs empty series object which is a child of \a parent. | |
50 | When series object is added to QChartView or QChart instance then the ownerships is transferred. |
|
50 | When series object is added to QChartView or QChart instance then the ownerships is transferred. | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | QSplineSeries::QSplineSeries(QObject *parent) : |
|
53 | QSplineSeries::QSplineSeries(QObject *parent) : | |
54 | QLineSeries(*new QSplineSeriesPrivate(this),parent) |
|
54 | QLineSeries(*new QSplineSeriesPrivate(this),parent) | |
55 | { |
|
55 | { | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | QSeries::QSeriesType QSplineSeries::type() const |
|
58 | QAbstractSeries::QSeriesType QSplineSeries::type() const | |
59 | { |
|
59 | { | |
60 | return QSeries::SeriesTypeSpline; |
|
60 | return QAbstractSeries::SeriesTypeSpline; | |
61 | } |
|
61 | } | |
62 |
|
62 | |||
63 | QPointF QSplineSeries::controlPoint(int index) const |
|
63 | QPointF QSplineSeries::controlPoint(int index) const | |
64 | { |
|
64 | { | |
65 | Q_D(const QSplineSeries); |
|
65 | Q_D(const QSplineSeries); | |
66 | return d->m_controlPoints[index]; |
|
66 | return d->m_controlPoints[index]; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void QSplineSeries::setModelMappingRange(int first, int count) |
|
69 | void QSplineSeries::setModelMappingRange(int first, int count) | |
70 | { |
|
70 | { | |
71 | Q_D(QSplineSeries); |
|
71 | Q_D(QSplineSeries); | |
72 | QLineSeries::setModelMappingRange(first, count); |
|
72 | QLineSeries::setModelMappingRange(first, count); | |
73 | d->calculateControlPoints(); |
|
73 | d->calculateControlPoints(); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
77 |
|
77 | |||
78 | QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(q) |
|
78 | QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(q) | |
79 | { |
|
79 | { | |
80 | QObject::connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); |
|
80 | QObject::connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); | |
81 | QObject::connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); |
|
81 | QObject::connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); | |
82 | QObject::connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); |
|
82 | QObject::connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); | |
83 | }; |
|
83 | }; | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \internal |
|
86 | \internal | |
87 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. |
|
87 | Calculates control points which are needed by QPainterPath.cubicTo function to draw the cubic Bezier cureve between two points. | |
88 | */ |
|
88 | */ | |
89 | void QSplineSeriesPrivate::calculateControlPoints() |
|
89 | void QSplineSeriesPrivate::calculateControlPoints() | |
90 | { |
|
90 | { | |
91 |
|
91 | |||
92 | Q_Q(QSplineSeries); |
|
92 | Q_Q(QSplineSeries); | |
93 | // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit |
|
93 | // Based on http://www.codeproject.com/Articles/31859/Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-wit | |
94 | // CPOL License |
|
94 | // CPOL License | |
95 |
|
95 | |||
96 | int n = q->count() - 1; |
|
96 | int n = q->count() - 1; | |
97 | if (n == 1) |
|
97 | if (n == 1) | |
98 | { // Special case: Bezier curve should be a straight line. |
|
98 | { // Special case: Bezier curve should be a straight line. | |
99 | // firstControlPoints = new Point[1]; |
|
99 | // firstControlPoints = new Point[1]; | |
100 | // 3P1 = 2P0 + P3 |
|
100 | // 3P1 = 2P0 + P3 | |
101 | m_controlPoints.append(QPointF((2 * q->x(0) + q->x(1)) / 3, (2 * q->y(0) + q->y(1)) / 3)); |
|
101 | m_controlPoints.append(QPointF((2 * q->x(0) + q->x(1)) / 3, (2 * q->y(0) + q->y(1)) / 3)); | |
102 |
|
102 | |||
103 | // P2 = 2P1 P0 |
|
103 | // P2 = 2P1 P0 | |
104 | m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - q->x(0), 2 * m_controlPoints[0].y() - q->y(0))); |
|
104 | m_controlPoints.append(QPointF(2 * m_controlPoints[0].x() - q->x(0), 2 * m_controlPoints[0].y() - q->y(0))); | |
105 | return; |
|
105 | return; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | // Calculate first Bezier control points |
|
108 | // Calculate first Bezier control points | |
109 | // Right hand side vector |
|
109 | // Right hand side vector | |
110 | // Set of equations for P0 to Pn points. |
|
110 | // Set of equations for P0 to Pn points. | |
111 | // |
|
111 | // | |
112 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | |
|
112 | // | 2 1 0 0 ... 0 0 0 ... 0 0 0 | | P1_1 | | P0 + 2 * P1 | | |
113 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | |
|
113 | // | 1 4 1 0 ... 0 0 0 ... 0 0 0 | | P1_2 | | 4 * P1 + 2 * P2 | | |
114 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | |
|
114 | // | 0 1 4 1 ... 0 0 0 ... 0 0 0 | | P1_3 | | 4 * P2 + 2 * P3 | | |
115 | // | . . . . . . . . . . . . | | ... | | ... | |
|
115 | // | . . . . . . . . . . . . | | ... | | ... | | |
116 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | |
|
116 | // | 0 0 0 0 ... 1 4 1 ... 0 0 0 | * | P1_i | = | 4 * P(i-1) + 2 * Pi | | |
117 | // | . . . . . . . . . . . . | | ... | | ... | |
|
117 | // | . . . . . . . . . . . . | | ... | | ... | | |
118 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | |
|
118 | // | 0 0 0 0 0 0 0 0 ... 1 4 1 | | P1_(n-1)| | 4 * P(n-2) + 2 * P(n-1) | | |
119 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | |
|
119 | // | 0 0 0 0 0 0 0 0 ... 0 2 7 | | P1_n | | 8 * P(n-1) + Pn | | |
120 | // |
|
120 | // | |
121 | QList<qreal> rhs; |
|
121 | QList<qreal> rhs; | |
122 | rhs.append(q->x(0) + 2 * q->x(1)); |
|
122 | rhs.append(q->x(0) + 2 * q->x(1)); | |
123 |
|
123 | |||
124 | // Set right hand side X values |
|
124 | // Set right hand side X values | |
125 | for (int i = 1; i < n - 1; ++i) |
|
125 | for (int i = 1; i < n - 1; ++i) | |
126 | rhs.append(4 * q->x(i) + 2 * q->x(i + 1)); |
|
126 | rhs.append(4 * q->x(i) + 2 * q->x(i + 1)); | |
127 |
|
127 | |||
128 | rhs.append((8 * q->x(n - 1) + q->x(n)) / 2.0); |
|
128 | rhs.append((8 * q->x(n - 1) + q->x(n)) / 2.0); | |
129 | // Get first control points X-values |
|
129 | // Get first control points X-values | |
130 | QList<qreal> xControl = getFirstControlPoints(rhs); |
|
130 | QList<qreal> xControl = getFirstControlPoints(rhs); | |
131 | rhs[0] = q->y(0) + 2 * q->y(1); |
|
131 | rhs[0] = q->y(0) + 2 * q->y(1); | |
132 |
|
132 | |||
133 | // Set right hand side Y values |
|
133 | // Set right hand side Y values | |
134 | for (int i = 1; i < n - 1; ++i) |
|
134 | for (int i = 1; i < n - 1; ++i) | |
135 | rhs[i] = 4 * q->y(i) + 2 * q->y(i + 1); |
|
135 | rhs[i] = 4 * q->y(i) + 2 * q->y(i + 1); | |
136 |
|
136 | |||
137 | rhs[n - 1] = (8 * q->y(n - 1) + q->y(n)) / 2.0; |
|
137 | rhs[n - 1] = (8 * q->y(n - 1) + q->y(n)) / 2.0; | |
138 | // Get first control points Y-values |
|
138 | // Get first control points Y-values | |
139 | QList<qreal> yControl = getFirstControlPoints(rhs); |
|
139 | QList<qreal> yControl = getFirstControlPoints(rhs); | |
140 |
|
140 | |||
141 | // Fill output arrays. |
|
141 | // Fill output arrays. | |
142 | for (int i = 0; i < n; ++i) { |
|
142 | for (int i = 0; i < n; ++i) { | |
143 | // First control point |
|
143 | // First control point | |
144 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); |
|
144 | m_controlPoints.append(QPointF(xControl[i], yControl[i])); | |
145 | // Second control point |
|
145 | // Second control point | |
146 | if (i < n - 1) |
|
146 | if (i < n - 1) | |
147 | m_controlPoints.append(QPointF(2 * q->x(i + 1) - xControl[i + 1], 2 * q->y(i + 1) - yControl[i + 1])); |
|
147 | m_controlPoints.append(QPointF(2 * q->x(i + 1) - xControl[i + 1], 2 * q->y(i + 1) - yControl[i + 1])); | |
148 | else |
|
148 | else | |
149 | m_controlPoints.append(QPointF((q->x(n) + xControl[n - 1]) / 2, (q->y(n) + yControl[n - 1]) / 2)); |
|
149 | m_controlPoints.append(QPointF((q->x(n) + xControl[n - 1]) / 2, (q->y(n) + yControl[n - 1]) / 2)); | |
150 | } |
|
150 | } | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | \internal |
|
154 | \internal | |
155 | */ |
|
155 | */ | |
156 | QList<qreal> QSplineSeriesPrivate::getFirstControlPoints(QList<qreal> rhs) |
|
156 | QList<qreal> QSplineSeriesPrivate::getFirstControlPoints(QList<qreal> rhs) | |
157 | { |
|
157 | { | |
158 | QList<qreal> x; // Solution vector. |
|
158 | QList<qreal> x; // Solution vector. | |
159 | QList<qreal> tmp; // Temp workspace. |
|
159 | QList<qreal> tmp; // Temp workspace. | |
160 |
|
160 | |||
161 | qreal b = 2.0; |
|
161 | qreal b = 2.0; | |
162 | x.append(rhs[0] / b); |
|
162 | x.append(rhs[0] / b); | |
163 | tmp.append(0); |
|
163 | tmp.append(0); | |
164 | for (int i = 1; i < rhs.size(); i++) { |
|
164 | for (int i = 1; i < rhs.size(); i++) { | |
165 | // Decomposition and forward substitution. |
|
165 | // Decomposition and forward substitution. | |
166 | tmp.append(1 / b); |
|
166 | tmp.append(1 / b); | |
167 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; |
|
167 | b = (i < rhs.size() - 1 ? 4.0 : 3.5) - tmp[i]; | |
168 | x.append((rhs[i] - x[i - 1]) / b); |
|
168 | x.append((rhs[i] - x[i - 1]) / b); | |
169 | } |
|
169 | } | |
170 | for (int i = 1; i < rhs.size(); i++) |
|
170 | for (int i = 1; i < rhs.size(); i++) | |
171 | x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution. |
|
171 | x[rhs.size() - i - 1] -= tmp[rhs.size() - i] * x[rhs.size() - i]; // Backsubstitution. | |
172 |
|
172 | |||
173 | return x; |
|
173 | return x; | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 | /*! |
|
176 | /*! | |
177 | \internal |
|
177 | \internal | |
178 | Updates the control points, besed on currently avaiable knots. |
|
178 | Updates the control points, besed on currently avaiable knots. | |
179 | */ |
|
179 | */ | |
180 | void QSplineSeriesPrivate::updateControlPoints() |
|
180 | void QSplineSeriesPrivate::updateControlPoints() | |
181 | { |
|
181 | { | |
182 | Q_Q(QSplineSeries); |
|
182 | Q_Q(QSplineSeries); | |
183 | if (q->count() > 1) { |
|
183 | if (q->count() > 1) { | |
184 | m_controlPoints.clear(); |
|
184 | m_controlPoints.clear(); | |
185 | calculateControlPoints(); |
|
185 | calculateControlPoints(); | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 |
|
188 | |||
189 | /*//! |
|
189 | /*//! | |
190 | \fn bool QSplineSeries::setModel(QAbstractItemModel *model) |
|
190 | \fn bool QSplineSeries::setModel(QAbstractItemModel *model) | |
191 | Sets the \a model to be used as a data source |
|
191 | Sets the \a model to be used as a data source | |
192 | \sa setModelMapping(), setModelMappingRange() |
|
192 | \sa setModelMapping(), setModelMappingRange() | |
193 | */ |
|
193 | */ | |
194 | //bool QSplineSeries::setModel(QAbstractItemModel* model) |
|
194 | //bool QSplineSeries::setModel(QAbstractItemModel* model) | |
195 | //{ |
|
195 | //{ | |
196 | // QXYSeries::setModel(model); |
|
196 | // QXYSeries::setModel(model); | |
197 | //// calculateControlPoints(); |
|
197 | //// calculateControlPoints(); | |
198 | // return true; |
|
198 | // return true; | |
199 | //} |
|
199 | //} | |
200 |
|
200 | |||
201 | /*//! |
|
201 | /*//! | |
202 | \fn bool QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
202 | \fn bool QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
203 | Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used |
|
203 | Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used | |
204 | as a data source for y coordinate. The \a orientation parameter specifies whether the data |
|
204 | as a data source for y coordinate. The \a orientation parameter specifies whether the data | |
205 | is in columns or in rows. |
|
205 | is in columns or in rows. | |
206 | */ |
|
206 | */ | |
207 | //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
207 | //void QSplineSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
208 | //{ |
|
208 | //{ | |
209 | // QLineSeries::setModelMapping(modelX, modelY, orientation); |
|
209 | // QLineSeries::setModelMapping(modelX, modelY, orientation); | |
210 | //// calculateControlPoints(); |
|
210 | //// calculateControlPoints(); | |
211 | //} |
|
211 | //} | |
212 |
|
212 | |||
213 | /*! |
|
213 | /*! | |
214 | \fn bool QSplineSeries::setModelMappingRange(int first, int count) |
|
214 | \fn bool QSplineSeries::setModelMappingRange(int first, int count) | |
215 | Allows limiting the model mapping. |
|
215 | Allows limiting the model mapping. | |
216 | Parameter \a first specifies which element of the model should be used as a first one of the series. |
|
216 | Parameter \a first specifies which element of the model should be used as a first one of the series. | |
217 | Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1) |
|
217 | Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1) | |
218 | then all the items following \a first item in a model are used. |
|
218 | then all the items following \a first item in a model are used. | |
219 | \sa setModel(), setModelMapping() |
|
219 | \sa setModel(), setModelMapping() | |
220 | */ |
|
220 | */ | |
221 |
|
221 | |||
222 | Chart* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
222 | Chart* QSplineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
223 | { |
|
223 | { | |
224 | Q_Q(QSplineSeries); |
|
224 | Q_Q(QSplineSeries); | |
225 | SplineChartItem* spline = new SplineChartItem(q,presenter); |
|
225 | SplineChartItem* spline = new SplineChartItem(q,presenter); | |
226 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
226 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
227 | presenter->animator()->addAnimation(spline); |
|
227 | presenter->animator()->addAnimation(spline); | |
228 | } |
|
228 | } | |
229 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
229 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
230 | return spline; |
|
230 | return spline; | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | #include "moc_qsplineseries.cpp" |
|
233 | #include "moc_qsplineseries.cpp" | |
234 | #include "moc_qsplineseries_p.cpp" |
|
234 | #include "moc_qsplineseries_p.cpp" | |
235 |
|
235 | |||
236 | QTCOMMERCIALCHART_END_NAMESPACE |
|
236 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,53 +1,53 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QSPLINESERIES_H |
|
21 | #ifndef QSPLINESERIES_H | |
22 | #define QSPLINESERIES_H |
|
22 | #define QSPLINESERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qlineseries.h> |
|
25 | #include <qlineseries.h> | |
26 | #include <QList> |
|
26 | #include <QList> | |
27 | #include <QPointF> |
|
27 | #include <QPointF> | |
28 | #include <QtGlobal> |
|
28 | #include <QtGlobal> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSplineSeriesPrivate; |
|
32 | class QSplineSeriesPrivate; | |
33 |
|
33 | |||
34 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries |
|
34 | class QTCOMMERCIALCHART_EXPORT QSplineSeries : public QLineSeries | |
35 | { |
|
35 | { | |
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 | public: |
|
37 | public: | |
38 |
|
38 | |||
39 | explicit QSplineSeries(QObject *parent = 0); |
|
39 | explicit QSplineSeries(QObject *parent = 0); | |
40 | QSeries::QSeriesType type() const; |
|
40 | QAbstractSeries::QSeriesType type() const; | |
41 |
|
41 | |||
42 | QPointF controlPoint(int index) const; |
|
42 | QPointF controlPoint(int index) const; | |
43 | void setModelMappingRange(int first, int count); |
|
43 | void setModelMappingRange(int first, int count); | |
44 |
|
44 | |||
45 | private: |
|
45 | private: | |
46 | Q_DECLARE_PRIVATE(QSplineSeries); |
|
46 | Q_DECLARE_PRIVATE(QSplineSeries); | |
47 | Q_DISABLE_COPY(QSplineSeries); |
|
47 | Q_DISABLE_COPY(QSplineSeries); | |
48 | friend class SplineChartItem; |
|
48 | friend class SplineChartItem; | |
49 | }; |
|
49 | }; | |
50 |
|
50 | |||
51 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | QTCOMMERCIALCHART_END_NAMESPACE | |
52 |
|
52 | |||
53 | #endif // QSPLINESERIES_H |
|
53 | #endif // QSPLINESERIES_H |
@@ -1,167 +1,167 | |||||
1 | !include( ../common.pri ):error( Couldn't find the common.pri file! ) |
|
1 | !include( ../common.pri ):error( Couldn't find the common.pri file! ) | |
2 | TARGET = QtCommercialChart |
|
2 | TARGET = QtCommercialChart | |
3 | DESTDIR = $$CHART_BUILD_LIB_DIR |
|
3 | DESTDIR = $$CHART_BUILD_LIB_DIR | |
4 | TEMPLATE = lib |
|
4 | TEMPLATE = lib | |
5 | QT += core \ |
|
5 | QT += core \ | |
6 | gui |
|
6 | gui | |
7 | win32-msvc*: LIBS += User32.lib |
|
7 | win32-msvc*: LIBS += User32.lib | |
8 | CONFIG += debug_and_release |
|
8 | CONFIG += debug_and_release | |
9 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd |
|
9 | CONFIG(debug, debug|release):TARGET = QtCommercialChartd | |
10 | SOURCES += \ |
|
10 | SOURCES += \ | |
11 | $$PWD/chartdataset.cpp \ |
|
11 | $$PWD/chartdataset.cpp \ | |
12 | $$PWD/chartpresenter.cpp \ |
|
12 | $$PWD/chartpresenter.cpp \ | |
13 | $$PWD/charttheme.cpp \ |
|
13 | $$PWD/charttheme.cpp \ | |
14 | $$PWD/domain.cpp \ |
|
14 | $$PWD/domain.cpp \ | |
15 | $$PWD/qchart.cpp \ |
|
15 | $$PWD/qchart.cpp \ | |
16 | $$PWD/qchartview.cpp \ |
|
16 | $$PWD/qchartview.cpp \ | |
17 | $$PWD/qseries.cpp \ |
|
17 | $$PWD/qabstractseries.cpp \ | |
18 | $$PWD/chartbackground.cpp \ |
|
18 | $$PWD/chartbackground.cpp \ | |
19 | $$PWD/chart.cpp \ |
|
19 | $$PWD/chart.cpp \ | |
20 | $$PWD/scroller.cpp |
|
20 | $$PWD/scroller.cpp | |
21 | PRIVATE_HEADERS += \ |
|
21 | PRIVATE_HEADERS += \ | |
22 | $$PWD/chartdataset_p.h \ |
|
22 | $$PWD/chartdataset_p.h \ | |
23 | $$PWD/chartitem_p.h \ |
|
23 | $$PWD/chartitem_p.h \ | |
24 | $$PWD/chartpresenter_p.h \ |
|
24 | $$PWD/chartpresenter_p.h \ | |
25 | $$PWD/charttheme_p.h \ |
|
25 | $$PWD/charttheme_p.h \ | |
26 | $$PWD/domain_p.h \ |
|
26 | $$PWD/domain_p.h \ | |
27 | $$PWD/chartbackground_p.h \ |
|
27 | $$PWD/chartbackground_p.h \ | |
28 | $$PWD/chart_p.h \ |
|
28 | $$PWD/chart_p.h \ | |
29 | $$PWD/chartconfig_p.h \ |
|
29 | $$PWD/chartconfig_p.h \ | |
30 | $$PWD/qchart_p.h \ |
|
30 | $$PWD/qchart_p.h \ | |
31 | $$PWD/qchartview_p.h \ |
|
31 | $$PWD/qchartview_p.h \ | |
32 | $$PWD/scroller_p.h \ |
|
32 | $$PWD/scroller_p.h \ | |
33 |
$$PWD/qseries_p.h |
|
33 | $$PWD/qabstractseries_p.h | |
34 | PUBLIC_HEADERS += \ |
|
34 | PUBLIC_HEADERS += \ | |
35 | $$PWD/qchart.h \ |
|
35 | $$PWD/qchart.h \ | |
36 | $$PWD/qchartglobal.h \ |
|
36 | $$PWD/qchartglobal.h \ | |
37 | $$PWD/qseries.h \ |
|
37 | $$PWD/qabstractseries.h \ | |
38 | $$PWD/qchartview.h |
|
38 | $$PWD/qchartview.h | |
39 |
|
39 | |||
40 | include(animations/animations.pri) |
|
40 | include(animations/animations.pri) | |
41 | include(areachart/areachart.pri) |
|
41 | include(areachart/areachart.pri) | |
42 | include(axis/axis.pri) |
|
42 | include(axis/axis.pri) | |
43 | include(barchart/barchart.pri) |
|
43 | include(barchart/barchart.pri) | |
44 | include(legend/legend.pri) |
|
44 | include(legend/legend.pri) | |
45 | include(linechart/linechart.pri) |
|
45 | include(linechart/linechart.pri) | |
46 | include(piechart/piechart.pri) |
|
46 | include(piechart/piechart.pri) | |
47 | include(scatterseries/scatter.pri) |
|
47 | include(scatterseries/scatter.pri) | |
48 | include(splinechart/splinechart.pri) |
|
48 | include(splinechart/splinechart.pri) | |
49 | include(themes/themes.pri) |
|
49 | include(themes/themes.pri) | |
50 | include(xychart/xychart.pri) |
|
50 | include(xychart/xychart.pri) | |
51 |
|
51 | |||
52 | HEADERS += $$PUBLIC_HEADERS |
|
52 | HEADERS += $$PUBLIC_HEADERS | |
53 | HEADERS += $$PRIVATE_HEADERS |
|
53 | HEADERS += $$PRIVATE_HEADERS | |
54 | HEADERS += $$THEMES |
|
54 | HEADERS += $$THEMES | |
55 | INCLUDEPATH += ../include . |
|
55 | INCLUDEPATH += ../include . | |
56 |
|
56 | |||
57 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
|
57 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib | |
58 | MOC_DIR = $$CHART_BUILD_DIR/lib |
|
58 | MOC_DIR = $$CHART_BUILD_DIR/lib | |
59 | UI_DIR = $$CHART_BUILD_DIR/lib |
|
59 | UI_DIR = $$CHART_BUILD_DIR/lib | |
60 | RCC_DIR = $$CHART_BUILD_DIR/lib |
|
60 | RCC_DIR = $$CHART_BUILD_DIR/lib | |
61 | DEFINES += QTCOMMERCIALCHART_LIBRARY |
|
61 | DEFINES += QTCOMMERCIALCHART_LIBRARY | |
62 |
|
62 | |||
63 | #qt public headers |
|
63 | #qt public headers | |
64 | #this is very primitive and lame parser , TODO: make perl script insted |
|
64 | #this is very primitive and lame parser , TODO: make perl script insted | |
65 | !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal) |
|
65 | !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal) | |
66 | { |
|
66 | { | |
67 | system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR) |
|
67 | system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR) | |
68 | win32:{ |
|
68 | win32:{ | |
69 | command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" |
|
69 | command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" | |
70 | }else{ |
|
70 | }else{ | |
71 | command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" |
|
71 | command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" | |
72 | } |
|
72 | } | |
73 | system($$command) |
|
73 | system($$command) | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | for(file, PUBLIC_HEADERS) { |
|
76 | for(file, PUBLIC_HEADERS) { | |
77 | name = $$split(file,'/') |
|
77 | name = $$split(file,'/') | |
78 | name = $$last(name) |
|
78 | name = $$last(name) | |
79 | class = "$$cat($$file)" |
|
79 | class = "$$cat($$file)" | |
80 | class = $$find(class,class) |
|
80 | class = $$find(class,class) | |
81 | !isEmpty(class){ |
|
81 | !isEmpty(class){ | |
82 | class = $$split(class,QTCOMMERCIALCHART_EXPORT) |
|
82 | class = $$split(class,QTCOMMERCIALCHART_EXPORT) | |
83 | class = $$member(class,1) |
|
83 | class = $$member(class,1) | |
84 | class = $$split(class,' ') |
|
84 | class = $$split(class,' ') | |
85 | class = $$replace(class,' ','') |
|
85 | class = $$replace(class,' ','') | |
86 | class = $$member(class,0) |
|
86 | class = $$member(class,0) | |
87 | win32:{ |
|
87 | win32:{ | |
88 | command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" |
|
88 | command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" | |
89 | }else{ |
|
89 | }else{ | |
90 | command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" |
|
90 | command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" | |
91 | } |
|
91 | } | |
92 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class |
|
92 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class | |
93 | system($$command) |
|
93 | system($$command) | |
94 | } |
|
94 | } | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart |
|
97 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart | |
98 | public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS |
|
98 | public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS | |
99 |
|
99 | |||
100 | target.path = $$[QT_INSTALL_LIBS] |
|
100 | target.path = $$[QT_INSTALL_LIBS] | |
101 | INSTALLS += target public_headers |
|
101 | INSTALLS += target public_headers | |
102 |
|
102 | |||
103 | install_build_public_headers.name = build_public_headers |
|
103 | install_build_public_headers.name = build_public_headers | |
104 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
104 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
105 | install_build_public_headers.input = PUBLIC_HEADERS |
|
105 | install_build_public_headers.input = PUBLIC_HEADERS | |
106 | install_build_public_headers.commands = $$QMAKE_COPY \ |
|
106 | install_build_public_headers.commands = $$QMAKE_COPY \ | |
107 | ${QMAKE_FILE_NAME} \ |
|
107 | ${QMAKE_FILE_NAME} \ | |
108 | $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
108 | $$CHART_BUILD_PUBLIC_HEADER_DIR | |
109 | install_build_public_headers.CONFIG += target_predeps \ |
|
109 | install_build_public_headers.CONFIG += target_predeps \ | |
110 | no_link |
|
110 | no_link | |
111 |
|
111 | |||
112 | install_build_private_headers.name = buld_private_headers |
|
112 | install_build_private_headers.name = buld_private_headers | |
113 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
113 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
114 | install_build_private_headers.input = PRIVATE_HEADERS |
|
114 | install_build_private_headers.input = PRIVATE_HEADERS | |
115 | install_build_private_headers.commands = $$QMAKE_COPY \ |
|
115 | install_build_private_headers.commands = $$QMAKE_COPY \ | |
116 | ${QMAKE_FILE_NAME} \ |
|
116 | ${QMAKE_FILE_NAME} \ | |
117 | $$CHART_BUILD_PRIVATE_HEADER_DIR |
|
117 | $$CHART_BUILD_PRIVATE_HEADER_DIR | |
118 | install_build_private_headers.CONFIG += target_predeps \ |
|
118 | install_build_private_headers.CONFIG += target_predeps \ | |
119 | no_link |
|
119 | no_link | |
120 |
|
120 | |||
121 | QMAKE_EXTRA_COMPILERS += install_build_public_headers \ |
|
121 | QMAKE_EXTRA_COMPILERS += install_build_public_headers \ | |
122 | install_build_private_headers \ |
|
122 | install_build_private_headers \ | |
123 |
|
123 | |||
124 |
|
124 | |||
125 | !win32-msvc*: { |
|
125 | !win32-msvc*: { | |
126 |
|
126 | |||
127 | # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly. |
|
127 | # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly. | |
128 | # This is the case at least with shadow builds. |
|
128 | # This is the case at least with shadow builds. | |
129 | # http://qt-project.org/wiki/jom |
|
129 | # http://qt-project.org/wiki/jom | |
130 |
|
130 | |||
131 | chartversion.target = $$PWD/qchartversion_p.h |
|
131 | chartversion.target = $$PWD/qchartversion_p.h | |
132 |
|
132 | |||
133 | unix:{ |
|
133 | unix:{ | |
134 | chartversion.commands = @echo \ |
|
134 | chartversion.commands = @echo \ | |
135 | "const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" \\; \ |
|
135 | "const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" \\; \ | |
136 | const char *gitHead = \\\"`git rev-parse HEAD`\\\" \\; " \ |
|
136 | const char *gitHead = \\\"`git rev-parse HEAD`\\\" \\; " \ | |
137 | > \ |
|
137 | > \ | |
138 | $$chartversion.target; |
|
138 | $$chartversion.target; | |
139 | }else{ |
|
139 | }else{ | |
140 | chartversion.commands = @echo \ |
|
140 | chartversion.commands = @echo \ | |
141 | "const char *buildTime = \"%date%_%time%\" ; \ |
|
141 | "const char *buildTime = \"%date%_%time%\" ; \ | |
142 | const char *gitHead = \"unknown\" ; " \ |
|
142 | const char *gitHead = \"unknown\" ; " \ | |
143 | > \ |
|
143 | > \ | |
144 | $$chartversion.target |
|
144 | $$chartversion.target | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | chartversion.depends = $$HEADERS \ |
|
147 | chartversion.depends = $$HEADERS \ | |
148 | $$SOURCES |
|
148 | $$SOURCES | |
149 |
|
149 | |||
150 | PRE_TARGETDEPS += $$PWD/qchartversion_p.h |
|
150 | PRE_TARGETDEPS += $$PWD/qchartversion_p.h | |
151 | QMAKE_CLEAN += $$PWD/qchartversion_p.h |
|
151 | QMAKE_CLEAN += $$PWD/qchartversion_p.h | |
152 | QMAKE_EXTRA_TARGETS += chartversion |
|
152 | QMAKE_EXTRA_TARGETS += chartversion | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | unix:QMAKE_DISTCLEAN += -r \ |
|
155 | unix:QMAKE_DISTCLEAN += -r \ | |
156 | $$CHART_BUILD_HEADER_DIR \ |
|
156 | $$CHART_BUILD_HEADER_DIR \ | |
157 | $$CHART_BUILD_LIB_DIR |
|
157 | $$CHART_BUILD_LIB_DIR | |
158 | win32:QMAKE_DISTCLEAN += /Q \ |
|
158 | win32:QMAKE_DISTCLEAN += /Q \ | |
159 | $$CHART_BUILD_HEADER_DIR \ |
|
159 | $$CHART_BUILD_HEADER_DIR \ | |
160 | $$CHART_BUILD_LIB_DIR |
|
160 | $$CHART_BUILD_LIB_DIR | |
161 |
|
161 | |||
162 | # treat warnings as errors |
|
162 | # treat warnings as errors | |
163 | win32-msvc*: { |
|
163 | win32-msvc*: { | |
164 | QMAKE_CXXFLAGS += /WX |
|
164 | QMAKE_CXXFLAGS += /WX | |
165 | } else { |
|
165 | } else { | |
166 | QMAKE_CXXFLAGS += -Werror |
|
166 | QMAKE_CXXFLAGS += -Werror | |
167 | } |
|
167 | } |
@@ -1,671 +1,670 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "domain_p.h" |
|
23 | #include "domain_p.h" | |
24 | #include "legendmarker_p.h" |
|
24 | #include "legendmarker_p.h" | |
25 | #include <QAbstractItemModel> |
|
25 | #include <QAbstractItemModel> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | /*! |
|
29 | /*! | |
30 | \class QXYSeries |
|
30 | \class QXYSeries | |
31 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
31 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
32 | */ |
|
32 | */ | |
33 |
|
33 | |||
34 | /*! |
|
34 | /*! | |
35 | \fn QPen QXYSeries::pen() const |
|
35 | \fn QPen QXYSeries::pen() const | |
36 | \brief Returns pen used to draw points for series. |
|
36 | \brief Returns pen used to draw points for series. | |
37 | \sa setPen() |
|
37 | \sa setPen() | |
38 | */ |
|
38 | */ | |
39 |
|
39 | |||
40 | /*! |
|
40 | /*! | |
41 | \fn QBrush QXYSeries::brush() const |
|
41 | \fn QBrush QXYSeries::brush() const | |
42 | \brief Returns brush used to draw points for series. |
|
42 | \brief Returns brush used to draw points for series. | |
43 | \sa setBrush() |
|
43 | \sa setBrush() | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | /*! |
|
46 | /*! | |
47 | \fn void QXYSeries::clicked(const QPointF& point) |
|
47 | \fn void QXYSeries::clicked(const QPointF& point) | |
48 | \brief Signal is emitted when user clicks the \a point on chart. |
|
48 | \brief Signal is emitted when user clicks the \a point on chart. | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | \fn void QXYSeries::selected() |
|
52 | \fn void QXYSeries::selected() | |
53 |
|
53 | |||
54 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
54 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
55 | implemented by the user of QXYSeries API. |
|
55 | implemented by the user of QXYSeries API. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn void QXYSeriesPrivate::pointReplaced(int index) |
|
59 | \fn void QXYSeriesPrivate::pointReplaced(int index) | |
60 | \brief \internal \a index |
|
60 | \brief \internal \a index | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \fn void QXYSeriesPrivate::pointAdded(int index) |
|
64 | \fn void QXYSeriesPrivate::pointAdded(int index) | |
65 | \brief \internal \a index |
|
65 | \brief \internal \a index | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \fn void QXYSeriesPrivate::pointRemoved(int index) |
|
69 | \fn void QXYSeriesPrivate::pointRemoved(int index) | |
70 | \brief \internal \a index |
|
70 | \brief \internal \a index | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \fn void QXYSeriesPrivate::updated() |
|
74 | \fn void QXYSeriesPrivate::updated() | |
75 | \brief \internal |
|
75 | \brief \internal | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \fn int QXYSeries::mapFirst() const |
|
79 | \fn int QXYSeries::mapFirst() const | |
80 | Returns the index of the model's item that is used as a first one for the series. |
|
80 | Returns the index of the model's item that is used as a first one for the series. | |
81 | \sa mapCount() |
|
81 | \sa mapCount() | |
82 | */ |
|
82 | */ | |
83 |
|
83 | |||
84 | /*! |
|
84 | /*! | |
85 | \fn int QXYSeries::mapCount() const |
|
85 | \fn int QXYSeries::mapCount() const | |
86 | Returns the number of the items that are taken from the model. |
|
86 | Returns the number of the items that are taken from the model. | |
87 | If -1 it means all the items of the model following the first one are used. |
|
87 | If -1 it means all the items of the model following the first one are used. | |
88 | \sa mapFirst() |
|
88 | \sa mapFirst() | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \internal |
|
92 | \internal | |
93 |
|
93 | |||
94 | Constructs empty series object which is a child of \a parent. |
|
94 | Constructs empty series object which is a child of \a parent. | |
95 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
95 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
96 | */ |
|
96 | */ | |
97 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent):QSeries(d,parent) |
|
97 | QXYSeries::QXYSeries(QXYSeriesPrivate &d,QObject *parent) : QAbstractSeries(d, parent) | |
98 | { |
|
98 | { | |
99 |
|
99 | |||
100 | } |
|
100 | } | |
101 | /*! |
|
101 | /*! | |
102 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
102 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
103 | and are deleted when mentioned object are destroyed. |
|
103 | and are deleted when mentioned object are destroyed. | |
104 | */ |
|
104 | */ | |
105 | QXYSeries::~QXYSeries() |
|
105 | QXYSeries::~QXYSeries() | |
106 | { |
|
106 | { | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
110 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
111 | */ |
|
111 | */ | |
112 | void QXYSeries::append(qreal x,qreal y) |
|
112 | void QXYSeries::append(qreal x,qreal y) | |
113 | { |
|
113 | { | |
114 | Q_D(QXYSeries); |
|
114 | Q_D(QXYSeries); | |
115 | Q_ASSERT(d->m_x.size() == d->m_y.size()); |
|
115 | Q_ASSERT(d->m_x.size() == d->m_y.size()); | |
116 | d->m_x<<x; |
|
116 | d->m_x<<x; | |
117 | d->m_y<<y; |
|
117 | d->m_y<<y; | |
118 | emit d->pointAdded(d->m_x.size()-1); |
|
118 | emit d->pointAdded(d->m_x.size()-1); | |
119 | } |
|
119 | } | |
120 |
|
120 | |||
121 | /*! |
|
121 | /*! | |
122 | This is an overloaded function. |
|
122 | This is an overloaded function. | |
123 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
123 | Adds data \a point to the series. Points are connected with lines on the chart. | |
124 | */ |
|
124 | */ | |
125 | void QXYSeries::append(const QPointF &point) |
|
125 | void QXYSeries::append(const QPointF &point) | |
126 | { |
|
126 | { | |
127 | append(point.x(),point.y()); |
|
127 | append(point.x(),point.y()); | |
128 | } |
|
128 | } | |
129 |
|
129 | |||
130 | /*! |
|
130 | /*! | |
131 | This is an overloaded function. |
|
131 | This is an overloaded function. | |
132 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
132 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
133 | */ |
|
133 | */ | |
134 | void QXYSeries::append(const QList<QPointF> points) |
|
134 | void QXYSeries::append(const QList<QPointF> points) | |
135 | { |
|
135 | { | |
136 | foreach(const QPointF& point , points) { |
|
136 | foreach(const QPointF& point , points) { | |
137 | append(point.x(),point.y()); |
|
137 | append(point.x(),point.y()); | |
138 | } |
|
138 | } | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | Modifies \a y value for given \a x a value. |
|
142 | Modifies \a y value for given \a x a value. | |
143 | */ |
|
143 | */ | |
144 | void QXYSeries::replace(qreal x,qreal y) |
|
144 | void QXYSeries::replace(qreal x,qreal y) | |
145 | { |
|
145 | { | |
146 | Q_D(QXYSeries); |
|
146 | Q_D(QXYSeries); | |
147 | int index = d->m_x.indexOf(x); |
|
147 | int index = d->m_x.indexOf(x); | |
148 | d->m_x[index] = x; |
|
148 | d->m_x[index] = x; | |
149 | d->m_y[index] = y; |
|
149 | d->m_y[index] = y; | |
150 | emit d->pointReplaced(index); |
|
150 | emit d->pointReplaced(index); | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | This is an overloaded function. |
|
154 | This is an overloaded function. | |
155 | Replaces current y value of for given \a point x value with \a point y value. |
|
155 | Replaces current y value of for given \a point x value with \a point y value. | |
156 | */ |
|
156 | */ | |
157 | void QXYSeries::replace(const QPointF &point) |
|
157 | void QXYSeries::replace(const QPointF &point) | |
158 | { |
|
158 | { | |
159 | replace(point.x(),point.y()); |
|
159 | replace(point.x(),point.y()); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | /*! |
|
162 | /*! | |
163 | Removes first \a x value and related y value. |
|
163 | Removes first \a x value and related y value. | |
164 | */ |
|
164 | */ | |
165 | void QXYSeries::remove(qreal x) |
|
165 | void QXYSeries::remove(qreal x) | |
166 | { |
|
166 | { | |
167 | Q_D(QXYSeries); |
|
167 | Q_D(QXYSeries); | |
168 | int index = d->m_x.indexOf(x); |
|
168 | int index = d->m_x.indexOf(x); | |
169 |
|
169 | |||
170 | if (index == -1) return; |
|
170 | if (index == -1) return; | |
171 |
|
171 | |||
172 | d->m_x.remove(index); |
|
172 | d->m_x.remove(index); | |
173 | d->m_y.remove(index); |
|
173 | d->m_y.remove(index); | |
174 |
|
174 | |||
175 | emit d->pointRemoved(index); |
|
175 | emit d->pointRemoved(index); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | /*! |
|
178 | /*! | |
179 | Removes current \a x and \a y value. |
|
179 | Removes current \a x and \a y value. | |
180 | */ |
|
180 | */ | |
181 | void QXYSeries::remove(qreal x,qreal y) |
|
181 | void QXYSeries::remove(qreal x,qreal y) | |
182 | { |
|
182 | { | |
183 | Q_D(QXYSeries); |
|
183 | Q_D(QXYSeries); | |
184 | int index =-1; |
|
184 | int index =-1; | |
185 | do { |
|
185 | do { | |
186 | index = d->m_x.indexOf(x,index+1); |
|
186 | index = d->m_x.indexOf(x,index+1); | |
187 | } while (index !=-1 && d->m_y.at(index)!=y); |
|
187 | } while (index !=-1 && d->m_y.at(index)!=y); | |
188 |
|
188 | |||
189 | if (index==-1) return; |
|
189 | if (index==-1) return; | |
190 |
|
190 | |||
191 | d->m_x.remove(index); |
|
191 | d->m_x.remove(index); | |
192 | d->m_y.remove(index); |
|
192 | d->m_y.remove(index); | |
193 | emit d->pointRemoved(index); |
|
193 | emit d->pointRemoved(index); | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | /*! |
|
196 | /*! | |
197 | Removes current \a point x value. Note \a point y value is ignored. |
|
197 | Removes current \a point x value. Note \a point y value is ignored. | |
198 | */ |
|
198 | */ | |
199 | void QXYSeries::remove(const QPointF &point) |
|
199 | void QXYSeries::remove(const QPointF &point) | |
200 | { |
|
200 | { | |
201 | remove(point.x(),point.y()); |
|
201 | remove(point.x(),point.y()); | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | Removes all data points from the series. |
|
205 | Removes all data points from the series. | |
206 | */ |
|
206 | */ | |
207 | void QXYSeries::removeAll() |
|
207 | void QXYSeries::removeAll() | |
208 | { |
|
208 | { | |
209 | Q_D(QXYSeries); |
|
209 | Q_D(QXYSeries); | |
210 | d->m_x.clear(); |
|
210 | d->m_x.clear(); | |
211 | d->m_y.clear(); |
|
211 | d->m_y.clear(); | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | \internal \a pos |
|
215 | \internal \a pos | |
216 | */ |
|
216 | */ | |
217 | qreal QXYSeries::x(int pos) const |
|
217 | qreal QXYSeries::x(int pos) const | |
218 | { |
|
218 | { | |
219 | Q_D(const QXYSeries); |
|
219 | Q_D(const QXYSeries); | |
220 | if (d->m_model) { |
|
220 | if (d->m_model) { | |
221 | if (d->m_mapOrientation == Qt::Vertical) |
|
221 | if (d->m_mapOrientation == Qt::Vertical) | |
222 | // consecutive data is read from model's column |
|
222 | // consecutive data is read from model's column | |
223 | return d->m_model->data(d->m_model->index(pos + d->m_mapFirst, d->m_mapX), Qt::DisplayRole).toDouble(); |
|
223 | return d->m_model->data(d->m_model->index(pos + d->m_mapFirst, d->m_mapX), Qt::DisplayRole).toDouble(); | |
224 | else |
|
224 | else | |
225 | // consecutive data is read from model's row |
|
225 | // consecutive data is read from model's row | |
226 | return d->m_model->data(d->m_model->index(d->m_mapX, pos + d->m_mapFirst), Qt::DisplayRole).toDouble(); |
|
226 | return d->m_model->data(d->m_model->index(d->m_mapX, pos + d->m_mapFirst), Qt::DisplayRole).toDouble(); | |
227 | } else { |
|
227 | } else { | |
228 | // model is not specified, return the data from series' internal data store |
|
228 | // model is not specified, return the data from series' internal data store | |
229 | return d->m_x.at(pos); |
|
229 | return d->m_x.at(pos); | |
230 | } |
|
230 | } | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | /*! |
|
233 | /*! | |
234 | \internal \a pos |
|
234 | \internal \a pos | |
235 | */ |
|
235 | */ | |
236 | qreal QXYSeries::y(int pos) const |
|
236 | qreal QXYSeries::y(int pos) const | |
237 | { |
|
237 | { | |
238 | Q_D(const QXYSeries); |
|
238 | Q_D(const QXYSeries); | |
239 | if (d->m_model) { |
|
239 | if (d->m_model) { | |
240 | if (d->m_mapOrientation == Qt::Vertical) |
|
240 | if (d->m_mapOrientation == Qt::Vertical) | |
241 | // consecutive data is read from model's column |
|
241 | // consecutive data is read from model's column | |
242 | return d->m_model->data(d->m_model->index(pos + d->m_mapFirst, d->m_mapY), Qt::DisplayRole).toDouble(); |
|
242 | return d->m_model->data(d->m_model->index(pos + d->m_mapFirst, d->m_mapY), Qt::DisplayRole).toDouble(); | |
243 | else |
|
243 | else | |
244 | // consecutive data is read from model's row |
|
244 | // consecutive data is read from model's row | |
245 | return d->m_model->data(d->m_model->index(d->m_mapY, pos + d->m_mapFirst), Qt::DisplayRole).toDouble(); |
|
245 | return d->m_model->data(d->m_model->index(d->m_mapY, pos + d->m_mapFirst), Qt::DisplayRole).toDouble(); | |
246 | } else { |
|
246 | } else { | |
247 | // model is not specified, return the data from series' internal data store |
|
247 | // model is not specified, return the data from series' internal data store | |
248 | return d->m_y.at(pos); |
|
248 | return d->m_y.at(pos); | |
249 | } |
|
249 | } | |
250 | } |
|
250 | } | |
251 |
|
251 | |||
252 | /*! |
|
252 | /*! | |
253 | Returns number of data points within series. |
|
253 | Returns number of data points within series. | |
254 | */ |
|
254 | */ | |
255 | int QXYSeries::count() const |
|
255 | int QXYSeries::count() const | |
256 | { |
|
256 | { | |
257 | Q_D(const QXYSeries); |
|
257 | Q_D(const QXYSeries); | |
258 |
|
258 | |||
259 | Q_ASSERT(d->m_x.size() == d->m_y.size()); |
|
259 | Q_ASSERT(d->m_x.size() == d->m_y.size()); | |
260 |
|
260 | |||
261 | if (d->m_model) { |
|
261 | if (d->m_model) { | |
262 | if (d->m_mapOrientation == Qt::Vertical) { |
|
262 | if (d->m_mapOrientation == Qt::Vertical) { | |
263 | // data is in a column. Return the number of mapped items if the model's column have enough items |
|
263 | // data is in a column. Return the number of mapped items if the model's column have enough items | |
264 | // or the number of items that can be mapped |
|
264 | // or the number of items that can be mapped | |
265 | if (d->m_mapLimited) |
|
265 | if (d->m_mapLimited) | |
266 | return qMin(d->m_mapCount, qMax(d->m_model->rowCount() - d->m_mapFirst, 0)); |
|
266 | return qMin(d->m_mapCount, qMax(d->m_model->rowCount() - d->m_mapFirst, 0)); | |
267 | else |
|
267 | else | |
268 | return qMax(d->m_model->rowCount() - d->m_mapFirst, 0); |
|
268 | return qMax(d->m_model->rowCount() - d->m_mapFirst, 0); | |
269 | } else { |
|
269 | } else { | |
270 | // data is in a row. Return the number of mapped items if the model's row have enough items |
|
270 | // data is in a row. Return the number of mapped items if the model's row have enough items | |
271 | // or the number of items that can be mapped |
|
271 | // or the number of items that can be mapped | |
272 | if (d->m_mapLimited) |
|
272 | if (d->m_mapLimited) | |
273 | return qMin(d->m_mapCount, qMax(d->m_model->columnCount() - d->m_mapFirst, 0)); |
|
273 | return qMin(d->m_mapCount, qMax(d->m_model->columnCount() - d->m_mapFirst, 0)); | |
274 | else |
|
274 | else | |
275 | return qMax(d->m_model->columnCount() - d->m_mapFirst, 0); |
|
275 | return qMax(d->m_model->columnCount() - d->m_mapFirst, 0); | |
276 | } |
|
276 | } | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | // model is not specified, return the number of points in the series internal data store |
|
279 | // model is not specified, return the number of points in the series internal data store | |
280 | return d->m_x.size(); |
|
280 | return d->m_x.size(); | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | /*! |
|
283 | /*! | |
284 | Returns the data points of the series. |
|
284 | Returns the data points of the series. | |
285 | */ |
|
285 | */ | |
286 | QList<QPointF> QXYSeries::data() |
|
286 | QList<QPointF> QXYSeries::data() | |
287 | { |
|
287 | { | |
288 | Q_D(QXYSeries); |
|
288 | Q_D(QXYSeries); | |
289 | QList<QPointF> data; |
|
289 | QList<QPointF> data; | |
290 | for (int i(0); i < d->m_x.count() && i < d->m_y.count(); i++) |
|
290 | for (int i(0); i < d->m_x.count() && i < d->m_y.count(); i++) | |
291 | data.append(QPointF(d->m_x.at(i), d->m_y.at(i))); |
|
291 | data.append(QPointF(d->m_x.at(i), d->m_y.at(i))); | |
292 | return data; |
|
292 | return data; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 |
|
295 | |||
296 | /*! |
|
296 | /*! | |
297 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
297 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
298 | pen from chart theme is used. |
|
298 | pen from chart theme is used. | |
299 | \sa QChart::setTheme() |
|
299 | \sa QChart::setTheme() | |
300 | */ |
|
300 | */ | |
301 | void QXYSeries::setPen(const QPen &pen) |
|
301 | void QXYSeries::setPen(const QPen &pen) | |
302 | { |
|
302 | { | |
303 | Q_D(QXYSeries); |
|
303 | Q_D(QXYSeries); | |
304 | if (d->m_pen!=pen) { |
|
304 | if (d->m_pen!=pen) { | |
305 | d->m_pen = pen; |
|
305 | d->m_pen = pen; | |
306 | emit d->updated(); |
|
306 | emit d->updated(); | |
307 | } |
|
307 | } | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | QPen QXYSeries::pen() const |
|
310 | QPen QXYSeries::pen() const | |
311 | { |
|
311 | { | |
312 | Q_D(const QXYSeries); |
|
312 | Q_D(const QXYSeries); | |
313 | return d->m_pen; |
|
313 | return d->m_pen; | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | /*! |
|
316 | /*! | |
317 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
317 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
318 | from chart theme setting is used. |
|
318 | from chart theme setting is used. | |
319 | \sa QChart::setTheme() |
|
319 | \sa QChart::setTheme() | |
320 | */ |
|
320 | */ | |
321 | void QXYSeries::setBrush(const QBrush &brush) |
|
321 | void QXYSeries::setBrush(const QBrush &brush) | |
322 | { |
|
322 | { | |
323 | Q_D(QXYSeries); |
|
323 | Q_D(QXYSeries); | |
324 | if (d->m_brush!=brush) { |
|
324 | if (d->m_brush!=brush) { | |
325 | d->m_brush = brush; |
|
325 | d->m_brush = brush; | |
326 | emit d->updated(); |
|
326 | emit d->updated(); | |
327 | } |
|
327 | } | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | QBrush QXYSeries::brush() const |
|
330 | QBrush QXYSeries::brush() const | |
331 | { |
|
331 | { | |
332 | Q_D(const QXYSeries); |
|
332 | Q_D(const QXYSeries); | |
333 | return d->m_brush; |
|
333 | return d->m_brush; | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 |
|
336 | |||
337 | /*! |
|
337 | /*! | |
338 | Sets if data points are \a visible and should be drawn on line. |
|
338 | Sets if data points are \a visible and should be drawn on line. | |
339 | */ |
|
339 | */ | |
340 | void QXYSeries::setPointsVisible(bool visible) |
|
340 | void QXYSeries::setPointsVisible(bool visible) | |
341 | { |
|
341 | { | |
342 | Q_D(QXYSeries); |
|
342 | Q_D(QXYSeries); | |
343 | if (d->m_pointsVisible != visible){ |
|
343 | if (d->m_pointsVisible != visible){ | |
344 | d->m_pointsVisible = visible; |
|
344 | d->m_pointsVisible = visible; | |
345 | emit d->updated(); |
|
345 | emit d->updated(); | |
346 | } |
|
346 | } | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | /*! |
|
349 | /*! | |
350 | Returns true if drawing the data points of the series is enabled. |
|
350 | Returns true if drawing the data points of the series is enabled. | |
351 | */ |
|
351 | */ | |
352 | bool QXYSeries::pointsVisible() const |
|
352 | bool QXYSeries::pointsVisible() const | |
353 | { |
|
353 | { | |
354 | Q_D(const QXYSeries); |
|
354 | Q_D(const QXYSeries); | |
355 | return d->m_pointsVisible; |
|
355 | return d->m_pointsVisible; | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 |
|
358 | |||
359 | /*! |
|
359 | /*! | |
360 | Stream operator for adding a data \a point to the series. |
|
360 | Stream operator for adding a data \a point to the series. | |
361 | \sa append() |
|
361 | \sa append() | |
362 | */ |
|
362 | */ | |
363 | QXYSeries& QXYSeries::operator<< (const QPointF &point) |
|
363 | QXYSeries& QXYSeries::operator<< (const QPointF &point) | |
364 | { |
|
364 | { | |
365 | append(point); |
|
365 | append(point); | |
366 | return *this; |
|
366 | return *this; | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 |
|
369 | |||
370 | /*! |
|
370 | /*! | |
371 | Stream operator for adding a list of \a points to the series. |
|
371 | Stream operator for adding a list of \a points to the series. | |
372 | \sa append() |
|
372 | \sa append() | |
373 | */ |
|
373 | */ | |
374 |
|
374 | |||
375 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) |
|
375 | QXYSeries& QXYSeries::operator<< (const QList<QPointF> points) | |
376 | { |
|
376 | { | |
377 | append(points); |
|
377 | append(points); | |
378 | return *this; |
|
378 | return *this; | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | /*! |
|
381 | /*! | |
382 | \internal |
|
382 | \internal | |
383 | */ |
|
383 | */ | |
384 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
384 | void QXYSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
385 | { |
|
385 | { | |
386 | Q_UNUSED(bottomRight) |
|
386 | Q_UNUSED(bottomRight) | |
387 | Q_D(QXYSeries); |
|
387 | Q_D(QXYSeries); | |
388 | if (d->m_mapOrientation == Qt::Vertical) { |
|
388 | if (d->m_mapOrientation == Qt::Vertical) { | |
389 | if (topLeft.row() >= d->m_mapFirst && (!d->m_mapLimited || topLeft.row() < d->m_mapFirst + d->m_mapCount)) |
|
389 | if (topLeft.row() >= d->m_mapFirst && (!d->m_mapLimited || topLeft.row() < d->m_mapFirst + d->m_mapCount)) | |
390 | emit d->pointReplaced(topLeft.row() - d->m_mapFirst); |
|
390 | emit d->pointReplaced(topLeft.row() - d->m_mapFirst); | |
391 | } else { |
|
391 | } else { | |
392 | if (topLeft.column() >= d->m_mapFirst && (!d->m_mapLimited || topLeft.column() < d->m_mapFirst + d->m_mapCount)) |
|
392 | if (topLeft.column() >= d->m_mapFirst && (!d->m_mapLimited || topLeft.column() < d->m_mapFirst + d->m_mapCount)) | |
393 | emit d->pointReplaced(topLeft.column() - d->m_mapFirst); |
|
393 | emit d->pointReplaced(topLeft.column() - d->m_mapFirst); | |
394 | } |
|
394 | } | |
395 | } |
|
395 | } | |
396 |
|
396 | |||
397 | /*! |
|
397 | /*! | |
398 | \internal |
|
398 | \internal | |
399 | */ |
|
399 | */ | |
400 | void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) |
|
400 | void QXYSeries::modelDataAboutToBeAdded(QModelIndex parent, int start, int end) | |
401 | { |
|
401 | { | |
402 | Q_UNUSED(parent) |
|
402 | Q_UNUSED(parent) | |
403 | // Q_UNUSED(end) |
|
403 | // Q_UNUSED(end) | |
404 | Q_D(QXYSeries); |
|
404 | Q_D(QXYSeries); | |
405 | if (d->m_mapLimited) { |
|
405 | if (d->m_mapLimited) { | |
406 | if (start >= d->m_mapFirst + d->m_mapCount) { |
|
406 | if (start >= d->m_mapFirst + d->m_mapCount) { | |
407 | // the added data is below mapped area |
|
407 | // the added data is below mapped area | |
408 | // therefore it has no relevance |
|
408 | // therefore it has no relevance | |
409 | return; |
|
409 | return; | |
410 | } else { |
|
410 | } else { | |
411 | // the added data is in the mapped area or before it and update is needed |
|
411 | // the added data is in the mapped area or before it and update is needed | |
412 |
|
412 | |||
413 | // check how many mapped items there is currently (before new items are added) |
|
413 | // check how many mapped items there is currently (before new items are added) | |
414 | // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem |
|
414 | // if the number of items currently is equal the m_mapCount then some needs to be removed from xychartitem | |
415 | // internal storage before new ones can be added |
|
415 | // internal storage before new ones can be added | |
416 |
|
416 | |||
417 | int itemsToRemove = qMin(count() - qMax(start - d->m_mapFirst, 0), end - start + 1); |
|
417 | int itemsToRemove = qMin(count() - qMax(start - d->m_mapFirst, 0), end - start + 1); | |
418 | if (d->m_mapCount == count()) { |
|
418 | if (d->m_mapCount == count()) { | |
419 | for (int i = 0; i < itemsToRemove; i++) |
|
419 | for (int i = 0; i < itemsToRemove; i++) | |
420 | emit d->pointRemoved(qMin(end, count()) - i); |
|
420 | emit d->pointRemoved(qMin(end, count()) - i); | |
421 | } |
|
421 | } | |
422 | } |
|
422 | } | |
423 | } else { |
|
423 | } else { | |
424 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) |
|
424 | // map is not limited (it includes all the items starting from m_mapFirst till the end of model) | |
425 | // nothing to do |
|
425 | // nothing to do | |
426 | // emit pointAdded(qMax(start - m_mapFirst, 0)); |
|
426 | // emit pointAdded(qMax(start - m_mapFirst, 0)); | |
427 | } |
|
427 | } | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | /*! |
|
430 | /*! | |
431 | \internal |
|
431 | \internal | |
432 | */ |
|
432 | */ | |
433 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) |
|
433 | void QXYSeries::modelDataAdded(QModelIndex parent, int start, int end) | |
434 | { |
|
434 | { | |
435 | Q_UNUSED(parent) |
|
435 | Q_UNUSED(parent) | |
436 | // Q_UNUSED(end) |
|
436 | // Q_UNUSED(end) | |
437 | Q_D(QXYSeries); |
|
437 | Q_D(QXYSeries); | |
438 | if (d->m_mapLimited) { |
|
438 | if (d->m_mapLimited) { | |
439 | if (start >= d->m_mapFirst + d->m_mapCount) { |
|
439 | if (start >= d->m_mapFirst + d->m_mapCount) { | |
440 | // the added data is below mapped area |
|
440 | // the added data is below mapped area | |
441 | // therefore it has no relevance |
|
441 | // therefore it has no relevance | |
442 | return; |
|
442 | return; | |
443 | } else { |
|
443 | } else { | |
444 | // the added data is in the mapped area or before it |
|
444 | // the added data is in the mapped area or before it | |
445 | // update needed |
|
445 | // update needed | |
446 | if (count() > 0) { |
|
446 | if (count() > 0) { | |
447 | int toBeAdded = qMin(d->m_mapCount - (start - d->m_mapFirst), end - start + 1); |
|
447 | int toBeAdded = qMin(d->m_mapCount - (start - d->m_mapFirst), end - start + 1); | |
448 | for (int i = 0; i < toBeAdded; i++) |
|
448 | for (int i = 0; i < toBeAdded; i++) | |
449 | if (start + i >= d->m_mapFirst) |
|
449 | if (start + i >= d->m_mapFirst) | |
450 | emit d->pointAdded(start + i); |
|
450 | emit d->pointAdded(start + i); | |
451 | } |
|
451 | } | |
452 | } |
|
452 | } | |
453 | } else { |
|
453 | } else { | |
454 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
454 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
455 | for (int i = 0; i < end - start + 1; i++) |
|
455 | for (int i = 0; i < end - start + 1; i++) | |
456 | emit d->pointAdded(start + i); |
|
456 | emit d->pointAdded(start + i); | |
457 | } |
|
457 | } | |
458 | } |
|
458 | } | |
459 |
|
459 | |||
460 | /*! |
|
460 | /*! | |
461 | \internal |
|
461 | \internal | |
462 | */ |
|
462 | */ | |
463 | void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end) |
|
463 | void QXYSeries::modelDataAboutToBeRemoved(QModelIndex parent, int start, int end) | |
464 | { |
|
464 | { | |
465 | Q_UNUSED(parent) |
|
465 | Q_UNUSED(parent) | |
466 | // Q_UNUSED(end) |
|
466 | // Q_UNUSED(end) | |
467 | Q_D(QXYSeries); |
|
467 | Q_D(QXYSeries); | |
468 | if (d->m_mapLimited) { |
|
468 | if (d->m_mapLimited) { | |
469 | if (start >= d->m_mapFirst + d->m_mapCount) { |
|
469 | if (start >= d->m_mapFirst + d->m_mapCount) { | |
470 | // the removed data is below mapped area |
|
470 | // the removed data is below mapped area | |
471 | // therefore it has no relevance |
|
471 | // therefore it has no relevance | |
472 | return; |
|
472 | return; | |
473 | } else { |
|
473 | } else { | |
474 | // the removed data is in the mapped area or before it |
|
474 | // the removed data is in the mapped area or before it | |
475 | // update needed |
|
475 | // update needed | |
476 |
|
476 | |||
477 | // check how many items need to be removed from the xychartitem storage |
|
477 | // check how many items need to be removed from the xychartitem storage | |
478 | // the number equals the number of items that are removed and that lay before |
|
478 | // the number equals the number of items that are removed and that lay before | |
479 | // or in the mapped area. Items that lay beyond the map do not count |
|
479 | // or in the mapped area. Items that lay beyond the map do not count | |
480 | // the max is the current number of items in storage (count()) |
|
480 | // the max is the current number of items in storage (count()) | |
481 | int itemsToRemove = qMin(count(), qMin(end, d->m_mapFirst + d->m_mapCount - 1) - start + 1); |
|
481 | int itemsToRemove = qMin(count(), qMin(end, d->m_mapFirst + d->m_mapCount - 1) - start + 1); | |
482 | for (int i = 0; i < itemsToRemove; i++) |
|
482 | for (int i = 0; i < itemsToRemove; i++) | |
483 | emit d->pointRemoved(start); |
|
483 | emit d->pointRemoved(start); | |
484 | } |
|
484 | } | |
485 | } else { |
|
485 | } else { | |
486 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) |
|
486 | // map is not limited (it included all the items starting from m_mapFirst till the end of model) | |
487 | for (int i = 0; i < end - start + 1; i++) |
|
487 | for (int i = 0; i < end - start + 1; i++) | |
488 | emit d->pointRemoved(start); |
|
488 | emit d->pointRemoved(start); | |
489 | } |
|
489 | } | |
490 | } |
|
490 | } | |
491 |
|
491 | |||
492 | /*! |
|
492 | /*! | |
493 | \internal |
|
493 | \internal | |
494 | */ |
|
494 | */ | |
495 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) |
|
495 | void QXYSeries::modelDataRemoved(QModelIndex parent, int start, int end) | |
496 | { |
|
496 | { | |
497 |
|
497 | |||
498 | Q_UNUSED(parent) |
|
498 | Q_UNUSED(parent) | |
499 | Q_UNUSED(end) |
|
499 | Q_UNUSED(end) | |
500 | Q_D(QXYSeries); |
|
500 | Q_D(QXYSeries); | |
501 | // how many items there were before data was removed |
|
501 | // how many items there were before data was removed | |
502 | // int oldCount = count() - 1; |
|
502 | // int oldCount = count() - 1; | |
503 |
|
503 | |||
504 | if (d->m_mapLimited) { |
|
504 | if (d->m_mapLimited) { | |
505 | if (start >= d->m_mapFirst + d->m_mapCount) { |
|
505 | if (start >= d->m_mapFirst + d->m_mapCount) { | |
506 | // the removed data is below mapped area |
|
506 | // the removed data is below mapped area | |
507 | // therefore it has no relevance |
|
507 | // therefore it has no relevance | |
508 | return; |
|
508 | return; | |
509 | } else { |
|
509 | } else { | |
510 | // if the current items count in the whole model is bigger than the index of the last item |
|
510 | // if the current items count in the whole model is bigger than the index of the last item | |
511 | // that was removed than it means there are some extra items available |
|
511 | // that was removed than it means there are some extra items available | |
512 |
|
512 | |||
513 | int removedItemsCount = qMin(count(), qMin(end, d->m_mapFirst + d->m_mapCount - 1) - start + 1); |
|
513 | int removedItemsCount = qMin(count(), qMin(end, d->m_mapFirst + d->m_mapCount - 1) - start + 1); | |
514 | int extraItemsAvailable = 0; |
|
514 | int extraItemsAvailable = 0; | |
515 | if (d->m_mapOrientation == Qt::Vertical) { |
|
515 | if (d->m_mapOrientation == Qt::Vertical) { | |
516 | extraItemsAvailable = qMax(d->m_model->rowCount() + (end - start + 1) - qMax(end + 1, d->m_mapFirst + d->m_mapCount), 0); |
|
516 | extraItemsAvailable = qMax(d->m_model->rowCount() + (end - start + 1) - qMax(end + 1, d->m_mapFirst + d->m_mapCount), 0); | |
517 | } else { |
|
517 | } else { | |
518 | extraItemsAvailable = qMax(d->m_model->columnCount() + (end - start + 1) - qMax(end + 1, d->m_mapFirst + d->m_mapCount), 0); |
|
518 | extraItemsAvailable = qMax(d->m_model->columnCount() + (end - start + 1) - qMax(end + 1, d->m_mapFirst + d->m_mapCount), 0); | |
519 | } |
|
519 | } | |
520 |
|
520 | |||
521 | // if there are excess items available (below the mapped area) use them to repopulate mapped area |
|
521 | // if there are excess items available (below the mapped area) use them to repopulate mapped area | |
522 | int toBeAdded = qMin(extraItemsAvailable, removedItemsCount); |
|
522 | int toBeAdded = qMin(extraItemsAvailable, removedItemsCount); | |
523 | for (int k = 0; k < toBeAdded; k++) |
|
523 | for (int k = 0; k < toBeAdded; k++) | |
524 | emit d->pointAdded(d->m_mapFirst + d->m_mapCount - removedItemsCount + k); |
|
524 | emit d->pointAdded(d->m_mapFirst + d->m_mapCount - removedItemsCount + k); | |
525 | } |
|
525 | } | |
526 | } else { |
|
526 | } else { | |
527 | // data was removed from XYSeries interal storage. Nothing more to do |
|
527 | // data was removed from XYSeries interal storage. Nothing more to do | |
528 | } |
|
528 | } | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | /*! |
|
531 | /*! | |
532 | \fn bool QXYSeries::setModel(QAbstractItemModel *model) |
|
532 | \fn bool QXYSeries::setModel(QAbstractItemModel *model) | |
533 | Sets the \a model to be used as a data source |
|
533 | Sets the \a model to be used as a data source | |
534 | \sa setModelMapping(), setModelMappingRange() |
|
534 | \sa setModelMapping(), setModelMappingRange() | |
535 | */ |
|
535 | */ | |
536 | bool QXYSeries::setModel(QAbstractItemModel *model) |
|
536 | bool QXYSeries::setModel(QAbstractItemModel *model) | |
537 | { |
|
537 | { | |
538 | Q_D(QXYSeries); |
|
538 | Q_D(QXYSeries); | |
539 | // disconnect signals from old model |
|
539 | // disconnect signals from old model | |
540 | if (d->m_model) { |
|
540 | if (d->m_model) { | |
541 | QObject::disconnect(d->m_model, 0, this, 0); |
|
541 | QObject::disconnect(d->m_model, 0, this, 0); | |
542 | d->m_mapX = -1; |
|
542 | d->m_mapX = -1; | |
543 | d->m_mapY = -1; |
|
543 | d->m_mapY = -1; | |
544 | d->m_mapFirst = 0; |
|
544 | d->m_mapFirst = 0; | |
545 | d->m_mapCount = 0; |
|
545 | d->m_mapCount = 0; | |
546 | d->m_mapLimited = false; |
|
546 | d->m_mapLimited = false; | |
547 | d->m_mapOrientation = Qt::Vertical; |
|
547 | d->m_mapOrientation = Qt::Vertical; | |
548 | } |
|
548 | } | |
549 |
|
549 | |||
550 | // set new model |
|
550 | // set new model | |
551 | if (model) { |
|
551 | if (model) { | |
552 | d->m_model = model; |
|
552 | d->m_model = model; | |
553 | return true; |
|
553 | return true; | |
554 | } else { |
|
554 | } else { | |
555 | d->m_model = 0; |
|
555 | d->m_model = 0; | |
556 | return false; |
|
556 | return false; | |
557 | } |
|
557 | } | |
558 | } |
|
558 | } | |
559 |
|
559 | |||
560 | /*! |
|
560 | /*! | |
561 | \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
561 | \fn bool QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
562 | Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used |
|
562 | Sets the \a modelX to be used as a data source for x coordinate and \a modelY to be used | |
563 | as a data source for y coordinate. The \a orientation parameter specifies whether the data |
|
563 | as a data source for y coordinate. The \a orientation parameter specifies whether the data | |
564 | is in columns or in rows. |
|
564 | is in columns or in rows. | |
565 | \sa setModel(), setModelMappingRange() |
|
565 | \sa setModel(), setModelMappingRange() | |
566 | */ |
|
566 | */ | |
567 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) |
|
567 | void QXYSeries::setModelMapping(int modelX, int modelY, Qt::Orientation orientation) | |
568 | { |
|
568 | { | |
569 | Q_D(QXYSeries); |
|
569 | Q_D(QXYSeries); | |
570 | if (d->m_model == 0) |
|
570 | if (d->m_model == 0) | |
571 | return; |
|
571 | return; | |
572 | d->m_mapX = modelX; |
|
572 | d->m_mapX = modelX; | |
573 | d->m_mapY = modelY; |
|
573 | d->m_mapY = modelY; | |
574 | d->m_mapFirst = 0; |
|
574 | d->m_mapFirst = 0; | |
575 | d->m_mapOrientation = orientation; |
|
575 | d->m_mapOrientation = orientation; | |
576 | if (d->m_mapOrientation == Qt::Vertical) { |
|
576 | if (d->m_mapOrientation == Qt::Vertical) { | |
577 | connect(d->m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
577 | connect(d->m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
578 | connect(d->m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
578 | connect(d->m_model,SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
579 | connect(d->m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
579 | connect(d->m_model,SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
580 | connect(d->m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); |
|
580 | connect(d->m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); | |
581 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
581 | connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
582 | } else { |
|
582 | } else { | |
583 | connect(d->m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); |
|
583 | connect(d->m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex,QModelIndex))); | |
584 | connect(d->m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); |
|
584 | connect(d->m_model,SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeAdded(QModelIndex,int,int))); | |
585 | connect(d->m_model,SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
585 | connect(d->m_model,SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); | |
586 | connect(d->m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); |
|
586 | connect(d->m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelDataAboutToBeRemoved(QModelIndex,int,int))); | |
587 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
587 | connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
588 | } |
|
588 | } | |
589 | } |
|
589 | } | |
590 |
|
590 | |||
591 | /*! |
|
591 | /*! | |
592 | \fn bool QXYSeries::setModelMappingRange(int first, int count) |
|
592 | \fn bool QXYSeries::setModelMappingRange(int first, int count) | |
593 | Allows limiting the model mapping. |
|
593 | Allows limiting the model mapping. | |
594 | Parameter \a first specifies which element of the model should be used as a first one of the series. |
|
594 | Parameter \a first specifies which element of the model should be used as a first one of the series. | |
595 | Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1) |
|
595 | Parameter \a count specifies how many elements should be mapped. If count is not specified (defaults to -1) | |
596 | then all the items following \a first item in a model are used. |
|
596 | then all the items following \a first item in a model are used. | |
597 | \sa setModel(), setModelMapping() |
|
597 | \sa setModel(), setModelMapping() | |
598 | */ |
|
598 | */ | |
599 | void QXYSeries::setModelMappingRange(int first, int count) |
|
599 | void QXYSeries::setModelMappingRange(int first, int count) | |
600 | { |
|
600 | { | |
601 | Q_D(QXYSeries); |
|
601 | Q_D(QXYSeries); | |
602 | d->m_mapFirst = first; |
|
602 | d->m_mapFirst = first; | |
603 | if (count == 0) { |
|
603 | if (count == 0) { | |
604 | d->m_mapLimited = false; |
|
604 | d->m_mapLimited = false; | |
605 | } else { |
|
605 | } else { | |
606 | d->m_mapCount = count; |
|
606 | d->m_mapCount = count; | |
607 | d->m_mapLimited = true; |
|
607 | d->m_mapLimited = true; | |
608 | } |
|
608 | } | |
609 | } |
|
609 | } | |
610 |
|
610 | |||
611 | int QXYSeries::mapFirst() const |
|
611 | int QXYSeries::mapFirst() const | |
612 | { |
|
612 | { | |
613 | Q_D(const QXYSeries); |
|
613 | Q_D(const QXYSeries); | |
614 | return d->m_mapFirst; |
|
614 | return d->m_mapFirst; | |
615 | } |
|
615 | } | |
616 |
|
616 | |||
617 | int QXYSeries::mapCount() const |
|
617 | int QXYSeries::mapCount() const | |
618 | { |
|
618 | { | |
619 | Q_D(const QXYSeries); |
|
619 | Q_D(const QXYSeries); | |
620 | return d->m_mapCount; |
|
620 | return d->m_mapCount; | |
621 | } |
|
621 | } | |
622 |
|
622 | |||
623 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
623 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
624 |
|
624 | |||
625 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q): QSeriesPrivate(q), |
|
625 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) : QAbstractSeriesPrivate(q), | |
626 | m_mapX(-1), |
|
626 | m_mapX(-1), | |
627 | m_mapY(-1), |
|
627 | m_mapY(-1), | |
628 | m_mapFirst(0), |
|
628 | m_mapFirst(0), | |
629 | m_mapCount(0), |
|
629 | m_mapCount(0), | |
630 | m_mapLimited(false), |
|
630 | m_mapLimited(false), | |
631 | m_mapOrientation( Qt::Vertical), |
|
631 | m_mapOrientation( Qt::Vertical), | |
632 | m_pointsVisible(false) |
|
632 | m_pointsVisible(false) | |
633 | { |
|
633 | { | |
634 |
|
||||
635 | } |
|
634 | } | |
636 |
|
635 | |||
637 | void QXYSeriesPrivate::scaleDomain(Domain& domain) |
|
636 | void QXYSeriesPrivate::scaleDomain(Domain& domain) | |
638 | { |
|
637 | { | |
639 | qreal minX(domain.minX()); |
|
638 | qreal minX(domain.minX()); | |
640 | qreal minY(domain.minY()); |
|
639 | qreal minY(domain.minY()); | |
641 | qreal maxX(domain.maxX()); |
|
640 | qreal maxX(domain.maxX()); | |
642 | qreal maxY(domain.maxY()); |
|
641 | qreal maxY(domain.maxY()); | |
643 | int tickXCount(domain.tickXCount()); |
|
642 | int tickXCount(domain.tickXCount()); | |
644 | int tickYCount(domain.tickYCount()); |
|
643 | int tickYCount(domain.tickYCount()); | |
645 |
|
644 | |||
646 | Q_Q(QXYSeries); |
|
645 | Q_Q(QXYSeries); | |
647 | for (int i = 0; i < q->count(); i++) |
|
646 | for (int i = 0; i < q->count(); i++) | |
648 | { |
|
647 | { | |
649 | qreal x = q->x(i); |
|
648 | qreal x = q->x(i); | |
650 | qreal y = q->y(i); |
|
649 | qreal y = q->y(i); | |
651 | minX = qMin(minX, x); |
|
650 | minX = qMin(minX, x); | |
652 | minY = qMin(minY, y); |
|
651 | minY = qMin(minY, y); | |
653 | maxX = qMax(maxX, x); |
|
652 | maxX = qMax(maxX, x); | |
654 | maxY = qMax(maxY, y); |
|
653 | maxY = qMax(maxY, y); | |
655 | } |
|
654 | } | |
656 |
|
655 | |||
657 | domain.setRangeX(minX,maxX,tickXCount); |
|
656 | domain.setRangeX(minX,maxX,tickXCount); | |
658 | domain.setRangeY(minY,maxY,tickYCount); |
|
657 | domain.setRangeY(minY,maxY,tickYCount); | |
659 | } |
|
658 | } | |
660 |
|
659 | |||
661 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) |
|
660 | QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |
662 | { |
|
661 | { | |
663 | Q_Q(QXYSeries); |
|
662 | Q_Q(QXYSeries); | |
664 | QList<LegendMarker*> list; |
|
663 | QList<LegendMarker*> list; | |
665 | return list << new XYLegendMarker(q,legend); |
|
664 | return list << new XYLegendMarker(q,legend); | |
666 | } |
|
665 | } | |
667 |
|
666 | |||
668 | #include "moc_qxyseries.cpp" |
|
667 | #include "moc_qxyseries.cpp" | |
669 | #include "moc_qxyseries_p.cpp" |
|
668 | #include "moc_qxyseries_p.cpp" | |
670 |
|
669 | |||
671 | QTCOMMERCIALCHART_END_NAMESPACE |
|
670 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,97 +1,97 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef QXYSERIES_H |
|
21 | #ifndef QXYSERIES_H | |
22 | #define QXYSERIES_H |
|
22 | #define QXYSERIES_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <qseries.h> |
|
25 | #include <qabstractseries.h> | |
26 | #include <QPen> |
|
26 | #include <QPen> | |
27 | #include <QBrush> |
|
27 | #include <QBrush> | |
28 |
|
28 | |||
29 | class QModelIndex; |
|
29 | class QModelIndex; | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | class QXYSeriesPrivate; |
|
33 | class QXYSeriesPrivate; | |
34 |
|
34 | |||
35 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries |
|
35 | class QTCOMMERCIALCHART_EXPORT QXYSeries : public QAbstractSeries | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 | protected: |
|
38 | protected: | |
39 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); |
|
39 | explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0); | |
40 | ~QXYSeries(); |
|
40 | ~QXYSeries(); | |
41 |
|
41 | |||
42 | public: |
|
42 | public: | |
43 | void append(qreal x, qreal y); |
|
43 | void append(qreal x, qreal y); | |
44 | void append(const QPointF &point); |
|
44 | void append(const QPointF &point); | |
45 | void append(const QList<QPointF> points); |
|
45 | void append(const QList<QPointF> points); | |
46 | void replace(qreal x,qreal y); |
|
46 | void replace(qreal x,qreal y); | |
47 | void replace(const QPointF &point); |
|
47 | void replace(const QPointF &point); | |
48 | void remove(qreal x); |
|
48 | void remove(qreal x); | |
49 | void remove(qreal x, qreal y); |
|
49 | void remove(qreal x, qreal y); | |
50 | void remove(const QPointF &point); |
|
50 | void remove(const QPointF &point); | |
51 | void removeAll(); |
|
51 | void removeAll(); | |
52 |
|
52 | |||
53 | int count() const; |
|
53 | int count() const; | |
54 | qreal x(int pos) const; |
|
54 | qreal x(int pos) const; | |
55 | qreal y(int pos) const; |
|
55 | qreal y(int pos) const; | |
56 | QList<QPointF> data(); |
|
56 | QList<QPointF> data(); | |
57 |
|
57 | |||
58 | QXYSeries& operator << (const QPointF &point); |
|
58 | QXYSeries& operator << (const QPointF &point); | |
59 | QXYSeries& operator << (const QList<QPointF> points); |
|
59 | QXYSeries& operator << (const QList<QPointF> points); | |
60 |
|
60 | |||
61 | void setPen(const QPen &pen); |
|
61 | void setPen(const QPen &pen); | |
62 | QPen pen() const; |
|
62 | QPen pen() const; | |
63 |
|
63 | |||
64 | void setBrush(const QBrush &brush); |
|
64 | void setBrush(const QBrush &brush); | |
65 | QBrush brush() const; |
|
65 | QBrush brush() const; | |
66 |
|
66 | |||
67 | void setPointsVisible(bool visible = true); |
|
67 | void setPointsVisible(bool visible = true); | |
68 | bool pointsVisible() const; |
|
68 | bool pointsVisible() const; | |
69 |
|
69 | |||
70 | bool setModel(QAbstractItemModel *model); |
|
70 | bool setModel(QAbstractItemModel *model); | |
71 |
|
71 | |||
72 | virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); |
|
72 | virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); | |
73 | virtual void setModelMappingRange(int first, int count = 0); |
|
73 | virtual void setModelMappingRange(int first, int count = 0); | |
74 | int mapFirst() const; |
|
74 | int mapFirst() const; | |
75 | int mapCount() const; |
|
75 | int mapCount() const; | |
76 |
|
76 | |||
77 | private Q_SLOTS: |
|
77 | private Q_SLOTS: | |
78 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
78 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | |
79 | void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); |
|
79 | void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); | |
80 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
80 | void modelDataAdded(QModelIndex parent, int start, int end); | |
81 | void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); |
|
81 | void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); | |
82 | void modelDataRemoved(QModelIndex parent, int start, int end); |
|
82 | void modelDataRemoved(QModelIndex parent, int start, int end); | |
83 |
|
83 | |||
84 | Q_SIGNALS: |
|
84 | Q_SIGNALS: | |
85 | void clicked(const QPointF &point); |
|
85 | void clicked(const QPointF &point); | |
86 | void selected(); |
|
86 | void selected(); | |
87 |
|
87 | |||
88 | private: |
|
88 | private: | |
89 | Q_DECLARE_PRIVATE(QXYSeries); |
|
89 | Q_DECLARE_PRIVATE(QXYSeries); | |
90 | Q_DISABLE_COPY(QXYSeries); |
|
90 | Q_DISABLE_COPY(QXYSeries); | |
91 | friend class XYLegendMarker; |
|
91 | friend class XYLegendMarker; | |
92 | friend class XYChartItem; |
|
92 | friend class XYChartItem; | |
93 | }; |
|
93 | }; | |
94 |
|
94 | |||
95 | QTCOMMERCIALCHART_END_NAMESPACE |
|
95 | QTCOMMERCIALCHART_END_NAMESPACE | |
96 |
|
96 | |||
97 | #endif |
|
97 | #endif |
@@ -1,79 +1,79 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef QXYSERIES_P_H |
|
30 | #ifndef QXYSERIES_P_H | |
31 | #define QXYSERIES_P_H |
|
31 | #define QXYSERIES_P_H | |
32 |
|
32 | |||
33 | #include "qseries_p.h" |
|
33 | #include "qabstractseries_p.h" | |
34 |
|
34 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
36 | |||
37 | class QXYSeries; |
|
37 | class QXYSeries; | |
38 |
|
38 | |||
39 | class QXYSeriesPrivate: public QSeriesPrivate |
|
39 | class QXYSeriesPrivate: public QAbstractSeriesPrivate | |
40 | { |
|
40 | { | |
41 | Q_OBJECT |
|
41 | Q_OBJECT | |
42 |
|
42 | |||
43 | public: |
|
43 | public: | |
44 | QXYSeriesPrivate(QXYSeries* q); |
|
44 | QXYSeriesPrivate(QXYSeries* q); | |
45 |
|
45 | |||
46 | void scaleDomain(Domain& domain); |
|
46 | void scaleDomain(Domain& domain); | |
47 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
47 | QList<LegendMarker*> createLegendMarker(QLegend* legend); | |
48 |
|
48 | |||
49 | Q_SIGNALS: |
|
49 | Q_SIGNALS: | |
50 | void updated(); |
|
50 | void updated(); | |
51 | void pointReplaced(int index); |
|
51 | void pointReplaced(int index); | |
52 | void pointRemoved(int index); |
|
52 | void pointRemoved(int index); | |
53 | void pointAdded(int index); |
|
53 | void pointAdded(int index); | |
54 |
|
54 | |||
55 | protected: |
|
55 | protected: | |
56 | QVector<qreal> m_x; |
|
56 | QVector<qreal> m_x; | |
57 | QVector<qreal> m_y; |
|
57 | QVector<qreal> m_y; | |
58 |
|
58 | |||
59 | QPen m_pen; |
|
59 | QPen m_pen; | |
60 | QBrush m_brush; |
|
60 | QBrush m_brush; | |
61 |
|
61 | |||
62 | int m_mapX; |
|
62 | int m_mapX; | |
63 | int m_mapY; |
|
63 | int m_mapY; | |
64 | int m_mapFirst; |
|
64 | int m_mapFirst; | |
65 | int m_mapCount; |
|
65 | int m_mapCount; | |
66 | bool m_mapLimited; |
|
66 | bool m_mapLimited; | |
67 | Qt::Orientation m_mapOrientation; |
|
67 | Qt::Orientation m_mapOrientation; | |
68 | int tempItemsRemoved; |
|
68 | int tempItemsRemoved; | |
69 | bool m_pointsVisible; |
|
69 | bool m_pointsVisible; | |
70 |
|
70 | |||
71 | private: |
|
71 | private: | |
72 | Q_DECLARE_PUBLIC(QXYSeries); |
|
72 | Q_DECLARE_PUBLIC(QXYSeries); | |
73 | friend class QScatterSeries; |
|
73 | friend class QScatterSeries; | |
74 |
|
74 | |||
75 | }; |
|
75 | }; | |
76 |
|
76 | |||
77 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE | |
78 |
|
78 | |||
79 | #endif |
|
79 | #endif |
@@ -1,570 +1,570 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qchartaxis.h> |
|
22 | #include <qchartaxis.h> | |
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <private/chartdataset_p.h> |
|
24 | #include <private/chartdataset_p.h> | |
25 | #include <private/domain_p.h> |
|
25 | #include <private/domain_p.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | Q_DECLARE_METATYPE(Domain*) |
|
29 | Q_DECLARE_METATYPE(Domain *) | |
30 | Q_DECLARE_METATYPE(QChartAxis*) |
|
30 | Q_DECLARE_METATYPE(QChartAxis *) | |
31 | Q_DECLARE_METATYPE(QSeries*) |
|
31 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
32 | Q_DECLARE_METATYPE(QLineSeries*) |
|
32 | Q_DECLARE_METATYPE(QLineSeries *) | |
33 |
|
33 | |||
34 | class tst_ChartDataSet: public QObject { |
|
34 | class tst_ChartDataSet: public QObject { | |
35 |
|
35 | |||
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 |
|
37 | |||
38 | public Q_SLOTS: |
|
38 | public Q_SLOTS: | |
39 | void initTestCase(); |
|
39 | void initTestCase(); | |
40 | void cleanupTestCase(); |
|
40 | void cleanupTestCase(); | |
41 | void init(); |
|
41 | void init(); | |
42 | void cleanup(); |
|
42 | void cleanup(); | |
43 |
|
43 | |||
44 | private Q_SLOTS: |
|
44 | private Q_SLOTS: | |
45 | void chartdataset_data(); |
|
45 | void chartdataset_data(); | |
46 | void chartdataset(); |
|
46 | void chartdataset(); | |
47 | void addSeries_data(); |
|
47 | void addSeries_data(); | |
48 | void addSeries(); |
|
48 | void addSeries(); | |
49 | void removeSeries_data(); |
|
49 | void removeSeries_data(); | |
50 | void removeSeries(); |
|
50 | void removeSeries(); | |
51 | void removeAllSeries_data(); |
|
51 | void removeAllSeries_data(); | |
52 | void removeAllSeries(); |
|
52 | void removeAllSeries(); | |
53 | void axisY_data(); |
|
53 | void axisY_data(); | |
54 | void axisY(); |
|
54 | void axisY(); | |
55 | void seriesCount_data(); |
|
55 | void seriesCount_data(); | |
56 | void seriesCount(); |
|
56 | void seriesCount(); | |
57 | void seriesIndex_data(); |
|
57 | void seriesIndex_data(); | |
58 | void seriesIndex(); |
|
58 | void seriesIndex(); | |
59 | void domain_data(); |
|
59 | void domain_data(); | |
60 | void domain(); |
|
60 | void domain(); | |
61 | void zoomInDomain_data(); |
|
61 | void zoomInDomain_data(); | |
62 | void zoomInDomain(); |
|
62 | void zoomInDomain(); | |
63 | void zoomOutDomain_data(); |
|
63 | void zoomOutDomain_data(); | |
64 | void zoomOutDomain(); |
|
64 | void zoomOutDomain(); | |
65 | void scrollDomain_data(); |
|
65 | void scrollDomain_data(); | |
66 | void scrollDomain(); |
|
66 | void scrollDomain(); | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | void tst_ChartDataSet::initTestCase() |
|
69 | void tst_ChartDataSet::initTestCase() | |
70 | { |
|
70 | { | |
71 | qRegisterMetaType<Domain*>(); |
|
71 | qRegisterMetaType<Domain*>(); | |
72 | qRegisterMetaType<QChartAxis*>(); |
|
72 | qRegisterMetaType<QChartAxis*>(); | |
73 | qRegisterMetaType<QSeries*>(); |
|
73 | qRegisterMetaType<QSeries*>(); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void tst_ChartDataSet::cleanupTestCase() |
|
76 | void tst_ChartDataSet::cleanupTestCase() | |
77 | { |
|
77 | { | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | void tst_ChartDataSet::init() |
|
80 | void tst_ChartDataSet::init() | |
81 | { |
|
81 | { | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void tst_ChartDataSet::cleanup() |
|
84 | void tst_ChartDataSet::cleanup() | |
85 | { |
|
85 | { | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void tst_ChartDataSet::chartdataset_data() |
|
88 | void tst_ChartDataSet::chartdataset_data() | |
89 | { |
|
89 | { | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | void tst_ChartDataSet::chartdataset() |
|
92 | void tst_ChartDataSet::chartdataset() | |
93 | { |
|
93 | { | |
94 | ChartDataSet dataSet; |
|
94 | ChartDataSet dataSet; | |
95 | QVERIFY2(dataSet.axisX(), "Missing axisX."); |
|
95 | QVERIFY2(dataSet.axisX(), "Missing axisX."); | |
96 | QVERIFY2(dataSet.axisY(), "Missing axisY."); |
|
96 | QVERIFY2(dataSet.axisY(), "Missing axisY."); | |
97 | //check if not dangling pointer |
|
97 | //check if not dangling pointer | |
98 | dataSet.axisX()->objectName(); |
|
98 | dataSet.axisX()->objectName(); | |
99 | dataSet.axisY()->objectName(); |
|
99 | dataSet.axisY()->objectName(); | |
100 | QLineSeries* series = new QLineSeries(this); |
|
100 | QLineSeries* series = new QLineSeries(this); | |
101 | QCOMPARE(dataSet.seriesIndex(series),-1); |
|
101 | QCOMPARE(dataSet.seriesIndex(series),-1); | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void tst_ChartDataSet::addSeries_data() |
|
104 | void tst_ChartDataSet::addSeries_data() | |
105 | { |
|
105 | { | |
106 | QTest::addColumn<QLineSeries*>("series0"); |
|
106 | QTest::addColumn<QLineSeries*>("series0"); | |
107 | QTest::addColumn<QChartAxis*>("axis0"); |
|
107 | QTest::addColumn<QChartAxis*>("axis0"); | |
108 | QTest::addColumn<QLineSeries*>("series1"); |
|
108 | QTest::addColumn<QLineSeries*>("series1"); | |
109 | QTest::addColumn<QChartAxis*>("axis1"); |
|
109 | QTest::addColumn<QChartAxis*>("axis1"); | |
110 | QTest::addColumn<QLineSeries*>("series2"); |
|
110 | QTest::addColumn<QLineSeries*>("series2"); | |
111 | QTest::addColumn<QChartAxis*>("axis2"); |
|
111 | QTest::addColumn<QChartAxis*>("axis2"); | |
112 | QTest::addColumn<int>("axisCount"); |
|
112 | QTest::addColumn<int>("axisCount"); | |
113 |
|
113 | |||
114 | QLineSeries* series0 = new QLineSeries(this); |
|
114 | QLineSeries* series0 = new QLineSeries(this); | |
115 | QLineSeries* series1 = new QLineSeries(this); |
|
115 | QLineSeries* series1 = new QLineSeries(this); | |
116 | QLineSeries* series2 = new QLineSeries(this); |
|
116 | QLineSeries* series2 = new QLineSeries(this); | |
117 |
|
117 | |||
118 | QChartAxis* axis0 = new QChartAxis(this); |
|
118 | QChartAxis* axis0 = new QChartAxis(this); | |
119 | QChartAxis* axis1 = new QChartAxis(this); |
|
119 | QChartAxis* axis1 = new QChartAxis(this); | |
120 | QChartAxis* axis2 = new QChartAxis(this); |
|
120 | QChartAxis* axis2 = new QChartAxis(this); | |
121 |
|
121 | |||
122 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QChartAxis*)0 << series1 << (QChartAxis*)0 << series2 << (QChartAxis*)0 << 2; |
|
122 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QChartAxis*)0 << series1 << (QChartAxis*)0 << series2 << (QChartAxis*)0 << 2; | |
123 | QTest::newRow("default axis Y: series0, axis 0: series1,series2") << series0 << (QChartAxis*)0 << series1 << axis0 << series2 << axis0 << 3; |
|
123 | QTest::newRow("default axis Y: series0, axis 0: series1,series2") << series0 << (QChartAxis*)0 << series1 << axis0 << series2 << axis0 << 3; | |
124 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; |
|
124 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; | |
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | void tst_ChartDataSet::addSeries() |
|
127 | void tst_ChartDataSet::addSeries() | |
128 | { |
|
128 | { | |
129 | QFETCH(QLineSeries*, series0); |
|
129 | QFETCH(QLineSeries*, series0); | |
130 | QFETCH(QChartAxis*, axis0); |
|
130 | QFETCH(QChartAxis*, axis0); | |
131 | QFETCH(QLineSeries*, series1); |
|
131 | QFETCH(QLineSeries*, series1); | |
132 | QFETCH(QChartAxis*, axis1); |
|
132 | QFETCH(QChartAxis*, axis1); | |
133 | QFETCH(QLineSeries*, series2); |
|
133 | QFETCH(QLineSeries*, series2); | |
134 | QFETCH(QChartAxis*, axis2); |
|
134 | QFETCH(QChartAxis*, axis2); | |
135 | QFETCH(int, axisCount); |
|
135 | QFETCH(int, axisCount); | |
136 |
|
136 | |||
137 | ChartDataSet dataSet; |
|
137 | ChartDataSet dataSet; | |
138 |
|
138 | |||
139 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
139 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); | |
140 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
140 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); | |
141 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
141 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); | |
142 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
142 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
143 |
|
143 | |||
144 | dataSet.addSeries(series0,axis0); |
|
144 | dataSet.addSeries(series0,axis0); | |
145 | dataSet.addSeries(series1,axis1); |
|
145 | dataSet.addSeries(series1,axis1); | |
146 | dataSet.addSeries(series2,axis2); |
|
146 | dataSet.addSeries(series2,axis2); | |
147 |
|
147 | |||
148 | QCOMPARE(spy0.count(), axisCount); |
|
148 | QCOMPARE(spy0.count(), axisCount); | |
149 | QCOMPARE(spy1.count(), 0); |
|
149 | QCOMPARE(spy1.count(), 0); | |
150 | QCOMPARE(spy2.count(), 3); |
|
150 | QCOMPARE(spy2.count(), 3); | |
151 | QCOMPARE(spy3.count(), 0); |
|
151 | QCOMPARE(spy3.count(), 0); | |
152 |
|
152 | |||
153 | if(axis0==0) axis0 = dataSet.axisY(); |
|
153 | if(axis0==0) axis0 = dataSet.axisY(); | |
154 | if(axis1==0) axis1 = dataSet.axisY(); |
|
154 | if(axis1==0) axis1 = dataSet.axisY(); | |
155 | if(axis2==0) axis2 = dataSet.axisY(); |
|
155 | if(axis2==0) axis2 = dataSet.axisY(); | |
156 |
|
156 | |||
157 | QVERIFY(axis0 == dataSet.removeSeries(series0)); |
|
157 | QVERIFY(axis0 == dataSet.removeSeries(series0)); | |
158 | QVERIFY(axis1 == dataSet.removeSeries(series1)); |
|
158 | QVERIFY(axis1 == dataSet.removeSeries(series1)); | |
159 | QVERIFY(axis2 == dataSet.removeSeries(series2)); |
|
159 | QVERIFY(axis2 == dataSet.removeSeries(series2)); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void tst_ChartDataSet::removeSeries_data() |
|
162 | void tst_ChartDataSet::removeSeries_data() | |
163 | { |
|
163 | { | |
164 | addSeries_data(); |
|
164 | addSeries_data(); | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void tst_ChartDataSet::removeSeries() |
|
167 | void tst_ChartDataSet::removeSeries() | |
168 | { |
|
168 | { | |
169 | QFETCH(QLineSeries*, series0); |
|
169 | QFETCH(QLineSeries*, series0); | |
170 | QFETCH(QChartAxis*, axis0); |
|
170 | QFETCH(QChartAxis*, axis0); | |
171 | QFETCH(QLineSeries*, series1); |
|
171 | QFETCH(QLineSeries*, series1); | |
172 | QFETCH(QChartAxis*, axis1); |
|
172 | QFETCH(QChartAxis*, axis1); | |
173 | QFETCH(QLineSeries*, series2); |
|
173 | QFETCH(QLineSeries*, series2); | |
174 | QFETCH(QChartAxis*, axis2); |
|
174 | QFETCH(QChartAxis*, axis2); | |
175 | QFETCH(int, axisCount); |
|
175 | QFETCH(int, axisCount); | |
176 |
|
176 | |||
177 | ChartDataSet dataSet; |
|
177 | ChartDataSet dataSet; | |
178 |
|
178 | |||
179 | dataSet.addSeries(series0,axis0); |
|
179 | dataSet.addSeries(series0,axis0); | |
180 | dataSet.addSeries(series1,axis1); |
|
180 | dataSet.addSeries(series1,axis1); | |
181 | dataSet.addSeries(series2,axis2); |
|
181 | dataSet.addSeries(series2,axis2); | |
182 |
|
182 | |||
183 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
183 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
184 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
184 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
185 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
185 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
186 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
186 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
187 |
|
187 | |||
188 | dataSet.removeSeries(series0); |
|
188 | dataSet.removeSeries(series0); | |
189 | dataSet.removeSeries(series1); |
|
189 | dataSet.removeSeries(series1); | |
190 | dataSet.removeSeries(series2); |
|
190 | dataSet.removeSeries(series2); | |
191 |
|
191 | |||
192 | QCOMPARE(spy0.count(), 0); |
|
192 | QCOMPARE(spy0.count(), 0); | |
193 | QCOMPARE(spy1.count(), axisCount); |
|
193 | QCOMPARE(spy1.count(), axisCount); | |
194 | QCOMPARE(spy2.count(), 0); |
|
194 | QCOMPARE(spy2.count(), 0); | |
195 | QCOMPARE(spy3.count(), 3); |
|
195 | QCOMPARE(spy3.count(), 3); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | void tst_ChartDataSet::removeAllSeries_data() |
|
198 | void tst_ChartDataSet::removeAllSeries_data() | |
199 | { |
|
199 | { | |
200 |
|
200 | |||
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | void tst_ChartDataSet::removeAllSeries() |
|
203 | void tst_ChartDataSet::removeAllSeries() | |
204 | { |
|
204 | { | |
205 | QLineSeries* series0 = new QLineSeries(this); |
|
205 | QLineSeries* series0 = new QLineSeries(this); | |
206 | QLineSeries* series1 = new QLineSeries(this); |
|
206 | QLineSeries* series1 = new QLineSeries(this); | |
207 | QLineSeries* series2 = new QLineSeries(this); |
|
207 | QLineSeries* series2 = new QLineSeries(this); | |
208 |
|
208 | |||
209 | QChartAxis* axis0 = new QChartAxis(this); |
|
209 | QChartAxis* axis0 = new QChartAxis(this); | |
210 | QChartAxis* axis1 = new QChartAxis(this); |
|
210 | QChartAxis* axis1 = new QChartAxis(this); | |
211 | QChartAxis* axis2 = new QChartAxis(this); |
|
211 | QChartAxis* axis2 = new QChartAxis(this); | |
212 |
|
212 | |||
213 |
|
213 | |||
214 | ChartDataSet dataSet; |
|
214 | ChartDataSet dataSet; | |
215 |
|
215 | |||
216 | dataSet.addSeries(series0, axis0); |
|
216 | dataSet.addSeries(series0, axis0); | |
217 | dataSet.addSeries(series1, axis1); |
|
217 | dataSet.addSeries(series1, axis1); | |
218 | dataSet.addSeries(series2, axis2); |
|
218 | dataSet.addSeries(series2, axis2); | |
219 |
|
219 | |||
220 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
220 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
221 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
221 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
222 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
222 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
223 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
223 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
224 |
|
224 | |||
225 | dataSet.removeAllSeries(); |
|
225 | dataSet.removeAllSeries(); | |
226 |
|
226 | |||
227 | QCOMPARE(spy0.count(), 0); |
|
227 | QCOMPARE(spy0.count(), 0); | |
228 | QCOMPARE(spy1.count(), 4); |
|
228 | QCOMPARE(spy1.count(), 4); | |
229 | QCOMPARE(spy2.count(), 0); |
|
229 | QCOMPARE(spy2.count(), 0); | |
230 | QCOMPARE(spy3.count(), 3); |
|
230 | QCOMPARE(spy3.count(), 3); | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 |
|
233 | |||
234 | void tst_ChartDataSet::axisY_data() |
|
234 | void tst_ChartDataSet::axisY_data() | |
235 | { |
|
235 | { | |
236 | QTest::addColumn<QChartAxis*>("axis0"); |
|
236 | QTest::addColumn<QChartAxis*>("axis0"); | |
237 | QTest::addColumn<QChartAxis*>("axis1"); |
|
237 | QTest::addColumn<QChartAxis*>("axis1"); | |
238 | QTest::addColumn<QChartAxis*>("axis2"); |
|
238 | QTest::addColumn<QChartAxis*>("axis2"); | |
239 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); |
|
239 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); | |
240 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); |
|
240 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | void tst_ChartDataSet::axisY() |
|
243 | void tst_ChartDataSet::axisY() | |
244 | { |
|
244 | { | |
245 | QFETCH(QChartAxis*, axis0); |
|
245 | QFETCH(QChartAxis*, axis0); | |
246 | QFETCH(QChartAxis*, axis1); |
|
246 | QFETCH(QChartAxis*, axis1); | |
247 | QFETCH(QChartAxis*, axis2); |
|
247 | QFETCH(QChartAxis*, axis2); | |
248 |
|
248 | |||
249 | ChartDataSet dataSet; |
|
249 | ChartDataSet dataSet; | |
250 |
|
250 | |||
251 | QChartAxis* defaultAxisY = dataSet.axisY(); |
|
251 | QChartAxis* defaultAxisY = dataSet.axisY(); | |
252 |
|
252 | |||
253 | QVERIFY2(defaultAxisY, "Missing axisY."); |
|
253 | QVERIFY2(defaultAxisY, "Missing axisY."); | |
254 |
|
254 | |||
255 | QLineSeries* series0 = new QLineSeries(); |
|
255 | QLineSeries* series0 = new QLineSeries(); | |
256 | dataSet.addSeries(series0,axis0); |
|
256 | dataSet.addSeries(series0,axis0); | |
257 |
|
257 | |||
258 | QLineSeries* series1 = new QLineSeries(); |
|
258 | QLineSeries* series1 = new QLineSeries(); | |
259 | dataSet.addSeries(series1,axis1); |
|
259 | dataSet.addSeries(series1,axis1); | |
260 |
|
260 | |||
261 | QLineSeries* series2 = new QLineSeries(); |
|
261 | QLineSeries* series2 = new QLineSeries(); | |
262 | dataSet.addSeries(series2,axis2); |
|
262 | dataSet.addSeries(series2,axis2); | |
263 |
|
263 | |||
264 | if(!axis0) axis0=defaultAxisY ; |
|
264 | if(!axis0) axis0=defaultAxisY ; | |
265 | if(!axis1) axis1=defaultAxisY ; |
|
265 | if(!axis1) axis1=defaultAxisY ; | |
266 | if(!axis2) axis2=defaultAxisY ; |
|
266 | if(!axis2) axis2=defaultAxisY ; | |
267 |
|
267 | |||
268 | QVERIFY(dataSet.axisY(series0) == axis0); |
|
268 | QVERIFY(dataSet.axisY(series0) == axis0); | |
269 | QVERIFY(dataSet.axisY(series1) == axis1); |
|
269 | QVERIFY(dataSet.axisY(series1) == axis1); | |
270 | QVERIFY(dataSet.axisY(series2) == axis2); |
|
270 | QVERIFY(dataSet.axisY(series2) == axis2); | |
271 |
|
271 | |||
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | void tst_ChartDataSet::seriesCount_data() |
|
274 | void tst_ChartDataSet::seriesCount_data() | |
275 | { |
|
275 | { | |
276 | addSeries_data(); |
|
276 | addSeries_data(); | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | void tst_ChartDataSet::seriesCount() |
|
279 | void tst_ChartDataSet::seriesCount() | |
280 | { |
|
280 | { | |
281 | QFETCH(QLineSeries*, series0); |
|
281 | QFETCH(QLineSeries*, series0); | |
282 | QFETCH(QChartAxis*, axis0); |
|
282 | QFETCH(QChartAxis*, axis0); | |
283 | QFETCH(QLineSeries*, series1); |
|
283 | QFETCH(QLineSeries*, series1); | |
284 | QFETCH(QChartAxis*, axis1); |
|
284 | QFETCH(QChartAxis*, axis1); | |
285 | QFETCH(QLineSeries*, series2); |
|
285 | QFETCH(QLineSeries*, series2); | |
286 | QFETCH(QChartAxis*, axis2); |
|
286 | QFETCH(QChartAxis*, axis2); | |
287 | QFETCH(int, axisCount); |
|
287 | QFETCH(int, axisCount); | |
288 | Q_UNUSED(axisCount); |
|
288 | Q_UNUSED(axisCount); | |
289 |
|
289 | |||
290 | ChartDataSet dataSet; |
|
290 | ChartDataSet dataSet; | |
291 |
|
291 | |||
292 | dataSet.addSeries(series0, axis0); |
|
292 | dataSet.addSeries(series0, axis0); | |
293 | dataSet.addSeries(series1, axis1); |
|
293 | dataSet.addSeries(series1, axis1); | |
294 | dataSet.addSeries(series2, axis2); |
|
294 | dataSet.addSeries(series2, axis2); | |
295 |
|
295 | |||
296 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
296 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
297 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
297 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
298 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
298 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
299 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
299 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
300 |
|
300 | |||
301 | QCOMPARE(dataSet.seriesCount(series0->type()),3); |
|
301 | QCOMPARE(dataSet.seriesCount(series0->type()),3); | |
302 | QCOMPARE(spy0.count(), 0); |
|
302 | QCOMPARE(spy0.count(), 0); | |
303 | QCOMPARE(spy1.count(), 0); |
|
303 | QCOMPARE(spy1.count(), 0); | |
304 | QCOMPARE(spy2.count(), 0); |
|
304 | QCOMPARE(spy2.count(), 0); | |
305 | QCOMPARE(spy3.count(), 0); |
|
305 | QCOMPARE(spy3.count(), 0); | |
306 |
|
306 | |||
307 | dataSet.removeSeries(series0); |
|
307 | dataSet.removeSeries(series0); | |
308 | dataSet.removeSeries(series1); |
|
308 | dataSet.removeSeries(series1); | |
309 | dataSet.removeSeries(series2); |
|
309 | dataSet.removeSeries(series2); | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | void tst_ChartDataSet::seriesIndex_data() |
|
312 | void tst_ChartDataSet::seriesIndex_data() | |
313 | { |
|
313 | { | |
314 | addSeries_data(); |
|
314 | addSeries_data(); | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | void tst_ChartDataSet::seriesIndex() |
|
317 | void tst_ChartDataSet::seriesIndex() | |
318 | { |
|
318 | { | |
319 | //TODO: rewrite this series_index_data to match better |
|
319 | //TODO: rewrite this series_index_data to match better | |
320 |
|
320 | |||
321 | QFETCH(QLineSeries*, series0); |
|
321 | QFETCH(QLineSeries*, series0); | |
322 | QFETCH(QChartAxis*, axis0); |
|
322 | QFETCH(QChartAxis*, axis0); | |
323 | QFETCH(QLineSeries*, series1); |
|
323 | QFETCH(QLineSeries*, series1); | |
324 | QFETCH(QChartAxis*, axis1); |
|
324 | QFETCH(QChartAxis*, axis1); | |
325 | QFETCH(QLineSeries*, series2); |
|
325 | QFETCH(QLineSeries*, series2); | |
326 | QFETCH(QChartAxis*, axis2); |
|
326 | QFETCH(QChartAxis*, axis2); | |
327 | QFETCH(int, axisCount); |
|
327 | QFETCH(int, axisCount); | |
328 | Q_UNUSED(axisCount); |
|
328 | Q_UNUSED(axisCount); | |
329 |
|
329 | |||
330 | ChartDataSet dataSet; |
|
330 | ChartDataSet dataSet; | |
331 |
|
331 | |||
332 | dataSet.addSeries(series0, axis0); |
|
332 | dataSet.addSeries(series0, axis0); | |
333 | dataSet.addSeries(series1, axis1); |
|
333 | dataSet.addSeries(series1, axis1); | |
334 | dataSet.addSeries(series2, axis2); |
|
334 | dataSet.addSeries(series2, axis2); | |
335 |
|
335 | |||
336 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
336 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); | |
337 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
337 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); | |
338 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
338 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); | |
339 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
339 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); | |
340 |
|
340 | |||
341 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
341 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
342 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
342 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
343 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
343 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
344 |
|
344 | |||
345 | QCOMPARE(spy0.count(), 0); |
|
345 | QCOMPARE(spy0.count(), 0); | |
346 | QCOMPARE(spy1.count(), 0); |
|
346 | QCOMPARE(spy1.count(), 0); | |
347 | QCOMPARE(spy2.count(), 0); |
|
347 | QCOMPARE(spy2.count(), 0); | |
348 | QCOMPARE(spy3.count(), 0); |
|
348 | QCOMPARE(spy3.count(), 0); | |
349 |
|
349 | |||
350 | dataSet.removeSeries(series0); |
|
350 | dataSet.removeSeries(series0); | |
351 | dataSet.removeSeries(series1); |
|
351 | dataSet.removeSeries(series1); | |
352 | dataSet.removeSeries(series2); |
|
352 | dataSet.removeSeries(series2); | |
353 |
|
353 | |||
354 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
354 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
355 | QCOMPARE(dataSet.seriesIndex(series1),-1); |
|
355 | QCOMPARE(dataSet.seriesIndex(series1),-1); | |
356 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
356 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
357 |
|
357 | |||
358 | dataSet.addSeries(series0, axis0); |
|
358 | dataSet.addSeries(series0, axis0); | |
359 | dataSet.addSeries(series1, axis1); |
|
359 | dataSet.addSeries(series1, axis1); | |
360 | dataSet.addSeries(series2, axis2); |
|
360 | dataSet.addSeries(series2, axis2); | |
361 |
|
361 | |||
362 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
362 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
363 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
363 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
364 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
364 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
365 |
|
365 | |||
366 | dataSet.removeSeries(series1); |
|
366 | dataSet.removeSeries(series1); | |
367 |
|
367 | |||
368 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
368 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
369 | QCOMPARE(dataSet.seriesIndex(series1),-1); |
|
369 | QCOMPARE(dataSet.seriesIndex(series1),-1); | |
370 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
370 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
371 |
|
371 | |||
372 | dataSet.addSeries(series1, axis1); |
|
372 | dataSet.addSeries(series1, axis1); | |
373 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
373 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
374 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
374 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
375 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
375 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
376 |
|
376 | |||
377 | dataSet.removeSeries(series2); |
|
377 | dataSet.removeSeries(series2); | |
378 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
378 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
379 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
379 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
380 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
380 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
381 |
|
381 | |||
382 | dataSet.removeSeries(series0); |
|
382 | dataSet.removeSeries(series0); | |
383 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
383 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
384 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
384 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
385 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
385 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
386 |
|
386 | |||
387 | dataSet.addSeries(series2); |
|
387 | dataSet.addSeries(series2); | |
388 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
388 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
389 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
389 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
390 | QCOMPARE(dataSet.seriesIndex(series2),0); |
|
390 | QCOMPARE(dataSet.seriesIndex(series2),0); | |
391 |
|
391 | |||
392 | dataSet.addSeries(series0); |
|
392 | dataSet.addSeries(series0); | |
393 | QCOMPARE(dataSet.seriesIndex(series0),2); |
|
393 | QCOMPARE(dataSet.seriesIndex(series0),2); | |
394 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
394 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
395 | QCOMPARE(dataSet.seriesIndex(series2),0); |
|
395 | QCOMPARE(dataSet.seriesIndex(series2),0); | |
396 |
|
396 | |||
397 | dataSet.removeSeries(series0); |
|
397 | dataSet.removeSeries(series0); | |
398 | dataSet.removeSeries(series1); |
|
398 | dataSet.removeSeries(series1); | |
399 | dataSet.removeSeries(series2); |
|
399 | dataSet.removeSeries(series2); | |
400 |
|
400 | |||
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | void tst_ChartDataSet::domain_data() |
|
403 | void tst_ChartDataSet::domain_data() | |
404 | { |
|
404 | { | |
405 | addSeries_data(); |
|
405 | addSeries_data(); | |
406 | } |
|
406 | } | |
407 |
|
407 | |||
408 | void tst_ChartDataSet::domain() |
|
408 | void tst_ChartDataSet::domain() | |
409 | { |
|
409 | { | |
410 | QFETCH(QLineSeries*, series0); |
|
410 | QFETCH(QLineSeries*, series0); | |
411 | QFETCH(QChartAxis*, axis0); |
|
411 | QFETCH(QChartAxis*, axis0); | |
412 | QFETCH(QLineSeries*, series1); |
|
412 | QFETCH(QLineSeries*, series1); | |
413 | QFETCH(QChartAxis*, axis1); |
|
413 | QFETCH(QChartAxis*, axis1); | |
414 | QFETCH(QLineSeries*, series2); |
|
414 | QFETCH(QLineSeries*, series2); | |
415 | QFETCH(QChartAxis*, axis2); |
|
415 | QFETCH(QChartAxis*, axis2); | |
416 | QFETCH(int, axisCount); |
|
416 | QFETCH(int, axisCount); | |
417 | Q_UNUSED(axisCount); |
|
417 | Q_UNUSED(axisCount); | |
418 |
|
418 | |||
419 | ChartDataSet dataSet; |
|
419 | ChartDataSet dataSet; | |
420 |
|
420 | |||
421 | dataSet.addSeries(series0, axis0); |
|
421 | dataSet.addSeries(series0, axis0); | |
422 | dataSet.addSeries(series1, axis1); |
|
422 | dataSet.addSeries(series1, axis1); | |
423 | dataSet.addSeries(series2, axis2); |
|
423 | dataSet.addSeries(series2, axis2); | |
424 |
|
424 | |||
425 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
425 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
426 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
426 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
427 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
427 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
428 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
428 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
429 |
|
429 | |||
430 | QVERIFY(dataSet.domain(axis0)==dataSet.domain(series0)); |
|
430 | QVERIFY(dataSet.domain(axis0)==dataSet.domain(series0)); | |
431 | QVERIFY(dataSet.domain(axis1)==dataSet.domain(series1)); |
|
431 | QVERIFY(dataSet.domain(axis1)==dataSet.domain(series1)); | |
432 | QVERIFY(dataSet.domain(axis2)==dataSet.domain(series2)); |
|
432 | QVERIFY(dataSet.domain(axis2)==dataSet.domain(series2)); | |
433 | QCOMPARE(spy0.count(), 0); |
|
433 | QCOMPARE(spy0.count(), 0); | |
434 | QCOMPARE(spy1.count(), 0); |
|
434 | QCOMPARE(spy1.count(), 0); | |
435 | QCOMPARE(spy2.count(), 0); |
|
435 | QCOMPARE(spy2.count(), 0); | |
436 | QCOMPARE(spy3.count(), 0); |
|
436 | QCOMPARE(spy3.count(), 0); | |
437 |
|
437 | |||
438 | dataSet.removeSeries(series0); |
|
438 | dataSet.removeSeries(series0); | |
439 | dataSet.removeSeries(series1); |
|
439 | dataSet.removeSeries(series1); | |
440 | dataSet.removeSeries(series2); |
|
440 | dataSet.removeSeries(series2); | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | void tst_ChartDataSet::zoomInDomain_data() |
|
443 | void tst_ChartDataSet::zoomInDomain_data() | |
444 | { |
|
444 | { | |
445 | addSeries_data(); |
|
445 | addSeries_data(); | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | void tst_ChartDataSet::zoomInDomain() |
|
448 | void tst_ChartDataSet::zoomInDomain() | |
449 | { |
|
449 | { | |
450 | QFETCH(QLineSeries*, series0); |
|
450 | QFETCH(QLineSeries*, series0); | |
451 | QFETCH(QChartAxis*, axis0); |
|
451 | QFETCH(QChartAxis*, axis0); | |
452 | QFETCH(QLineSeries*, series1); |
|
452 | QFETCH(QLineSeries*, series1); | |
453 | QFETCH(QChartAxis*, axis1); |
|
453 | QFETCH(QChartAxis*, axis1); | |
454 | QFETCH(QLineSeries*, series2); |
|
454 | QFETCH(QLineSeries*, series2); | |
455 | QFETCH(QChartAxis*, axis2); |
|
455 | QFETCH(QChartAxis*, axis2); | |
456 | QFETCH(int, axisCount); |
|
456 | QFETCH(int, axisCount); | |
457 |
|
457 | |||
458 | Q_UNUSED(axisCount); |
|
458 | Q_UNUSED(axisCount); | |
459 | ChartDataSet dataSet; |
|
459 | ChartDataSet dataSet; | |
460 |
|
460 | |||
461 | dataSet.addSeries(series0, axis0); |
|
461 | dataSet.addSeries(series0, axis0); | |
462 | dataSet.addSeries(series1, axis1); |
|
462 | dataSet.addSeries(series1, axis1); | |
463 | dataSet.addSeries(series2, axis2); |
|
463 | dataSet.addSeries(series2, axis2); | |
464 |
|
464 | |||
465 | Domain* domain0 = dataSet.domain(series0); |
|
465 | Domain* domain0 = dataSet.domain(series0); | |
466 | Domain* domain1 = dataSet.domain(series1); |
|
466 | Domain* domain1 = dataSet.domain(series1); | |
467 | Domain* domain2 = dataSet.domain(series2); |
|
467 | Domain* domain2 = dataSet.domain(series2); | |
468 |
|
468 | |||
469 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
469 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
470 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
470 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
471 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
471 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
472 |
|
472 | |||
473 | dataSet.zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
473 | dataSet.zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
474 |
|
474 | |||
475 | QCOMPARE(spy0.count(), 1); |
|
475 | QCOMPARE(spy0.count(), 1); | |
476 | QCOMPARE(spy1.count(), 1); |
|
476 | QCOMPARE(spy1.count(), 1); | |
477 | QCOMPARE(spy2.count(), 1); |
|
477 | QCOMPARE(spy2.count(), 1); | |
478 |
|
478 | |||
479 | dataSet.removeSeries(series0); |
|
479 | dataSet.removeSeries(series0); | |
480 | dataSet.removeSeries(series1); |
|
480 | dataSet.removeSeries(series1); | |
481 | dataSet.removeSeries(series2); |
|
481 | dataSet.removeSeries(series2); | |
482 | } |
|
482 | } | |
483 |
|
483 | |||
484 | void tst_ChartDataSet::zoomOutDomain_data() |
|
484 | void tst_ChartDataSet::zoomOutDomain_data() | |
485 | { |
|
485 | { | |
486 | addSeries_data(); |
|
486 | addSeries_data(); | |
487 | } |
|
487 | } | |
488 |
|
488 | |||
489 | void tst_ChartDataSet::zoomOutDomain() |
|
489 | void tst_ChartDataSet::zoomOutDomain() | |
490 | { |
|
490 | { | |
491 | QFETCH(QLineSeries*, series0); |
|
491 | QFETCH(QLineSeries*, series0); | |
492 | QFETCH(QChartAxis*, axis0); |
|
492 | QFETCH(QChartAxis*, axis0); | |
493 | QFETCH(QLineSeries*, series1); |
|
493 | QFETCH(QLineSeries*, series1); | |
494 | QFETCH(QChartAxis*, axis1); |
|
494 | QFETCH(QChartAxis*, axis1); | |
495 | QFETCH(QLineSeries*, series2); |
|
495 | QFETCH(QLineSeries*, series2); | |
496 | QFETCH(QChartAxis*, axis2); |
|
496 | QFETCH(QChartAxis*, axis2); | |
497 | QFETCH(int, axisCount); |
|
497 | QFETCH(int, axisCount); | |
498 |
|
498 | |||
499 | Q_UNUSED(axisCount); |
|
499 | Q_UNUSED(axisCount); | |
500 |
|
500 | |||
501 | ChartDataSet dataSet; |
|
501 | ChartDataSet dataSet; | |
502 |
|
502 | |||
503 | dataSet.addSeries(series0, axis0); |
|
503 | dataSet.addSeries(series0, axis0); | |
504 | dataSet.addSeries(series1, axis1); |
|
504 | dataSet.addSeries(series1, axis1); | |
505 | dataSet.addSeries(series2, axis2); |
|
505 | dataSet.addSeries(series2, axis2); | |
506 |
|
506 | |||
507 | Domain* domain0 = dataSet.domain(series0); |
|
507 | Domain* domain0 = dataSet.domain(series0); | |
508 | Domain* domain1 = dataSet.domain(series1); |
|
508 | Domain* domain1 = dataSet.domain(series1); | |
509 | Domain* domain2 = dataSet.domain(series2); |
|
509 | Domain* domain2 = dataSet.domain(series2); | |
510 |
|
510 | |||
511 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
511 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
512 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
512 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
513 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
513 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
514 |
|
514 | |||
515 | dataSet.zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
515 | dataSet.zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
516 |
|
516 | |||
517 | QCOMPARE(spy0.count(), 1); |
|
517 | QCOMPARE(spy0.count(), 1); | |
518 | QCOMPARE(spy1.count(), 1); |
|
518 | QCOMPARE(spy1.count(), 1); | |
519 | QCOMPARE(spy2.count(), 1); |
|
519 | QCOMPARE(spy2.count(), 1); | |
520 |
|
520 | |||
521 | dataSet.removeSeries(series0); |
|
521 | dataSet.removeSeries(series0); | |
522 | dataSet.removeSeries(series1); |
|
522 | dataSet.removeSeries(series1); | |
523 | dataSet.removeSeries(series2); |
|
523 | dataSet.removeSeries(series2); | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | void tst_ChartDataSet::scrollDomain_data() |
|
526 | void tst_ChartDataSet::scrollDomain_data() | |
527 | { |
|
527 | { | |
528 | addSeries_data(); |
|
528 | addSeries_data(); | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | void tst_ChartDataSet::scrollDomain() |
|
531 | void tst_ChartDataSet::scrollDomain() | |
532 | { |
|
532 | { | |
533 | QFETCH(QLineSeries*, series0); |
|
533 | QFETCH(QLineSeries*, series0); | |
534 | QFETCH(QChartAxis*, axis0); |
|
534 | QFETCH(QChartAxis*, axis0); | |
535 | QFETCH(QLineSeries*, series1); |
|
535 | QFETCH(QLineSeries*, series1); | |
536 | QFETCH(QChartAxis*, axis1); |
|
536 | QFETCH(QChartAxis*, axis1); | |
537 | QFETCH(QLineSeries*, series2); |
|
537 | QFETCH(QLineSeries*, series2); | |
538 | QFETCH(QChartAxis*, axis2); |
|
538 | QFETCH(QChartAxis*, axis2); | |
539 | QFETCH(int, axisCount); |
|
539 | QFETCH(int, axisCount); | |
540 |
|
540 | |||
541 | Q_UNUSED(axisCount); |
|
541 | Q_UNUSED(axisCount); | |
542 |
|
542 | |||
543 | ChartDataSet dataSet; |
|
543 | ChartDataSet dataSet; | |
544 |
|
544 | |||
545 | dataSet.addSeries(series0, axis0); |
|
545 | dataSet.addSeries(series0, axis0); | |
546 | dataSet.addSeries(series1, axis1); |
|
546 | dataSet.addSeries(series1, axis1); | |
547 | dataSet.addSeries(series2, axis2); |
|
547 | dataSet.addSeries(series2, axis2); | |
548 |
|
548 | |||
549 | Domain* domain0 = dataSet.domain(series0); |
|
549 | Domain* domain0 = dataSet.domain(series0); | |
550 | Domain* domain1 = dataSet.domain(series1); |
|
550 | Domain* domain1 = dataSet.domain(series1); | |
551 | Domain* domain2 = dataSet.domain(series2); |
|
551 | Domain* domain2 = dataSet.domain(series2); | |
552 |
|
552 | |||
553 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
553 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
554 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
554 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
555 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
555 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
556 |
|
556 | |||
557 | dataSet.scrollDomain(10,10,QSize(1000,1000)); |
|
557 | dataSet.scrollDomain(10,10,QSize(1000,1000)); | |
558 |
|
558 | |||
559 | QCOMPARE(spy0.count(), 1); |
|
559 | QCOMPARE(spy0.count(), 1); | |
560 | QCOMPARE(spy1.count(), 1); |
|
560 | QCOMPARE(spy1.count(), 1); | |
561 | QCOMPARE(spy2.count(), 1); |
|
561 | QCOMPARE(spy2.count(), 1); | |
562 |
|
562 | |||
563 | dataSet.removeSeries(series0); |
|
563 | dataSet.removeSeries(series0); | |
564 | dataSet.removeSeries(series1); |
|
564 | dataSet.removeSeries(series1); | |
565 | dataSet.removeSeries(series2); |
|
565 | dataSet.removeSeries(series2); | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | QTEST_MAIN(tst_ChartDataSet) |
|
568 | QTEST_MAIN(tst_ChartDataSet) | |
569 | #include "tst_chartdataset.moc" |
|
569 | #include "tst_chartdataset.moc" | |
570 |
|
570 |
@@ -1,572 +1,572 | |||||
1 | #include <QtTest/QtTest> |
|
1 | #include <QtTest/QtTest> | |
2 | #include <qchartview.h> |
|
2 | #include <qchartview.h> | |
3 | #include <qlineseries.h> |
|
3 | #include <qlineseries.h> | |
4 | #include <qareaseries.h> |
|
4 | #include <qareaseries.h> | |
5 | #include <qscatterseries.h> |
|
5 | #include <qscatterseries.h> | |
6 | #include <qsplineseries.h> |
|
6 | #include <qsplineseries.h> | |
7 | #include <qpieseries.h> |
|
7 | #include <qpieseries.h> | |
8 | #include <qbarseries.h> |
|
8 | #include <qbarseries.h> | |
9 | #include <qpercentbarseries.h> |
|
9 | #include <qpercentbarseries.h> | |
10 | #include <qstackedbarseries.h> |
|
10 | #include <qstackedbarseries.h> | |
11 |
|
11 | |||
12 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
12 | QTCOMMERCIALCHART_USE_NAMESPACE | |
13 |
|
13 | |||
14 | Q_DECLARE_METATYPE(QChartAxis*) |
|
14 | Q_DECLARE_METATYPE(QChartAxis *) | |
15 | Q_DECLARE_METATYPE(QSeries*) |
|
15 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
16 | Q_DECLARE_METATYPE(QChart::AnimationOption) |
|
16 | Q_DECLARE_METATYPE(QChart::AnimationOption) | |
17 | Q_DECLARE_METATYPE(QBrush) |
|
17 | Q_DECLARE_METATYPE(QBrush) | |
18 | Q_DECLARE_METATYPE(QPen) |
|
18 | Q_DECLARE_METATYPE(QPen) | |
19 | Q_DECLARE_METATYPE(QChart::ChartTheme) |
|
19 | Q_DECLARE_METATYPE(QChart::ChartTheme) | |
20 |
|
20 | |||
21 | class tst_QChart : public QObject |
|
21 | class tst_QChart : public QObject | |
22 | { |
|
22 | { | |
23 | Q_OBJECT |
|
23 | Q_OBJECT | |
24 |
|
24 | |||
25 | public slots: |
|
25 | public slots: | |
26 | void initTestCase(); |
|
26 | void initTestCase(); | |
27 | void cleanupTestCase(); |
|
27 | void cleanupTestCase(); | |
28 | void init(); |
|
28 | void init(); | |
29 | void cleanup(); |
|
29 | void cleanup(); | |
30 |
|
30 | |||
31 | private slots: |
|
31 | private slots: | |
32 | void qchart_data(); |
|
32 | void qchart_data(); | |
33 | void qchart(); |
|
33 | void qchart(); | |
34 |
|
34 | |||
35 | void addSeries_data(); |
|
35 | void addSeries_data(); | |
36 | void addSeries(); |
|
36 | void addSeries(); | |
37 | void animationOptions_data(); |
|
37 | void animationOptions_data(); | |
38 | void animationOptions(); |
|
38 | void animationOptions(); | |
39 | void axisX_data(); |
|
39 | void axisX_data(); | |
40 | void axisX(); |
|
40 | void axisX(); | |
41 | void axisY_data(); |
|
41 | void axisY_data(); | |
42 | void axisY(); |
|
42 | void axisY(); | |
43 | void backgroundBrush_data(); |
|
43 | void backgroundBrush_data(); | |
44 | void backgroundBrush(); |
|
44 | void backgroundBrush(); | |
45 | void backgroundPen_data(); |
|
45 | void backgroundPen_data(); | |
46 | void backgroundPen(); |
|
46 | void backgroundPen(); | |
47 | void isBackgroundVisible_data(); |
|
47 | void isBackgroundVisible_data(); | |
48 | void isBackgroundVisible(); |
|
48 | void isBackgroundVisible(); | |
49 | void legend_data(); |
|
49 | void legend_data(); | |
50 | void legend(); |
|
50 | void legend(); | |
51 | void margins_data(); |
|
51 | void margins_data(); | |
52 | void margins(); |
|
52 | void margins(); | |
53 | void removeAllSeries_data(); |
|
53 | void removeAllSeries_data(); | |
54 | void removeAllSeries(); |
|
54 | void removeAllSeries(); | |
55 | void removeSeries_data(); |
|
55 | void removeSeries_data(); | |
56 | void removeSeries(); |
|
56 | void removeSeries(); | |
57 | void scrollDown_data(); |
|
57 | void scrollDown_data(); | |
58 | void scrollDown(); |
|
58 | void scrollDown(); | |
59 | void scrollLeft_data(); |
|
59 | void scrollLeft_data(); | |
60 | void scrollLeft(); |
|
60 | void scrollLeft(); | |
61 | void scrollRight_data(); |
|
61 | void scrollRight_data(); | |
62 | void scrollRight(); |
|
62 | void scrollRight(); | |
63 | void scrollUp_data(); |
|
63 | void scrollUp_data(); | |
64 | void scrollUp(); |
|
64 | void scrollUp(); | |
65 | void theme_data(); |
|
65 | void theme_data(); | |
66 | void theme(); |
|
66 | void theme(); | |
67 | void title_data(); |
|
67 | void title_data(); | |
68 | void title(); |
|
68 | void title(); | |
69 | void titleBrush_data(); |
|
69 | void titleBrush_data(); | |
70 | void titleBrush(); |
|
70 | void titleBrush(); | |
71 | void titleFont_data(); |
|
71 | void titleFont_data(); | |
72 | void titleFont(); |
|
72 | void titleFont(); | |
73 | void zoomIn_data(); |
|
73 | void zoomIn_data(); | |
74 | void zoomIn(); |
|
74 | void zoomIn(); | |
75 | void zoomOut_data(); |
|
75 | void zoomOut_data(); | |
76 | void zoomOut(); |
|
76 | void zoomOut(); | |
77 |
|
77 | |||
78 | private: |
|
78 | private: | |
79 | void createTestData(); |
|
79 | void createTestData(); | |
80 |
|
80 | |||
81 | private: |
|
81 | private: | |
82 | QChartView* m_view; |
|
82 | QChartView* m_view; | |
83 | QChart* m_chart; |
|
83 | QChart* m_chart; | |
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | void tst_QChart::initTestCase() |
|
86 | void tst_QChart::initTestCase() | |
87 | { |
|
87 | { | |
88 |
|
88 | |||
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | void tst_QChart::cleanupTestCase() |
|
91 | void tst_QChart::cleanupTestCase() | |
92 | { |
|
92 | { | |
93 |
|
93 | |||
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | void tst_QChart::init() |
|
96 | void tst_QChart::init() | |
97 | { |
|
97 | { | |
98 | m_view = new QChartView(new QChart()); |
|
98 | m_view = new QChartView(new QChart()); | |
99 | m_chart = m_view->chart(); |
|
99 | m_chart = m_view->chart(); | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | void tst_QChart::createTestData() |
|
102 | void tst_QChart::createTestData() | |
103 | { |
|
103 | { | |
104 | QLineSeries* series0 = new QLineSeries(this); |
|
104 | QLineSeries* series0 = new QLineSeries(this); | |
105 | *series0 << QPointF(0, 0) << QPointF(100, 100); |
|
105 | *series0 << QPointF(0, 0) << QPointF(100, 100); | |
106 | m_chart->addSeries(series0); |
|
106 | m_chart->addSeries(series0); | |
107 | m_view->show(); |
|
107 | m_view->show(); | |
108 | QTest::qWaitForWindowShown(m_view); |
|
108 | QTest::qWaitForWindowShown(m_view); | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | void tst_QChart::cleanup() |
|
111 | void tst_QChart::cleanup() | |
112 | { |
|
112 | { | |
113 | delete m_view; |
|
113 | delete m_view; | |
114 | m_view = 0; |
|
114 | m_view = 0; | |
115 | m_chart = 0; |
|
115 | m_chart = 0; | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void tst_QChart::qchart_data() |
|
118 | void tst_QChart::qchart_data() | |
119 | { |
|
119 | { | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | void tst_QChart::qchart() |
|
122 | void tst_QChart::qchart() | |
123 | { |
|
123 | { | |
124 | QVERIFY(m_chart); |
|
124 | QVERIFY(m_chart); | |
125 | QVERIFY(m_chart->legend()); |
|
125 | QVERIFY(m_chart->legend()); | |
126 | QVERIFY(!m_chart->legend()->isVisible()); |
|
126 | QVERIFY(!m_chart->legend()->isVisible()); | |
127 |
|
127 | |||
128 | QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); |
|
128 | QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); | |
129 | QVERIFY(m_chart->axisX()); |
|
129 | QVERIFY(m_chart->axisX()); | |
130 | QVERIFY(m_chart->axisY()); |
|
130 | QVERIFY(m_chart->axisY()); | |
131 | QVERIFY(m_chart->backgroundBrush()!=QBrush()); |
|
131 | QVERIFY(m_chart->backgroundBrush()!=QBrush()); | |
132 | QVERIFY(m_chart->backgroundPen()!=QPen()); |
|
132 | QVERIFY(m_chart->backgroundPen()!=QPen()); | |
133 | QCOMPARE(m_chart->isBackgroundVisible(), true); |
|
133 | QCOMPARE(m_chart->isBackgroundVisible(), true); | |
134 |
|
134 | |||
135 | QVERIFY(m_chart->margins().top()>0); |
|
135 | QVERIFY(m_chart->margins().top()>0); | |
136 | QVERIFY(m_chart->margins().left()>0); |
|
136 | QVERIFY(m_chart->margins().left()>0); | |
137 | QVERIFY(m_chart->margins().right()>0); |
|
137 | QVERIFY(m_chart->margins().right()>0); | |
138 | QVERIFY(m_chart->margins().bottom()>0); |
|
138 | QVERIFY(m_chart->margins().bottom()>0); | |
139 |
|
139 | |||
140 | QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); |
|
140 | QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); | |
141 | QCOMPARE(m_chart->title(), QString()); |
|
141 | QCOMPARE(m_chart->title(), QString()); | |
142 |
|
142 | |||
143 | //QCOMPARE(m_chart->titleBrush(),QBrush()); |
|
143 | //QCOMPARE(m_chart->titleBrush(),QBrush()); | |
144 | //QCOMPARE(m_chart->titleFont(),QFont()); |
|
144 | //QCOMPARE(m_chart->titleFont(),QFont()); | |
145 |
|
145 | |||
146 | m_chart->removeAllSeries(); |
|
146 | m_chart->removeAllSeries(); | |
147 | m_chart->scrollDown(); |
|
147 | m_chart->scrollDown(); | |
148 | m_chart->scrollLeft(); |
|
148 | m_chart->scrollLeft(); | |
149 | m_chart->scrollRight(); |
|
149 | m_chart->scrollRight(); | |
150 | m_chart->scrollUp(); |
|
150 | m_chart->scrollUp(); | |
151 |
|
151 | |||
152 | m_chart->zoomIn(); |
|
152 | m_chart->zoomIn(); | |
153 | m_chart->zoomIn(QRectF()); |
|
153 | m_chart->zoomIn(QRectF()); | |
154 | m_chart->zoomOut(); |
|
154 | m_chart->zoomOut(); | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | void tst_QChart::addSeries_data() |
|
157 | void tst_QChart::addSeries_data() | |
158 | { |
|
158 | { | |
159 | QTest::addColumn<QSeries*>("series"); |
|
159 | QTest::addColumn<QAbstractSeries *>("series"); | |
160 | QTest::addColumn<QChartAxis*>("axis"); |
|
160 | QTest::addColumn<QChartAxis *>("axis"); | |
161 |
|
161 | |||
162 | QSeries* series0 = new QLineSeries(this); |
|
162 | QAbstractSeries* series0 = new QLineSeries(this); | |
163 | QSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); |
|
163 | QAbstractSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); | |
164 | QSeries* series2 = new QScatterSeries(this); |
|
164 | QAbstractSeries* series2 = new QScatterSeries(this); | |
165 | QSeries* series3 = new QSplineSeries(this); |
|
165 | QAbstractSeries* series3 = new QSplineSeries(this); | |
166 | QSeries* series4 = new QPieSeries(this); |
|
166 | QAbstractSeries* series4 = new QPieSeries(this); | |
167 | QSeries* series5 = new QBarSeries(QBarCategories(),this); |
|
167 | QAbstractSeries* series5 = new QBarSeries(QBarCategories(),this); | |
168 | QSeries* series6 = new QPercentBarSeries(QBarCategories(),this); |
|
168 | QAbstractSeries* series6 = new QPercentBarSeries(QBarCategories(),this); | |
169 | QSeries* series7 = new QStackedBarSeries(QBarCategories(),this); |
|
169 | QAbstractSeries* series7 = new QStackedBarSeries(QBarCategories(),this); | |
170 |
|
170 | |||
171 | QChartAxis* axis = new QChartAxis(this); |
|
171 | QChartAxis* axis = new QChartAxis(this); | |
172 |
|
172 | |||
173 | QTest::newRow("default axis: lineSeries") << series0 << (QChartAxis*) 0; |
|
173 | QTest::newRow("default axis: lineSeries") << series0 << (QChartAxis*) 0; | |
174 | QTest::newRow("axis0: lineSeries") << series0 << axis; |
|
174 | QTest::newRow("axis0: lineSeries") << series0 << axis; | |
175 | QTest::newRow("default axis: areaSeries") << series1 << (QChartAxis*) 0; |
|
175 | QTest::newRow("default axis: areaSeries") << series1 << (QChartAxis*) 0; | |
176 | QTest::newRow("axis: areaSeries") << series1 << axis; |
|
176 | QTest::newRow("axis: areaSeries") << series1 << axis; | |
177 | QTest::newRow("default axis: scatterSeries") << series2 << (QChartAxis*) 0; |
|
177 | QTest::newRow("default axis: scatterSeries") << series2 << (QChartAxis*) 0; | |
178 | QTest::newRow("axis1: scatterSeries") << series2 << axis; |
|
178 | QTest::newRow("axis1: scatterSeries") << series2 << axis; | |
179 | QTest::newRow("default axis: splineSeries") << series3 << (QChartAxis*) 0; |
|
179 | QTest::newRow("default axis: splineSeries") << series3 << (QChartAxis*) 0; | |
180 | QTest::newRow("axis: splineSeries") << series3 << axis; |
|
180 | QTest::newRow("axis: splineSeries") << series3 << axis; | |
181 | QTest::newRow("default axis: pieSeries") << series4 << (QChartAxis*) 0; |
|
181 | QTest::newRow("default axis: pieSeries") << series4 << (QChartAxis*) 0; | |
182 | QTest::newRow("axis: pieSeries") << series4 << axis; |
|
182 | QTest::newRow("axis: pieSeries") << series4 << axis; | |
183 | QTest::newRow("default axis: barSeries") << series5 << (QChartAxis*) 0; |
|
183 | QTest::newRow("default axis: barSeries") << series5 << (QChartAxis*) 0; | |
184 | QTest::newRow("axis: barSeries") << series5 << axis; |
|
184 | QTest::newRow("axis: barSeries") << series5 << axis; | |
185 | QTest::newRow("default axis: percentBarSeries") << series6 << (QChartAxis*) 0; |
|
185 | QTest::newRow("default axis: percentBarSeries") << series6 << (QChartAxis*) 0; | |
186 | QTest::newRow("axis: barSeries") << series6 << axis; |
|
186 | QTest::newRow("axis: barSeries") << series6 << axis; | |
187 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QChartAxis*) 0; |
|
187 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QChartAxis*) 0; | |
188 | QTest::newRow("axis: barSeries") << series7 << axis; |
|
188 | QTest::newRow("axis: barSeries") << series7 << axis; | |
189 |
|
189 | |||
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | void tst_QChart::addSeries() |
|
192 | void tst_QChart::addSeries() | |
193 | { |
|
193 | { | |
194 | QFETCH(QSeries*, series); |
|
194 | QFETCH(QAbstractSeries *, series); | |
195 | QFETCH(QChartAxis*, axis); |
|
195 | QFETCH(QChartAxis *, axis); | |
196 | m_view->show(); |
|
196 | m_view->show(); | |
197 | QTest::qWaitForWindowShown(m_view); |
|
197 | QTest::qWaitForWindowShown(m_view); | |
198 | if(!axis) axis = m_chart->axisY(); |
|
198 | if(!axis) axis = m_chart->axisY(); | |
199 | m_chart->addSeries(series,axis); |
|
199 | m_chart->addSeries(series,axis); | |
200 | QCOMPARE(m_chart->axisY(series),axis); |
|
200 | QCOMPARE(m_chart->axisY(series),axis); | |
201 | m_chart->removeSeries(series); |
|
201 | m_chart->removeSeries(series); | |
202 |
|
202 | |||
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | void tst_QChart::animationOptions_data() |
|
205 | void tst_QChart::animationOptions_data() | |
206 | { |
|
206 | { | |
207 | QTest::addColumn<QChart::AnimationOption>("animationOptions"); |
|
207 | QTest::addColumn<QChart::AnimationOption>("animationOptions"); | |
208 | QTest::newRow("AllAnimations") << QChart::AllAnimations; |
|
208 | QTest::newRow("AllAnimations") << QChart::AllAnimations; | |
209 | QTest::newRow("NoAnimation") << QChart::NoAnimation; |
|
209 | QTest::newRow("NoAnimation") << QChart::NoAnimation; | |
210 | QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations; |
|
210 | QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations; | |
211 | QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations; |
|
211 | QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations; | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void tst_QChart::animationOptions() |
|
214 | void tst_QChart::animationOptions() | |
215 | { |
|
215 | { | |
216 | createTestData(); |
|
216 | createTestData(); | |
217 | QFETCH(QChart::AnimationOption, animationOptions); |
|
217 | QFETCH(QChart::AnimationOption, animationOptions); | |
218 | m_chart->setAnimationOptions(animationOptions); |
|
218 | m_chart->setAnimationOptions(animationOptions); | |
219 | QCOMPARE(m_chart->animationOptions(), animationOptions); |
|
219 | QCOMPARE(m_chart->animationOptions(), animationOptions); | |
220 | } |
|
220 | } | |
221 |
|
221 | |||
222 | void tst_QChart::axisX_data() |
|
222 | void tst_QChart::axisX_data() | |
223 | { |
|
223 | { | |
224 |
|
224 | |||
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | void tst_QChart::axisX() |
|
227 | void tst_QChart::axisX() | |
228 | { |
|
228 | { | |
229 | QVERIFY(m_chart->axisX()); |
|
229 | QVERIFY(m_chart->axisX()); | |
230 | QChartAxis* axis = m_chart->axisX(); |
|
230 | QChartAxis* axis = m_chart->axisX(); | |
231 | createTestData(); |
|
231 | createTestData(); | |
232 | //it should be the same axis |
|
232 | //it should be the same axis | |
233 | QCOMPARE(axis,m_chart->axisX()); |
|
233 | QCOMPARE(axis,m_chart->axisX()); | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | void tst_QChart::axisY_data() |
|
236 | void tst_QChart::axisY_data() | |
237 | { |
|
237 | { | |
238 | QTest::addColumn<QChartAxis*>("axis0"); |
|
238 | QTest::addColumn<QChartAxis*>("axis0"); | |
239 | QTest::addColumn<QChartAxis*>("axis1"); |
|
239 | QTest::addColumn<QChartAxis*>("axis1"); | |
240 | QTest::addColumn<QChartAxis*>("axis2"); |
|
240 | QTest::addColumn<QChartAxis*>("axis2"); | |
241 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); |
|
241 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); | |
242 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); |
|
242 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); | |
243 | } |
|
243 | } | |
244 |
|
244 | |||
245 |
|
245 | |||
246 | void tst_QChart::axisY() |
|
246 | void tst_QChart::axisY() | |
247 | { |
|
247 | { | |
248 | QFETCH(QChartAxis*, axis0); |
|
248 | QFETCH(QChartAxis*, axis0); | |
249 | QFETCH(QChartAxis*, axis1); |
|
249 | QFETCH(QChartAxis*, axis1); | |
250 | QFETCH(QChartAxis*, axis2); |
|
250 | QFETCH(QChartAxis*, axis2); | |
251 |
|
251 | |||
252 | QChartAxis* defaultAxisY = m_chart->axisY(); |
|
252 | QChartAxis* defaultAxisY = m_chart->axisY(); | |
253 |
|
253 | |||
254 | QVERIFY2(defaultAxisY, "Missing axisY."); |
|
254 | QVERIFY2(defaultAxisY, "Missing axisY."); | |
255 |
|
255 | |||
256 | QLineSeries* series0 = new QLineSeries(); |
|
256 | QLineSeries* series0 = new QLineSeries(); | |
257 | m_chart->addSeries(series0, axis0); |
|
257 | m_chart->addSeries(series0, axis0); | |
258 |
|
258 | |||
259 | QLineSeries* series1 = new QLineSeries(); |
|
259 | QLineSeries* series1 = new QLineSeries(); | |
260 | m_chart->addSeries(series1, axis1); |
|
260 | m_chart->addSeries(series1, axis1); | |
261 |
|
261 | |||
262 | QLineSeries* series2 = new QLineSeries(); |
|
262 | QLineSeries* series2 = new QLineSeries(); | |
263 | m_chart->addSeries(series2, axis2); |
|
263 | m_chart->addSeries(series2, axis2); | |
264 |
|
264 | |||
265 | if (!axis0) |
|
265 | if (!axis0) | |
266 | axis0 = defaultAxisY; |
|
266 | axis0 = defaultAxisY; | |
267 | if (!axis1) |
|
267 | if (!axis1) | |
268 | axis1 = defaultAxisY; |
|
268 | axis1 = defaultAxisY; | |
269 | if (!axis2) |
|
269 | if (!axis2) | |
270 | axis2 = defaultAxisY; |
|
270 | axis2 = defaultAxisY; | |
271 |
|
271 | |||
272 | QVERIFY(m_chart->axisY(series0) == axis0); |
|
272 | QVERIFY(m_chart->axisY(series0) == axis0); | |
273 | QVERIFY(m_chart->axisY(series1) == axis1); |
|
273 | QVERIFY(m_chart->axisY(series1) == axis1); | |
274 | QVERIFY(m_chart->axisY(series2) == axis2); |
|
274 | QVERIFY(m_chart->axisY(series2) == axis2); | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | void tst_QChart::backgroundBrush_data() |
|
277 | void tst_QChart::backgroundBrush_data() | |
278 | { |
|
278 | { | |
279 | QTest::addColumn<QBrush>("backgroundBrush"); |
|
279 | QTest::addColumn<QBrush>("backgroundBrush"); | |
280 | QTest::newRow("null") << QBrush(); |
|
280 | QTest::newRow("null") << QBrush(); | |
281 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
281 | QTest::newRow("blue") << QBrush(Qt::blue); | |
282 | QTest::newRow("white") << QBrush(Qt::white); |
|
282 | QTest::newRow("white") << QBrush(Qt::white); | |
283 | QTest::newRow("black") << QBrush(Qt::black); |
|
283 | QTest::newRow("black") << QBrush(Qt::black); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void tst_QChart::backgroundBrush() |
|
286 | void tst_QChart::backgroundBrush() | |
287 | { |
|
287 | { | |
288 | QFETCH(QBrush, backgroundBrush); |
|
288 | QFETCH(QBrush, backgroundBrush); | |
289 | m_chart->setBackgroundBrush(backgroundBrush); |
|
289 | m_chart->setBackgroundBrush(backgroundBrush); | |
290 | QCOMPARE(m_chart->backgroundBrush(), backgroundBrush); |
|
290 | QCOMPARE(m_chart->backgroundBrush(), backgroundBrush); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | void tst_QChart::backgroundPen_data() |
|
293 | void tst_QChart::backgroundPen_data() | |
294 | { |
|
294 | { | |
295 | QTest::addColumn<QPen>("backgroundPen"); |
|
295 | QTest::addColumn<QPen>("backgroundPen"); | |
296 | QTest::newRow("null") << QPen(); |
|
296 | QTest::newRow("null") << QPen(); | |
297 | QTest::newRow("blue") << QPen(Qt::blue); |
|
297 | QTest::newRow("blue") << QPen(Qt::blue); | |
298 | QTest::newRow("white") << QPen(Qt::white); |
|
298 | QTest::newRow("white") << QPen(Qt::white); | |
299 | QTest::newRow("black") << QPen(Qt::black); |
|
299 | QTest::newRow("black") << QPen(Qt::black); | |
300 | } |
|
300 | } | |
301 |
|
301 | |||
302 |
|
302 | |||
303 | void tst_QChart::backgroundPen() |
|
303 | void tst_QChart::backgroundPen() | |
304 | { |
|
304 | { | |
305 | QFETCH(QPen, backgroundPen); |
|
305 | QFETCH(QPen, backgroundPen); | |
306 | m_chart->setBackgroundPen(backgroundPen); |
|
306 | m_chart->setBackgroundPen(backgroundPen); | |
307 | QCOMPARE(m_chart->backgroundPen(), backgroundPen); |
|
307 | QCOMPARE(m_chart->backgroundPen(), backgroundPen); | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void tst_QChart::isBackgroundVisible_data() |
|
310 | void tst_QChart::isBackgroundVisible_data() | |
311 | { |
|
311 | { | |
312 | QTest::addColumn<bool>("isBackgroundVisible"); |
|
312 | QTest::addColumn<bool>("isBackgroundVisible"); | |
313 | QTest::newRow("true") << true; |
|
313 | QTest::newRow("true") << true; | |
314 | QTest::newRow("false") << false; |
|
314 | QTest::newRow("false") << false; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | void tst_QChart::isBackgroundVisible() |
|
317 | void tst_QChart::isBackgroundVisible() | |
318 | { |
|
318 | { | |
319 | QFETCH(bool, isBackgroundVisible); |
|
319 | QFETCH(bool, isBackgroundVisible); | |
320 | m_chart->setBackgroundVisible(isBackgroundVisible); |
|
320 | m_chart->setBackgroundVisible(isBackgroundVisible); | |
321 | QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); |
|
321 | QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); | |
322 |
|
322 | |||
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | void tst_QChart::legend_data() |
|
325 | void tst_QChart::legend_data() | |
326 | { |
|
326 | { | |
327 |
|
327 | |||
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | void tst_QChart::legend() |
|
330 | void tst_QChart::legend() | |
331 | { |
|
331 | { | |
332 | QVERIFY(m_chart->legend()); |
|
332 | QVERIFY(m_chart->legend()); | |
333 | } |
|
333 | } | |
334 |
|
334 | |||
335 | void tst_QChart::margins_data() |
|
335 | void tst_QChart::margins_data() | |
336 | { |
|
336 | { | |
337 |
|
337 | |||
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | void tst_QChart::margins() |
|
340 | void tst_QChart::margins() | |
341 | {QTest::addColumn<int>("seriesCount"); |
|
341 | {QTest::addColumn<int>("seriesCount"); | |
342 | QTest::newRow("0") << 0; |
|
342 | QTest::newRow("0") << 0; | |
343 | QTest::newRow("-1") << -1; |
|
343 | QTest::newRow("-1") << -1; | |
344 | createTestData(); |
|
344 | createTestData(); | |
345 | QRectF rect = m_chart->geometry(); |
|
345 | QRectF rect = m_chart->geometry(); | |
346 |
|
346 | |||
347 | QVERIFY(m_chart->margins().top()+m_chart->margins().bottom() < rect.height()); |
|
347 | QVERIFY(m_chart->margins().top()+m_chart->margins().bottom() < rect.height()); | |
348 | QVERIFY(m_chart->margins().left()+m_chart->margins().right() < rect.width()); |
|
348 | QVERIFY(m_chart->margins().left()+m_chart->margins().right() < rect.width()); | |
349 |
|
349 | |||
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | void tst_QChart::removeAllSeries_data() |
|
352 | void tst_QChart::removeAllSeries_data() | |
353 | { |
|
353 | { | |
354 |
|
354 | |||
355 | } |
|
355 | } | |
356 |
|
356 | |||
357 | void tst_QChart::removeAllSeries() |
|
357 | void tst_QChart::removeAllSeries() | |
358 | { |
|
358 | { | |
359 | QLineSeries* series0 = new QLineSeries(this); |
|
359 | QLineSeries* series0 = new QLineSeries(this); | |
360 | QLineSeries* series1 = new QLineSeries(this); |
|
360 | QLineSeries* series1 = new QLineSeries(this); | |
361 | QLineSeries* series2 = new QLineSeries(this); |
|
361 | QLineSeries* series2 = new QLineSeries(this); | |
362 |
|
362 | |||
363 | m_chart->addSeries(series0); |
|
363 | m_chart->addSeries(series0); | |
364 | m_chart->addSeries(series1); |
|
364 | m_chart->addSeries(series1); | |
365 | m_chart->addSeries(series2); |
|
365 | m_chart->addSeries(series2); | |
366 | m_view->show(); |
|
366 | m_view->show(); | |
367 | QTest::qWaitForWindowShown(m_view); |
|
367 | QTest::qWaitForWindowShown(m_view); | |
368 |
|
368 | |||
369 | QVERIFY(m_chart->axisY(series0)!=0); |
|
369 | QVERIFY(m_chart->axisY(series0)!=0); | |
370 | QVERIFY(m_chart->axisY(series1)!=0); |
|
370 | QVERIFY(m_chart->axisY(series1)!=0); | |
371 | QVERIFY(m_chart->axisY(series2)!=0); |
|
371 | QVERIFY(m_chart->axisY(series2)!=0); | |
372 |
|
372 | |||
373 | m_chart->removeAllSeries(); |
|
373 | m_chart->removeAllSeries(); | |
374 |
|
374 | |||
375 | QVERIFY(m_chart->axisY(series0)==0); |
|
375 | QVERIFY(m_chart->axisY(series0)==0); | |
376 | QVERIFY(m_chart->axisY(series1)==0); |
|
376 | QVERIFY(m_chart->axisY(series1)==0); | |
377 | QVERIFY(m_chart->axisY(series2)==0); |
|
377 | QVERIFY(m_chart->axisY(series2)==0); | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | void tst_QChart::removeSeries_data() |
|
380 | void tst_QChart::removeSeries_data() | |
381 | { |
|
381 | { | |
382 | addSeries_data(); |
|
382 | addSeries_data(); | |
383 | } |
|
383 | } | |
384 |
|
384 | |||
385 | void tst_QChart::removeSeries() |
|
385 | void tst_QChart::removeSeries() | |
386 | { |
|
386 | { | |
387 | QFETCH(QSeries*, series); |
|
387 | QFETCH(QAbstractSeries *, series); | |
388 | QFETCH(QChartAxis*, axis); |
|
388 | QFETCH(QChartAxis *, axis); | |
389 | m_view->show(); |
|
389 | m_view->show(); | |
390 | QTest::qWaitForWindowShown(m_view); |
|
390 | QTest::qWaitForWindowShown(m_view); | |
391 | if(!axis) axis = m_chart->axisY(); |
|
391 | if(!axis) axis = m_chart->axisY(); | |
392 | m_chart->addSeries(series,axis); |
|
392 | m_chart->addSeries(series,axis); | |
393 | QCOMPARE(m_chart->axisY(series),axis); |
|
393 | QCOMPARE(m_chart->axisY(series),axis); | |
394 | m_chart->removeSeries(series); |
|
394 | m_chart->removeSeries(series); | |
395 | QVERIFY(m_chart->axisY(series)==0); |
|
395 | QVERIFY(m_chart->axisY(series)==0); | |
396 | } |
|
396 | } | |
397 |
|
397 | |||
398 | void tst_QChart::scrollDown_data() |
|
398 | void tst_QChart::scrollDown_data() | |
399 | { |
|
399 | { | |
400 |
|
400 | |||
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | void tst_QChart::scrollDown() |
|
403 | void tst_QChart::scrollDown() | |
404 | { |
|
404 | { | |
405 | createTestData(); |
|
405 | createTestData(); | |
406 | qreal min = m_chart->axisY()->min(); |
|
406 | qreal min = m_chart->axisY()->min(); | |
407 | m_chart->scrollDown(); |
|
407 | m_chart->scrollDown(); | |
408 | QVERIFY(m_chart->axisY()->min()<min); |
|
408 | QVERIFY(m_chart->axisY()->min()<min); | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | void tst_QChart::scrollLeft_data() |
|
411 | void tst_QChart::scrollLeft_data() | |
412 | { |
|
412 | { | |
413 |
|
413 | |||
414 | } |
|
414 | } | |
415 |
|
415 | |||
416 | void tst_QChart::scrollLeft() |
|
416 | void tst_QChart::scrollLeft() | |
417 | { |
|
417 | { | |
418 | createTestData(); |
|
418 | createTestData(); | |
419 | qreal min = m_chart->axisX()->min(); |
|
419 | qreal min = m_chart->axisX()->min(); | |
420 | m_chart->scrollLeft(); |
|
420 | m_chart->scrollLeft(); | |
421 | QVERIFY(m_chart->axisX()->min()<min); |
|
421 | QVERIFY(m_chart->axisX()->min()<min); | |
422 | } |
|
422 | } | |
423 |
|
423 | |||
424 | void tst_QChart::scrollRight_data() |
|
424 | void tst_QChart::scrollRight_data() | |
425 | { |
|
425 | { | |
426 |
|
426 | |||
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | void tst_QChart::scrollRight() |
|
429 | void tst_QChart::scrollRight() | |
430 | { |
|
430 | { | |
431 | createTestData(); |
|
431 | createTestData(); | |
432 | qreal min = m_chart->axisX()->min(); |
|
432 | qreal min = m_chart->axisX()->min(); | |
433 | m_chart->scrollRight(); |
|
433 | m_chart->scrollRight(); | |
434 | QVERIFY(m_chart->axisX()->min()>min); |
|
434 | QVERIFY(m_chart->axisX()->min()>min); | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | void tst_QChart::scrollUp_data() |
|
437 | void tst_QChart::scrollUp_data() | |
438 | { |
|
438 | { | |
439 |
|
439 | |||
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | void tst_QChart::scrollUp() |
|
442 | void tst_QChart::scrollUp() | |
443 | { |
|
443 | { | |
444 | createTestData(); |
|
444 | createTestData(); | |
445 | qreal min = m_chart->axisY()->min(); |
|
445 | qreal min = m_chart->axisY()->min(); | |
446 | m_chart->scrollUp(); |
|
446 | m_chart->scrollUp(); | |
447 | QVERIFY(m_chart->axisY()->min()>min); |
|
447 | QVERIFY(m_chart->axisY()->min()>min); | |
448 | } |
|
448 | } | |
449 |
|
449 | |||
450 | void tst_QChart::theme_data() |
|
450 | void tst_QChart::theme_data() | |
451 | { |
|
451 | { | |
452 | QTest::addColumn<QChart::ChartTheme>("theme"); |
|
452 | QTest::addColumn<QChart::ChartTheme>("theme"); | |
453 | QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean; |
|
453 | QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean; | |
454 | QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy; |
|
454 | QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy; | |
455 | QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs; |
|
455 | QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs; | |
456 | QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand; |
|
456 | QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand; | |
457 | QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark; |
|
457 | QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark; | |
458 | QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast; |
|
458 | QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast; | |
459 | QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight; |
|
459 | QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight; | |
460 | } |
|
460 | } | |
461 |
|
461 | |||
462 | void tst_QChart::theme() |
|
462 | void tst_QChart::theme() | |
463 | { |
|
463 | { | |
464 | QFETCH(QChart::ChartTheme, theme); |
|
464 | QFETCH(QChart::ChartTheme, theme); | |
465 | createTestData(); |
|
465 | createTestData(); | |
466 | m_chart->setTheme(theme); |
|
466 | m_chart->setTheme(theme); | |
467 | QVERIFY(m_chart->theme()==theme); |
|
467 | QVERIFY(m_chart->theme()==theme); | |
468 | } |
|
468 | } | |
469 |
|
469 | |||
470 | void tst_QChart::title_data() |
|
470 | void tst_QChart::title_data() | |
471 | { |
|
471 | { | |
472 | QTest::addColumn<QString>("title"); |
|
472 | QTest::addColumn<QString>("title"); | |
473 | QTest::newRow("null") << QString(); |
|
473 | QTest::newRow("null") << QString(); | |
474 | QTest::newRow("foo") << QString("foo"); |
|
474 | QTest::newRow("foo") << QString("foo"); | |
475 | } |
|
475 | } | |
476 |
|
476 | |||
477 | void tst_QChart::title() |
|
477 | void tst_QChart::title() | |
478 | { |
|
478 | { | |
479 | QFETCH(QString, title); |
|
479 | QFETCH(QString, title); | |
480 | m_chart->setTitle(title); |
|
480 | m_chart->setTitle(title); | |
481 | QCOMPARE(m_chart->title(), title); |
|
481 | QCOMPARE(m_chart->title(), title); | |
482 | } |
|
482 | } | |
483 |
|
483 | |||
484 | void tst_QChart::titleBrush_data() |
|
484 | void tst_QChart::titleBrush_data() | |
485 | { |
|
485 | { | |
486 | QTest::addColumn<QBrush>("titleBrush"); |
|
486 | QTest::addColumn<QBrush>("titleBrush"); | |
487 | QTest::newRow("null") << QBrush(); |
|
487 | QTest::newRow("null") << QBrush(); | |
488 | QTest::newRow("blue") << QBrush(Qt::blue); |
|
488 | QTest::newRow("blue") << QBrush(Qt::blue); | |
489 | QTest::newRow("white") << QBrush(Qt::white); |
|
489 | QTest::newRow("white") << QBrush(Qt::white); | |
490 | QTest::newRow("black") << QBrush(Qt::black); |
|
490 | QTest::newRow("black") << QBrush(Qt::black); | |
491 | } |
|
491 | } | |
492 |
|
492 | |||
493 | void tst_QChart::titleBrush() |
|
493 | void tst_QChart::titleBrush() | |
494 | { |
|
494 | { | |
495 | QFETCH(QBrush, titleBrush); |
|
495 | QFETCH(QBrush, titleBrush); | |
496 | m_chart->setTitleBrush(titleBrush); |
|
496 | m_chart->setTitleBrush(titleBrush); | |
497 | QCOMPARE(m_chart->titleBrush(), titleBrush); |
|
497 | QCOMPARE(m_chart->titleBrush(), titleBrush); | |
498 | } |
|
498 | } | |
499 |
|
499 | |||
500 | void tst_QChart::titleFont_data() |
|
500 | void tst_QChart::titleFont_data() | |
501 | { |
|
501 | { | |
502 | QTest::addColumn<QFont>("titleFont"); |
|
502 | QTest::addColumn<QFont>("titleFont"); | |
503 | QTest::newRow("null") << QFont(); |
|
503 | QTest::newRow("null") << QFont(); | |
504 | QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true); |
|
504 | QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true); | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | void tst_QChart::titleFont() |
|
507 | void tst_QChart::titleFont() | |
508 | { |
|
508 | { | |
509 | QFETCH(QFont, titleFont); |
|
509 | QFETCH(QFont, titleFont); | |
510 | m_chart->setTitleFont(titleFont); |
|
510 | m_chart->setTitleFont(titleFont); | |
511 | QCOMPARE(m_chart->titleFont(), titleFont); |
|
511 | QCOMPARE(m_chart->titleFont(), titleFont); | |
512 | } |
|
512 | } | |
513 |
|
513 | |||
514 | void tst_QChart::zoomIn_data() |
|
514 | void tst_QChart::zoomIn_data() | |
515 | { |
|
515 | { | |
516 | QTest::addColumn<QRectF>("rect"); |
|
516 | QTest::addColumn<QRectF>("rect"); | |
517 | QTest::newRow("null") << QRectF(); |
|
517 | QTest::newRow("null") << QRectF(); | |
518 | QTest::newRow("100x100") << QRectF(10,10,100,100); |
|
518 | QTest::newRow("100x100") << QRectF(10,10,100,100); | |
519 | QTest::newRow("200x200") << QRectF(10,10,200,200); |
|
519 | QTest::newRow("200x200") << QRectF(10,10,200,200); | |
520 | } |
|
520 | } | |
521 |
|
521 | |||
522 |
|
522 | |||
523 | void tst_QChart::zoomIn() |
|
523 | void tst_QChart::zoomIn() | |
524 | { |
|
524 | { | |
525 | QFETCH(QRectF, rect); |
|
525 | QFETCH(QRectF, rect); | |
526 | createTestData(); |
|
526 | createTestData(); | |
527 | QRectF marigns = m_chart->margins(); |
|
527 | QRectF marigns = m_chart->margins(); | |
528 | rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom()); |
|
528 | rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom()); | |
529 | qreal minX = m_chart->axisX()->min(); |
|
529 | qreal minX = m_chart->axisX()->min(); | |
530 | qreal minY = m_chart->axisY()->min(); |
|
530 | qreal minY = m_chart->axisY()->min(); | |
531 | qreal maxX = m_chart->axisX()->max(); |
|
531 | qreal maxX = m_chart->axisX()->max(); | |
532 | qreal maxY = m_chart->axisY()->max(); |
|
532 | qreal maxY = m_chart->axisY()->max(); | |
533 | m_chart->zoomIn(rect); |
|
533 | m_chart->zoomIn(rect); | |
534 | if(rect.isValid()){ |
|
534 | if(rect.isValid()){ | |
535 | QVERIFY(minX<m_chart->axisX()->min()); |
|
535 | QVERIFY(minX<m_chart->axisX()->min()); | |
536 | QVERIFY(maxX>m_chart->axisX()->max()); |
|
536 | QVERIFY(maxX>m_chart->axisX()->max()); | |
537 | QVERIFY(minY<m_chart->axisY()->min()); |
|
537 | QVERIFY(minY<m_chart->axisY()->min()); | |
538 | QVERIFY(maxY>m_chart->axisY()->max()); |
|
538 | QVERIFY(maxY>m_chart->axisY()->max()); | |
539 | } |
|
539 | } | |
540 | } |
|
540 | } | |
541 |
|
541 | |||
542 | void tst_QChart::zoomOut_data() |
|
542 | void tst_QChart::zoomOut_data() | |
543 | { |
|
543 | { | |
544 |
|
544 | |||
545 | } |
|
545 | } | |
546 |
|
546 | |||
547 | void tst_QChart::zoomOut() |
|
547 | void tst_QChart::zoomOut() | |
548 | { |
|
548 | { | |
549 | createTestData(); |
|
549 | createTestData(); | |
550 | qreal minX = m_chart->axisX()->min(); |
|
550 | qreal minX = m_chart->axisX()->min(); | |
551 | qreal minY = m_chart->axisY()->min(); |
|
551 | qreal minY = m_chart->axisY()->min(); | |
552 | qreal maxX = m_chart->axisX()->max(); |
|
552 | qreal maxX = m_chart->axisX()->max(); | |
553 | qreal maxY = m_chart->axisY()->max(); |
|
553 | qreal maxY = m_chart->axisY()->max(); | |
554 |
|
554 | |||
555 | m_chart->zoomIn(); |
|
555 | m_chart->zoomIn(); | |
556 |
|
556 | |||
557 | QVERIFY(minX<m_chart->axisX()->min()); |
|
557 | QVERIFY(minX<m_chart->axisX()->min()); | |
558 | QVERIFY(maxX>m_chart->axisX()->max()); |
|
558 | QVERIFY(maxX>m_chart->axisX()->max()); | |
559 | QVERIFY(minY<m_chart->axisY()->min()); |
|
559 | QVERIFY(minY<m_chart->axisY()->min()); | |
560 | QVERIFY(maxY>m_chart->axisY()->max()); |
|
560 | QVERIFY(maxY>m_chart->axisY()->max()); | |
561 |
|
561 | |||
562 | m_chart->zoomOut(); |
|
562 | m_chart->zoomOut(); | |
563 |
|
563 | |||
564 | QVERIFY(minX==m_chart->axisX()->min()); |
|
564 | QVERIFY(minX==m_chart->axisX()->min()); | |
565 | QVERIFY(maxX==m_chart->axisX()->max()); |
|
565 | QVERIFY(maxX==m_chart->axisX()->max()); | |
566 | QVERIFY(minY==m_chart->axisY()->min()); |
|
566 | QVERIFY(minY==m_chart->axisY()->min()); | |
567 | QVERIFY(maxY==m_chart->axisY()->max()); |
|
567 | QVERIFY(maxY==m_chart->axisY()->max()); | |
568 | } |
|
568 | } | |
569 |
|
569 | |||
570 | QTEST_MAIN(tst_QChart) |
|
570 | QTEST_MAIN(tst_QChart) | |
571 | #include "tst_qchart.moc" |
|
571 | #include "tst_qchart.moc" | |
572 |
|
572 |
@@ -1,66 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef TABLEWIDGET_H |
|
21 | #ifndef TABLEWIDGET_H | |
22 | #define TABLEWIDGET_H |
|
22 | #define TABLEWIDGET_H | |
23 |
|
23 | |||
24 | #include <QtGui/QWidget> |
|
24 | #include <QtGui/QWidget> | |
25 | #include "qchartview.h" |
|
25 | #include "qchartview.h" | |
26 | #include "qxyseries.h" |
|
26 | #include "qxyseries.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | class CustomTableModel; |
|
30 | class CustomTableModel; | |
31 | class QTableView; |
|
31 | class QTableView; | |
32 | class QRadioButton; |
|
32 | class QRadioButton; | |
33 | class QSpinBox; |
|
33 | class QSpinBox; | |
34 | //class QSeries; |
|
|||
35 |
|
34 | |||
36 | class TableWidget : public QWidget |
|
35 | class TableWidget : public QWidget | |
37 | { |
|
36 | { | |
38 | Q_OBJECT |
|
37 | Q_OBJECT | |
39 |
|
38 | |||
40 | public: |
|
39 | public: | |
41 | TableWidget(QWidget *parent = 0); |
|
40 | TableWidget(QWidget *parent = 0); | |
42 | ~TableWidget(); |
|
41 | ~TableWidget(); | |
43 |
|
42 | |||
44 |
|
43 | |||
45 | public slots: |
|
44 | public slots: | |
46 | void addRowAbove(); |
|
45 | void addRowAbove(); | |
47 | void addRowBelow(); |
|
46 | void addRowBelow(); | |
48 | void removeRow(); |
|
47 | void removeRow(); | |
49 | void updateChartType(bool toggle); |
|
48 | void updateChartType(bool toggle); | |
50 |
|
49 | |||
51 | private: |
|
50 | private: | |
52 | QChartView* m_chartView; |
|
51 | QChartView* m_chartView; | |
53 | QChart* m_chart; |
|
52 | QChart* m_chart; | |
54 | QXYSeries* m_series; |
|
53 | QXYSeries* m_series; | |
55 | CustomTableModel* m_model; |
|
54 | CustomTableModel* m_model; | |
56 | QTableView* m_tableView; |
|
55 | QTableView* m_tableView; | |
57 | QRadioButton* m_lineRadioButton; |
|
56 | QRadioButton* m_lineRadioButton; | |
58 | QRadioButton* m_splineRadioButton; |
|
57 | QRadioButton* m_splineRadioButton; | |
59 | QRadioButton* m_scatterRadioButton; |
|
58 | QRadioButton* m_scatterRadioButton; | |
60 | QRadioButton* m_pieRadioButton; |
|
59 | QRadioButton* m_pieRadioButton; | |
61 | QRadioButton* m_areaRadioButton; |
|
60 | QRadioButton* m_areaRadioButton; | |
62 | QRadioButton* m_barRadioButton; |
|
61 | QRadioButton* m_barRadioButton; | |
63 | QSpinBox* m_linesCountSpinBox; |
|
62 | QSpinBox* m_linesCountSpinBox; | |
64 | }; |
|
63 | }; | |
65 |
|
64 | |||
66 | #endif // TABLEWIDGET_H |
|
65 | #endif // TABLEWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now