@@ -1,151 +1,155 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qscatterseries.h" |
|
21 | #include "qscatterseries.h" | |
22 | #include "qscatterseries_p.h" |
|
22 | #include "qscatterseries_p.h" | |
23 | #include "scatterchartitem_p.h" |
|
23 | #include "scatterchartitem_p.h" | |
24 | #include "chartdataset_p.h" |
|
24 | #include "chartdataset_p.h" | |
25 | #include "charttheme_p.h" |
|
25 | #include "charttheme_p.h" | |
26 | #include "chartanimator_p.h" |
|
26 | #include "chartanimator_p.h" | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QScatterSeries |
|
29 | \class QScatterSeries | |
30 | \brief The QScatterSeries class is used for making scatter charts. |
|
30 | \brief The QScatterSeries class is used for making scatter charts. | |
31 |
|
31 | |||
32 | \mainclass |
|
32 | \mainclass | |
33 |
|
33 | |||
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis | |
35 | and the vertical axis. |
|
35 | and the vertical axis. | |
36 |
|
36 | |||
37 | \image examples_scatterchart.png |
|
37 | \image examples_scatterchart.png | |
38 |
|
38 | |||
39 | Creating basic scatter chart is simple: |
|
39 | Creating basic scatter chart is simple: | |
40 | \code |
|
40 | \code | |
41 | QScatterSeries* series = new QScatterSeries(); |
|
41 | QScatterSeries* series = new QScatterSeries(); | |
42 | series->append(0, 6); |
|
42 | series->append(0, 6); | |
43 | series->append(2, 4); |
|
43 | series->append(2, 4); | |
44 | ... |
|
44 | ... | |
45 | chart->addSeries(series); |
|
45 | chart->addSeries(series); | |
46 | \endcode |
|
46 | \endcode | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \enum QScatterSeries::MarkerShape |
|
50 | \enum QScatterSeries::MarkerShape | |
51 |
|
51 | |||
52 | This enum describes the shape used when rendering marker items. |
|
52 | This enum describes the shape used when rendering marker items. | |
53 |
|
53 | |||
54 | \value MarkerShapeCircle |
|
54 | \value MarkerShapeCircle | |
55 | \value MarkerShapeRectangle |
|
55 | \value MarkerShapeRectangle | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \fn QChartSeriesType QScatterSeries::type() const |
|
59 | \fn QChartSeriesType QScatterSeries::type() const | |
60 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
60 | \brief Returns QChartSeries::SeriesTypeScatter. | |
61 | \sa QAbstractSeries, SeriesType |
|
61 | \sa QAbstractSeries, SeriesType | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
65 |
|
65 | |||
66 | /*! |
|
66 | /*! | |
67 | Constructs a series object which is a child of \a parent. |
|
67 | Constructs a series object which is a child of \a parent. | |
68 | */ |
|
68 | */ | |
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
70 | { |
|
70 | { | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
75 | */ |
|
75 | */ | |
76 | QScatterSeries::~QScatterSeries() |
|
76 | QScatterSeries::~QScatterSeries() | |
77 | { |
|
77 | { | |
|
78 | Q_D(QScatterSeries); | |||
|
79 | if(d->m_dataset) { | |||
|
80 | d->m_dataset->removeSeries(this); | |||
|
81 | } | |||
78 | } |
|
82 | } | |
79 |
|
83 | |||
80 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
84 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
81 | { |
|
85 | { | |
82 | return QAbstractSeries::SeriesTypeScatter; |
|
86 | return QAbstractSeries::SeriesTypeScatter; | |
83 | } |
|
87 | } | |
84 |
|
88 | |||
85 | /*! |
|
89 | /*! | |
86 | Returns the shape used for drawing markers. |
|
90 | Returns the shape used for drawing markers. | |
87 | */ |
|
91 | */ | |
88 | QScatterSeries::MarkerShape QScatterSeries::shape() const |
|
92 | QScatterSeries::MarkerShape QScatterSeries::shape() const | |
89 | { |
|
93 | { | |
90 | Q_D(const QScatterSeries); |
|
94 | Q_D(const QScatterSeries); | |
91 | return d->m_shape; |
|
95 | return d->m_shape; | |
92 | } |
|
96 | } | |
93 |
|
97 | |||
94 | /*! |
|
98 | /*! | |
95 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
99 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
96 | is defined by chart theme setting. |
|
100 | is defined by chart theme setting. | |
97 | */ |
|
101 | */ | |
98 | void QScatterSeries::setShape(MarkerShape shape) |
|
102 | void QScatterSeries::setShape(MarkerShape shape) | |
99 | { |
|
103 | { | |
100 | Q_D(QScatterSeries); |
|
104 | Q_D(QScatterSeries); | |
101 | if (d->m_shape != shape) { |
|
105 | if (d->m_shape != shape) { | |
102 | d->m_shape = shape; |
|
106 | d->m_shape = shape; | |
103 | emit d->updated(); |
|
107 | emit d->updated(); | |
104 | } |
|
108 | } | |
105 | } |
|
109 | } | |
106 |
|
110 | |||
107 | /*! |
|
111 | /*! | |
108 | Returns the size of the marker items. |
|
112 | Returns the size of the marker items. | |
109 | */ |
|
113 | */ | |
110 | qreal QScatterSeries::size() const |
|
114 | qreal QScatterSeries::size() const | |
111 | { |
|
115 | { | |
112 | Q_D(const QScatterSeries); |
|
116 | Q_D(const QScatterSeries); | |
113 | return d->m_size; |
|
117 | return d->m_size; | |
114 | } |
|
118 | } | |
115 |
|
119 | |||
116 | /*! |
|
120 | /*! | |
117 | Set the \a size of the marker items. The default size is 15. |
|
121 | Set the \a size of the marker items. The default size is 15. | |
118 | */ |
|
122 | */ | |
119 | void QScatterSeries::setSize(qreal size) |
|
123 | void QScatterSeries::setSize(qreal size) | |
120 | { |
|
124 | { | |
121 | Q_D(QScatterSeries); |
|
125 | Q_D(QScatterSeries); | |
122 |
|
126 | |||
123 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
127 | if (!qFuzzyIsNull(d->m_size - size)) { | |
124 | d->m_size = size; |
|
128 | d->m_size = size; | |
125 | emit d->updated(); |
|
129 | emit d->updated(); | |
126 | } |
|
130 | } | |
127 | } |
|
131 | } | |
128 |
|
132 | |||
129 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
130 |
|
134 | |||
131 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
135 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), | |
132 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
136 | m_shape(QScatterSeries::MarkerShapeCircle), | |
133 | m_size(15.0) |
|
137 | m_size(15.0) | |
134 | { |
|
138 | { | |
135 |
|
139 | |||
136 | }; |
|
140 | }; | |
137 |
|
141 | |||
138 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
142 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
139 | { |
|
143 | { | |
140 | Q_Q(QScatterSeries); |
|
144 | Q_Q(QScatterSeries); | |
141 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
145 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
142 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
146 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
143 | scatter->setAnimator(presenter->animator()); |
|
147 | scatter->setAnimator(presenter->animator()); | |
144 | scatter->setAnimation(new XYAnimation(scatter)); |
|
148 | scatter->setAnimation(new XYAnimation(scatter)); | |
145 | } |
|
149 | } | |
146 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
150 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
147 | return scatter; |
|
151 | return scatter; | |
148 | } |
|
152 | } | |
149 |
|
153 | |||
150 |
|
154 | |||
151 | QTCOMMERCIALCHART_END_NAMESPACE |
|
155 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now