@@ -1,65 +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 "chart.h" |
|
21 | #include "chart.h" | |
22 | #include <QAbstractAxis> |
|
22 | #include <QAbstractAxis> | |
23 | #include <QSplineSeries> |
|
23 | #include <QSplineSeries> | |
|
24 | #include <QValuesAxis> | |||
24 | #include <QTime> |
|
25 | #include <QTime> | |
|
26 | #include <QDebug> | |||
25 |
|
27 | |||
26 | Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) |
|
28 | Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) | |
27 | :QChart(parent, wFlags), |
|
29 | :QChart(parent, wFlags), | |
28 |
m_step( |
|
30 | m_step(0), | |
29 | m_x(0), |
|
31 | m_axis(new QValuesAxis), | |
|
32 | m_x(5), | |||
30 | m_y(1) |
|
33 | m_y(1) | |
31 | { |
|
34 | { | |
32 | qsrand((uint) QTime::currentTime().msec()); |
|
35 | qsrand((uint) QTime::currentTime().msec()); | |
33 |
|
36 | |||
34 | QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); |
|
37 | QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); | |
35 | m_timer.setInterval(1000); |
|
38 | m_timer.setInterval(1000); | |
36 |
|
39 | |||
37 | m_series = new QSplineSeries(this); |
|
40 | m_series = new QSplineSeries(this); | |
38 | QPen green(Qt::red); |
|
41 | QPen green(Qt::red); | |
39 | green.setWidth(3); |
|
42 | green.setWidth(3); | |
40 | m_series->setPen(green); |
|
43 | m_series->setPen(green); | |
41 | m_series->append(m_x, m_y); |
|
44 | m_series->append(m_x, m_y); | |
42 |
|
45 | |||
43 | addSeries(m_series); |
|
46 | addSeries(m_series); | |
44 | createDefaultAxes(); |
|
47 | createDefaultAxes(); | |
45 |
|
48 | setAxisX(m_axis,m_series); | ||
46 |
axis |
|
49 | m_axis->setTicksCount(5); | |
47 |
axisX()->setRange( |
|
50 | axisX()->setRange(0, 10); | |
48 | //TODO:axisX()->setTicksCount(11); |
|
51 | axisY()->setRange(-5, 10); | |
49 |
|
52 | |||
50 | m_timer.start(); |
|
53 | m_timer.start(); | |
51 | } |
|
54 | } | |
52 |
|
55 | |||
53 | Chart::~Chart() |
|
56 | Chart::~Chart() | |
54 | { |
|
57 | { | |
55 |
|
58 | |||
56 | } |
|
59 | } | |
57 |
|
60 | |||
58 | void Chart::handleTimeout() |
|
61 | void Chart::handleTimeout() | |
59 | { |
|
62 | { | |
60 | m_x += m_step; |
|
63 | qreal x = plotArea().width()/m_axis->ticksCount(); | |
|
64 | qreal y =(m_axis->max() - m_axis->min())/m_axis->ticksCount(); | |||
|
65 | m_x += y; | |||
61 | m_y = qrand() % 5 - 2.5; |
|
66 | m_y = qrand() % 5 - 2.5; | |
62 | m_series->append(m_x, m_y); |
|
67 | m_series->append(m_x, m_y); | |
63 |
scroll( |
|
68 | scroll(x,0); | |
64 | if(m_x==100) m_timer.stop(); |
|
69 | if(m_x==100) m_timer.stop(); | |
65 | } |
|
70 | } |
@@ -1,54 +1,56 | |||||
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 CHART_H_ |
|
21 | #ifndef CHART_H_ | |
22 | #define CHART_H_ |
|
22 | #define CHART_H_ | |
23 |
|
23 | |||
24 | #include <QChart> |
|
24 | #include <QChart> | |
25 | #include <QTimer> |
|
25 | #include <QTimer> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 | class QSplineSeries; |
|
28 | class QSplineSeries; | |
|
29 | class QValuesAxis; | |||
29 | QTCOMMERCIALCHART_END_NAMESPACE |
|
30 | QTCOMMERCIALCHART_END_NAMESPACE | |
30 |
|
31 | |||
31 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
32 | QTCOMMERCIALCHART_USE_NAMESPACE | |
32 |
|
33 | |||
33 | //![1] |
|
34 | //![1] | |
34 | class Chart: public QChart |
|
35 | class Chart: public QChart | |
35 | { |
|
36 | { | |
36 | Q_OBJECT |
|
37 | Q_OBJECT | |
37 | public: |
|
38 | public: | |
38 | Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
39 | Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
39 | virtual ~Chart(); |
|
40 | virtual ~Chart(); | |
40 |
|
41 | |||
41 | public slots: |
|
42 | public slots: | |
42 | void handleTimeout(); |
|
43 | void handleTimeout(); | |
43 |
|
44 | |||
44 | private: |
|
45 | private: | |
45 | QTimer m_timer; |
|
46 | QTimer m_timer; | |
46 | QSplineSeries* m_series; |
|
47 | QSplineSeries* m_series; | |
47 | QStringList m_titles; |
|
48 | QStringList m_titles; | |
|
49 | QValuesAxis* m_axis; | |||
48 | qreal m_step; |
|
50 | qreal m_step; | |
49 | qreal m_x; |
|
51 | qreal m_x; | |
50 | qreal m_y; |
|
52 | qreal m_y; | |
51 | }; |
|
53 | }; | |
52 | //![1] |
|
54 | //![1] | |
53 |
|
55 | |||
54 | #endif /* CHART_H_ */ |
|
56 | #endif /* CHART_H_ */ |
@@ -1,474 +1,474 | |||||
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 "qabstractaxis.h" |
|
23 | #include "qabstractaxis.h" | |
24 | #include "qabstractaxis_p.h" |
|
24 | #include "qabstractaxis_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 "chartanimation_p.h" |
|
28 | #include "chartanimation_p.h" | |
29 | #include "qabstractseries_p.h" |
|
29 | #include "qabstractseries_p.h" | |
30 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
31 | #include "chartaxis_p.h" |
|
31 | #include "chartaxis_p.h" | |
32 | //#include "chartaxisx_p.h" |
|
32 | //#include "chartaxisx_p.h" | |
33 | //#include "chartaxisy_p.h" |
|
33 | //#include "chartaxisy_p.h" | |
34 | #include "areachartitem_p.h" |
|
34 | #include "areachartitem_p.h" | |
35 | #include "chartbackground_p.h" |
|
35 | #include "chartbackground_p.h" | |
36 | #include "chartlayout_p.h" |
|
36 | #include "chartlayout_p.h" | |
37 | #include <QTimer> |
|
37 | #include <QTimer> | |
38 |
|
38 | |||
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
40 |
|
40 | |||
41 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), |
|
41 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | |
42 | m_chart(chart), |
|
42 | m_chart(chart), | |
43 | m_animator(0), |
|
43 | m_animator(0), | |
44 | m_dataset(dataset), |
|
44 | m_dataset(dataset), | |
45 | m_chartTheme(0), |
|
45 | m_chartTheme(0), | |
46 | m_options(QChart::NoAnimation), |
|
46 | m_options(QChart::NoAnimation), | |
47 | m_state(ShowState), |
|
47 | m_state(ShowState), | |
48 | m_layout(new ChartLayout(this)), |
|
48 | m_layout(new ChartLayout(this)), | |
49 | m_backgroundItem(0), |
|
49 | m_backgroundItem(0), | |
50 | m_titleItem(0) |
|
50 | m_titleItem(0) | |
51 | { |
|
51 | { | |
52 |
|
52 | |||
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | ChartPresenter::~ChartPresenter() |
|
55 | ChartPresenter::~ChartPresenter() | |
56 | { |
|
56 | { | |
57 | delete m_chartTheme; |
|
57 | delete m_chartTheme; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void ChartPresenter::setGeometry(const QRectF& rect) |
|
60 | void ChartPresenter::setGeometry(const QRectF& rect) | |
61 | { |
|
61 | { | |
62 |
|
62 | |||
63 | Q_ASSERT(rect.isValid()); |
|
63 | Q_ASSERT(rect.isValid()); | |
64 |
|
64 | |||
65 | if(m_rect!=rect) { |
|
65 | if(m_rect!=rect) { | |
66 | m_rect=rect; |
|
66 | m_rect=rect; | |
67 | emit geometryChanged(m_rect); |
|
67 | emit geometryChanged(m_rect); | |
68 | } |
|
68 | } | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) |
|
71 | void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) | |
72 | { |
|
72 | { | |
73 | ChartAxis* item = axis->d_ptr->createGraphics(this); |
|
73 | ChartAxis* item = axis->d_ptr->createGraphics(this); | |
74 | item->setDomain(domain); |
|
74 | item->setDomain(domain); | |
75 |
|
75 | |||
76 | if(m_options.testFlag(QChart::GridAxisAnimations)){ |
|
76 | if(m_options.testFlag(QChart::GridAxisAnimations)){ | |
77 | item->setAnimator(m_animator); |
|
77 | item->setAnimator(m_animator); | |
78 | item->setAnimation(new AxisAnimation(item)); |
|
78 | item->setAnimation(new AxisAnimation(item)); | |
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | if(item->axisType()==ChartAxis::X_AXIS){ |
|
81 | if(item->axisType()==ChartAxis::X_AXIS){ | |
82 | m_chartTheme->decorate(axis,true); |
|
82 | m_chartTheme->decorate(axis,true); | |
83 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
83 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | |
84 | //initialize |
|
84 | //initialize | |
85 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); |
|
85 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); | |
86 |
|
86 | |||
87 | } |
|
87 | } | |
88 | else{ |
|
88 | else{ | |
89 | m_chartTheme->decorate(axis,false); |
|
89 | m_chartTheme->decorate(axis,false); | |
90 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
90 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); | |
91 | //initialize |
|
91 | //initialize | |
92 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); |
|
92 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
95 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); | |
96 | QObject::connect(axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleAxisVisibleChanged(bool))); |
|
96 | QObject::connect(axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleAxisVisibleChanged(bool))); | |
97 | //initialize |
|
97 | //initialize | |
98 | if(m_rect.isValid()) item->handleGeometryChanged(m_rect); |
|
98 | if(m_rect.isValid()) item->handleGeometryChanged(m_rect); | |
99 | //reload visiblity |
|
99 | //reload visiblity | |
100 | m_axisItems.insert(axis, item); |
|
100 | m_axisItems.insert(axis, item); | |
101 | selectVisibleAxis(); |
|
101 | selectVisibleAxis(); | |
102 |
|
102 | |||
103 | } |
|
103 | } | |
104 |
|
104 | |||
105 | void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis) |
|
105 | void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis) | |
106 | { |
|
106 | { | |
107 | ChartAxis* item = m_axisItems.take(axis); |
|
107 | ChartAxis* item = m_axisItems.take(axis); | |
108 | Q_ASSERT(item); |
|
108 | Q_ASSERT(item); | |
109 | selectVisibleAxis(); |
|
109 | selectVisibleAxis(); | |
110 | if(m_animator) m_animator->removeAnimation(item); |
|
110 | if(m_animator) m_animator->removeAnimation(item); | |
111 | item->deleteLater(); |
|
111 | item->deleteLater(); | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain) |
|
115 | void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain) | |
116 | { |
|
116 | { | |
117 | Chart *item = series->d_ptr->createGraphics(this); |
|
117 | Chart *item = series->d_ptr->createGraphics(this); | |
118 | Q_ASSERT(item); |
|
118 | Q_ASSERT(item); | |
119 | item->setDomain(domain); |
|
119 | item->setDomain(domain); | |
120 |
|
120 | |||
121 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
121 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); | |
122 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
122 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); | |
123 | //initialize |
|
123 | //initialize | |
124 | item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); |
|
124 | item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY()); | |
125 | if(m_rect.isValid()) item->handleGeometryChanged(m_rect); |
|
125 | if(m_rect.isValid()) item->handleGeometryChanged(m_rect); | |
126 | m_chartItems.insert(series,item); |
|
126 | m_chartItems.insert(series,item); | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series) |
|
129 | void ChartPresenter::handleSeriesRemoved(QAbstractSeries* series) | |
130 | { |
|
130 | { | |
131 | Chart* item = m_chartItems.take(series); |
|
131 | Chart* item = m_chartItems.take(series); | |
132 | Q_ASSERT(item); |
|
132 | Q_ASSERT(item); | |
133 | if(m_animator) { |
|
133 | if(m_animator) { | |
134 | //small hack to handle area animations |
|
134 | //small hack to handle area animations | |
135 | if(series->type() == QAbstractSeries::SeriesTypeArea){ |
|
135 | if(series->type() == QAbstractSeries::SeriesTypeArea){ | |
136 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); |
|
136 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); | |
137 | AreaChartItem* area = static_cast<AreaChartItem*>(item); |
|
137 | AreaChartItem* area = static_cast<AreaChartItem*>(item); | |
138 | m_animator->removeAnimation(area->upperLineItem()); |
|
138 | m_animator->removeAnimation(area->upperLineItem()); | |
139 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); |
|
139 | if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem()); | |
140 | }else |
|
140 | }else | |
141 | m_animator->removeAnimation(item); |
|
141 | m_animator->removeAnimation(item); | |
142 | } |
|
142 | } | |
143 | item->deleteLater(); |
|
143 | item->deleteLater(); | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | void ChartPresenter::selectVisibleAxis() |
|
146 | void ChartPresenter::selectVisibleAxis() | |
147 | { |
|
147 | { | |
148 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); |
|
148 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); | |
149 |
|
149 | |||
150 | while (i.hasNext()) { |
|
150 | while (i.hasNext()) { | |
151 | i.next(); |
|
151 | i.next(); | |
152 | i.key()->hide(); |
|
152 | i.key()->hide(); | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | i.toFront(); |
|
155 | i.toFront(); | |
156 |
|
156 | |||
157 | bool axisX=false; |
|
157 | bool axisX=false; | |
158 | bool axisY=false; |
|
158 | bool axisY=false; | |
159 |
|
159 | |||
160 | while (i.hasNext()) { |
|
160 | while (i.hasNext()) { | |
161 | i.next(); |
|
161 | i.next(); | |
162 | if(i.key()->d_ptr->m_orientation==Qt::Vertical && !axisY) { |
|
162 | if(i.key()->d_ptr->m_orientation==Qt::Vertical && !axisY) { | |
163 | axisY=true; |
|
163 | axisY=true; | |
164 | i.key()->show(); |
|
164 | i.key()->show(); | |
165 | } |
|
165 | } | |
166 | if(i.key()->d_ptr->m_orientation==Qt::Horizontal && !axisX) { |
|
166 | if(i.key()->d_ptr->m_orientation==Qt::Horizontal && !axisX) { | |
167 | axisX=true; |
|
167 | axisX=true; | |
168 | i.key()->show(); |
|
168 | i.key()->show(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | } |
|
171 | } | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 |
|
174 | |||
175 | void ChartPresenter::handleAxisVisibleChanged(bool visible) |
|
175 | void ChartPresenter::handleAxisVisibleChanged(bool visible) | |
176 | { |
|
176 | { | |
177 | QAbstractAxis* axis = static_cast<QAbstractAxis*> (sender()); |
|
177 | QAbstractAxis* axis = static_cast<QAbstractAxis*> (sender()); | |
178 | Q_ASSERT(axis); |
|
178 | Q_ASSERT(axis); | |
179 | if(visible){ |
|
179 | if(visible){ | |
180 |
|
180 | |||
181 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); |
|
181 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); | |
182 |
|
182 | |||
183 | while (i.hasNext()) { |
|
183 | while (i.hasNext()) { | |
184 | i.next(); |
|
184 | i.next(); | |
185 | if(i.key()==axis) { |
|
185 | if(i.key()==axis) { | |
186 | continue; |
|
186 | continue; | |
187 | } |
|
187 | } | |
188 | if(i.key()->d_ptr->m_orientation==axis->d_ptr->m_orientation) { |
|
188 | if(i.key()->d_ptr->m_orientation==axis->d_ptr->m_orientation) { | |
189 | i.key()->setVisible(false); |
|
189 | i.key()->setVisible(false); | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 | } |
|
192 | } | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) |
|
195 | void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force) | |
196 | { |
|
196 | { | |
197 | if(m_chartTheme && m_chartTheme->id() == theme) return; |
|
197 | if(m_chartTheme && m_chartTheme->id() == theme) return; | |
198 | delete m_chartTheme; |
|
198 | delete m_chartTheme; | |
199 | m_chartTheme = ChartTheme::createTheme(theme); |
|
199 | m_chartTheme = ChartTheme::createTheme(theme); | |
200 | m_chartTheme->setForced(force); |
|
200 | m_chartTheme->setForced(force); | |
201 | m_chartTheme->decorate(m_chart); |
|
201 | m_chartTheme->decorate(m_chart); | |
202 | m_chartTheme->decorate(m_chart->legend()); |
|
202 | m_chartTheme->decorate(m_chart->legend()); | |
203 | resetAllElements(); |
|
203 | resetAllElements(); | |
204 |
|
204 | |||
205 | // We do not want "force" to stay on. |
|
205 | // We do not want "force" to stay on. | |
206 | // Bar/pie are calling decorate when adding/removing slices/bars which means |
|
206 | // Bar/pie are calling decorate when adding/removing slices/bars which means | |
207 | // that to preserve users colors "force" must not be on. |
|
207 | // that to preserve users colors "force" must not be on. | |
208 | m_chartTheme->setForced(false); |
|
208 | m_chartTheme->setForced(false); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | QChart::ChartTheme ChartPresenter::theme() |
|
211 | QChart::ChartTheme ChartPresenter::theme() | |
212 | { |
|
212 | { | |
213 | return m_chartTheme->id(); |
|
213 | return m_chartTheme->id(); | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) |
|
216 | void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | |
217 | { |
|
217 | { | |
218 | if(m_options!=options) { |
|
218 | if(m_options!=options) { | |
219 |
|
219 | |||
220 | m_options=options; |
|
220 | m_options=options; | |
221 |
|
221 | |||
222 | if(m_options!=QChart::NoAnimation && !m_animator) { |
|
222 | if(m_options!=QChart::NoAnimation && !m_animator) { | |
223 | m_animator= new ChartAnimator(this); |
|
223 | m_animator= new ChartAnimator(this); | |
224 | } |
|
224 | } | |
225 | resetAllElements(); |
|
225 | resetAllElements(); | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | void ChartPresenter::resetAllElements() |
|
230 | void ChartPresenter::resetAllElements() | |
231 | { |
|
231 | { | |
232 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); |
|
232 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); | |
233 | while (i.hasNext()) { |
|
233 | while (i.hasNext()) { | |
234 | i.next(); |
|
234 | i.next(); | |
235 | Domain* domain = i.value()->domain(); |
|
235 | Domain* domain = i.value()->domain(); | |
236 | QAbstractAxis* axis = i.key(); |
|
236 | QAbstractAxis* axis = i.key(); | |
237 | handleAxisRemoved(axis); |
|
237 | handleAxisRemoved(axis); | |
238 | handleAxisAdded(axis,domain); |
|
238 | handleAxisAdded(axis,domain); | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | QMapIterator<QAbstractSeries*, Chart*> j(m_chartItems); |
|
241 | QMapIterator<QAbstractSeries*, Chart*> j(m_chartItems); | |
242 | while (j.hasNext()) { |
|
242 | while (j.hasNext()) { | |
243 | j.next(); |
|
243 | j.next(); | |
244 | Domain* domain = j.value()->domain(); |
|
244 | Domain* domain = j.value()->domain(); | |
245 | QAbstractSeries* series = j.key(); |
|
245 | QAbstractSeries* series = j.key(); | |
246 | handleSeriesRemoved(series); |
|
246 | handleSeriesRemoved(series); | |
247 | handleSeriesAdded(series,domain); |
|
247 | handleSeriesAdded(series,domain); | |
248 | } |
|
248 | } | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void ChartPresenter::zoomIn(qreal factor) |
|
251 | void ChartPresenter::zoomIn(qreal factor) | |
252 | { |
|
252 | { | |
253 | QRectF rect = geometry(); |
|
253 | QRectF rect = geometry(); | |
254 | rect.setWidth(rect.width()/factor); |
|
254 | rect.setWidth(rect.width()/factor); | |
255 | rect.setHeight(rect.height()/factor); |
|
255 | rect.setHeight(rect.height()/factor); | |
256 | rect.moveCenter(geometry().center()); |
|
256 | rect.moveCenter(geometry().center()); | |
257 | zoomIn(rect); |
|
257 | zoomIn(rect); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | void ChartPresenter::zoomIn(const QRectF& rect) |
|
260 | void ChartPresenter::zoomIn(const QRectF& rect) | |
261 | { |
|
261 | { | |
262 | QRectF r = rect.normalized(); |
|
262 | QRectF r = rect.normalized(); | |
263 | r.translate(-geometry().topLeft()); |
|
263 | r.translate(-geometry().topLeft()); | |
264 | if (!r.isValid()) |
|
264 | if (!r.isValid()) | |
265 | return; |
|
265 | return; | |
266 |
|
266 | |||
267 | m_state = ZoomInState; |
|
267 | m_state = ZoomInState; | |
268 | m_statePoint = QPointF(r.center().x()/geometry().width(),r.center().y()/geometry().height()); |
|
268 | m_statePoint = QPointF(r.center().x()/geometry().width(),r.center().y()/geometry().height()); | |
269 | m_dataset->zoomInDomain(r,geometry().size()); |
|
269 | m_dataset->zoomInDomain(r,geometry().size()); | |
270 | m_state = ShowState; |
|
270 | m_state = ShowState; | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | void ChartPresenter::zoomOut(qreal factor) |
|
273 | void ChartPresenter::zoomOut(qreal factor) | |
274 | { |
|
274 | { | |
275 | m_state = ZoomOutState; |
|
275 | m_state = ZoomOutState; | |
276 |
|
276 | |||
277 | QRectF chartRect; |
|
277 | QRectF chartRect; | |
278 | chartRect.setSize(geometry().size()); |
|
278 | chartRect.setSize(geometry().size()); | |
279 |
|
279 | |||
280 | QRectF rect; |
|
280 | QRectF rect; | |
281 | rect.setSize(chartRect.size()/factor); |
|
281 | rect.setSize(chartRect.size()/factor); | |
282 | rect.moveCenter(chartRect.center()); |
|
282 | rect.moveCenter(chartRect.center()); | |
283 | if (!rect.isValid()) |
|
283 | if (!rect.isValid()) | |
284 | return; |
|
284 | return; | |
285 | m_statePoint = QPointF(rect.center().x()/geometry().width(),rect.center().y()/geometry().height()); |
|
285 | m_statePoint = QPointF(rect.center().x()/geometry().width(),rect.center().y()/geometry().height()); | |
286 | m_dataset->zoomOutDomain(rect, chartRect.size()); |
|
286 | m_dataset->zoomOutDomain(rect, chartRect.size()); | |
287 | m_state = ShowState; |
|
287 | m_state = ShowState; | |
288 | } |
|
288 | } | |
289 |
|
289 | |||
290 | void ChartPresenter::scroll(qreal dx,qreal dy) |
|
290 | void ChartPresenter::scroll(qreal dx,qreal dy) | |
291 | { |
|
291 | { | |
292 | if(dx<0) m_state=ScrollLeftState; |
|
292 | if(dx<0) m_state=ScrollLeftState; | |
293 | if(dx>0) m_state=ScrollRightState; |
|
293 | if(dx>0) m_state=ScrollRightState; | |
294 | if(dy<0) m_state=ScrollUpState; |
|
294 | if(dy<0) m_state=ScrollUpState; | |
295 | if(dy>0) m_state=ScrollDownState; |
|
295 | if(dy>0) m_state=ScrollDownState; | |
296 |
|
296 | |||
297 | m_dataset->scrollDomain(dx,dy,geometry().size()); |
|
297 | m_dataset->scrollDomain(dx,dy,geometry().size()); | |
298 | m_state = ShowState; |
|
298 | m_state = ShowState; | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | QChart::AnimationOptions ChartPresenter::animationOptions() const |
|
301 | QChart::AnimationOptions ChartPresenter::animationOptions() const | |
302 | { |
|
302 | { | |
303 | return m_options; |
|
303 | return m_options; | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | void ChartPresenter::createBackgroundItem() |
|
306 | void ChartPresenter::createBackgroundItem() | |
307 | { |
|
307 | { | |
308 | if (!m_backgroundItem) { |
|
308 | if (!m_backgroundItem) { | |
309 | m_backgroundItem = new ChartBackground(rootItem()); |
|
309 | m_backgroundItem = new ChartBackground(rootItem()); | |
310 | m_backgroundItem->setPen(Qt::NoPen); |
|
310 | m_backgroundItem->setPen(Qt::NoPen); | |
311 | m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); |
|
311 | m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); | |
312 | } |
|
312 | } | |
313 | } |
|
313 | } | |
314 |
|
314 | |||
315 | void ChartPresenter::createTitleItem() |
|
315 | void ChartPresenter::createTitleItem() | |
316 | { |
|
316 | { | |
317 | if (!m_titleItem) { |
|
317 | if (!m_titleItem) { | |
318 | m_titleItem = new QGraphicsSimpleTextItem(rootItem()); |
|
318 | m_titleItem = new QGraphicsSimpleTextItem(rootItem()); | |
319 | m_titleItem->setZValue(ChartPresenter::BackgroundZValue); |
|
319 | m_titleItem->setZValue(ChartPresenter::BackgroundZValue); | |
320 | } |
|
320 | } | |
321 | } |
|
321 | } | |
322 |
|
322 | |||
323 |
|
323 | |||
324 | void ChartPresenter::handleAnimationFinished() |
|
324 | void ChartPresenter::handleAnimationFinished() | |
325 | { |
|
325 | { | |
326 | m_animations.removeAll(qobject_cast<ChartAnimation*>(sender())); |
|
326 | m_animations.removeAll(qobject_cast<ChartAnimation*>(sender())); | |
327 | if(m_animations.empty()) emit animationsFinished(); |
|
327 | if(m_animations.empty()) emit animationsFinished(); | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | void ChartPresenter::startAnimation(ChartAnimation* animation) |
|
330 | void ChartPresenter::startAnimation(ChartAnimation* animation) | |
331 | { |
|
331 | { | |
332 | if (animation->state() != QAbstractAnimation::Stopped) animation->stop(); |
|
332 | if (animation->state() != QAbstractAnimation::Stopped) animation->stop(); | |
333 | QObject::connect(animation, SIGNAL(finished()),this,SLOT(handleAnimationFinished()),Qt::UniqueConnection); |
|
333 | QObject::connect(animation, SIGNAL(finished()),this,SLOT(handleAnimationFinished()),Qt::UniqueConnection); | |
334 | if(!m_animations.isEmpty()){ |
|
334 | if(!m_animations.isEmpty()){ | |
335 | m_animations.append(animation); |
|
335 | m_animations.append(animation); | |
336 | } |
|
336 | } | |
337 | QTimer::singleShot(0, animation, SLOT(start())); |
|
337 | QTimer::singleShot(0, animation, SLOT(start())); | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | QGraphicsRectItem* ChartPresenter::backgroundItem() |
|
340 | QGraphicsRectItem* ChartPresenter::backgroundItem() | |
341 | { |
|
341 | { | |
342 | return m_backgroundItem; |
|
342 | return m_backgroundItem; | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | void ChartPresenter::setBackgroundBrush(const QBrush& brush) |
|
345 | void ChartPresenter::setBackgroundBrush(const QBrush& brush) | |
346 | { |
|
346 | { | |
347 | createBackgroundItem(); |
|
347 | createBackgroundItem(); | |
348 | m_backgroundItem->setBrush(brush); |
|
348 | m_backgroundItem->setBrush(brush); | |
349 | m_layout->invalidate(); |
|
349 | m_layout->invalidate(); | |
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | QBrush ChartPresenter::backgroundBrush() const |
|
352 | QBrush ChartPresenter::backgroundBrush() const | |
353 | { |
|
353 | { | |
354 | if (!m_backgroundItem) return QBrush(); |
|
354 | if (!m_backgroundItem) return QBrush(); | |
355 | return m_backgroundItem->brush(); |
|
355 | return m_backgroundItem->brush(); | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | void ChartPresenter::setBackgroundPen(const QPen& pen) |
|
358 | void ChartPresenter::setBackgroundPen(const QPen& pen) | |
359 | { |
|
359 | { | |
360 | createBackgroundItem(); |
|
360 | createBackgroundItem(); | |
361 | m_backgroundItem->setPen(pen); |
|
361 | m_backgroundItem->setPen(pen); | |
362 | m_layout->invalidate(); |
|
362 | m_layout->invalidate(); | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | QPen ChartPresenter::backgroundPen() const |
|
365 | QPen ChartPresenter::backgroundPen() const | |
366 | { |
|
366 | { | |
367 | if (!m_backgroundItem) return QPen(); |
|
367 | if (!m_backgroundItem) return QPen(); | |
368 | return m_backgroundItem->pen(); |
|
368 | return m_backgroundItem->pen(); | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | QGraphicsItem* ChartPresenter::titleItem() |
|
371 | QGraphicsItem* ChartPresenter::titleItem() | |
372 | { |
|
372 | { | |
373 | return m_titleItem; |
|
373 | return m_titleItem; | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | void ChartPresenter::setTitle(const QString& title) |
|
376 | void ChartPresenter::setTitle(const QString& title) | |
377 | { |
|
377 | { | |
378 | createTitleItem(); |
|
378 | createTitleItem(); | |
379 | m_titleItem->setText(title); |
|
379 | m_titleItem->setText(title); | |
380 | m_layout->invalidate(); |
|
380 | m_layout->invalidate(); | |
381 | } |
|
381 | } | |
382 |
|
382 | |||
383 | QString ChartPresenter::title() const |
|
383 | QString ChartPresenter::title() const | |
384 | { |
|
384 | { | |
385 | if (!m_titleItem) return QString(); |
|
385 | if (!m_titleItem) return QString(); | |
386 | return m_titleItem->text(); |
|
386 | return m_titleItem->text(); | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | void ChartPresenter::setTitleFont(const QFont& font) |
|
389 | void ChartPresenter::setTitleFont(const QFont& font) | |
390 | { |
|
390 | { | |
391 | createTitleItem(); |
|
391 | createTitleItem(); | |
392 | m_titleItem->setFont(font); |
|
392 | m_titleItem->setFont(font); | |
393 | m_layout->invalidate(); |
|
393 | m_layout->invalidate(); | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | QFont ChartPresenter::titleFont() const |
|
396 | QFont ChartPresenter::titleFont() const | |
397 | { |
|
397 | { | |
398 | if (!m_titleItem) return QFont(); |
|
398 | if (!m_titleItem) return QFont(); | |
399 | return m_titleItem->font(); |
|
399 | return m_titleItem->font(); | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | void ChartPresenter::setTitleBrush(const QBrush &brush) |
|
402 | void ChartPresenter::setTitleBrush(const QBrush &brush) | |
403 | { |
|
403 | { | |
404 | createTitleItem(); |
|
404 | createTitleItem(); | |
405 | m_titleItem->setBrush(brush); |
|
405 | m_titleItem->setBrush(brush); | |
406 | m_layout->invalidate(); |
|
406 | m_layout->invalidate(); | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | QBrush ChartPresenter::titleBrush() const |
|
409 | QBrush ChartPresenter::titleBrush() const | |
410 | { |
|
410 | { | |
411 | if (!m_titleItem) return QBrush(); |
|
411 | if (!m_titleItem) return QBrush(); | |
412 | return m_titleItem->brush(); |
|
412 | return m_titleItem->brush(); | |
413 | } |
|
413 | } | |
414 |
|
414 | |||
415 | void ChartPresenter::setBackgroundVisible(bool visible) |
|
415 | void ChartPresenter::setBackgroundVisible(bool visible) | |
416 | { |
|
416 | { | |
417 | createBackgroundItem(); |
|
417 | createBackgroundItem(); | |
418 | m_backgroundItem->setVisible(visible); |
|
418 | m_backgroundItem->setVisible(visible); | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 |
|
421 | |||
422 | bool ChartPresenter::isBackgroundVisible() const |
|
422 | bool ChartPresenter::isBackgroundVisible() const | |
423 | { |
|
423 | { | |
424 | if (!m_backgroundItem) return false; |
|
424 | if (!m_backgroundItem) return false; | |
425 | return m_backgroundItem->isVisible(); |
|
425 | return m_backgroundItem->isVisible(); | |
426 | } |
|
426 | } | |
427 |
|
427 | |||
428 | void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled) |
|
428 | void ChartPresenter::setBackgroundDropShadowEnabled(bool enabled) | |
429 | { |
|
429 | { | |
430 | createBackgroundItem(); |
|
430 | createBackgroundItem(); | |
431 | m_backgroundItem->setDropShadowEnabled(enabled); |
|
431 | m_backgroundItem->setDropShadowEnabled(enabled); | |
432 | } |
|
432 | } | |
433 |
|
433 | |||
434 | bool ChartPresenter::isBackgroundDropShadowEnabled() const |
|
434 | bool ChartPresenter::isBackgroundDropShadowEnabled() const | |
435 | { |
|
435 | { | |
436 | if (!m_backgroundItem) return false; |
|
436 | if (!m_backgroundItem) return false; | |
437 | return m_backgroundItem->isDropShadowEnabled(); |
|
437 | return m_backgroundItem->isDropShadowEnabled(); | |
438 | } |
|
438 | } | |
439 |
|
439 | |||
440 |
|
440 | |||
441 | QGraphicsLayout* ChartPresenter::layout() |
|
441 | QGraphicsLayout* ChartPresenter::layout() | |
442 | { |
|
442 | { | |
443 | return m_layout; |
|
443 | return m_layout; | |
444 | } |
|
444 | } | |
445 |
|
445 | |||
446 | void ChartPresenter::setMarginsMinimum(const QRectF& margins) |
|
446 | void ChartPresenter::setMarginsMinimum(const QRectF& margins) | |
447 | { |
|
447 | { | |
448 | Q_UNUSED(margins); |
|
448 | Q_UNUSED(margins); | |
449 | // m_layout->setMarginsMinimum(margins); |
|
449 | // m_layout->setMarginsMinimum(margins); | |
450 | } |
|
450 | } | |
451 |
|
451 | |||
452 | QRectF ChartPresenter::margins() const |
|
452 | QRectF ChartPresenter::margins() const | |
453 | { |
|
453 | { | |
454 |
return |
|
454 | return m_layout->margins(); | |
455 | } |
|
455 | } | |
456 |
|
456 | |||
457 | QLegend* ChartPresenter::legend() |
|
457 | QLegend* ChartPresenter::legend() | |
458 | { |
|
458 | { | |
459 | return m_chart->legend(); |
|
459 | return m_chart->legend(); | |
460 | } |
|
460 | } | |
461 |
|
461 | |||
462 | QList<ChartAxis*> ChartPresenter::axisItems() const |
|
462 | QList<ChartAxis*> ChartPresenter::axisItems() const | |
463 | { |
|
463 | { | |
464 | return m_axisItems.values(); |
|
464 | return m_axisItems.values(); | |
465 | } |
|
465 | } | |
466 |
|
466 | |||
467 | void ChartPresenter::setVisible(bool visible) |
|
467 | void ChartPresenter::setVisible(bool visible) | |
468 | { |
|
468 | { | |
469 | m_chart->setVisible(visible); |
|
469 | m_chart->setVisible(visible); | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | #include "moc_chartpresenter_p.cpp" |
|
472 | #include "moc_chartpresenter_p.cpp" | |
473 |
|
473 | |||
474 | QTCOMMERCIALCHART_END_NAMESPACE |
|
474 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,485 +1,490 | |||||
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 "chartbackground_p.h" |
|
25 | #include "chartbackground_p.h" | |
26 | #include "qabstractaxis.h" |
|
26 | #include "qabstractaxis.h" | |
27 | #include <QGraphicsScene> |
|
27 | #include <QGraphicsScene> | |
28 | #include <QGraphicsSceneResizeEvent> |
|
28 | #include <QGraphicsSceneResizeEvent> | |
29 | #include <QGraphicsLayout> |
|
29 | #include <QGraphicsLayout> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \enum QChart::ChartTheme |
|
34 | \enum QChart::ChartTheme | |
35 |
|
35 | |||
36 | This enum describes the theme used by the chart. |
|
36 | This enum describes the theme used by the chart. | |
37 |
|
37 | |||
38 | \value ChartThemeLight The default theme |
|
38 | \value ChartThemeLight The default theme | |
39 | \value ChartThemeBlueCerulean |
|
39 | \value ChartThemeBlueCerulean | |
40 | \value ChartThemeDark |
|
40 | \value ChartThemeDark | |
41 | \value ChartThemeBrownSand |
|
41 | \value ChartThemeBrownSand | |
42 | \value ChartThemeBlueNcs |
|
42 | \value ChartThemeBlueNcs | |
43 | \value ChartThemeHighContrast |
|
43 | \value ChartThemeHighContrast | |
44 | \value ChartThemeBlueIcy |
|
44 | \value ChartThemeBlueIcy | |
45 | */ |
|
45 | */ | |
46 |
|
46 | |||
47 | /*! |
|
47 | /*! | |
48 | \enum QChart::AnimationOption |
|
48 | \enum QChart::AnimationOption | |
49 |
|
49 | |||
50 | For enabling/disabling animations. Defaults to NoAnimation. |
|
50 | For enabling/disabling animations. Defaults to NoAnimation. | |
51 |
|
51 | |||
52 | \value NoAnimation |
|
52 | \value NoAnimation | |
53 | \value GridAxisAnimations |
|
53 | \value GridAxisAnimations | |
54 | \value SeriesAnimations |
|
54 | \value SeriesAnimations | |
55 | \value AllAnimations |
|
55 | \value AllAnimations | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \class QChart |
|
59 | \class QChart | |
60 | \brief QtCommercial chart API. |
|
60 | \brief QtCommercial chart API. | |
61 |
|
61 | |||
62 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
62 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
63 | representation of different types of series and other chart related objects like |
|
63 | representation of different types of series and other chart related objects like | |
64 | QAxis and QLegend. If you simply want to show a chart in a layout, you can use the |
|
64 | QAxis and QLegend. If you simply want to show a chart in a layout, you can use the | |
65 | convenience class QChartView instead of QChart. |
|
65 | convenience class QChartView instead of QChart. | |
66 | \sa QChartView |
|
66 | \sa QChartView | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \property QChart::animationOptions |
|
70 | \property QChart::animationOptions | |
71 | The animation \a options for the chart. Animations are enabled/disabled based on this setting. |
|
71 | The animation \a options for the chart. Animations are enabled/disabled based on this setting. | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \property QChart::backgroundVisible |
|
75 | \property QChart::backgroundVisible | |
76 | Whether the chart background is visible or not. |
|
76 | Whether the chart background is visible or not. | |
77 | \sa setBackgroundBrush(), setBackgroundPen() |
|
77 | \sa setBackgroundBrush(), setBackgroundPen() | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QChart::dropShadowEnabled |
|
81 | \property QChart::dropShadowEnabled | |
82 | If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop |
|
82 | If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop | |
83 | shadow effect depends on theme, which means the setting may be changed if you switch to another theme. |
|
83 | shadow effect depends on theme, which means the setting may be changed if you switch to another theme. | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \property QChart::margins |
|
87 | \property QChart::margins | |
88 | Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes. |
|
88 | Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes. | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \property QChart::theme |
|
92 | \property QChart::theme | |
93 | Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors, |
|
93 | Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors, | |
94 | pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few |
|
94 | pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few | |
95 | different themes. |
|
95 | different themes. | |
96 | Note: changing the theme will overwrite all customizations previously applied to the series. |
|
96 | Note: changing the theme will overwrite all customizations previously applied to the series. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \property QChart::title |
|
100 | \property QChart::title | |
101 | Title is the name (label) of a chart. It is shown as a headline on top of the chart. |
|
101 | Title is the name (label) of a chart. It is shown as a headline on top of the chart. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \fn void QChart::marginsChanged(QRectF newMargins) |
|
105 | \fn void QChart::marginsChanged(QRectF newMargins) | |
106 | The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size, |
|
106 | The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size, | |
107 | modify axes or hide/show legend. |
|
107 | modify axes or hide/show legend. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
111 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
112 | */ |
|
112 | */ | |
113 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
113 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
114 | d_ptr(new QChartPrivate()) |
|
114 | d_ptr(new QChartPrivate()) | |
115 | { |
|
115 | { | |
116 | d_ptr->m_dataset = new ChartDataSet(this); |
|
116 | d_ptr->m_dataset = new ChartDataSet(this); | |
117 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
117 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
118 | d_ptr->createConnections(); |
|
118 | d_ptr->createConnections(); | |
119 | d_ptr->m_legend = new LegendScroller(this); |
|
119 | d_ptr->m_legend = new LegendScroller(this); | |
120 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
120 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
121 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); |
|
121 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); | |
122 | setLayout(d_ptr->m_presenter->layout()); |
|
122 | setLayout(d_ptr->m_presenter->layout()); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | Destroys the object and it's children, like series and axis objects added to it. |
|
126 | Destroys the object and it's children, like series and axis objects added to it. | |
127 | */ |
|
127 | */ | |
128 | QChart::~QChart() |
|
128 | QChart::~QChart() | |
129 | { |
|
129 | { | |
130 | //delete first presenter , since this is a root of all the graphical items |
|
130 | //delete first presenter , since this is a root of all the graphical items | |
131 | setLayout(0); |
|
131 | setLayout(0); | |
132 | delete d_ptr->m_presenter; |
|
132 | delete d_ptr->m_presenter; | |
133 | d_ptr->m_presenter=0; |
|
133 | d_ptr->m_presenter=0; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | /*! |
|
136 | /*! | |
137 | Adds the \a series onto the chart and takes the ownership of the object. |
|
137 | Adds the \a series onto the chart and takes the ownership of the object. | |
138 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
138 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
139 | the y axis). |
|
139 | the y axis). | |
140 |
|
140 | |||
141 | \sa removeSeries(), removeAllSeries() |
|
141 | \sa removeSeries(), removeAllSeries() | |
142 | */ |
|
142 | */ | |
143 | void QChart::addSeries(QAbstractSeries *series) |
|
143 | void QChart::addSeries(QAbstractSeries *series) | |
144 | { |
|
144 | { | |
145 | Q_ASSERT(series); |
|
145 | Q_ASSERT(series); | |
146 | d_ptr->m_dataset->addSeries(series); |
|
146 | d_ptr->m_dataset->addSeries(series); | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | Removes the \a series specified in a perameter from the QChartView. |
|
150 | Removes the \a series specified in a perameter from the QChartView. | |
151 | It releses its ownership of the specified QChartSeries object. |
|
151 | It releses its ownership of the specified QChartSeries object. | |
152 | It does not delete the pointed QChartSeries data object |
|
152 | It does not delete the pointed QChartSeries data object | |
153 | \sa addSeries(), removeAllSeries() |
|
153 | \sa addSeries(), removeAllSeries() | |
154 | */ |
|
154 | */ | |
155 | void QChart::removeSeries(QAbstractSeries *series) |
|
155 | void QChart::removeSeries(QAbstractSeries *series) | |
156 | { |
|
156 | { | |
157 | Q_ASSERT(series); |
|
157 | Q_ASSERT(series); | |
158 | d_ptr->m_dataset->removeSeries(series); |
|
158 | d_ptr->m_dataset->removeSeries(series); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | Removes all the QChartSeries that have been added to the QChartView |
|
162 | Removes all the QChartSeries that have been added to the QChartView | |
163 | It also deletes the pointed QChartSeries data objects |
|
163 | It also deletes the pointed QChartSeries data objects | |
164 | \sa addSeries(), removeSeries() |
|
164 | \sa addSeries(), removeSeries() | |
165 | */ |
|
165 | */ | |
166 | void QChart::removeAllSeries() |
|
166 | void QChart::removeAllSeries() | |
167 | { |
|
167 | { | |
168 | d_ptr->m_dataset->removeAllSeries(); |
|
168 | d_ptr->m_dataset->removeAllSeries(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Sets the \a brush that is used for painting the background of the chart area. |
|
172 | Sets the \a brush that is used for painting the background of the chart area. | |
173 | */ |
|
173 | */ | |
174 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
174 | void QChart::setBackgroundBrush(const QBrush& brush) | |
175 | { |
|
175 | { | |
176 | d_ptr->m_presenter->setBackgroundBrush(brush); |
|
176 | d_ptr->m_presenter->setBackgroundBrush(brush); | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | Gets the brush that is used for painting the background of the chart area. |
|
180 | Gets the brush that is used for painting the background of the chart area. | |
181 | */ |
|
181 | */ | |
182 | QBrush QChart::backgroundBrush() const |
|
182 | QBrush QChart::backgroundBrush() const | |
183 | { |
|
183 | { | |
184 | return d_ptr->m_presenter->backgroundBrush(); |
|
184 | return d_ptr->m_presenter->backgroundBrush(); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | Sets the \a pen that is used for painting the background of the chart area. |
|
188 | Sets the \a pen that is used for painting the background of the chart area. | |
189 | */ |
|
189 | */ | |
190 | void QChart::setBackgroundPen(const QPen& pen) |
|
190 | void QChart::setBackgroundPen(const QPen& pen) | |
191 | { |
|
191 | { | |
192 | d_ptr->m_presenter->setBackgroundPen(pen); |
|
192 | d_ptr->m_presenter->setBackgroundPen(pen); | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Gets the pen that is used for painting the background of the chart area. |
|
196 | Gets the pen that is used for painting the background of the chart area. | |
197 | */ |
|
197 | */ | |
198 | QPen QChart::backgroundPen() const |
|
198 | QPen QChart::backgroundPen() const | |
199 | { |
|
199 | { | |
200 | return d_ptr->m_presenter->backgroundPen(); |
|
200 | return d_ptr->m_presenter->backgroundPen(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | Sets the chart \a title. The description text that is drawn above the chart. |
|
204 | Sets the chart \a title. The description text that is drawn above the chart. | |
205 | */ |
|
205 | */ | |
206 | void QChart::setTitle(const QString& title) |
|
206 | void QChart::setTitle(const QString& title) | |
207 | { |
|
207 | { | |
208 | d_ptr->m_presenter->setTitle(title); |
|
208 | d_ptr->m_presenter->setTitle(title); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Returns the chart title. The description text that is drawn above the chart. |
|
212 | Returns the chart title. The description text that is drawn above the chart. | |
213 | */ |
|
213 | */ | |
214 | QString QChart::title() const |
|
214 | QString QChart::title() const | |
215 | { |
|
215 | { | |
216 | return d_ptr->m_presenter->title(); |
|
216 | return d_ptr->m_presenter->title(); | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
220 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
221 | */ |
|
221 | */ | |
222 | void QChart::setTitleFont(const QFont& font) |
|
222 | void QChart::setTitleFont(const QFont& font) | |
223 | { |
|
223 | { | |
224 | d_ptr->m_presenter->setTitleFont(font); |
|
224 | d_ptr->m_presenter->setTitleFont(font); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | /*! |
|
227 | /*! | |
228 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
228 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
229 | */ |
|
229 | */ | |
230 | QFont QChart::titleFont() const |
|
230 | QFont QChart::titleFont() const | |
231 | { |
|
231 | { | |
232 | return d_ptr->m_presenter->titleFont(); |
|
232 | return d_ptr->m_presenter->titleFont(); | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | /*! |
|
235 | /*! | |
236 | Sets the \a brush used for rendering the title text. |
|
236 | Sets the \a brush used for rendering the title text. | |
237 | */ |
|
237 | */ | |
238 | void QChart::setTitleBrush(const QBrush &brush) |
|
238 | void QChart::setTitleBrush(const QBrush &brush) | |
239 | { |
|
239 | { | |
240 | d_ptr->m_presenter->setTitleBrush(brush); |
|
240 | d_ptr->m_presenter->setTitleBrush(brush); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | /*! |
|
243 | /*! | |
244 | Returns the brush used for rendering the title text. |
|
244 | Returns the brush used for rendering the title text. | |
245 | */ |
|
245 | */ | |
246 | QBrush QChart::titleBrush() const |
|
246 | QBrush QChart::titleBrush() const | |
247 | { |
|
247 | { | |
248 | return d_ptr->m_presenter->titleBrush(); |
|
248 | return d_ptr->m_presenter->titleBrush(); | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void QChart::setTheme(QChart::ChartTheme theme) |
|
251 | void QChart::setTheme(QChart::ChartTheme theme) | |
252 | { |
|
252 | { | |
253 | d_ptr->m_presenter->setTheme(theme); |
|
253 | d_ptr->m_presenter->setTheme(theme); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | QChart::ChartTheme QChart::theme() const |
|
256 | QChart::ChartTheme QChart::theme() const | |
257 | { |
|
257 | { | |
258 | return d_ptr->m_presenter->theme(); |
|
258 | return d_ptr->m_presenter->theme(); | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | /*! |
|
261 | /*! | |
262 | Zooms in the view by a factor of 2 |
|
262 | Zooms in the view by a factor of 2 | |
263 | */ |
|
263 | */ | |
264 | void QChart::zoomIn() |
|
264 | void QChart::zoomIn() | |
265 | { |
|
265 | { | |
266 | d_ptr->m_presenter->zoomIn(2.0); |
|
266 | d_ptr->m_presenter->zoomIn(2.0); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | /*! |
|
269 | /*! | |
270 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
270 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
271 | */ |
|
271 | */ | |
272 | void QChart::zoomIn(const QRectF& rect) |
|
272 | void QChart::zoomIn(const QRectF& rect) | |
273 | { |
|
273 | { | |
274 | if (!rect.isValid()) return; |
|
274 | if (!rect.isValid()) return; | |
275 | d_ptr->m_presenter->zoomIn(rect); |
|
275 | d_ptr->m_presenter->zoomIn(rect); | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | Restores the view zoom level to the previous one. |
|
279 | Restores the view zoom level to the previous one. | |
280 | */ |
|
280 | */ | |
281 | void QChart::zoomOut() |
|
281 | void QChart::zoomOut() | |
282 | { |
|
282 | { | |
283 | d_ptr->m_presenter->zoomOut(2.0); |
|
283 | d_ptr->m_presenter->zoomOut(2.0); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | /*! |
|
286 | /*! | |
287 | Zooms in the view by a \a factor. |
|
287 | Zooms in the view by a \a factor. | |
288 |
|
288 | |||
289 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. |
|
289 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. | |
290 | */ |
|
290 | */ | |
291 | void QChart::zoom(qreal factor) |
|
291 | void QChart::zoom(qreal factor) | |
292 | { |
|
292 | { | |
293 | if (qFuzzyIsNull(factor)) |
|
293 | if (qFuzzyIsNull(factor)) | |
294 | return; |
|
294 | return; | |
295 |
|
295 | |||
296 | if (qFuzzyCompare(factor, 1.0)) |
|
296 | if (qFuzzyCompare(factor, 1.0)) | |
297 | return; |
|
297 | return; | |
298 |
|
298 | |||
299 | if (factor < 0) |
|
299 | if (factor < 0) | |
300 | return; |
|
300 | return; | |
301 |
|
301 | |||
302 | if (factor > 1.0) |
|
302 | if (factor > 1.0) | |
303 | d_ptr->m_presenter->zoomIn(factor); |
|
303 | d_ptr->m_presenter->zoomIn(factor); | |
304 | else |
|
304 | else | |
305 | d_ptr->m_presenter->zoomOut(1.0 / factor); |
|
305 | d_ptr->m_presenter->zoomOut(1.0 / factor); | |
306 | } |
|
306 | } | |
307 |
|
307 | |||
308 | /*! |
|
308 | /*! | |
309 | Returns the pointer to the x axis object of the chart asociated with the specified \a series |
|
309 | Returns the pointer to the x axis object of the chart asociated with the specified \a series | |
310 | If no series is provided then pointer to currently visible axis is provided |
|
310 | If no series is provided then pointer to currently visible axis is provided | |
311 | */ |
|
311 | */ | |
312 | QAbstractAxis* QChart::axisX(QAbstractSeries* series) const |
|
312 | QAbstractAxis* QChart::axisX(QAbstractSeries* series) const | |
313 | { |
|
313 | { | |
314 | return d_ptr->m_dataset->axisX(series); |
|
314 | return d_ptr->m_dataset->axisX(series); | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | /*! |
|
317 | /*! | |
318 | Returns the pointer to the y axis object of the chart asociated with the specified \a series |
|
318 | Returns the pointer to the y axis object of the chart asociated with the specified \a series | |
319 | If no series is provided then pointer to currently visible axis is provided |
|
319 | If no series is provided then pointer to currently visible axis is provided | |
320 | */ |
|
320 | */ | |
321 | QAbstractAxis* QChart::axisY(QAbstractSeries *series) const |
|
321 | QAbstractAxis* QChart::axisY(QAbstractSeries *series) const | |
322 | { |
|
322 | { | |
323 | return d_ptr->m_dataset->axisY(series); |
|
323 | return d_ptr->m_dataset->axisY(series); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | /*! |
|
326 | /*! | |
327 | NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL. |
|
327 | NOTICE: This function has to be called after series has been added to the chart if no customized axes are set to the chart. Otherwise axisX(), axisY() calls return NULL. | |
328 |
|
328 | |||
329 | Creates the axes for the chart based on the series that has already been added to the chart. |
|
329 | Creates the axes for the chart based on the series that has already been added to the chart. | |
330 |
|
330 | |||
331 | \table |
|
331 | \table | |
332 | \header |
|
332 | \header | |
333 | \o Series type |
|
333 | \o Series type | |
334 | \o X-axis |
|
334 | \o X-axis | |
335 | \o Y-axis |
|
335 | \o Y-axis | |
336 | \row |
|
336 | \row | |
337 | \o QXYSeries |
|
337 | \o QXYSeries | |
338 | \o QValuesAxis |
|
338 | \o QValuesAxis | |
339 | \o QValuesAxis |
|
339 | \o QValuesAxis | |
340 | \row |
|
340 | \row | |
341 | \o QBarSeries |
|
341 | \o QBarSeries | |
342 | \o QBarCategoriesAxis |
|
342 | \o QBarCategoriesAxis | |
343 | \o QValuesAxis |
|
343 | \o QValuesAxis | |
344 | \row |
|
344 | \row | |
345 | \o QPieSeries |
|
345 | \o QPieSeries | |
346 | \o None |
|
346 | \o None | |
347 | \o None |
|
347 | \o None | |
348 | \endtable |
|
348 | \endtable | |
349 |
|
349 | |||
350 | If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created. |
|
350 | If there are several QXYSeries derived series added to the chart and no other series type has been added then only one pair of axes is created. | |
351 | If there are sevaral series added of different types then each series gets its own axes pair. |
|
351 | If there are sevaral series added of different types then each series gets its own axes pair. | |
352 |
|
352 | |||
353 | NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown. |
|
353 | NOTICE: if there is more than one x and y axes created then no axis is drawn by default and one needs to choose explicitly which axis should be shown. | |
354 |
|
354 | |||
355 | Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls. |
|
355 | Axis specifix to the series can be later obtained from the chart by providing the series as the parameter of axisX(), axisY() function calls. | |
356 | QPieSeries does not create any axes. |
|
356 | QPieSeries does not create any axes. | |
357 |
|
357 | |||
358 | \sa axisX(), axisY(), setAxisX(), setAxisY() |
|
358 | \sa axisX(), axisY(), setAxisX(), setAxisY() | |
359 | */ |
|
359 | */ | |
360 | void QChart::createDefaultAxes() |
|
360 | void QChart::createDefaultAxes() | |
361 | { |
|
361 | { | |
362 | d_ptr->m_dataset->createDefaultAxes(); |
|
362 | d_ptr->m_dataset->createDefaultAxes(); | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | /*! |
|
365 | /*! | |
366 | Returns the legend object of the chart. Ownership stays in chart. |
|
366 | Returns the legend object of the chart. Ownership stays in chart. | |
367 | */ |
|
367 | */ | |
368 | QLegend* QChart::legend() const |
|
368 | QLegend* QChart::legend() const | |
369 | { |
|
369 | { | |
370 | return d_ptr->m_legend; |
|
370 | return d_ptr->m_legend; | |
371 | } |
|
371 | } | |
372 |
|
372 | |||
373 | /*! |
|
373 | /*! | |
374 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
374 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
375 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
375 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
376 | */ |
|
376 | */ | |
377 | QRectF QChart::margins() const |
|
377 | QRectF QChart::margins() const | |
378 | { |
|
378 | { | |
379 | return d_ptr->m_presenter->margins(); |
|
379 | return d_ptr->m_presenter->margins(); | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
|
382 | QRectF QChart::plotArea() const | |||
|
383 | { | |||
|
384 | return d_ptr->m_presenter->geometry(); | |||
|
385 | } | |||
|
386 | ||||
382 | /*! |
|
387 | /*! | |
383 | Sets animation \a options for the chart |
|
388 | Sets animation \a options for the chart | |
384 | */ |
|
389 | */ | |
385 |
|
390 | |||
386 | void QChart::setAnimationOptions(AnimationOptions options) |
|
391 | void QChart::setAnimationOptions(AnimationOptions options) | |
387 | { |
|
392 | { | |
388 | d_ptr->m_presenter->setAnimationOptions(options); |
|
393 | d_ptr->m_presenter->setAnimationOptions(options); | |
389 | } |
|
394 | } | |
390 |
|
395 | |||
391 | QChart::AnimationOptions QChart::animationOptions() const |
|
396 | QChart::AnimationOptions QChart::animationOptions() const | |
392 | { |
|
397 | { | |
393 | return d_ptr->m_presenter->animationOptions(); |
|
398 | return d_ptr->m_presenter->animationOptions(); | |
394 | } |
|
399 | } | |
395 |
|
400 | |||
396 | /*! |
|
401 | /*! | |
397 | Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy. |
|
402 | Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy. | |
398 | */ |
|
403 | */ | |
399 | void QChart::scroll(qreal dx, qreal dy) |
|
404 | void QChart::scroll(qreal dx, qreal dy) | |
400 | { |
|
405 | { | |
401 | d_ptr->m_presenter->scroll(dx, dy); |
|
406 | d_ptr->m_presenter->scroll(dx, dy); | |
402 | } |
|
407 | } | |
403 |
|
408 | |||
404 | void QChart::setBackgroundVisible(bool visible) |
|
409 | void QChart::setBackgroundVisible(bool visible) | |
405 | { |
|
410 | { | |
406 | d_ptr->m_presenter->setBackgroundVisible(visible); |
|
411 | d_ptr->m_presenter->setBackgroundVisible(visible); | |
407 | } |
|
412 | } | |
408 |
|
413 | |||
409 | bool QChart::isBackgroundVisible() const |
|
414 | bool QChart::isBackgroundVisible() const | |
410 | { |
|
415 | { | |
411 | return d_ptr->m_presenter->isBackgroundVisible(); |
|
416 | return d_ptr->m_presenter->isBackgroundVisible(); | |
412 | } |
|
417 | } | |
413 |
|
418 | |||
414 | void QChart::setDropShadowEnabled(bool enabled) |
|
419 | void QChart::setDropShadowEnabled(bool enabled) | |
415 | { |
|
420 | { | |
416 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); |
|
421 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); | |
417 | } |
|
422 | } | |
418 |
|
423 | |||
419 | bool QChart::isDropShadowEnabled() const |
|
424 | bool QChart::isDropShadowEnabled() const | |
420 | { |
|
425 | { | |
421 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); |
|
426 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); | |
422 | } |
|
427 | } | |
423 |
|
428 | |||
424 | /*! |
|
429 | /*! | |
425 | Returns all the series that are added to the chart. |
|
430 | Returns all the series that are added to the chart. | |
426 |
|
431 | |||
427 | \sa addSeries(), removeSeries(), removeAllSeries() |
|
432 | \sa addSeries(), removeSeries(), removeAllSeries() | |
428 | */ |
|
433 | */ | |
429 | QList<QAbstractSeries*> QChart::series() const |
|
434 | QList<QAbstractSeries*> QChart::series() const | |
430 | { |
|
435 | { | |
431 | return d_ptr->m_dataset->series(); |
|
436 | return d_ptr->m_dataset->series(); | |
432 | } |
|
437 | } | |
433 |
|
438 | |||
434 | void QChart::setMarginsMinimum(const QRectF& margins) |
|
439 | void QChart::setMarginsMinimum(const QRectF& margins) | |
435 | { |
|
440 | { | |
436 | d_ptr->m_presenter->setMarginsMinimum(margins); |
|
441 | d_ptr->m_presenter->setMarginsMinimum(margins); | |
437 | } |
|
442 | } | |
438 |
|
443 | |||
439 | /*! |
|
444 | /*! | |
440 | Sets \a axis to the chart, which will control the presentation of the \a series |
|
445 | Sets \a axis to the chart, which will control the presentation of the \a series | |
441 |
|
446 | |||
442 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes() |
|
447 | \sa axisX(), axisY(), setAxisY(), createDefaultAxes() | |
443 | */ |
|
448 | */ | |
444 | void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series) |
|
449 | void QChart::setAxisX(QAbstractAxis* axis , QAbstractSeries *series) | |
445 | { |
|
450 | { | |
446 | d_ptr->m_dataset->setAxisX(series,axis); |
|
451 | d_ptr->m_dataset->setAxisX(series,axis); | |
447 | } |
|
452 | } | |
448 |
|
453 | |||
449 | /*! |
|
454 | /*! | |
450 | Sets \a axis to the chart, which will control the presentation of the \a series |
|
455 | Sets \a axis to the chart, which will control the presentation of the \a series | |
451 |
|
456 | |||
452 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes() |
|
457 | \sa axisX(), axisY(), setAxisX(), createDefaultAxes() | |
453 | */ |
|
458 | */ | |
454 | void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series) |
|
459 | void QChart::setAxisY( QAbstractAxis* axis , QAbstractSeries *series) | |
455 | { |
|
460 | { | |
456 | d_ptr->m_dataset->setAxisY(series,axis); |
|
461 | d_ptr->m_dataset->setAxisY(series,axis); | |
457 | } |
|
462 | } | |
458 |
|
463 | |||
459 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
464 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
460 |
|
465 | |||
461 | QChartPrivate::QChartPrivate(): |
|
466 | QChartPrivate::QChartPrivate(): | |
462 | m_legend(0), |
|
467 | m_legend(0), | |
463 | m_dataset(0), |
|
468 | m_dataset(0), | |
464 | m_presenter(0) |
|
469 | m_presenter(0) | |
465 | { |
|
470 | { | |
466 |
|
471 | |||
467 | } |
|
472 | } | |
468 |
|
473 | |||
469 | QChartPrivate::~QChartPrivate() |
|
474 | QChartPrivate::~QChartPrivate() | |
470 | { |
|
475 | { | |
471 |
|
476 | |||
472 | } |
|
477 | } | |
473 |
|
478 | |||
474 | void QChartPrivate::createConnections() |
|
479 | void QChartPrivate::createConnections() | |
475 | { |
|
480 | { | |
476 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
481 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
477 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
482 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
478 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*))); |
|
483 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*))); | |
479 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*))); |
|
484 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*))); | |
480 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); |
|
485 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); | |
481 | } |
|
486 | } | |
482 |
|
487 | |||
483 | #include "moc_qchart.cpp" |
|
488 | #include "moc_qchart.cpp" | |
484 |
|
489 | |||
485 | QTCOMMERCIALCHART_END_NAMESPACE |
|
490 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,135 +1,136 | |||||
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 <QAbstractSeries> |
|
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 QAbstractSeries; |
|
32 | class QAbstractSeries; | |
33 | class QAbstractAxis; |
|
33 | class QAbstractAxis; | |
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_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) |
|
40 | Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) | |
41 | Q_PROPERTY(QString title READ title WRITE setTitle) |
|
41 | Q_PROPERTY(QString title READ title WRITE setTitle) | |
42 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) |
|
42 | Q_PROPERTY(bool backgroundVisible READ isBackgroundVisible WRITE setBackgroundVisible) | |
43 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) |
|
43 | Q_PROPERTY(bool dropShadowEnabled READ isDropShadowEnabled WRITE setDropShadowEnabled) | |
44 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) |
|
44 | Q_PROPERTY(QChart::AnimationOptions animationOptions READ animationOptions WRITE setAnimationOptions) | |
45 | Q_PROPERTY(QRectF margins READ margins NOTIFY marginsChanged) |
|
45 | Q_PROPERTY(QRectF margins READ margins NOTIFY marginsChanged) | |
46 | Q_ENUMS(ChartTheme) |
|
46 | Q_ENUMS(ChartTheme) | |
47 | Q_ENUMS(AnimationOption) |
|
47 | Q_ENUMS(AnimationOption) | |
48 |
|
48 | |||
49 | public: |
|
49 | public: | |
50 | enum ChartTheme { |
|
50 | enum ChartTheme { | |
51 | ChartThemeLight = 0, |
|
51 | ChartThemeLight = 0, | |
52 | ChartThemeBlueCerulean, |
|
52 | ChartThemeBlueCerulean, | |
53 | ChartThemeDark, |
|
53 | ChartThemeDark, | |
54 | ChartThemeBrownSand, |
|
54 | ChartThemeBrownSand, | |
55 | ChartThemeBlueNcs, |
|
55 | ChartThemeBlueNcs, | |
56 | ChartThemeHighContrast, |
|
56 | ChartThemeHighContrast, | |
57 | ChartThemeBlueIcy |
|
57 | ChartThemeBlueIcy | |
58 | }; |
|
58 | }; | |
59 |
|
59 | |||
60 | enum AnimationOption { |
|
60 | enum AnimationOption { | |
61 | NoAnimation = 0x0, |
|
61 | NoAnimation = 0x0, | |
62 | GridAxisAnimations = 0x1, |
|
62 | GridAxisAnimations = 0x1, | |
63 | SeriesAnimations =0x2, |
|
63 | SeriesAnimations =0x2, | |
64 | AllAnimations = 0x3 |
|
64 | AllAnimations = 0x3 | |
65 | }; |
|
65 | }; | |
66 |
|
66 | |||
67 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) |
|
67 | Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) | |
68 |
|
68 | |||
69 | public: |
|
69 | public: | |
70 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
70 | explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
71 | ~QChart(); |
|
71 | ~QChart(); | |
72 |
|
72 | |||
73 | void addSeries(QAbstractSeries *series); |
|
73 | void addSeries(QAbstractSeries *series); | |
74 | void removeSeries(QAbstractSeries *series); |
|
74 | void removeSeries(QAbstractSeries *series); | |
75 | void removeAllSeries(); |
|
75 | void removeAllSeries(); | |
76 | QList<QAbstractSeries*> series() const; |
|
76 | QList<QAbstractSeries*> series() const; | |
77 |
|
77 | |||
78 | void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
78 | void setAxisX(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
79 | void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); |
|
79 | void setAxisY(QAbstractAxis* axis, QAbstractSeries *series = 0); | |
80 |
|
80 | |||
81 | QAbstractAxis* axisX(QAbstractSeries* series = 0) const; |
|
81 | QAbstractAxis* axisX(QAbstractSeries* series = 0) const; | |
82 | QAbstractAxis* axisY(QAbstractSeries* series = 0) const; |
|
82 | QAbstractAxis* axisY(QAbstractSeries* series = 0) const; | |
83 |
|
83 | |||
84 | void createDefaultAxes(); |
|
84 | void createDefaultAxes(); | |
85 |
|
85 | |||
86 | void setTheme(QChart::ChartTheme theme); |
|
86 | void setTheme(QChart::ChartTheme theme); | |
87 | QChart::ChartTheme theme() const; |
|
87 | QChart::ChartTheme theme() const; | |
88 |
|
88 | |||
89 | void setTitle(const QString& title); |
|
89 | void setTitle(const QString& title); | |
90 | QString title() const; |
|
90 | QString title() const; | |
91 | void setTitleFont(const QFont& font); |
|
91 | void setTitleFont(const QFont& font); | |
92 | QFont titleFont() const; |
|
92 | QFont titleFont() const; | |
93 | void setTitleBrush(const QBrush &brush); |
|
93 | void setTitleBrush(const QBrush &brush); | |
94 | QBrush titleBrush() const; |
|
94 | QBrush titleBrush() const; | |
95 |
|
95 | |||
96 | void setBackgroundBrush(const QBrush &brush); |
|
96 | void setBackgroundBrush(const QBrush &brush); | |
97 | QBrush backgroundBrush() const; |
|
97 | QBrush backgroundBrush() const; | |
98 | void setBackgroundPen(const QPen &pen); |
|
98 | void setBackgroundPen(const QPen &pen); | |
99 | QPen backgroundPen() const; |
|
99 | QPen backgroundPen() const; | |
100 | void setBackgroundVisible(bool visible = true); |
|
100 | void setBackgroundVisible(bool visible = true); | |
101 | bool isBackgroundVisible() const; |
|
101 | bool isBackgroundVisible() const; | |
102 |
|
102 | |||
103 | void setDropShadowEnabled(bool enabled = true); |
|
103 | void setDropShadowEnabled(bool enabled = true); | |
104 | bool isDropShadowEnabled() const; |
|
104 | bool isDropShadowEnabled() const; | |
105 | void setAnimationOptions(AnimationOptions options); |
|
105 | void setAnimationOptions(AnimationOptions options); | |
106 | AnimationOptions animationOptions() const; |
|
106 | AnimationOptions animationOptions() const; | |
107 |
|
107 | |||
108 | void zoomIn(); |
|
108 | void zoomIn(); | |
109 | void zoomIn(const QRectF &rect); |
|
109 | void zoomIn(const QRectF &rect); | |
110 | void zoomOut(); |
|
110 | void zoomOut(); | |
111 | void zoom(qreal factor); |
|
111 | void zoom(qreal factor); | |
112 | void scroll(qreal dx, qreal dy); |
|
112 | void scroll(qreal dx, qreal dy); | |
113 |
|
113 | |||
114 | void adjustViewToSeries(QAbstractSeries* series = 0); |
|
114 | void adjustViewToSeries(QAbstractSeries* series = 0); | |
115 |
|
115 | |||
116 | QLegend* legend() const; |
|
116 | QLegend* legend() const; | |
117 |
|
117 | |||
118 | void setMarginsMinimum(const QRectF& margins); |
|
118 | void setMarginsMinimum(const QRectF& margins); | |
119 | QRectF margins() const; |
|
119 | QRectF margins() const; | |
|
120 | QRectF plotArea() const; | |||
120 |
|
121 | |||
121 | Q_SIGNALS: |
|
122 | Q_SIGNALS: | |
122 | void marginsChanged(QRectF newMargins); |
|
123 | void marginsChanged(QRectF newMargins); | |
123 |
|
124 | |||
124 | protected: |
|
125 | protected: | |
125 | QScopedPointer<QChartPrivate> d_ptr; |
|
126 | QScopedPointer<QChartPrivate> d_ptr; | |
126 | friend class QLegend; |
|
127 | friend class QLegend; | |
127 | friend class ChartPresenter; |
|
128 | friend class ChartPresenter; | |
128 | Q_DISABLE_COPY(QChart) |
|
129 | Q_DISABLE_COPY(QChart) | |
129 | }; |
|
130 | }; | |
130 |
|
131 | |||
131 | QTCOMMERCIALCHART_END_NAMESPACE |
|
132 | QTCOMMERCIALCHART_END_NAMESPACE | |
132 |
|
133 | |||
133 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) |
|
134 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions) | |
134 |
|
135 | |||
135 | #endif |
|
136 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now