@@ -1,462 +1,497 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include <QtCharts/QAbstractSeries> |
|
19 | #include <QtCharts/QAbstractSeries> | |
20 | #include <private/qabstractseries_p.h> |
|
20 | #include <private/qabstractseries_p.h> | |
21 | #include <private/chartdataset_p.h> |
|
21 | #include <private/chartdataset_p.h> | |
22 | #include <QtCharts/QChart> |
|
22 | #include <QtCharts/QChart> | |
23 | #include <private/qchart_p.h> |
|
23 | #include <private/qchart_p.h> | |
24 | #include <private/chartitem_p.h> |
|
24 | #include <private/chartitem_p.h> | |
25 | #include <private/xydomain_p.h> |
|
25 | #include <private/xydomain_p.h> | |
26 | #include <private/xlogydomain_p.h> |
|
26 | #include <private/xlogydomain_p.h> | |
27 | #include <private/logxydomain_p.h> |
|
27 | #include <private/logxydomain_p.h> | |
28 | #include <private/logxlogydomain_p.h> |
|
28 | #include <private/logxlogydomain_p.h> | |
29 |
|
29 | |||
30 | QT_CHARTS_BEGIN_NAMESPACE |
|
30 | QT_CHARTS_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \class QAbstractSeries |
|
33 | \class QAbstractSeries | |
34 | \inmodule Qt Charts |
|
34 | \inmodule Qt Charts | |
35 | \brief Base class for all Qt Chart series. |
|
35 | \brief Base class for all Qt Chart series. | |
36 |
|
36 | |||
37 | Usually you use the series type specific inherited classes instead of the base class. |
|
37 | Usually you use the series type specific inherited classes instead of the base class. | |
38 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, |
|
38 | \sa QXYSeries, QLineSeries, QSplineSeries, QScatterSeries, QAreaSeries, QAbstractBarSeries, QStackedBarSeries, | |
39 | QPercentBarSeries, QPieSeries |
|
39 | QPercentBarSeries, QPieSeries | |
40 | */ |
|
40 | */ | |
41 | /*! |
|
41 | /*! | |
42 | \qmltype AbstractSeries |
|
42 | \qmltype AbstractSeries | |
43 | \instantiates QAbstractSeries |
|
43 | \instantiates QAbstractSeries | |
44 | \inqmlmodule QtCharts |
|
44 | \inqmlmodule QtCharts | |
45 |
|
45 | |||
46 | \brief Base class for all Qt Chart series. |
|
46 | \brief Base class for all Qt Chart series. | |
47 |
|
47 | |||
48 | AbstractSeries is the base class for all series. |
|
48 | AbstractSeries is the base class for all series. | |
49 | The class cannot be instantiated by the user. |
|
49 | The class cannot be instantiated by the user. | |
50 | */ |
|
50 | */ | |
51 |
|
51 | |||
52 | /*! |
|
52 | /*! | |
53 | \enum QAbstractSeries::SeriesType |
|
53 | \enum QAbstractSeries::SeriesType | |
54 |
|
54 | |||
55 | The type of the series object. |
|
55 | The type of the series object. | |
56 |
|
56 | |||
57 | \value SeriesTypeLine |
|
57 | \value SeriesTypeLine | |
58 | \value SeriesTypeArea |
|
58 | \value SeriesTypeArea | |
59 | \value SeriesTypeBar |
|
59 | \value SeriesTypeBar | |
60 | \value SeriesTypeStackedBar |
|
60 | \value SeriesTypeStackedBar | |
61 | \value SeriesTypePercentBar |
|
61 | \value SeriesTypePercentBar | |
62 | \value SeriesTypePie |
|
62 | \value SeriesTypePie | |
63 | \value SeriesTypeScatter |
|
63 | \value SeriesTypeScatter | |
64 | \value SeriesTypeSpline |
|
64 | \value SeriesTypeSpline | |
65 | \value SeriesTypeHorizontalBar |
|
65 | \value SeriesTypeHorizontalBar | |
66 | \value SeriesTypeHorizontalStackedBar |
|
66 | \value SeriesTypeHorizontalStackedBar | |
67 | \value SeriesTypeHorizontalPercentBar |
|
67 | \value SeriesTypeHorizontalPercentBar | |
68 | \value SeriesTypeBoxPlot |
|
68 | \value SeriesTypeBoxPlot | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \property QAbstractSeries::type |
|
72 | \property QAbstractSeries::type | |
73 | The type of the series. |
|
73 | The type of the series. | |
74 | */ |
|
74 | */ | |
75 | /*! |
|
75 | /*! | |
76 | \qmlproperty ChartView.SeriesType AbstractSeries::type |
|
76 | \qmlproperty ChartView.SeriesType AbstractSeries::type | |
77 | The type of the series. |
|
77 | The type of the series. | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QAbstractSeries::name |
|
81 | \property QAbstractSeries::name | |
82 | \brief name of the series property. The name is shown in legend for series and supports html formatting. |
|
82 | \brief name of the series property. The name is shown in legend for series and supports html formatting. | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty string AbstractSeries::name |
|
85 | \qmlproperty string AbstractSeries::name | |
86 | Name of the series. The name is shown in legend for series and supports html formatting. |
|
86 | Name of the series. The name is shown in legend for series and supports html formatting. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \fn void QAbstractSeries::nameChanged() |
|
90 | \fn void QAbstractSeries::nameChanged() | |
91 | This signal is emitted when the series name changes. |
|
91 | This signal is emitted when the series name changes. | |
92 | */ |
|
92 | */ | |
93 | /*! |
|
93 | /*! | |
94 | \qmlsignal AbstractSeries::onNameChanged() |
|
94 | \qmlsignal AbstractSeries::onNameChanged() | |
95 | This signal is emitted when the series name changes. |
|
95 | This signal is emitted when the series name changes. | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \property QAbstractSeries::visible |
|
99 | \property QAbstractSeries::visible | |
100 | \brief whether the series is visible or not; true by default. |
|
100 | \brief whether the series is visible or not; true by default. | |
101 | */ |
|
101 | */ | |
102 | /*! |
|
102 | /*! | |
103 | \qmlproperty bool AbstractSeries::visible |
|
103 | \qmlproperty bool AbstractSeries::visible | |
104 | Visibility of the series. True by default. |
|
104 | Visibility of the series. True by default. | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \fn void QAbstractSeries::visibleChanged() |
|
108 | \fn void QAbstractSeries::visibleChanged() | |
109 | Emitted when the series visibility changes. |
|
109 | Emitted when the series visibility changes. | |
110 | */ |
|
110 | */ | |
111 | /*! |
|
111 | /*! | |
112 | \qmlsignal AbstractSeries::onVisibleChanged() |
|
112 | \qmlsignal AbstractSeries::onVisibleChanged() | |
113 | Emitted when the series visibility changes. |
|
113 | Emitted when the series visibility changes. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \property QAbstractSeries::opacity |
|
117 | \property QAbstractSeries::opacity | |
118 | \brief The opacity of the series. |
|
118 | \brief The opacity of the series. | |
119 |
|
119 | |||
120 | By default the opacity is 1.0. The valid values range from 0.0 (transparent) to 1.0 (opaque). |
|
120 | By default the opacity is 1.0. The valid values range from 0.0 (transparent) to 1.0 (opaque). | |
121 | */ |
|
121 | */ | |
122 | /*! |
|
122 | /*! | |
123 | \qmlproperty real AbstractSeries::opacity |
|
123 | \qmlproperty real AbstractSeries::opacity | |
124 | The opacity of the series. By default the opacity is 1.0. |
|
124 | The opacity of the series. By default the opacity is 1.0. | |
125 | The valid values range from 0.0 (transparent) to 1.0 (opaque). |
|
125 | The valid values range from 0.0 (transparent) to 1.0 (opaque). | |
126 | */ |
|
126 | */ | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | \fn void QAbstractSeries::opacityChanged() |
|
129 | \fn void QAbstractSeries::opacityChanged() | |
130 | Emitted when the opacity of the series changes. |
|
130 | Emitted when the opacity of the series changes. | |
131 | */ |
|
131 | */ | |
132 | /*! |
|
132 | /*! | |
133 | \qmlsignal AbstractSeries::onOpacityChanged() |
|
133 | \qmlsignal AbstractSeries::onOpacityChanged() | |
134 | Emitted when the opacity of the series changes. |
|
134 | Emitted when the opacity of the series changes. | |
135 | */ |
|
135 | */ | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \property QAbstractSeries::useOpenGL |
|
138 | \property QAbstractSeries::useOpenGL | |
139 | \brief Specifies whether or not the series drawing is accelerated with OpenGL. |
|
139 | \brief Specifies whether or not the series drawing is accelerated with OpenGL. | |
140 |
|
140 | |||
141 | Drawing series with OpenGL is supported only for QLineSeries and QScatterSeries. |
|
141 | Drawing series with OpenGL is supported only for QLineSeries and QScatterSeries. | |
142 | Line series used as edge series for a QAreaSeries cannot use OpenGL acceleration. |
|
142 | Line series used as edge series for a QAreaSeries cannot use OpenGL acceleration. | |
143 | When a chart contains any series that are drawn with OpenGL, a transparent QOpenGLWidget |
|
143 | When a chart contains any series that are drawn with OpenGL, a transparent QOpenGLWidget | |
144 |
is created on top of the chart plot area. |
|
144 | is created on top of the chart plot area. The accelerated series are not drawn on the underlying | |
145 | QGraphicsView, but are instead drawn on the created QOpenGLWidget. |
|
145 | QGraphicsView, but are instead drawn on the created QOpenGLWidget. | |
146 |
|
146 | |||
147 | Performance gained from using OpenGL to accelerate series drawing depends on the underlying |
|
147 | Performance gained from using OpenGL to accelerate series drawing depends on the underlying | |
148 | hardware, but in most cases it is significant. For example, on a standard desktop computer, |
|
148 | hardware, but in most cases it is significant. For example, on a standard desktop computer, | |
149 | enabling OpenGL acceleration for a series typically allows rendering at least hundred times |
|
149 | enabling OpenGL acceleration for a series typically allows rendering at least hundred times | |
150 | more points without reduction on the frame rate. |
|
150 | more points without reduction on the frame rate. | |
151 | Chart size also has less effect on the frame rate. |
|
151 | Chart size also has less effect on the frame rate. | |
152 |
|
152 | |||
153 | The OpenGL acceleration of series drawing is meant for use cases that need fast drawing of |
|
153 | The OpenGL acceleration of series drawing is meant for use cases that need fast drawing of | |
154 | large numbers of points. It is optimized for efficiency, and therefore the series using |
|
154 | large numbers of points. It is optimized for efficiency, and therefore the series using | |
155 |
it lack support for |
|
155 | it lack support for many features available to non-accelerated series: | |
156 |
|
||||
157 | There are the following restrictions imposed on charts and series when using OpenGL |
|
|||
158 | acceleration: |
|
|||
159 |
|
156 | |||
160 | \list |
|
157 | \list | |
161 | \li Series animations are not supported for accelerated series. |
|
158 | \li Series animations are not supported for accelerated series. | |
162 | \li Antialiasing is not supported for accelerated series. |
|
159 | \li Antialiasing is not supported for accelerated series. | |
163 | \li Point labels are not supported for accelerated series. |
|
160 | \li Point labels are not supported for accelerated series. | |
164 | \li Pen styles and marker shapes are ignored for accelerated series. |
|
161 | \li Pen styles and marker shapes are ignored for accelerated series. | |
165 | Only solid lines and plain scatter dots are supported. |
|
162 | Only solid lines and plain scatter dots are supported. | |
166 | The scatter dots may be circular or rectangular, depending on the underlying graphics |
|
163 | The scatter dots may be circular or rectangular, depending on the underlying graphics | |
167 | hardware and drivers. |
|
164 | hardware and drivers. | |
168 |
\li Polar charts |
|
165 | \li Polar charts do not support accelerated series. | |
169 | \li Mouse events are not supported for accelerated series. |
|
166 | \li Mouse events are not supported for accelerated series. | |
170 | \li Since the accelerated series are drawn on top of the entire graphics view, they get drawn |
|
|||
171 | on top of any other graphics items that you may have on top chart in the same scene. |
|
|||
172 | \li To enable QOpenGLWidget to be partially transparent, it needs to be stacked on top of |
|
|||
173 | all other widgets. This means you cannot have other widgets partially covering the |
|
|||
174 | chart. |
|
|||
175 | \li Enabling chart drop shadow is not recommended when using accelerated series, |
|
167 | \li Enabling chart drop shadow is not recommended when using accelerated series, | |
176 | as that can slow the frame rate down significantly. |
|
168 | as that can slow the frame rate down significantly. | |
177 | \endlist |
|
169 | \endlist | |
178 |
|
170 | |||
|
171 | These additional restrictions stem from the fact that the accelerated series is drawn on a | |||
|
172 | separate widget on top of the chart: | |||
|
173 | ||||
|
174 | \list | |||
|
175 | \li If you draw any graphics items on top of a chart containing an accelerated series, | |||
|
176 | the accelerated series is drawn over those items. | |||
|
177 | \li To enable QOpenGLWidget to be partially transparent, it needs to be stacked on top of | |||
|
178 | all other widgets. This means you cannot have other widgets partially covering the | |||
|
179 | chart when using accelerated series. | |||
|
180 | \li Accelerated series are not supported for use cases where the graphics scene has more than | |||
|
181 | one graphics view attached to it. | |||
|
182 | \li Accelerated series are not supported for use cases where the chart doesn't fill the entire | |||
|
183 | graphics view or has non-default geometry. For example, scrolling the view with scroll | |||
|
184 | bars or adding transformations to the graphics view cause the accelerated series to | |||
|
185 | be drawn in incorrect position related to the chart. | |||
|
186 | \endlist | |||
|
187 | ||||
179 | The default value is \c{false}. |
|
188 | The default value is \c{false}. | |
180 | */ |
|
189 | */ | |
181 | /*! |
|
190 | /*! | |
182 | \qmlproperty bool AbstractSeries::useOpenGL |
|
191 | \qmlproperty bool AbstractSeries::useOpenGL | |
183 | Specifies whether or not the series is drawn with OpenGL. |
|
192 | Specifies whether or not the series is drawn with OpenGL. | |
184 |
|
193 | |||
185 | Drawing series with OpenGL is supported only for LineSeries and ScatterSeries. |
|
194 | Drawing series with OpenGL is supported only for LineSeries and ScatterSeries. | |
|
195 | Line series used as edge series for a AreaSeries cannot use OpenGL acceleration. | |||
|
196 | When a chart contains any series that are drawn with OpenGL, an additional transparent child | |||
|
197 | node is created for the ChartView node. The accelerated series are not drawn on the | |||
|
198 | ChartView node, but are instead drawn on the child node. | |||
|
199 | ||||
|
200 | Performance gained from using OpenGL to accelerate series drawing depends on the underlying | |||
|
201 | hardware, but in most cases it is significant. For example, on a standard desktop computer, | |||
|
202 | enabling OpenGL acceleration for a series typically allows rendering at least hundred times | |||
|
203 | more points without reduction on the frame rate. | |||
|
204 | Chart size also has less effect on the frame rate. | |||
|
205 | The biggest performance sink when rendering ChartView is rendering and uploading the underlying | |||
|
206 | chart texture. If the underlying chart itself is not changing rapidly, significant extra | |||
|
207 | performance is gained from not needing to regenerate the chart texture for each frame. | |||
|
208 | ||||
|
209 | The OpenGL acceleration of series drawing is meant for use cases that need fast drawing of | |||
|
210 | large numbers of points. It is optimized for efficiency, and therefore the series using | |||
|
211 | it lack support for many features available to non-accelerated series: | |||
186 |
|
212 | |||
187 | For more details, see QAbstractSeries::useOpenGL documentation. QML applications have similar |
|
213 | \list | |
188 | restrictions as those listed in QAbstractSeries::useOpenGL documentation, |
|
214 | \li Series animations are not supported for accelerated series. | |
189 | except there is no restriction about covering the ChartView partially with other |
|
215 | \li Antialiasing is not supported for accelerated series. | |
190 | items due to different rendering mechanism. |
|
216 | \li Point labels are not supported for accelerated series. | |
|
217 | \li Marker shapes are ignored for accelerated series. | |||
|
218 | Only plain scatter dots are supported. | |||
|
219 | The scatter dots may be circular or rectangular, depending on the underlying graphics | |||
|
220 | hardware and drivers. | |||
|
221 | \li Polar charts do not support accelerated series. | |||
|
222 | \li Mouse events are not supported for accelerated series. | |||
|
223 | \li Enabling chart drop shadow is not recommended when using accelerated series, | |||
|
224 | as that can slow the frame rate down significantly. | |||
|
225 | \endlist | |||
191 |
|
226 | |||
192 | The default value is \c{false}. |
|
227 | The default value is \c{false}. | |
193 | */ |
|
228 | */ | |
194 |
|
229 | |||
195 | /*! |
|
230 | /*! | |
196 | \fn void QAbstractSeries::useOpenGLChanged() |
|
231 | \fn void QAbstractSeries::useOpenGLChanged() | |
197 | Emitted when the useOpenGL property value changes. |
|
232 | Emitted when the useOpenGL property value changes. | |
198 | */ |
|
233 | */ | |
199 | /*! |
|
234 | /*! | |
200 | \qmlsignal AbstractSeries::onUseOpenGLChanged() |
|
235 | \qmlsignal AbstractSeries::onUseOpenGLChanged() | |
201 | Emitted when the useOpenGL property value changes. |
|
236 | Emitted when the useOpenGL property value changes. | |
202 | */ |
|
237 | */ | |
203 |
|
238 | |||
204 | /*! |
|
239 | /*! | |
205 | \internal |
|
240 | \internal | |
206 | \brief Constructs QAbstractSeries object with \a parent. |
|
241 | \brief Constructs QAbstractSeries object with \a parent. | |
207 | */ |
|
242 | */ | |
208 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : |
|
243 | QAbstractSeries::QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent) : | |
209 | QObject(parent), |
|
244 | QObject(parent), | |
210 | d_ptr(&d) |
|
245 | d_ptr(&d) | |
211 | { |
|
246 | { | |
212 | } |
|
247 | } | |
213 |
|
248 | |||
214 | /*! |
|
249 | /*! | |
215 | \brief Virtual destructor for the chart series. |
|
250 | \brief Virtual destructor for the chart series. | |
216 | */ |
|
251 | */ | |
217 | QAbstractSeries::~QAbstractSeries() |
|
252 | QAbstractSeries::~QAbstractSeries() | |
218 | { |
|
253 | { | |
219 | if (d_ptr->m_chart) |
|
254 | if (d_ptr->m_chart) | |
220 | qFatal("Series still bound to a chart when destroyed!"); |
|
255 | qFatal("Series still bound to a chart when destroyed!"); | |
221 | } |
|
256 | } | |
222 |
|
257 | |||
223 | void QAbstractSeries::setName(const QString &name) |
|
258 | void QAbstractSeries::setName(const QString &name) | |
224 | { |
|
259 | { | |
225 | if (name != d_ptr->m_name) { |
|
260 | if (name != d_ptr->m_name) { | |
226 | d_ptr->m_name = name; |
|
261 | d_ptr->m_name = name; | |
227 | emit nameChanged(); |
|
262 | emit nameChanged(); | |
228 | } |
|
263 | } | |
229 | } |
|
264 | } | |
230 |
|
265 | |||
231 | QString QAbstractSeries::name() const |
|
266 | QString QAbstractSeries::name() const | |
232 | { |
|
267 | { | |
233 | return d_ptr->m_name; |
|
268 | return d_ptr->m_name; | |
234 | } |
|
269 | } | |
235 |
|
270 | |||
236 | void QAbstractSeries::setVisible(bool visible) |
|
271 | void QAbstractSeries::setVisible(bool visible) | |
237 | { |
|
272 | { | |
238 | if (visible != d_ptr->m_visible) { |
|
273 | if (visible != d_ptr->m_visible) { | |
239 | d_ptr->m_visible = visible; |
|
274 | d_ptr->m_visible = visible; | |
240 | emit visibleChanged(); |
|
275 | emit visibleChanged(); | |
241 | } |
|
276 | } | |
242 | } |
|
277 | } | |
243 |
|
278 | |||
244 | bool QAbstractSeries::isVisible() const |
|
279 | bool QAbstractSeries::isVisible() const | |
245 | { |
|
280 | { | |
246 | return d_ptr->m_visible; |
|
281 | return d_ptr->m_visible; | |
247 | } |
|
282 | } | |
248 |
|
283 | |||
249 | qreal QAbstractSeries::opacity() const |
|
284 | qreal QAbstractSeries::opacity() const | |
250 | { |
|
285 | { | |
251 | return d_ptr->m_opacity; |
|
286 | return d_ptr->m_opacity; | |
252 | } |
|
287 | } | |
253 |
|
288 | |||
254 | void QAbstractSeries::setOpacity(qreal opacity) |
|
289 | void QAbstractSeries::setOpacity(qreal opacity) | |
255 | { |
|
290 | { | |
256 | if (opacity != d_ptr->m_opacity) { |
|
291 | if (opacity != d_ptr->m_opacity) { | |
257 | d_ptr->m_opacity = opacity; |
|
292 | d_ptr->m_opacity = opacity; | |
258 | emit opacityChanged(); |
|
293 | emit opacityChanged(); | |
259 | } |
|
294 | } | |
260 | } |
|
295 | } | |
261 |
|
296 | |||
262 | void QAbstractSeries::setUseOpenGL(bool enable) |
|
297 | void QAbstractSeries::setUseOpenGL(bool enable) | |
263 | { |
|
298 | { | |
264 | #ifdef QT_NO_OPENGL |
|
299 | #ifdef QT_NO_OPENGL | |
265 | Q_UNUSED(enable) |
|
300 | Q_UNUSED(enable) | |
266 | #else |
|
301 | #else | |
267 | bool polarChart = d_ptr->m_chart && d_ptr->m_chart->chartType() == QChart::ChartTypePolar; |
|
302 | bool polarChart = d_ptr->m_chart && d_ptr->m_chart->chartType() == QChart::ChartTypePolar; | |
268 | bool supportedSeries = (type() == SeriesTypeLine || type() == SeriesTypeScatter); |
|
303 | bool supportedSeries = (type() == SeriesTypeLine || type() == SeriesTypeScatter); | |
269 | if ((!enable || !d_ptr->m_blockOpenGL) |
|
304 | if ((!enable || !d_ptr->m_blockOpenGL) | |
270 | && supportedSeries |
|
305 | && supportedSeries | |
271 | && enable != d_ptr->m_useOpenGL |
|
306 | && enable != d_ptr->m_useOpenGL | |
272 | && (!enable || !polarChart)) { |
|
307 | && (!enable || !polarChart)) { | |
273 | d_ptr->m_useOpenGL = enable; |
|
308 | d_ptr->m_useOpenGL = enable; | |
274 | emit useOpenGLChanged(); |
|
309 | emit useOpenGLChanged(); | |
275 | } |
|
310 | } | |
276 | #endif |
|
311 | #endif | |
277 | } |
|
312 | } | |
278 |
|
313 | |||
279 | bool QAbstractSeries::useOpenGL() const |
|
314 | bool QAbstractSeries::useOpenGL() const | |
280 | { |
|
315 | { | |
281 | return d_ptr->m_useOpenGL; |
|
316 | return d_ptr->m_useOpenGL; | |
282 | } |
|
317 | } | |
283 |
|
318 | |||
284 | /*! |
|
319 | /*! | |
285 | \brief Returns the chart where series belongs to. |
|
320 | \brief Returns the chart where series belongs to. | |
286 |
|
321 | |||
287 | Set automatically when the series is added to the chart |
|
322 | Set automatically when the series is added to the chart | |
288 | and unset when the series is removed from the chart. |
|
323 | and unset when the series is removed from the chart. | |
289 | */ |
|
324 | */ | |
290 | QChart *QAbstractSeries::chart() const |
|
325 | QChart *QAbstractSeries::chart() const | |
291 | { |
|
326 | { | |
292 | return d_ptr->m_chart; |
|
327 | return d_ptr->m_chart; | |
293 | } |
|
328 | } | |
294 |
|
329 | |||
295 | /*! |
|
330 | /*! | |
296 | \brief Sets the visibility of the series to true. |
|
331 | \brief Sets the visibility of the series to true. | |
297 |
|
332 | |||
298 | \sa setVisible(), isVisible() |
|
333 | \sa setVisible(), isVisible() | |
299 | */ |
|
334 | */ | |
300 | void QAbstractSeries::show() |
|
335 | void QAbstractSeries::show() | |
301 | { |
|
336 | { | |
302 | setVisible(true); |
|
337 | setVisible(true); | |
303 | } |
|
338 | } | |
304 |
|
339 | |||
305 | /*! |
|
340 | /*! | |
306 | \brief Sets the visibility of the series to false. |
|
341 | \brief Sets the visibility of the series to false. | |
307 |
|
342 | |||
308 | \sa setVisible(), isVisible() |
|
343 | \sa setVisible(), isVisible() | |
309 | */ |
|
344 | */ | |
310 | void QAbstractSeries::hide() |
|
345 | void QAbstractSeries::hide() | |
311 | { |
|
346 | { | |
312 | setVisible(false); |
|
347 | setVisible(false); | |
313 | } |
|
348 | } | |
314 |
|
349 | |||
315 | /*! |
|
350 | /*! | |
316 | Attach \a axis to the series. |
|
351 | Attach \a axis to the series. | |
317 | \return true if the axis was attached successfully, false otherwise. |
|
352 | \return true if the axis was attached successfully, false otherwise. | |
318 | \note If multiple axes of same orientation are attached to same series, |
|
353 | \note If multiple axes of same orientation are attached to same series, | |
319 | they will have same min/max ranges. |
|
354 | they will have same min/max ranges. | |
320 | \sa QChart::addAxis(), QChart::createDefaultAxes() |
|
355 | \sa QChart::addAxis(), QChart::createDefaultAxes() | |
321 | */ |
|
356 | */ | |
322 | bool QAbstractSeries::attachAxis(QAbstractAxis* axis) |
|
357 | bool QAbstractSeries::attachAxis(QAbstractAxis* axis) | |
323 | { |
|
358 | { | |
324 | if(d_ptr->m_chart) { |
|
359 | if(d_ptr->m_chart) { | |
325 | return d_ptr->m_chart->d_ptr->m_dataset->attachAxis(this, axis); |
|
360 | return d_ptr->m_chart->d_ptr->m_dataset->attachAxis(this, axis); | |
326 | } else { |
|
361 | } else { | |
327 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; |
|
362 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; | |
328 | return false; |
|
363 | return false; | |
329 | } |
|
364 | } | |
330 | } |
|
365 | } | |
331 |
|
366 | |||
332 | /*! |
|
367 | /*! | |
333 | Detach \a axis from the series. |
|
368 | Detach \a axis from the series. | |
334 | \return true if the axis was detached successfully, false otherwise. |
|
369 | \return true if the axis was detached successfully, false otherwise. | |
335 | \sa QChart::removeAxis() |
|
370 | \sa QChart::removeAxis() | |
336 | */ |
|
371 | */ | |
337 | bool QAbstractSeries::detachAxis(QAbstractAxis* axis) |
|
372 | bool QAbstractSeries::detachAxis(QAbstractAxis* axis) | |
338 | { |
|
373 | { | |
339 | if(d_ptr->m_chart) { |
|
374 | if(d_ptr->m_chart) { | |
340 | return d_ptr->m_chart->d_ptr->m_dataset->detachAxis(this, axis); |
|
375 | return d_ptr->m_chart->d_ptr->m_dataset->detachAxis(this, axis); | |
341 | } |
|
376 | } | |
342 | else { |
|
377 | else { | |
343 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; |
|
378 | qWarning()<<"Series not in the chart. Please addSeries to chart first."; | |
344 | return false; |
|
379 | return false; | |
345 | } |
|
380 | } | |
346 | } |
|
381 | } | |
347 |
|
382 | |||
348 | /*! |
|
383 | /*! | |
349 | Returns the list of axes attached to the series. Usually there is an x-axis and a y-axis attached to a series, except |
|
384 | Returns the list of axes attached to the series. Usually there is an x-axis and a y-axis attached to a series, except | |
350 | in case of a QPieSeries, which does not have any axes attached. |
|
385 | in case of a QPieSeries, which does not have any axes attached. | |
351 | \sa attachAxis(), detachAxis() |
|
386 | \sa attachAxis(), detachAxis() | |
352 | */ |
|
387 | */ | |
353 | QList<QAbstractAxis*> QAbstractSeries::attachedAxes() |
|
388 | QList<QAbstractAxis*> QAbstractSeries::attachedAxes() | |
354 | { |
|
389 | { | |
355 | return d_ptr->m_axes; |
|
390 | return d_ptr->m_axes; | |
356 | } |
|
391 | } | |
357 |
|
392 | |||
358 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
393 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
359 |
|
394 | |||
360 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries *q) |
|
395 | QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries *q) | |
361 | : q_ptr(q), |
|
396 | : q_ptr(q), | |
362 | m_chart(0), |
|
397 | m_chart(0), | |
363 | m_item(0), |
|
398 | m_item(0), | |
364 | m_domain(new XYDomain()), |
|
399 | m_domain(new XYDomain()), | |
365 | m_visible(true), |
|
400 | m_visible(true), | |
366 | m_opacity(1.0), |
|
401 | m_opacity(1.0), | |
367 | m_useOpenGL(false), |
|
402 | m_useOpenGL(false), | |
368 | m_blockOpenGL(false) |
|
403 | m_blockOpenGL(false) | |
369 | { |
|
404 | { | |
370 | } |
|
405 | } | |
371 |
|
406 | |||
372 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() |
|
407 | QAbstractSeriesPrivate::~QAbstractSeriesPrivate() | |
373 | { |
|
408 | { | |
374 | } |
|
409 | } | |
375 |
|
410 | |||
376 | void QAbstractSeriesPrivate::setDomain(AbstractDomain* domain) |
|
411 | void QAbstractSeriesPrivate::setDomain(AbstractDomain* domain) | |
377 | { |
|
412 | { | |
378 | Q_ASSERT(domain); |
|
413 | Q_ASSERT(domain); | |
379 | if(m_domain.data()!=domain) { |
|
414 | if(m_domain.data()!=domain) { | |
380 | if(!m_item.isNull()) QObject::disconnect(m_domain.data(), SIGNAL(updated()), m_item.data(), SLOT(handleDomainUpdated())); |
|
415 | if(!m_item.isNull()) QObject::disconnect(m_domain.data(), SIGNAL(updated()), m_item.data(), SLOT(handleDomainUpdated())); | |
381 | m_domain.reset(domain); |
|
416 | m_domain.reset(domain); | |
382 | if(!m_item.isNull()) { |
|
417 | if(!m_item.isNull()) { | |
383 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); |
|
418 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); | |
384 | m_item->handleDomainUpdated(); |
|
419 | m_item->handleDomainUpdated(); | |
385 | } |
|
420 | } | |
386 | } |
|
421 | } | |
387 | } |
|
422 | } | |
388 |
|
423 | |||
389 | void QAbstractSeriesPrivate::setPresenter(ChartPresenter *presenter) |
|
424 | void QAbstractSeriesPrivate::setPresenter(ChartPresenter *presenter) | |
390 | { |
|
425 | { | |
391 | m_presenter = presenter; |
|
426 | m_presenter = presenter; | |
392 | } |
|
427 | } | |
393 |
|
428 | |||
394 | ChartPresenter *QAbstractSeriesPrivate::presenter() const |
|
429 | ChartPresenter *QAbstractSeriesPrivate::presenter() const | |
395 | { |
|
430 | { | |
396 | return m_presenter; |
|
431 | return m_presenter; | |
397 | } |
|
432 | } | |
398 |
|
433 | |||
399 | void QAbstractSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
434 | void QAbstractSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
400 | { |
|
435 | { | |
401 | Q_ASSERT(!m_item.isNull()); |
|
436 | Q_ASSERT(!m_item.isNull()); | |
402 | Q_UNUSED(parent); |
|
437 | Q_UNUSED(parent); | |
403 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); |
|
438 | QObject::connect(m_domain.data(), SIGNAL(updated()),m_item.data(), SLOT(handleDomainUpdated())); | |
404 | } |
|
439 | } | |
405 |
|
440 | |||
406 | void QAbstractSeriesPrivate::initializeAnimations(QChart::AnimationOptions options, int duration, |
|
441 | void QAbstractSeriesPrivate::initializeAnimations(QChart::AnimationOptions options, int duration, | |
407 | QEasingCurve &curve) |
|
442 | QEasingCurve &curve) | |
408 | { |
|
443 | { | |
409 | Q_UNUSED(options); |
|
444 | Q_UNUSED(options); | |
410 | Q_UNUSED(duration); |
|
445 | Q_UNUSED(duration); | |
411 | Q_UNUSED(curve); |
|
446 | Q_UNUSED(curve); | |
412 | } |
|
447 | } | |
413 |
|
448 | |||
414 | bool QAbstractSeriesPrivate::reverseXAxis() |
|
449 | bool QAbstractSeriesPrivate::reverseXAxis() | |
415 | { |
|
450 | { | |
416 | bool reverseXAxis = false; |
|
451 | bool reverseXAxis = false; | |
417 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { |
|
452 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { | |
418 | int i = 0; |
|
453 | int i = 0; | |
419 | while (i < m_axes.size()) { |
|
454 | while (i < m_axes.size()) { | |
420 | if (m_axes.at(i)->orientation() == Qt::Horizontal && m_axes.at(i)->isReverse()) { |
|
455 | if (m_axes.at(i)->orientation() == Qt::Horizontal && m_axes.at(i)->isReverse()) { | |
421 | reverseXAxis = true; |
|
456 | reverseXAxis = true; | |
422 | break; |
|
457 | break; | |
423 | } |
|
458 | } | |
424 | i++; |
|
459 | i++; | |
425 | } |
|
460 | } | |
426 | } |
|
461 | } | |
427 |
|
462 | |||
428 | return reverseXAxis; |
|
463 | return reverseXAxis; | |
429 | } |
|
464 | } | |
430 |
|
465 | |||
431 | bool QAbstractSeriesPrivate::reverseYAxis() |
|
466 | bool QAbstractSeriesPrivate::reverseYAxis() | |
432 | { |
|
467 | { | |
433 | bool reverseYAxis = false; |
|
468 | bool reverseYAxis = false; | |
434 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { |
|
469 | if (m_axes.size() != 0 && !(m_chart->chartType() == QChart::ChartTypePolar)) { | |
435 | int i = 0; |
|
470 | int i = 0; | |
436 | while (i < m_axes.size()) { |
|
471 | while (i < m_axes.size()) { | |
437 | if (m_axes.at(i)->orientation() == Qt::Vertical && m_axes.at(i)->isReverse()) { |
|
472 | if (m_axes.at(i)->orientation() == Qt::Vertical && m_axes.at(i)->isReverse()) { | |
438 | reverseYAxis = true; |
|
473 | reverseYAxis = true; | |
439 | break; |
|
474 | break; | |
440 | } |
|
475 | } | |
441 | i++; |
|
476 | i++; | |
442 | } |
|
477 | } | |
443 | } |
|
478 | } | |
444 |
|
479 | |||
445 | return reverseYAxis; |
|
480 | return reverseYAxis; | |
446 | } |
|
481 | } | |
447 |
|
482 | |||
448 | // This function can be used to explicitly block OpenGL use from some otherwise supported series, |
|
483 | // This function can be used to explicitly block OpenGL use from some otherwise supported series, | |
449 | // such as the line series used as edge series of an area series. |
|
484 | // such as the line series used as edge series of an area series. | |
450 | void QAbstractSeriesPrivate::setBlockOpenGL(bool enable) |
|
485 | void QAbstractSeriesPrivate::setBlockOpenGL(bool enable) | |
451 | { |
|
486 | { | |
452 | m_blockOpenGL = enable; |
|
487 | m_blockOpenGL = enable; | |
453 | if (enable) |
|
488 | if (enable) | |
454 | q_ptr->setUseOpenGL(false); |
|
489 | q_ptr->setUseOpenGL(false); | |
455 | } |
|
490 | } | |
456 |
|
491 | |||
457 | #include "moc_qabstractseries.cpp" |
|
492 | #include "moc_qabstractseries.cpp" | |
458 | #include "moc_qabstractseries_p.cpp" |
|
493 | #include "moc_qabstractseries_p.cpp" | |
459 |
|
494 | |||
460 | QT_CHARTS_END_NAMESPACE |
|
495 | QT_CHARTS_END_NAMESPACE | |
461 |
|
496 | |||
462 |
|
497 |
General Comments 0
You need to be logged in to leave comments.
Login now