##// END OF EJS Templates
Adds AxisY(series) getter
Michal Klocek -
r899:46c4ead56465
parent child
Show More
@@ -1,382 +1,382
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 <QGraphicsScene>
23 #include <QGraphicsScene>
24 #include <QGraphicsSceneResizeEvent>
24 #include <QGraphicsSceneResizeEvent>
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 /*!
28 /*!
29 \enum QChart::ChartTheme
29 \enum QChart::ChartTheme
30
30
31 This enum describes the theme used by the chart.
31 This enum describes the theme used by the chart.
32
32
33 \value ChartThemeLight The default theme
33 \value ChartThemeLight The default theme
34 \value ChartThemeBlueCerulean
34 \value ChartThemeBlueCerulean
35 \value ChartThemeDark
35 \value ChartThemeDark
36 \value ChartThemeBrownSand
36 \value ChartThemeBrownSand
37 \value ChartThemeBlueNcs
37 \value ChartThemeBlueNcs
38 \value ChartThemeHighContrast
38 \value ChartThemeHighContrast
39 \value ChartThemeBlueIcy
39 \value ChartThemeBlueIcy
40 \value ChartThemeCount Not really a theme; the total count of themes.
40 \value ChartThemeCount Not really a theme; the total count of themes.
41 */
41 */
42
42
43 /*!
43 /*!
44 \enum QChart::AnimationOption
44 \enum QChart::AnimationOption
45
45
46 For enabling/disabling animations. Defaults to NoAnimation.
46 For enabling/disabling animations. Defaults to NoAnimation.
47
47
48 \value NoAnimation
48 \value NoAnimation
49 \value GridAxisAnimations
49 \value GridAxisAnimations
50 \value SeriesAnimations
50 \value SeriesAnimations
51 \value AllAnimations
51 \value AllAnimations
52 */
52 */
53
53
54 /*!
54 /*!
55 \class QChart
55 \class QChart
56 \brief QtCommercial chart API.
56 \brief QtCommercial chart API.
57
57
58 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
58 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
59 representation of different types of QChartSeries and other chart related objects like
59 representation of different types of QChartSeries and other chart related objects like
60 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
60 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
61 convenience class QChartView instead of QChart.
61 convenience class QChartView instead of QChart.
62 \sa QChartView
62 \sa QChartView
63 */
63 */
64
64
65 /*!
65 /*!
66 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
66 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
67 */
67 */
68 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
68 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
69 d_ptr(new QChartPrivate())
69 d_ptr(new QChartPrivate())
70 {
70 {
71 d_ptr->m_legend = new ScrolledQLegend(this);
71 d_ptr->m_legend = new ScrolledQLegend(this);
72 d_ptr->m_legend->setVisible(false);
72 d_ptr->m_legend->setVisible(false);
73 d_ptr->m_dataset = new ChartDataSet(this);
73 d_ptr->m_dataset = new ChartDataSet(this);
74 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
74 d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset);
75 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
75 d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false);
76 d_ptr->createConnections();
76 d_ptr->createConnections();
77 //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3);
77 //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3);
78 }
78 }
79
79
80 /*!
80 /*!
81 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
81 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
82 */
82 */
83 QChart::~QChart()
83 QChart::~QChart()
84 {
84 {
85 //delete first presenter , since this is a root of all the graphical items
85 //delete first presenter , since this is a root of all the graphical items
86 delete d_ptr->m_presenter;
86 delete d_ptr->m_presenter;
87 d_ptr->m_presenter=0;
87 d_ptr->m_presenter=0;
88 }
88 }
89
89
90 /*!
90 /*!
91 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
91 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
92 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
92 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
93 the y axis).
93 the y axis).
94 */
94 */
95 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
95 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
96 {
96 {
97 Q_ASSERT(series);
97 Q_ASSERT(series);
98 d_ptr->m_dataset->addSeries(series, axisY);
98 d_ptr->m_dataset->addSeries(series, axisY);
99 }
99 }
100
100
101 /*!
101 /*!
102 Removes the \a series specified in a perameter from the QChartView.
102 Removes the \a series specified in a perameter from the QChartView.
103 It releses its ownership of the specified QChartSeries object.
103 It releses its ownership of the specified QChartSeries object.
104 It does not delete the pointed QChartSeries data object
104 It does not delete the pointed QChartSeries data object
105 \sa addSeries(), removeAllSeries()
105 \sa addSeries(), removeAllSeries()
106 */
106 */
107 void QChart::removeSeries(QSeries* series)
107 void QChart::removeSeries(QSeries* series)
108 {
108 {
109 Q_ASSERT(series);
109 Q_ASSERT(series);
110 d_ptr->m_dataset->removeSeries(series);
110 d_ptr->m_dataset->removeSeries(series);
111 }
111 }
112
112
113 /*!
113 /*!
114 Removes all the QChartSeries that have been added to the QChartView
114 Removes all the QChartSeries that have been added to the QChartView
115 It also deletes the pointed QChartSeries data objects
115 It also deletes the pointed QChartSeries data objects
116 \sa addSeries(), removeSeries()
116 \sa addSeries(), removeSeries()
117 */
117 */
118 void QChart::removeAllSeries()
118 void QChart::removeAllSeries()
119 {
119 {
120 d_ptr->m_dataset->removeAllSeries();
120 d_ptr->m_dataset->removeAllSeries();
121 }
121 }
122
122
123 /*!
123 /*!
124 Sets the \a brush that is used for painting the background of the chart area.
124 Sets the \a brush that is used for painting the background of the chart area.
125 */
125 */
126 void QChart::setBackgroundBrush(const QBrush& brush)
126 void QChart::setBackgroundBrush(const QBrush& brush)
127 {
127 {
128 //TODO: refactor me
128 //TODO: refactor me
129 d_ptr->m_presenter->createChartBackgroundItem();
129 d_ptr->m_presenter->createChartBackgroundItem();
130 d_ptr->m_presenter->m_backgroundItem->setBrush(brush);
130 d_ptr->m_presenter->m_backgroundItem->setBrush(brush);
131 d_ptr->m_presenter->m_backgroundItem->update();
131 d_ptr->m_presenter->m_backgroundItem->update();
132 }
132 }
133
133
134 QBrush QChart::backgroundBrush() const
134 QBrush QChart::backgroundBrush() const
135 {
135 {
136 //TODO: refactor me
136 //TODO: refactor me
137 if (!d_ptr->m_presenter->m_backgroundItem) return QBrush();
137 if (!d_ptr->m_presenter->m_backgroundItem) return QBrush();
138 return (d_ptr->m_presenter->m_backgroundItem)->brush();
138 return (d_ptr->m_presenter->m_backgroundItem)->brush();
139 }
139 }
140
140
141 /*!
141 /*!
142 Sets the \a pen that is used for painting the background of the chart area.
142 Sets the \a pen that is used for painting the background of the chart area.
143 */
143 */
144 void QChart::setBackgroundPen(const QPen& pen)
144 void QChart::setBackgroundPen(const QPen& pen)
145 {
145 {
146 //TODO: refactor me
146 //TODO: refactor me
147 d_ptr->m_presenter->createChartBackgroundItem();
147 d_ptr->m_presenter->createChartBackgroundItem();
148 d_ptr->m_presenter->m_backgroundItem->setPen(pen);
148 d_ptr->m_presenter->m_backgroundItem->setPen(pen);
149 d_ptr->m_presenter->m_backgroundItem->update();
149 d_ptr->m_presenter->m_backgroundItem->update();
150 }
150 }
151
151
152 QPen QChart::backgroundPen() const
152 QPen QChart::backgroundPen() const
153 {
153 {
154 //TODO: refactor me
154 //TODO: refactor me
155 if (!d_ptr->m_presenter->m_backgroundItem) return QPen();
155 if (!d_ptr->m_presenter->m_backgroundItem) return QPen();
156 return d_ptr->m_presenter->m_backgroundItem->pen();
156 return d_ptr->m_presenter->m_backgroundItem->pen();
157 }
157 }
158
158
159 /*!
159 /*!
160 Sets the chart \a title. The description text that is drawn above the chart.
160 Sets the chart \a title. The description text that is drawn above the chart.
161 */
161 */
162 void QChart::setTitle(const QString& title)
162 void QChart::setTitle(const QString& title)
163 {
163 {
164 //TODO: refactor me
164 //TODO: refactor me
165 d_ptr->m_presenter->createChartTitleItem();
165 d_ptr->m_presenter->createChartTitleItem();
166 d_ptr->m_presenter->m_titleItem->setText(title);
166 d_ptr->m_presenter->m_titleItem->setText(title);
167 d_ptr->m_presenter->updateLayout();
167 d_ptr->m_presenter->updateLayout();
168 }
168 }
169
169
170 /*!
170 /*!
171 Returns the chart title. The description text that is drawn above the chart.
171 Returns the chart title. The description text that is drawn above the chart.
172 */
172 */
173 QString QChart::title() const
173 QString QChart::title() const
174 {
174 {
175 //TODO: refactor me
175 //TODO: refactor me
176 if (d_ptr->m_presenter->m_titleItem)
176 if (d_ptr->m_presenter->m_titleItem)
177 return d_ptr->m_presenter->m_titleItem->text();
177 return d_ptr->m_presenter->m_titleItem->text();
178 else
178 else
179 return QString();
179 return QString();
180 }
180 }
181
181
182 /*!
182 /*!
183 Sets the \a font that is used for rendering the description text that is rendered above the chart.
183 Sets the \a font that is used for rendering the description text that is rendered above the chart.
184 */
184 */
185 void QChart::setTitleFont(const QFont& font)
185 void QChart::setTitleFont(const QFont& font)
186 {
186 {
187 //TODO: refactor me
187 //TODO: refactor me
188 d_ptr->m_presenter->createChartTitleItem();
188 d_ptr->m_presenter->createChartTitleItem();
189 d_ptr->m_presenter->m_titleItem->setFont(font);
189 d_ptr->m_presenter->m_titleItem->setFont(font);
190 d_ptr->m_presenter->updateLayout();
190 d_ptr->m_presenter->updateLayout();
191 }
191 }
192
192
193 QFont QChart::titleFont() const
193 QFont QChart::titleFont() const
194 {
194 {
195 if (d_ptr->m_presenter->m_titleItem)
195 if (d_ptr->m_presenter->m_titleItem)
196 return d_ptr->m_presenter->m_titleItem->font();
196 return d_ptr->m_presenter->m_titleItem->font();
197 else
197 else
198 return QFont();
198 return QFont();
199 }
199 }
200
200
201 /*!
201 /*!
202 Sets the \a brush used for rendering the title text.
202 Sets the \a brush used for rendering the title text.
203 */
203 */
204 void QChart::setTitleBrush(const QBrush &brush)
204 void QChart::setTitleBrush(const QBrush &brush)
205 {
205 {
206 //TODO: refactor me
206 //TODO: refactor me
207 d_ptr->m_presenter->createChartTitleItem();
207 d_ptr->m_presenter->createChartTitleItem();
208 d_ptr->m_presenter->m_titleItem->setBrush(brush);
208 d_ptr->m_presenter->m_titleItem->setBrush(brush);
209 d_ptr->m_presenter->updateLayout();
209 d_ptr->m_presenter->updateLayout();
210 }
210 }
211
211
212 /*!
212 /*!
213 Returns the brush used for rendering the title text.
213 Returns the brush used for rendering the title text.
214 */
214 */
215 QBrush QChart::titleBrush() const
215 QBrush QChart::titleBrush() const
216 {
216 {
217 //TODO: refactor me
217 //TODO: refactor me
218 if (!d_ptr->m_presenter->m_titleItem) return QBrush();
218 if (!d_ptr->m_presenter->m_titleItem) return QBrush();
219 return d_ptr->m_presenter->m_titleItem->brush();
219 return d_ptr->m_presenter->m_titleItem->brush();
220 }
220 }
221
221
222 /*!
222 /*!
223 Sets the \a theme used by the chart for rendering the graphical representation of the data
223 Sets the \a theme used by the chart for rendering the graphical representation of the data
224 \sa ChartTheme, chartTheme()
224 \sa ChartTheme, chartTheme()
225 */
225 */
226 void QChart::setTheme(QChart::ChartTheme theme)
226 void QChart::setTheme(QChart::ChartTheme theme)
227 {
227 {
228 d_ptr->m_presenter->setTheme(theme);
228 d_ptr->m_presenter->setTheme(theme);
229 }
229 }
230
230
231 /*!
231 /*!
232 Returns the theme enum used by the chart.
232 Returns the theme enum used by the chart.
233 \sa ChartTheme, setChartTheme()
233 \sa ChartTheme, setChartTheme()
234 */
234 */
235 QChart::ChartTheme QChart::theme() const
235 QChart::ChartTheme QChart::theme() const
236 {
236 {
237 return d_ptr->m_presenter->theme();
237 return d_ptr->m_presenter->theme();
238 }
238 }
239
239
240 /*!
240 /*!
241 Zooms in the view by a factor of 2
241 Zooms in the view by a factor of 2
242 */
242 */
243 void QChart::zoomIn()
243 void QChart::zoomIn()
244 {
244 {
245 d_ptr->m_presenter->zoomIn();
245 d_ptr->m_presenter->zoomIn();
246 }
246 }
247
247
248 /*!
248 /*!
249 Zooms in the view to a maximum level at which \a rect is still fully visible.
249 Zooms in the view to a maximum level at which \a rect is still fully visible.
250 */
250 */
251 void QChart::zoomIn(const QRectF& rect)
251 void QChart::zoomIn(const QRectF& rect)
252 {
252 {
253 if (!rect.isValid()) return;
253 if (!rect.isValid()) return;
254 d_ptr->m_presenter->zoomIn(rect);
254 d_ptr->m_presenter->zoomIn(rect);
255 }
255 }
256
256
257 /*!
257 /*!
258 Restores the view zoom level to the previous one.
258 Restores the view zoom level to the previous one.
259 */
259 */
260 void QChart::zoomOut()
260 void QChart::zoomOut()
261 {
261 {
262 d_ptr->m_presenter->zoomOut();
262 d_ptr->m_presenter->zoomOut();
263 }
263 }
264
264
265 /*!
265 /*!
266 Returns the pointer to the x axis object of the chart
266 Returns the pointer to the x axis object of the chart
267 */
267 */
268 QChartAxis* QChart::axisX() const
268 QChartAxis* QChart::axisX() const
269 {
269 {
270 return d_ptr->m_dataset->axisX();
270 return d_ptr->m_dataset->axisX();
271 }
271 }
272
272
273 /*!
273 /*!
274 Returns the pointer to the y axis object of the chart
274 Returns the pointer to the y axis object of the chart
275 */
275 */
276 QChartAxis* QChart::axisY() const
276 QChartAxis* QChart::axisY(QSeries* series) const
277 {
277 {
278 return d_ptr->m_dataset->axisY();
278 return d_ptr->m_dataset->axisY(series);
279 }
279 }
280
280
281 /*!
281 /*!
282 Returns the legend object of the chart. Ownership stays in chart.
282 Returns the legend object of the chart. Ownership stays in chart.
283 */
283 */
284 QLegend* QChart::legend() const
284 QLegend* QChart::legend() const
285 {
285 {
286 return d_ptr->m_legend;
286 return d_ptr->m_legend;
287 }
287 }
288
288
289 QRectF QChart::margins() const
289 QRectF QChart::margins() const
290 {
290 {
291 return d_ptr->m_presenter->margins();
291 return d_ptr->m_presenter->margins();
292 }
292 }
293
293
294
294
295 /*!
295 /*!
296 Resizes and updates the chart area using the \a event data
296 Resizes and updates the chart area using the \a event data
297 */
297 */
298 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
298 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
299 {
299 {
300 d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize());
300 d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize());
301 QGraphicsWidget::resizeEvent(event);
301 QGraphicsWidget::resizeEvent(event);
302 d_ptr->m_presenter->setGeometry(d_ptr->m_rect);
302 d_ptr->m_presenter->setGeometry(d_ptr->m_rect);
303 }
303 }
304
304
305 /*!
305 /*!
306 Sets animation \a options for the chart
306 Sets animation \a options for the chart
307 */
307 */
308 void QChart::setAnimationOptions(AnimationOptions options)
308 void QChart::setAnimationOptions(AnimationOptions options)
309 {
309 {
310 d_ptr->m_presenter->setAnimationOptions(options);
310 d_ptr->m_presenter->setAnimationOptions(options);
311 }
311 }
312
312
313 /*!
313 /*!
314 Returns animation options for the chart
314 Returns animation options for the chart
315 */
315 */
316 QChart::AnimationOptions QChart::animationOptions() const
316 QChart::AnimationOptions QChart::animationOptions() const
317 {
317 {
318 return d_ptr->m_presenter->animationOptions();
318 return d_ptr->m_presenter->animationOptions();
319 }
319 }
320
320
321 void QChart::scrollLeft()
321 void QChart::scrollLeft()
322 {
322 {
323 d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
323 d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
324 }
324 }
325
325
326 void QChart::scrollRight()
326 void QChart::scrollRight()
327 {
327 {
328 d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
328 d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0);
329 }
329 }
330
330
331 void QChart::scrollUp()
331 void QChart::scrollUp()
332 {
332 {
333 d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
333 d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
334 }
334 }
335
335
336 void QChart::scrollDown()
336 void QChart::scrollDown()
337 {
337 {
338 d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
338 d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1));
339 }
339 }
340
340
341 void QChart::setBackgroundVisible(bool visible)
341 void QChart::setBackgroundVisible(bool visible)
342 {
342 {
343 //TODO: refactor me
343 //TODO: refactor me
344 d_ptr->m_presenter->createChartBackgroundItem();
344 d_ptr->m_presenter->createChartBackgroundItem();
345 d_ptr->m_presenter->m_backgroundItem->setVisible(visible);
345 d_ptr->m_presenter->m_backgroundItem->setVisible(visible);
346 }
346 }
347
347
348 bool QChart::isBackgroundVisible() const
348 bool QChart::isBackgroundVisible() const
349 {
349 {
350 //TODO: refactor me
350 //TODO: refactor me
351 if (!d_ptr->m_presenter->m_backgroundItem) return false;
351 if (!d_ptr->m_presenter->m_backgroundItem) return false;
352 return d_ptr->m_presenter->m_backgroundItem->isVisible();
352 return d_ptr->m_presenter->m_backgroundItem->isVisible();
353 }
353 }
354
354
355 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
355 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
356
356
357 QChartPrivate::QChartPrivate():
357 QChartPrivate::QChartPrivate():
358 m_legend(0),
358 m_legend(0),
359 m_dataset(0),
359 m_dataset(0),
360 m_presenter(0)
360 m_presenter(0)
361 {
361 {
362
362
363 }
363 }
364
364
365 QChartPrivate::~QChartPrivate()
365 QChartPrivate::~QChartPrivate()
366 {
366 {
367
367
368 }
368 }
369
369
370 void QChartPrivate::createConnections()
370 void QChartPrivate::createConnections()
371 {
371 {
372 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
372 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
373 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
373 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
374 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*)));
374 QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*)));
375 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*)));
375 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*)));
376 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*)));
376 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*)));
377 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*)));
377 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*)));
378 }
378 }
379
379
380 #include "moc_qchart.cpp"
380 #include "moc_qchart.cpp"
381
381
382 QTCOMMERCIALCHART_END_NAMESPACE
382 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,119 +1,120
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 <QSeries>
25 #include <QLegend>
25 #include <QGraphicsWidget>
26 #include <QGraphicsWidget>
26
27
27 class QGraphicsSceneResizeEvent;
28 class QGraphicsSceneResizeEvent;
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 class QSeries;
32 class QSeries;
32 class QChartAxis;
33 class QChartAxis;
33 class QLegend;
34 class QLegend;
34 struct QChartPrivate;
35 struct QChartPrivate;
35
36
36 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
37 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
37 {
38 {
38 Q_OBJECT
39 Q_OBJECT
39 Q_ENUMS(ChartTheme)
40 Q_ENUMS(ChartTheme)
40
41
41 public:
42 public:
42 enum ChartTheme {
43 enum ChartTheme {
43 ChartThemeLight = 0,
44 ChartThemeLight = 0,
44 ChartThemeBlueCerulean,
45 ChartThemeBlueCerulean,
45 ChartThemeDark,
46 ChartThemeDark,
46 ChartThemeBrownSand,
47 ChartThemeBrownSand,
47 ChartThemeBlueNcs,
48 ChartThemeBlueNcs,
48 ChartThemeHighContrast,
49 ChartThemeHighContrast,
49 ChartThemeBlueIcy,
50 ChartThemeBlueIcy,
50 ChartThemeCount
51 ChartThemeCount
51 };
52 };
52
53
53 enum AnimationOption {
54 enum AnimationOption {
54 NoAnimation = 0x0,
55 NoAnimation = 0x0,
55 GridAxisAnimations = 0x1,
56 GridAxisAnimations = 0x1,
56 SeriesAnimations =0x2,
57 SeriesAnimations =0x2,
57 AllAnimations = 0x3
58 AllAnimations = 0x3
58 };
59 };
59
60
60 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
61 Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)
61
62
62 public:
63 public:
63 explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
64 explicit QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
64 ~QChart();
65 ~QChart();
65
66
66 void addSeries(QSeries *series, QChartAxis *axisY = 0);
67 void addSeries(QSeries *series, QChartAxis *axisY = 0);
67 void removeSeries(QSeries *series);
68 void removeSeries(QSeries *series);
68 void removeAllSeries();
69 void removeAllSeries();
69
70
70 void setTheme(QChart::ChartTheme theme);
71 void setTheme(QChart::ChartTheme theme);
71 QChart::ChartTheme theme() const;
72 QChart::ChartTheme theme() const;
72
73
73 void setTitle(const QString& title);
74 void setTitle(const QString& title);
74 QString title() const;
75 QString title() const;
75 void setTitleFont(const QFont& font);
76 void setTitleFont(const QFont& font);
76 QFont titleFont() const;
77 QFont titleFont() const;
77 void setTitleBrush(const QBrush &brush);
78 void setTitleBrush(const QBrush &brush);
78 QBrush titleBrush() const;
79 QBrush titleBrush() const;
79
80
80 void setBackgroundBrush(const QBrush &brush);
81 void setBackgroundBrush(const QBrush &brush);
81 QBrush backgroundBrush() const;
82 QBrush backgroundBrush() const;
82 void setBackgroundPen(const QPen &pen);
83 void setBackgroundPen(const QPen &pen);
83 QPen backgroundPen() const;
84 QPen backgroundPen() const;
84
85
85 void setBackgroundVisible(bool visible);
86 void setBackgroundVisible(bool visible);
86 bool isBackgroundVisible() const;
87 bool isBackgroundVisible() const;
87
88
88 void setAnimationOptions(AnimationOptions options);
89 void setAnimationOptions(AnimationOptions options);
89 AnimationOptions animationOptions() const;
90 AnimationOptions animationOptions() const;
90
91
91 void zoomIn();
92 void zoomIn();
92 void zoomIn(const QRectF &rect);
93 void zoomIn(const QRectF &rect);
93 void zoomOut();
94 void zoomOut();
94 void scrollLeft();
95 void scrollLeft();
95 void scrollRight();
96 void scrollRight();
96 void scrollUp();
97 void scrollUp();
97 void scrollDown();
98 void scrollDown();
98
99
99 QChartAxis* axisX() const;
100 QChartAxis* axisX() const;
100 QChartAxis* axisY() const;
101 QChartAxis* axisY(QSeries* series = 0) const;
101
102
102 QLegend* legend() const;
103 QLegend* legend() const;
103 QRectF margins() const;
104 QRectF margins() const;
104
105
105 protected:
106 protected:
106 void resizeEvent(QGraphicsSceneResizeEvent *event);
107 void resizeEvent(QGraphicsSceneResizeEvent *event);
107
108
108 protected:
109 protected:
109 QScopedPointer<QChartPrivate> d_ptr;
110 QScopedPointer<QChartPrivate> d_ptr;
110 friend class QLegend;
111 friend class QLegend;
111 friend class ChartPresenter;
112 friend class ChartPresenter;
112 Q_DISABLE_COPY(QChart)
113 Q_DISABLE_COPY(QChart)
113 };
114 };
114
115
115 QTCOMMERCIALCHART_END_NAMESPACE
116 QTCOMMERCIALCHART_END_NAMESPACE
116
117
117 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
118 Q_DECLARE_OPERATORS_FOR_FLAGS(QTCOMMERCIALCHART_NAMESPACE::QChart::AnimationOptions)
118
119
119 #endif
120 #endif
General Comments 0
You need to be logged in to leave comments. Login now