@@ -1,156 +1,168 | |||||
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 | \property QScatterSeries::markerShape | |||
|
60 | ||||
|
61 | Defines the shape of the marker used to draw the points in the series. | |||
|
62 | */ | |||
|
63 | ||||
|
64 | /*! | |||
|
65 | \property QScatterSeries::markerSize | |||
|
66 | ||||
|
67 | Defines the size of the marker used to draw the points in the series. | |||
|
68 | */ | |||
|
69 | ||||
|
70 | /*! | |||
59 | \fn QChartSeriesType QScatterSeries::type() const |
|
71 | \fn QChartSeriesType QScatterSeries::type() const | |
60 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
72 | \brief Returns QChartSeries::SeriesTypeScatter. | |
61 | \sa QAbstractSeries, SeriesType |
|
73 | \sa QAbstractSeries, SeriesType | |
62 | */ |
|
74 | */ | |
63 |
|
75 | |||
64 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
76 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
65 |
|
77 | |||
66 | /*! |
|
78 | /*! | |
67 | Constructs a series object which is a child of \a parent. |
|
79 | Constructs a series object which is a child of \a parent. | |
68 | */ |
|
80 | */ | |
69 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
81 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) | |
70 | { |
|
82 | { | |
71 | } |
|
83 | } | |
72 |
|
84 | |||
73 | /*! |
|
85 | /*! | |
74 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
86 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
75 | */ |
|
87 | */ | |
76 | QScatterSeries::~QScatterSeries() |
|
88 | QScatterSeries::~QScatterSeries() | |
77 | { |
|
89 | { | |
78 | Q_D(QScatterSeries); |
|
90 | Q_D(QScatterSeries); | |
79 | if(d->m_dataset) { |
|
91 | if(d->m_dataset) { | |
80 | d->m_dataset->removeSeries(this); |
|
92 | d->m_dataset->removeSeries(this); | |
81 | } |
|
93 | } | |
82 | } |
|
94 | } | |
83 |
|
95 | |||
84 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
96 | QAbstractSeries::SeriesType QScatterSeries::type() const | |
85 | { |
|
97 | { | |
86 | return QAbstractSeries::SeriesTypeScatter; |
|
98 | return QAbstractSeries::SeriesTypeScatter; | |
87 | } |
|
99 | } | |
88 |
|
100 | |||
89 | /*! |
|
101 | /*! | |
90 | Returns the shape used for drawing markers. |
|
102 | Returns the shape used for drawing markers. | |
91 | */ |
|
103 | */ | |
92 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const |
|
104 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const | |
93 | { |
|
105 | { | |
94 | Q_D(const QScatterSeries); |
|
106 | Q_D(const QScatterSeries); | |
95 | return d->m_shape; |
|
107 | return d->m_shape; | |
96 | } |
|
108 | } | |
97 |
|
109 | |||
98 | /*! |
|
110 | /*! | |
99 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
111 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
100 | is defined by chart theme setting. |
|
112 | is defined by chart theme setting. | |
101 | */ |
|
113 | */ | |
102 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
114 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
103 | { |
|
115 | { | |
104 | Q_D(QScatterSeries); |
|
116 | Q_D(QScatterSeries); | |
105 | if (d->m_shape != shape) { |
|
117 | if (d->m_shape != shape) { | |
106 | d->m_shape = shape; |
|
118 | d->m_shape = shape; | |
107 | emit d->updated(); |
|
119 | emit d->updated(); | |
108 | } |
|
120 | } | |
109 | } |
|
121 | } | |
110 |
|
122 | |||
111 | /*! |
|
123 | /*! | |
112 | Returns the size of the marker items. |
|
124 | Returns the size of the marker items. | |
113 | */ |
|
125 | */ | |
114 | qreal QScatterSeries::markerSize() const |
|
126 | qreal QScatterSeries::markerSize() const | |
115 | { |
|
127 | { | |
116 | Q_D(const QScatterSeries); |
|
128 | Q_D(const QScatterSeries); | |
117 | return d->m_size; |
|
129 | return d->m_size; | |
118 | } |
|
130 | } | |
119 |
|
131 | |||
120 | /*! |
|
132 | /*! | |
121 | Set the \a size of the marker items. The default size is 15. |
|
133 | Set the \a size of the marker items. The default size is 15. | |
122 | */ |
|
134 | */ | |
123 | void QScatterSeries::setMarkerSize(qreal size) |
|
135 | void QScatterSeries::setMarkerSize(qreal size) | |
124 | { |
|
136 | { | |
125 | Q_D(QScatterSeries); |
|
137 | Q_D(QScatterSeries); | |
126 |
|
138 | |||
127 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
139 | if (!qFuzzyIsNull(d->m_size - size)) { | |
128 | d->m_size = size; |
|
140 | d->m_size = size; | |
129 | emit d->updated(); |
|
141 | emit d->updated(); | |
130 | } |
|
142 | } | |
131 | } |
|
143 | } | |
132 |
|
144 | |||
133 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
145 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
134 |
|
146 | |||
135 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
147 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), | |
136 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
148 | m_shape(QScatterSeries::MarkerShapeCircle), | |
137 | m_size(15.0) |
|
149 | m_size(15.0) | |
138 | { |
|
150 | { | |
139 |
|
151 | |||
140 | }; |
|
152 | }; | |
141 |
|
153 | |||
142 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
154 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
143 | { |
|
155 | { | |
144 | Q_Q(QScatterSeries); |
|
156 | Q_Q(QScatterSeries); | |
145 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
157 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); | |
146 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
158 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
147 | scatter->setAnimator(presenter->animator()); |
|
159 | scatter->setAnimator(presenter->animator()); | |
148 | scatter->setAnimation(new XYAnimation(scatter)); |
|
160 | scatter->setAnimation(new XYAnimation(scatter)); | |
149 | } |
|
161 | } | |
150 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
162 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
151 | return scatter; |
|
163 | return scatter; | |
152 | } |
|
164 | } | |
153 |
|
165 | |||
154 | #include "moc_qscatterseries.cpp" |
|
166 | #include "moc_qscatterseries.cpp" | |
155 |
|
167 | |||
156 | QTCOMMERCIALCHART_END_NAMESPACE |
|
168 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now