@@ -1,228 +1,228 | |||||
1 | #include "qscatterseries.h" |
|
1 | #include "qscatterseries.h" | |
2 | #include "scatterseries_p.h" |
|
2 | #include "scatterseries_p.h" | |
3 | #include "qchart.h" |
|
3 | #include "qchart.h" | |
4 |
|
4 | |||
5 | /*! |
|
5 | /*! | |
6 | \class QScatterSeries |
|
6 | \class QScatterSeries | |
7 | \brief QtCommercial Chart series API for showing scatter series. |
|
7 | \brief QtCommercial Chart series API for showing scatter series. | |
8 |
|
8 | |||
9 | \mainclass |
|
9 | \mainclass | |
10 |
|
10 | |||
11 | Example on how to create a chart with scatter series: |
|
11 | Example on how to create a chart with scatter series: | |
12 | \snippet ../example/scatter/main.cpp 1 |
|
12 | \snippet ../example/scatter/main.cpp 1 | |
13 |
|
13 | |||
14 | The example code would result the following: |
|
14 | The example code would result the following: | |
15 |
|
15 | |||
16 | \image scatter_example1.jpg |
|
16 | \image scatter_example1.jpg | |
17 | */ |
|
17 | */ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \enum QScatterSeries::MarkerShape |
|
20 | \enum QScatterSeries::MarkerShape | |
21 |
|
21 | |||
22 | This enum describes the shape used when rendering marker items. |
|
22 | This enum describes the shape used when rendering marker items. | |
23 |
|
23 | |||
24 | \value MarkerShapeDefault |
|
24 | \value MarkerShapeDefault | |
25 | \value MarkerShapePoint |
|
25 | \value MarkerShapePoint | |
26 | \value MarkerShapeX |
|
26 | \value MarkerShapeX | |
27 | \value MarkerShapeRectangle |
|
27 | \value MarkerShapeRectangle | |
28 | \value MarkerShapeTiltedRectangle |
|
28 | \value MarkerShapeTiltedRectangle | |
29 | \value MarkerShapeTriangle |
|
29 | \value MarkerShapeTriangle | |
30 | \value MarkerShapeCircle |
|
30 | \value MarkerShapeCircle | |
31 | */ |
|
31 | */ | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \fn QChartSeriesType QScatterSeries::type() const |
|
34 | \fn QChartSeriesType QScatterSeries::type() const | |
35 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
35 | \brief Returns QChartSeries::SeriesTypeScatter. | |
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | /*! |
|
38 | /*! | |
39 | \fn void QScatterSeries::clicked() |
|
39 | \fn void QScatterSeries::clicked() | |
40 | \brief TODO |
|
40 | \brief TODO | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \fn void QScatterSeries::hoverEnter() |
|
44 | \fn void QScatterSeries::hoverEnter() | |
45 | \brief TODO |
|
45 | \brief TODO | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | /*! |
|
48 | /*! | |
49 | \fn void QScatterSeries::hoverLeave() |
|
49 | \fn void QScatterSeries::hoverLeave() | |
50 | \brief TODO |
|
50 | \brief TODO | |
51 | */ |
|
51 | */ | |
52 |
|
52 | |||
53 | /*! |
|
53 | /*! | |
54 | \fn void QScatterSeries::changed() |
|
54 | \fn void QScatterSeries::changed() | |
55 | \brief TODO |
|
55 | \brief TODO | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
58 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
59 |
|
59 | |||
60 | QScatterSeriesPrivate::QScatterSeriesPrivate() : |
|
60 | QScatterSeriesPrivate::QScatterSeriesPrivate() : | |
61 | m_data(QList<QPointF>()), |
|
61 | m_data(QList<QPointF>()), | |
62 | m_markerPen(QPen()), |
|
62 | m_markerPen(QPen()), | |
63 | m_markerBrush(QBrush()), |
|
63 | m_markerBrush(QBrush()), | |
64 | m_markerShape(QScatterSeries::MarkerShapeDefault) |
|
64 | m_markerShape(QScatterSeries::MarkerShapeDefault) | |
65 | { |
|
65 | { | |
66 | // Initialize pen color to invalid to use a theme color by default |
|
66 | // Initialize pen color to invalid to use a theme color by default | |
67 | m_markerPen.setColor(QColor::Invalid); |
|
67 | m_markerPen.setColor(QColor::Invalid); | |
68 | m_markerBrush.setColor(QColor::Invalid); |
|
68 | m_markerBrush.setColor(QColor::Invalid); | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | Constructs a series object which is a child of \a parent. |
|
72 | Constructs a series object which is a child of \a parent. | |
73 | */ |
|
73 | */ | |
74 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
74 | QScatterSeries::QScatterSeries(QObject *parent) : | |
75 | QChartSeries(parent), |
|
75 | QChartSeries(parent), | |
76 | d(new QScatterSeriesPrivate()) |
|
76 | d(new QScatterSeriesPrivate()) | |
77 | { |
|
77 | { | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
81 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
82 | */ |
|
82 | */ | |
83 | QScatterSeries::~QScatterSeries() |
|
83 | QScatterSeries::~QScatterSeries() | |
84 | { |
|
84 | { | |
85 | delete d; |
|
85 | delete d; | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | Add single data point with \a value to the series. |
|
89 | Add single data point with \a value to the series. | |
90 | For example: |
|
90 | For example: | |
91 | \snippet ../example/scatter/main.cpp 2 |
|
91 | \snippet ../example/scatter/main.cpp 2 | |
92 | */ |
|
92 | */ | |
93 | void QScatterSeries::addData(QPointF value) |
|
93 | void QScatterSeries::addData(QPointF value) | |
94 | { |
|
94 | { | |
95 | d->m_data.append(value); |
|
95 | d->m_data.append(value); | |
96 | emit changed(); |
|
96 | emit changed(); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | Add list of \a points to the series. |
|
100 | Add list of \a points to the series. | |
101 | */ |
|
101 | */ | |
102 | void QScatterSeries::addData(QList<QPointF> points) |
|
102 | void QScatterSeries::addData(QList<QPointF> points) | |
103 | { |
|
103 | { | |
104 |
d->m_data.append( |
|
104 | d->m_data.append(points); | |
105 | emit changed(); |
|
105 | emit changed(); | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | Stream operator for adding a data point with \a value to the series. |
|
109 | Stream operator for adding a data point with \a value to the series. | |
110 | \sa addData() |
|
110 | \sa addData() | |
111 |
|
111 | |||
112 | For example: |
|
112 | For example: | |
113 | \snippet ../example/scatter/main.cpp 3 |
|
113 | \snippet ../example/scatter/main.cpp 3 | |
114 | */ |
|
114 | */ | |
115 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) |
|
115 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |
116 | { |
|
116 | { | |
117 | d->m_data.append(value); |
|
117 | d->m_data.append(value); | |
118 | emit changed(); |
|
118 | emit changed(); | |
119 | return *this; |
|
119 | return *this; | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | Stream operator for adding a list of points to the series. |
|
123 | Stream operator for adding a list of points to the series. | |
124 | \sa addData() |
|
124 | \sa addData() | |
125 | */ |
|
125 | */ | |
126 | QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) |
|
126 | QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) | |
127 | { |
|
127 | { | |
128 | d->m_data.append(value); |
|
128 | d->m_data.append(value); | |
129 | emit changed(); |
|
129 | emit changed(); | |
130 | return *this; |
|
130 | return *this; | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | /*! |
|
133 | /*! | |
134 | Replaces the data of the series with the given list of data \a points. |
|
134 | Replaces the data of the series with the given list of data \a points. | |
135 | */ |
|
135 | */ | |
136 | void QScatterSeries::setData(QList<QPointF> points) |
|
136 | void QScatterSeries::setData(QList<QPointF> points) | |
137 | { |
|
137 | { | |
138 |
d->m_data = |
|
138 | d->m_data = points; | |
139 | emit changed(); |
|
139 | emit changed(); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | Returns the current list of data points of the series. |
|
143 | Returns the current list of data points of the series. | |
144 | */ |
|
144 | */ | |
145 | QList<QPointF> QScatterSeries::data() |
|
145 | QList<QPointF> QScatterSeries::data() | |
146 | { |
|
146 | { | |
147 | return d->m_data; |
|
147 | return d->m_data; | |
148 | } |
|
148 | } | |
149 |
|
149 | |||
150 | /*! |
|
150 | /*! | |
151 | Overrides the default pen used for drawing a marker item with a user defined \a pen. The |
|
151 | Overrides the default pen used for drawing a marker item with a user defined \a pen. The | |
152 | default pen is defined by chart theme setting. |
|
152 | default pen is defined by chart theme setting. | |
153 |
|
153 | |||
154 | For example: |
|
154 | For example: | |
155 | \snippet ../example/scatter/main.cpp 5 |
|
155 | \snippet ../example/scatter/main.cpp 5 | |
156 |
|
156 | |||
157 | Would present your scatter markers with an opaque, uglyish green outlines instead of the |
|
157 | Would present your scatter markers with an opaque, uglyish green outlines instead of the | |
158 | beatiful markers defined by the chart's theme: |
|
158 | beatiful markers defined by the chart's theme: | |
159 | \image scatter_example_pen.jpg |
|
159 | \image scatter_example_pen.jpg | |
160 |
|
160 | |||
161 | \sa setMarkerBrush() |
|
161 | \sa setMarkerBrush() | |
162 | \sa QChart::setChartTheme() |
|
162 | \sa QChart::setChartTheme() | |
163 | */ |
|
163 | */ | |
164 | void QScatterSeries::setMarkerPen(QPen pen) |
|
164 | void QScatterSeries::setMarkerPen(QPen pen) | |
165 | { |
|
165 | { | |
166 | d->m_markerPen = pen; |
|
166 | d->m_markerPen = pen; | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | /*! |
|
169 | /*! | |
170 | Returns the pen used for drawing markers. |
|
170 | Returns the pen used for drawing markers. | |
171 | */ |
|
171 | */ | |
172 | QPen QScatterSeries::markerPen() |
|
172 | QPen QScatterSeries::markerPen() | |
173 | { |
|
173 | { | |
174 | return d->m_markerPen; |
|
174 | return d->m_markerPen; | |
175 | } |
|
175 | } | |
176 |
|
176 | |||
177 | /*! |
|
177 | /*! | |
178 | Overrides the default brush of the marker items with a user defined \a brush. The default brush |
|
178 | Overrides the default brush of the marker items with a user defined \a brush. The default brush | |
179 | is defined by chart theme setting. |
|
179 | is defined by chart theme setting. | |
180 |
|
180 | |||
181 | For example: |
|
181 | For example: | |
182 | \snippet ../example/scatter/main.cpp 4 |
|
182 | \snippet ../example/scatter/main.cpp 4 | |
183 |
|
183 | |||
184 | Would fill your scatter markers with an opaque red color: |
|
184 | Would fill your scatter markers with an opaque red color: | |
185 | \image scatter_example_brush.jpg |
|
185 | \image scatter_example_brush.jpg | |
186 |
|
186 | |||
187 | \sa setMarkerPen() |
|
187 | \sa setMarkerPen() | |
188 | \sa QChart::setChartTheme() |
|
188 | \sa QChart::setChartTheme() | |
189 | */ |
|
189 | */ | |
190 | void QScatterSeries::setMarkerBrush(QBrush brush) |
|
190 | void QScatterSeries::setMarkerBrush(QBrush brush) | |
191 | { |
|
191 | { | |
192 | d->m_markerBrush = brush; |
|
192 | d->m_markerBrush = brush; | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Returns the brush used for drawing markers. |
|
196 | Returns the brush used for drawing markers. | |
197 | */ |
|
197 | */ | |
198 | QBrush QScatterSeries::markerBrush() |
|
198 | QBrush QScatterSeries::markerBrush() | |
199 | { |
|
199 | { | |
200 | return d->m_markerBrush; |
|
200 | return d->m_markerBrush; | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
204 | Overrides the default shape of the marker items with a user defined \a shape. The default shape | |
205 | is defined by chart theme setting. |
|
205 | is defined by chart theme setting. | |
206 |
|
206 | |||
207 | For example: |
|
207 | For example: | |
208 | \snippet ../example/scatter/main.cpp 6 |
|
208 | \snippet ../example/scatter/main.cpp 6 | |
209 |
|
209 | |||
210 | Would make your scatter marker items rectangle: |
|
210 | Would make your scatter marker items rectangle: | |
211 | \image scatter_example_shape.jpg |
|
211 | \image scatter_example_shape.jpg | |
212 | */ |
|
212 | */ | |
213 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
213 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
214 | { |
|
214 | { | |
215 | d->m_markerShape = shape; |
|
215 | d->m_markerShape = shape; | |
216 | } |
|
216 | } | |
217 |
|
217 | |||
218 | /*! |
|
218 | /*! | |
219 | Returns the shape used for drawing markers. |
|
219 | Returns the shape used for drawing markers. | |
220 | */ |
|
220 | */ | |
221 | QScatterSeries::MarkerShape QScatterSeries::markerShape() |
|
221 | QScatterSeries::MarkerShape QScatterSeries::markerShape() | |
222 | { |
|
222 | { | |
223 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
|
223 | return (QScatterSeries::MarkerShape) d->m_markerShape; | |
224 | } |
|
224 | } | |
225 |
|
225 | |||
226 | #include "moc_qscatterseries.cpp" |
|
226 | #include "moc_qscatterseries.cpp" | |
227 |
|
227 | |||
228 | QTCOMMERCIALCHART_END_NAMESPACE |
|
228 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now