@@ -0,0 +1,26 | |||||
|
1 | #ifndef CHARTHELPERS_P_H | |||
|
2 | #define CHARTHELPERS_P_H | |||
|
3 | ||||
|
4 | #include <qnumeric.h> | |||
|
5 | #include <QPointF> | |||
|
6 | ||||
|
7 | static inline bool isValidValue(qreal value) | |||
|
8 | { | |||
|
9 | if (qIsNaN(value) || qIsInf(value)) { | |||
|
10 | qWarning("Ignored NaN, Inf, or -Inf value."); | |||
|
11 | return false; | |||
|
12 | } | |||
|
13 | return true; | |||
|
14 | } | |||
|
15 | ||||
|
16 | static inline bool isValidValue(qreal x, qreal y) | |||
|
17 | { | |||
|
18 | return (isValidValue(x) && isValidValue(y)); | |||
|
19 | } | |||
|
20 | ||||
|
21 | static inline bool isValidValue(const QPointF point) | |||
|
22 | { | |||
|
23 | return (isValidValue(point.x()) && isValidValue(point.y())); | |||
|
24 | } | |||
|
25 | ||||
|
26 | #endif // CHARTHELPERS_P_H |
@@ -1,638 +1,644 | |||||
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 "qbarset.h" |
|
21 | #include "qbarset.h" | |
22 | #include "qbarset_p.h" |
|
22 | #include "qbarset_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QBarSet |
|
27 | \class QBarSet | |
28 | \brief Building block for different bar charts |
|
28 | \brief Building block for different bar charts | |
29 |
|
29 | |||
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. |
|
30 | QBarSet represents one set of bars. Set of bars contains one data value for each category. | |
31 | First value of set is assumed to belong to first category, second to second category and so on. |
|
31 | First value of set is assumed to belong to first category, second to second category and so on. | |
32 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
32 | If set has fewer values than there are categories, then the missing values are assumed to be | |
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
33 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
34 |
|
34 | |||
35 | \mainclass |
|
35 | \mainclass | |
36 |
|
36 | |||
37 | \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries |
|
37 | \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries | |
38 | */ |
|
38 | */ | |
39 | /*! |
|
39 | /*! | |
40 | \qmlclass BarSet QBarSet |
|
40 | \qmlclass BarSet QBarSet | |
41 |
|
41 | |||
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. |
|
42 | BarSet represents one set of bars. Set of bars contains one data value for each category. | |
43 | First value of set is assumed to belong to first category, second to second category and so on. |
|
43 | First value of set is assumed to belong to first category, second to second category and so on. | |
44 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
44 | If set has fewer values than there are categories, then the missing values are assumed to be | |
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. |
|
45 | at the end of set. For missing values in middle of a set, numerical value of zero is used. | |
46 | \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries |
|
46 | \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \property QBarSet::label |
|
50 | \property QBarSet::label | |
51 | Defines the label of the barSet. |
|
51 | Defines the label of the barSet. | |
52 | */ |
|
52 | */ | |
53 | /*! |
|
53 | /*! | |
54 | \qmlproperty string BarSet::label |
|
54 | \qmlproperty string BarSet::label | |
55 | Defines the label of the barSet. |
|
55 | Defines the label of the barSet. | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \property QBarSet::pen |
|
59 | \property QBarSet::pen | |
60 | \brief Defines the pen used by the barSet. |
|
60 | \brief Defines the pen used by the barSet. | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \property QBarSet::brush |
|
64 | \property QBarSet::brush | |
65 | \brief Defines the brush used by the barSet. |
|
65 | \brief Defines the brush used by the barSet. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QBarSet::labelBrush |
|
69 | \property QBarSet::labelBrush | |
70 | \brief Defines the brush used by the barSet's label. |
|
70 | \brief Defines the brush used by the barSet's label. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \property QBarSet::labelFont |
|
74 | \property QBarSet::labelFont | |
75 | \brief Defines the font used by the barSet's label. |
|
75 | \brief Defines the font used by the barSet's label. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \qmlproperty Font BarSet::labelFont |
|
79 | \qmlproperty Font BarSet::labelFont | |
80 | Defines the font used by the barSet's label. |
|
80 | Defines the font used by the barSet's label. | |
81 |
|
81 | |||
82 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
82 | See the \l {Font} {QML Font Element} for detailed documentation. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \property QBarSet::color |
|
86 | \property QBarSet::color | |
87 | The fill (brush) color of the bar set. |
|
87 | The fill (brush) color of the bar set. | |
88 | */ |
|
88 | */ | |
89 | /*! |
|
89 | /*! | |
90 | \qmlproperty color BarSet::color |
|
90 | \qmlproperty color BarSet::color | |
91 | The fill (brush) color of the bar set. |
|
91 | The fill (brush) color of the bar set. | |
92 | */ |
|
92 | */ | |
93 |
|
93 | |||
94 | /*! |
|
94 | /*! | |
95 | \property QBarSet::borderColor |
|
95 | \property QBarSet::borderColor | |
96 | The line (pen) color of the bar set. |
|
96 | The line (pen) color of the bar set. | |
97 | */ |
|
97 | */ | |
98 | /*! |
|
98 | /*! | |
99 | \qmlproperty color BarSet::borderColor |
|
99 | \qmlproperty color BarSet::borderColor | |
100 | The line (pen) color of the bar set. |
|
100 | The line (pen) color of the bar set. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \qmlproperty real BarSet::borderWidth |
|
104 | \qmlproperty real BarSet::borderWidth | |
105 | The width of the border line. By default the width is 2.0. |
|
105 | The width of the border line. By default the width is 2.0. | |
106 | */ |
|
106 | */ | |
107 |
|
107 | |||
108 | /*! |
|
108 | /*! | |
109 | \property QBarSet::labelColor |
|
109 | \property QBarSet::labelColor | |
110 | The text (label) color of the bar set. |
|
110 | The text (label) color of the bar set. | |
111 | */ |
|
111 | */ | |
112 | /*! |
|
112 | /*! | |
113 | \qmlproperty color BarSet::labelColor |
|
113 | \qmlproperty color BarSet::labelColor | |
114 | The text (label) color of the bar set. |
|
114 | The text (label) color of the bar set. | |
115 | */ |
|
115 | */ | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | \fn void QBarSet::clicked(int index) |
|
118 | \fn void QBarSet::clicked(int index) | |
119 |
|
119 | |||
120 | The signal is emitted if the user clicks with a mouse on top of barset. |
|
120 | The signal is emitted if the user clicks with a mouse on top of barset. | |
121 | Clicked bar inside set is indexed by \a index |
|
121 | Clicked bar inside set is indexed by \a index | |
122 | */ |
|
122 | */ | |
123 |
|
123 | |||
124 | /*! |
|
124 | /*! | |
125 | \fn void QBarSet::hovered(bool status) |
|
125 | \fn void QBarSet::hovered(bool status) | |
126 |
|
126 | |||
127 | The signal is emitted if mouse is hovered on top of barset. |
|
127 | The signal is emitted if mouse is hovered on top of barset. | |
128 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. |
|
128 | Parameter \a status is true, if mouse entered on top of barset, false if mouse left from top of barset. | |
129 | */ |
|
129 | */ | |
130 |
|
130 | |||
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \fn void QBarSet::labelChanged() |
|
133 | \fn void QBarSet::labelChanged() | |
134 | This signal is emitted when the label of the barSet has changed. |
|
134 | This signal is emitted when the label of the barSet has changed. | |
135 | \sa label |
|
135 | \sa label | |
136 | */ |
|
136 | */ | |
137 | /*! |
|
137 | /*! | |
138 | \qmlsignal BarSet::onLabelChanged() |
|
138 | \qmlsignal BarSet::onLabelChanged() | |
139 | This signal is emitted when the label of the barSet has changed. |
|
139 | This signal is emitted when the label of the barSet has changed. | |
140 | */ |
|
140 | */ | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | \fn void QBarSet::penChanged() |
|
143 | \fn void QBarSet::penChanged() | |
144 | This signal is emitted when the pen of the barSet has changed. |
|
144 | This signal is emitted when the pen of the barSet has changed. | |
145 | \sa pen |
|
145 | \sa pen | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | /*! |
|
148 | /*! | |
149 | \fn void QBarSet::brushChanged() |
|
149 | \fn void QBarSet::brushChanged() | |
150 | This signal is emitted when the brush of the barSet has changed. |
|
150 | This signal is emitted when the brush of the barSet has changed. | |
151 | \sa brush |
|
151 | \sa brush | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | \fn void QBarSet::labelBrushChanged() |
|
155 | \fn void QBarSet::labelBrushChanged() | |
156 | This signal is emitted when the brush of the barSet's label has changed. |
|
156 | This signal is emitted when the brush of the barSet's label has changed. | |
157 | \sa labelBrush |
|
157 | \sa labelBrush | |
158 | */ |
|
158 | */ | |
159 |
|
159 | |||
160 | /*! |
|
160 | /*! | |
161 | \fn void QBarSet::labelFontChanged() |
|
161 | \fn void QBarSet::labelFontChanged() | |
162 | This signal is emitted when the font of the barSet's label has changed. |
|
162 | This signal is emitted when the font of the barSet's label has changed. | |
163 | \sa labelBrush |
|
163 | \sa labelBrush | |
164 | */ |
|
164 | */ | |
165 |
|
165 | |||
166 | /*! |
|
166 | /*! | |
167 | \fn void QBarSet::colorChanged(QColor) |
|
167 | \fn void QBarSet::colorChanged(QColor) | |
168 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
168 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
169 | */ |
|
169 | */ | |
170 | /*! |
|
170 | /*! | |
171 | \qmlsignal BarSet::onColorChanged(color color) |
|
171 | \qmlsignal BarSet::onColorChanged(color color) | |
172 | This signal is emitted when the fill (brush) color of the set has changed to \a color. |
|
172 | This signal is emitted when the fill (brush) color of the set has changed to \a color. | |
173 | */ |
|
173 | */ | |
174 |
|
174 | |||
175 | /*! |
|
175 | /*! | |
176 | \fn void QBarSet::borderColorChanged(QColor) |
|
176 | \fn void QBarSet::borderColorChanged(QColor) | |
177 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
177 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
178 | */ |
|
178 | */ | |
179 | /*! |
|
179 | /*! | |
180 | \qmlsignal BarSet::onBorderColorChanged(color color) |
|
180 | \qmlsignal BarSet::onBorderColorChanged(color color) | |
181 | This signal is emitted when the line (pen) color of the set has changed to \a color. |
|
181 | This signal is emitted when the line (pen) color of the set has changed to \a color. | |
182 | */ |
|
182 | */ | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | \fn void QBarSet::labelColorChanged(QColor) |
|
185 | \fn void QBarSet::labelColorChanged(QColor) | |
186 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
186 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
187 | */ |
|
187 | */ | |
188 | /*! |
|
188 | /*! | |
189 | \qmlsignal BarSet::onLabelColorChanged(color color) |
|
189 | \qmlsignal BarSet::onLabelColorChanged(color color) | |
190 | This signal is emitted when the text (label) color of the set has changed to \a color. |
|
190 | This signal is emitted when the text (label) color of the set has changed to \a color. | |
191 | */ |
|
191 | */ | |
192 |
|
192 | |||
193 | /*! |
|
193 | /*! | |
194 | \fn void QBarSet::valuesAdded(int index, int count) |
|
194 | \fn void QBarSet::valuesAdded(int index, int count) | |
195 | This signal is emitted when new values have been added to the set. |
|
195 | This signal is emitted when new values have been added to the set. | |
196 | Parameter \a index indicates the position of the first inserted value. |
|
196 | Parameter \a index indicates the position of the first inserted value. | |
197 | Parameter \a count is the number of iserted values. |
|
197 | Parameter \a count is the number of iserted values. | |
198 | \sa append(), insert() |
|
198 | \sa append(), insert() | |
199 | */ |
|
199 | */ | |
200 | /*! |
|
200 | /*! | |
201 | \qmlsignal BarSet::onValuesAdded(int index, int count) |
|
201 | \qmlsignal BarSet::onValuesAdded(int index, int count) | |
202 | This signal is emitted when new values have been added to the set. |
|
202 | This signal is emitted when new values have been added to the set. | |
203 | Parameter \a index indicates the position of the first inserted value. |
|
203 | Parameter \a index indicates the position of the first inserted value. | |
204 | Parameter \a count is the number of iserted values. |
|
204 | Parameter \a count is the number of iserted values. | |
205 | */ |
|
205 | */ | |
206 |
|
206 | |||
207 | /*! |
|
207 | /*! | |
208 | \fn void QBarSet::valuesRemoved(int index, int count) |
|
208 | \fn void QBarSet::valuesRemoved(int index, int count) | |
209 | This signal is emitted values have been removed from the set. |
|
209 | This signal is emitted values have been removed from the set. | |
210 | Parameter \a index indicates the position of the first removed value. |
|
210 | Parameter \a index indicates the position of the first removed value. | |
211 | Parameter \a count is the number of removed values. |
|
211 | Parameter \a count is the number of removed values. | |
212 | \sa remove() |
|
212 | \sa remove() | |
213 | */ |
|
213 | */ | |
214 | /*! |
|
214 | /*! | |
215 | \qmlsignal BarSet::onValuesRemoved(int index, int count) |
|
215 | \qmlsignal BarSet::onValuesRemoved(int index, int count) | |
216 | This signal is emitted values have been removed from the set. |
|
216 | This signal is emitted values have been removed from the set. | |
217 | Parameter \a index indicates the position of the first removed value. |
|
217 | Parameter \a index indicates the position of the first removed value. | |
218 | Parameter \a count is the number of removed values. |
|
218 | Parameter \a count is the number of removed values. | |
219 | */ |
|
219 | */ | |
220 |
|
220 | |||
221 | /*! |
|
221 | /*! | |
222 | \fn void QBarSet::valueChanged(int index) |
|
222 | \fn void QBarSet::valueChanged(int index) | |
223 | This signal is emitted values the value in the set has been modified. |
|
223 | This signal is emitted values the value in the set has been modified. | |
224 | Parameter \a index indicates the position of the modified value. |
|
224 | Parameter \a index indicates the position of the modified value. | |
225 | \sa at() |
|
225 | \sa at() | |
226 | */ |
|
226 | */ | |
227 | /*! |
|
227 | /*! | |
228 | \qmlsignal BarSet::onValueChanged(int index) |
|
228 | \qmlsignal BarSet::onValueChanged(int index) | |
229 | This signal is emitted values the value in the set has been modified. |
|
229 | This signal is emitted values the value in the set has been modified. | |
230 | Parameter \a index indicates the position of the modified value. |
|
230 | Parameter \a index indicates the position of the modified value. | |
231 | */ |
|
231 | */ | |
232 |
|
232 | |||
233 | /*! |
|
233 | /*! | |
234 | \qmlproperty int BarSet::count |
|
234 | \qmlproperty int BarSet::count | |
235 | The count of values on the barset |
|
235 | The count of values on the barset | |
236 | */ |
|
236 | */ | |
237 |
|
237 | |||
238 | /*! |
|
238 | /*! | |
239 | \qmlproperty QVariantList BarSet::values |
|
239 | \qmlproperty QVariantList BarSet::values | |
240 | The values of the barset. You can set either a list of reals or a list of points as values. If you set a list of |
|
240 | The values of the barset. You can set either a list of reals or a list of points as values. If you set a list of | |
241 | reals as values, the values are automatically completed to points by using the index of a value as it's |
|
241 | reals as values, the values are automatically completed to points by using the index of a value as it's | |
242 | x-coordinate. For example: |
|
242 | x-coordinate. For example: | |
243 | \code |
|
243 | \code | |
244 | myBarSet1.values = [0, 5, 1, 5]; |
|
244 | myBarSet1.values = [0, 5, 1, 5]; | |
245 | myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)]; |
|
245 | myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)]; | |
246 | \endcode |
|
246 | \endcode | |
247 | */ |
|
247 | */ | |
248 |
|
248 | |||
249 | /*! |
|
249 | /*! | |
250 | Constructs QBarSet with a label of \a label and with parent of \a parent |
|
250 | Constructs QBarSet with a label of \a label and with parent of \a parent | |
251 | */ |
|
251 | */ | |
252 | QBarSet::QBarSet(const QString label, QObject *parent) |
|
252 | QBarSet::QBarSet(const QString label, QObject *parent) | |
253 | : QObject(parent), |
|
253 | : QObject(parent), | |
254 | d_ptr(new QBarSetPrivate(label, this)) |
|
254 | d_ptr(new QBarSetPrivate(label, this)) | |
255 | { |
|
255 | { | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | /*! |
|
258 | /*! | |
259 | Destroys the barset |
|
259 | Destroys the barset | |
260 | */ |
|
260 | */ | |
261 | QBarSet::~QBarSet() |
|
261 | QBarSet::~QBarSet() | |
262 | { |
|
262 | { | |
263 | // NOTE: d_ptr destroyed by QObject |
|
263 | // NOTE: d_ptr destroyed by QObject | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | /*! |
|
266 | /*! | |
267 | Sets new \a label for set. |
|
267 | Sets new \a label for set. | |
268 | */ |
|
268 | */ | |
269 | void QBarSet::setLabel(const QString label) |
|
269 | void QBarSet::setLabel(const QString label) | |
270 | { |
|
270 | { | |
271 | d_ptr->m_label = label; |
|
271 | d_ptr->m_label = label; | |
272 | emit labelChanged(); |
|
272 | emit labelChanged(); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | /*! |
|
275 | /*! | |
276 | Returns label of the set. |
|
276 | Returns label of the set. | |
277 | */ |
|
277 | */ | |
278 | QString QBarSet::label() const |
|
278 | QString QBarSet::label() const | |
279 | { |
|
279 | { | |
280 | return d_ptr->m_label; |
|
280 | return d_ptr->m_label; | |
281 | } |
|
281 | } | |
282 |
|
282 | |||
283 | /*! |
|
283 | /*! | |
284 | Appends new value \a value to the end of set. |
|
284 | Appends new value \a value to the end of set. | |
285 | */ |
|
285 | */ | |
286 | void QBarSet::append(const qreal value) |
|
286 | void QBarSet::append(const qreal value) | |
287 | { |
|
287 | { | |
288 | // Convert to QPointF |
|
288 | // Convert to QPointF | |
289 | int index = d_ptr->m_values.count(); |
|
289 | int index = d_ptr->m_values.count(); | |
290 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); |
|
290 | d_ptr->append(QPointF(d_ptr->m_values.count(), value)); | |
291 | emit valuesAdded(index, 1); |
|
291 | emit valuesAdded(index, 1); | |
292 | } |
|
292 | } | |
293 |
|
293 | |||
294 | /*! |
|
294 | /*! | |
295 | Appends a list of reals to set. Works like append with single real value. The \a values in list |
|
295 | Appends a list of reals to set. Works like append with single real value. The \a values in list | |
296 | are appended to end of barset |
|
296 | are appended to end of barset | |
297 | \sa append() |
|
297 | \sa append() | |
298 | */ |
|
298 | */ | |
299 | void QBarSet::append(const QList<qreal> &values) |
|
299 | void QBarSet::append(const QList<qreal> &values) | |
300 | { |
|
300 | { | |
301 | int index = d_ptr->m_values.count(); |
|
301 | int index = d_ptr->m_values.count(); | |
302 | d_ptr->append(values); |
|
302 | d_ptr->append(values); | |
303 | emit valuesAdded(index, values.count()); |
|
303 | emit valuesAdded(index, values.count()); | |
304 | } |
|
304 | } | |
305 |
|
305 | |||
306 | /*! |
|
306 | /*! | |
307 | Convenience operator. Same as append, with real \a value. |
|
307 | Convenience operator. Same as append, with real \a value. | |
308 | \sa append() |
|
308 | \sa append() | |
309 | */ |
|
309 | */ | |
310 | QBarSet &QBarSet::operator << (const qreal &value) |
|
310 | QBarSet &QBarSet::operator << (const qreal &value) | |
311 | { |
|
311 | { | |
312 | append(value); |
|
312 | append(value); | |
313 | return *this; |
|
313 | return *this; | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | /*! |
|
316 | /*! | |
317 | Inserts new \a value on the \a index position. |
|
317 | Inserts new \a value on the \a index position. | |
318 | The value that is currently at this postion is moved to postion index + 1 |
|
318 | The value that is currently at this postion is moved to postion index + 1 | |
319 | \sa remove() |
|
319 | \sa remove() | |
320 | */ |
|
320 | */ | |
321 | void QBarSet::insert(const int index, const qreal value) |
|
321 | void QBarSet::insert(const int index, const qreal value) | |
322 | { |
|
322 | { | |
323 | d_ptr->insert(index, value); |
|
323 | d_ptr->insert(index, value); | |
324 | emit valuesAdded(index, 1); |
|
324 | emit valuesAdded(index, 1); | |
325 | } |
|
325 | } | |
326 |
|
326 | |||
327 | /*! |
|
327 | /*! | |
328 | Removes \a count number of values from the set starting at \a index. |
|
328 | Removes \a count number of values from the set starting at \a index. | |
329 | \sa insert() |
|
329 | \sa insert() | |
330 | */ |
|
330 | */ | |
331 | void QBarSet::remove(const int index, const int count) |
|
331 | void QBarSet::remove(const int index, const int count) | |
332 | { |
|
332 | { | |
333 | int removedCount = d_ptr->remove(index, count); |
|
333 | int removedCount = d_ptr->remove(index, count); | |
334 | if (removedCount > 0) |
|
334 | if (removedCount > 0) | |
335 | emit valuesRemoved(index, removedCount); |
|
335 | emit valuesRemoved(index, removedCount); | |
336 | return; |
|
336 | return; | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | /*! |
|
339 | /*! | |
340 | Sets a new value \a value to set, indexed by \a index |
|
340 | Sets a new value \a value to set, indexed by \a index | |
341 | */ |
|
341 | */ | |
342 | void QBarSet::replace(const int index, const qreal value) |
|
342 | void QBarSet::replace(const int index, const qreal value) | |
343 | { |
|
343 | { | |
344 | if (index >= 0 && index < d_ptr->m_values.count()) { |
|
344 | if (index >= 0 && index < d_ptr->m_values.count()) { | |
345 | d_ptr->replace(index, value); |
|
345 | d_ptr->replace(index, value); | |
346 | emit valueChanged(index); |
|
346 | emit valueChanged(index); | |
347 | } |
|
347 | } | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 |
|
350 | |||
351 | /*! |
|
351 | /*! | |
352 | Returns value of set indexed by \a index. |
|
352 | Returns value of set indexed by \a index. | |
353 | If the index is out of bounds 0.0 is returned. |
|
353 | If the index is out of bounds 0.0 is returned. | |
354 | */ |
|
354 | */ | |
355 | qreal QBarSet::at(const int index) const |
|
355 | qreal QBarSet::at(const int index) const | |
356 | { |
|
356 | { | |
357 | if (index < 0 || index >= d_ptr->m_values.count()) |
|
357 | if (index < 0 || index >= d_ptr->m_values.count()) | |
358 | return 0; |
|
358 | return 0; | |
359 | return d_ptr->m_values.at(index).y(); |
|
359 | return d_ptr->m_values.at(index).y(); | |
360 | } |
|
360 | } | |
361 |
|
361 | |||
362 | /*! |
|
362 | /*! | |
363 | Returns value of set indexed by \a index. |
|
363 | Returns value of set indexed by \a index. | |
364 | If the index is out of bounds 0.0 is returned. |
|
364 | If the index is out of bounds 0.0 is returned. | |
365 | */ |
|
365 | */ | |
366 | qreal QBarSet::operator [](const int index) const |
|
366 | qreal QBarSet::operator [](const int index) const | |
367 | { |
|
367 | { | |
368 | return at(index); |
|
368 | return at(index); | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | /*! |
|
371 | /*! | |
372 | Returns count of values in set. |
|
372 | Returns count of values in set. | |
373 | */ |
|
373 | */ | |
374 | int QBarSet::count() const |
|
374 | int QBarSet::count() const | |
375 | { |
|
375 | { | |
376 | return d_ptr->m_values.count(); |
|
376 | return d_ptr->m_values.count(); | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | /*! |
|
379 | /*! | |
380 | Returns sum of all values in barset. |
|
380 | Returns sum of all values in barset. | |
381 | */ |
|
381 | */ | |
382 | qreal QBarSet::sum() const |
|
382 | qreal QBarSet::sum() const | |
383 | { |
|
383 | { | |
384 | qreal total(0); |
|
384 | qreal total(0); | |
385 | for (int i = 0; i < d_ptr->m_values.count(); i++) |
|
385 | for (int i = 0; i < d_ptr->m_values.count(); i++) | |
386 | total += d_ptr->m_values.at(i).y(); |
|
386 | total += d_ptr->m_values.at(i).y(); | |
387 | return total; |
|
387 | return total; | |
388 | } |
|
388 | } | |
389 |
|
389 | |||
390 | /*! |
|
390 | /*! | |
391 | Sets pen for set. Bars of this set are drawn using \a pen |
|
391 | Sets pen for set. Bars of this set are drawn using \a pen | |
392 | */ |
|
392 | */ | |
393 | void QBarSet::setPen(const QPen &pen) |
|
393 | void QBarSet::setPen(const QPen &pen) | |
394 | { |
|
394 | { | |
395 | if (d_ptr->m_pen != pen) { |
|
395 | if (d_ptr->m_pen != pen) { | |
396 | d_ptr->m_pen = pen; |
|
396 | d_ptr->m_pen = pen; | |
397 | emit d_ptr->updatedBars(); |
|
397 | emit d_ptr->updatedBars(); | |
398 | emit penChanged(); |
|
398 | emit penChanged(); | |
399 | } |
|
399 | } | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | /*! |
|
402 | /*! | |
403 | Returns pen of the set. |
|
403 | Returns pen of the set. | |
404 | */ |
|
404 | */ | |
405 | QPen QBarSet::pen() const |
|
405 | QPen QBarSet::pen() const | |
406 | { |
|
406 | { | |
407 | return d_ptr->m_pen; |
|
407 | return d_ptr->m_pen; | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | /*! |
|
410 | /*! | |
411 | Sets brush for the set. Bars of this set are drawn using \a brush |
|
411 | Sets brush for the set. Bars of this set are drawn using \a brush | |
412 | */ |
|
412 | */ | |
413 | void QBarSet::setBrush(const QBrush &brush) |
|
413 | void QBarSet::setBrush(const QBrush &brush) | |
414 | { |
|
414 | { | |
415 | if (d_ptr->m_brush != brush) { |
|
415 | if (d_ptr->m_brush != brush) { | |
416 | d_ptr->m_brush = brush; |
|
416 | d_ptr->m_brush = brush; | |
417 | emit d_ptr->updatedBars(); |
|
417 | emit d_ptr->updatedBars(); | |
418 | emit brushChanged(); |
|
418 | emit brushChanged(); | |
419 | } |
|
419 | } | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | /*! |
|
422 | /*! | |
423 | Returns brush of the set. |
|
423 | Returns brush of the set. | |
424 | */ |
|
424 | */ | |
425 | QBrush QBarSet::brush() const |
|
425 | QBrush QBarSet::brush() const | |
426 | { |
|
426 | { | |
427 | return d_ptr->m_brush; |
|
427 | return d_ptr->m_brush; | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | /*! |
|
430 | /*! | |
431 | Sets \a brush of the values that are drawn on top of this barset |
|
431 | Sets \a brush of the values that are drawn on top of this barset | |
432 | */ |
|
432 | */ | |
433 | void QBarSet::setLabelBrush(const QBrush &brush) |
|
433 | void QBarSet::setLabelBrush(const QBrush &brush) | |
434 | { |
|
434 | { | |
435 | if (d_ptr->m_labelBrush != brush) { |
|
435 | if (d_ptr->m_labelBrush != brush) { | |
436 | d_ptr->m_labelBrush = brush; |
|
436 | d_ptr->m_labelBrush = brush; | |
437 | emit d_ptr->updatedBars(); |
|
437 | emit d_ptr->updatedBars(); | |
438 | emit labelBrushChanged(); |
|
438 | emit labelBrushChanged(); | |
439 | } |
|
439 | } | |
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | /*! |
|
442 | /*! | |
443 | Returns brush of the values that are drawn on top of this barset |
|
443 | Returns brush of the values that are drawn on top of this barset | |
444 | */ |
|
444 | */ | |
445 | QBrush QBarSet::labelBrush() const |
|
445 | QBrush QBarSet::labelBrush() const | |
446 | { |
|
446 | { | |
447 | return d_ptr->m_labelBrush; |
|
447 | return d_ptr->m_labelBrush; | |
448 | } |
|
448 | } | |
449 |
|
449 | |||
450 | /*! |
|
450 | /*! | |
451 | Sets the \a font for values that are drawn on top of this barset |
|
451 | Sets the \a font for values that are drawn on top of this barset | |
452 | */ |
|
452 | */ | |
453 | void QBarSet::setLabelFont(const QFont &font) |
|
453 | void QBarSet::setLabelFont(const QFont &font) | |
454 | { |
|
454 | { | |
455 | if (d_ptr->m_labelFont != font) { |
|
455 | if (d_ptr->m_labelFont != font) { | |
456 | d_ptr->m_labelFont = font; |
|
456 | d_ptr->m_labelFont = font; | |
457 | emit d_ptr->updatedBars(); |
|
457 | emit d_ptr->updatedBars(); | |
458 | emit labelFontChanged(); |
|
458 | emit labelFontChanged(); | |
459 | } |
|
459 | } | |
460 |
|
460 | |||
461 | } |
|
461 | } | |
462 |
|
462 | |||
463 | /*! |
|
463 | /*! | |
464 | Returns the pen for values that are drawn on top of this barset |
|
464 | Returns the pen for values that are drawn on top of this barset | |
465 | */ |
|
465 | */ | |
466 | QFont QBarSet::labelFont() const |
|
466 | QFont QBarSet::labelFont() const | |
467 | { |
|
467 | { | |
468 | return d_ptr->m_labelFont; |
|
468 | return d_ptr->m_labelFont; | |
469 | } |
|
469 | } | |
470 |
|
470 | |||
471 | /*! |
|
471 | /*! | |
472 | Returns the color of the brush of barset. |
|
472 | Returns the color of the brush of barset. | |
473 | */ |
|
473 | */ | |
474 | QColor QBarSet::color() |
|
474 | QColor QBarSet::color() | |
475 | { |
|
475 | { | |
476 | return brush().color(); |
|
476 | return brush().color(); | |
477 | } |
|
477 | } | |
478 |
|
478 | |||
479 | /*! |
|
479 | /*! | |
480 | Sets the \a color of brush for this barset |
|
480 | Sets the \a color of brush for this barset | |
481 | */ |
|
481 | */ | |
482 | void QBarSet::setColor(QColor color) |
|
482 | void QBarSet::setColor(QColor color) | |
483 | { |
|
483 | { | |
484 | QBrush b = brush(); |
|
484 | QBrush b = brush(); | |
485 | if ((b.color() != color) || (b.style() == Qt::NoBrush)) { |
|
485 | if ((b.color() != color) || (b.style() == Qt::NoBrush)) { | |
486 | b.setColor(color); |
|
486 | b.setColor(color); | |
487 | if (b.style() == Qt::NoBrush) { |
|
487 | if (b.style() == Qt::NoBrush) { | |
488 | // Set tyle to Qt::SolidPattern. (Default is Qt::NoBrush) |
|
488 | // Set tyle to Qt::SolidPattern. (Default is Qt::NoBrush) | |
489 | // This prevents theme to override color defined in QML side: |
|
489 | // This prevents theme to override color defined in QML side: | |
490 | // BarSet { label: "Bob"; color:"red"; values: [1,2,3] } |
|
490 | // BarSet { label: "Bob"; color:"red"; values: [1,2,3] } | |
491 | // The color must be obeyed, since user wanted it. |
|
491 | // The color must be obeyed, since user wanted it. | |
492 | b.setStyle(Qt::SolidPattern); |
|
492 | b.setStyle(Qt::SolidPattern); | |
493 | } |
|
493 | } | |
494 | setBrush(b); |
|
494 | setBrush(b); | |
495 | emit colorChanged(color); |
|
495 | emit colorChanged(color); | |
496 | } |
|
496 | } | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | /*! |
|
499 | /*! | |
500 | Returns the color of pen of this barset |
|
500 | Returns the color of pen of this barset | |
501 | */ |
|
501 | */ | |
502 | QColor QBarSet::borderColor() |
|
502 | QColor QBarSet::borderColor() | |
503 | { |
|
503 | { | |
504 | return pen().color(); |
|
504 | return pen().color(); | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | /*! |
|
507 | /*! | |
508 | Sets the color of pen for this barset |
|
508 | Sets the color of pen for this barset | |
509 | */ |
|
509 | */ | |
510 | void QBarSet::setBorderColor(QColor color) |
|
510 | void QBarSet::setBorderColor(QColor color) | |
511 | { |
|
511 | { | |
512 | QPen p = pen(); |
|
512 | QPen p = pen(); | |
513 | if (p.color() != color) { |
|
513 | if (p.color() != color) { | |
514 | p.setColor(color); |
|
514 | p.setColor(color); | |
515 | setPen(p); |
|
515 | setPen(p); | |
516 | emit borderColorChanged(color); |
|
516 | emit borderColorChanged(color); | |
517 | } |
|
517 | } | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | /*! |
|
520 | /*! | |
521 | Returns the color of labels of this barset |
|
521 | Returns the color of labels of this barset | |
522 | */ |
|
522 | */ | |
523 | QColor QBarSet::labelColor() |
|
523 | QColor QBarSet::labelColor() | |
524 | { |
|
524 | { | |
525 | return labelBrush().color(); |
|
525 | return labelBrush().color(); | |
526 | } |
|
526 | } | |
527 |
|
527 | |||
528 | /*! |
|
528 | /*! | |
529 | Sets the color of labels for this barset |
|
529 | Sets the color of labels for this barset | |
530 | */ |
|
530 | */ | |
531 | void QBarSet::setLabelColor(QColor color) |
|
531 | void QBarSet::setLabelColor(QColor color) | |
532 | { |
|
532 | { | |
533 | QBrush b = labelBrush(); |
|
533 | QBrush b = labelBrush(); | |
534 | if (b == QBrush()) |
|
534 | if (b == QBrush()) | |
535 | b.setStyle(Qt::SolidPattern); |
|
535 | b.setStyle(Qt::SolidPattern); | |
536 |
|
536 | |||
537 | if (b.color() != color) { |
|
537 | if (b.color() != color) { | |
538 | b.setColor(color); |
|
538 | b.setColor(color); | |
539 | setLabelBrush(b); |
|
539 | setLabelBrush(b); | |
540 | emit labelColorChanged(color); |
|
540 | emit labelColorChanged(color); | |
541 | } |
|
541 | } | |
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
544 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
545 |
|
545 | |||
546 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), |
|
546 | QBarSetPrivate::QBarSetPrivate(const QString label, QBarSet *parent) : QObject(parent), | |
547 | q_ptr(parent), |
|
547 | q_ptr(parent), | |
548 | m_label(label) |
|
548 | m_label(label) | |
549 | { |
|
549 | { | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | QBarSetPrivate::~QBarSetPrivate() |
|
552 | QBarSetPrivate::~QBarSetPrivate() | |
553 | { |
|
553 | { | |
554 | } |
|
554 | } | |
555 |
|
555 | |||
556 | void QBarSetPrivate::append(QPointF value) |
|
556 | void QBarSetPrivate::append(QPointF value) | |
557 | { |
|
557 | { | |
558 | m_values.append(value); |
|
558 | if (isValidValue(value)) { | |
559 | emit restructuredBars(); |
|
559 | m_values.append(value); | |
|
560 | emit restructuredBars(); | |||
|
561 | } | |||
560 | } |
|
562 | } | |
561 |
|
563 | |||
562 | void QBarSetPrivate::append(QList<QPointF> values) |
|
564 | void QBarSetPrivate::append(QList<QPointF> values) | |
563 | { |
|
565 | { | |
564 | for (int i = 0; i < values.count(); i++) |
|
566 | for (int i = 0; i < values.count(); i++) { | |
565 |
|
|
567 | if (isValidValue(values.at(i))) | |
|
568 | m_values.append(values.at(i)); | |||
|
569 | } | |||
566 | emit restructuredBars(); |
|
570 | emit restructuredBars(); | |
567 | } |
|
571 | } | |
568 |
|
572 | |||
569 | void QBarSetPrivate::append(QList<qreal> values) |
|
573 | void QBarSetPrivate::append(QList<qreal> values) | |
570 | { |
|
574 | { | |
571 | int index = m_values.count(); |
|
575 | int index = m_values.count(); | |
572 | for (int i = 0; i < values.count(); i++) { |
|
576 | for (int i = 0; i < values.count(); i++) { | |
573 | m_values.append(QPointF(index, values.at(i))); |
|
577 | if (isValidValue(values.at(i))) { | |
574 | index++; |
|
578 | m_values.append(QPointF(index, values.at(i))); | |
|
579 | index++; | |||
|
580 | } | |||
575 | } |
|
581 | } | |
576 | emit restructuredBars(); |
|
582 | emit restructuredBars(); | |
577 | } |
|
583 | } | |
578 |
|
584 | |||
579 | void QBarSetPrivate::insert(const int index, const qreal value) |
|
585 | void QBarSetPrivate::insert(const int index, const qreal value) | |
580 | { |
|
586 | { | |
581 | m_values.insert(index, QPointF(index, value)); |
|
587 | m_values.insert(index, QPointF(index, value)); | |
582 | emit restructuredBars(); |
|
588 | emit restructuredBars(); | |
583 | } |
|
589 | } | |
584 |
|
590 | |||
585 | void QBarSetPrivate::insert(const int index, const QPointF value) |
|
591 | void QBarSetPrivate::insert(const int index, const QPointF value) | |
586 | { |
|
592 | { | |
587 | m_values.insert(index, value); |
|
593 | m_values.insert(index, value); | |
588 | emit restructuredBars(); |
|
594 | emit restructuredBars(); | |
589 | } |
|
595 | } | |
590 |
|
596 | |||
591 | int QBarSetPrivate::remove(const int index, const int count) |
|
597 | int QBarSetPrivate::remove(const int index, const int count) | |
592 | { |
|
598 | { | |
593 | int removeCount = count; |
|
599 | int removeCount = count; | |
594 |
|
600 | |||
595 | if ((index < 0) || (m_values.count() == 0)) |
|
601 | if ((index < 0) || (m_values.count() == 0)) | |
596 | return 0; // Invalid index or not values in list, remove nothing. |
|
602 | return 0; // Invalid index or not values in list, remove nothing. | |
597 | else if ((index + count) > m_values.count()) |
|
603 | else if ((index + count) > m_values.count()) | |
598 | removeCount = m_values.count() - index; // Trying to remove more items than list has. Limit amount to be removed. |
|
604 | removeCount = m_values.count() - index; // Trying to remove more items than list has. Limit amount to be removed. | |
599 |
|
605 | |||
600 | int c = 0; |
|
606 | int c = 0; | |
601 | while (c < removeCount) { |
|
607 | while (c < removeCount) { | |
602 | m_values.removeAt(index); |
|
608 | m_values.removeAt(index); | |
603 | c++; |
|
609 | c++; | |
604 | } |
|
610 | } | |
605 | emit restructuredBars(); |
|
611 | emit restructuredBars(); | |
606 | return removeCount; |
|
612 | return removeCount; | |
607 | } |
|
613 | } | |
608 |
|
614 | |||
609 | void QBarSetPrivate::replace(const int index, const qreal value) |
|
615 | void QBarSetPrivate::replace(const int index, const qreal value) | |
610 | { |
|
616 | { | |
611 | m_values.replace(index, QPointF(index, value)); |
|
617 | m_values.replace(index, QPointF(index, value)); | |
612 | emit updatedLayout(); |
|
618 | emit updatedLayout(); | |
613 | } |
|
619 | } | |
614 |
|
620 | |||
615 | void QBarSetPrivate::replace(const int index, const QPointF value) |
|
621 | void QBarSetPrivate::replace(const int index, const QPointF value) | |
616 | { |
|
622 | { | |
617 | m_values.replace(index, value); |
|
623 | m_values.replace(index, value); | |
618 | emit updatedLayout(); |
|
624 | emit updatedLayout(); | |
619 | } |
|
625 | } | |
620 |
|
626 | |||
621 | qreal QBarSetPrivate::pos(const int index) |
|
627 | qreal QBarSetPrivate::pos(const int index) | |
622 | { |
|
628 | { | |
623 | if (index < 0 || index >= m_values.count()) |
|
629 | if (index < 0 || index >= m_values.count()) | |
624 | return 0; |
|
630 | return 0; | |
625 | return m_values.at(index).x(); |
|
631 | return m_values.at(index).x(); | |
626 | } |
|
632 | } | |
627 |
|
633 | |||
628 | qreal QBarSetPrivate::value(const int index) |
|
634 | qreal QBarSetPrivate::value(const int index) | |
629 | { |
|
635 | { | |
630 | if (index < 0 || index >= m_values.count()) |
|
636 | if (index < 0 || index >= m_values.count()) | |
631 | return 0; |
|
637 | return 0; | |
632 | return m_values.at(index).y(); |
|
638 | return m_values.at(index).y(); | |
633 | } |
|
639 | } | |
634 |
|
640 | |||
635 | #include "moc_qbarset.cpp" |
|
641 | #include "moc_qbarset.cpp" | |
636 | #include "moc_qbarset_p.cpp" |
|
642 | #include "moc_qbarset_p.cpp" | |
637 |
|
643 | |||
638 | QTCOMMERCIALCHART_END_NAMESPACE |
|
644 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,118 +1,119 | |||||
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 QBARSET_H |
|
21 | #ifndef QBARSET_H | |
22 | #define QBARSET_H |
|
22 | #define QBARSET_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
|
28 | #include "charthelpers_p.h" | |||
28 |
|
29 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QBarSetPrivate; |
|
31 | class QBarSetPrivate; | |
31 |
|
32 | |||
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject | |
33 | { |
|
34 | { | |
34 | Q_OBJECT |
|
35 | Q_OBJECT | |
35 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
36 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) | |
36 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
37 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) | |
37 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
38 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) | |
38 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
39 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) | |
39 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) |
|
40 | Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged) | |
40 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
41 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
41 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) |
|
42 | Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) | |
42 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) |
|
43 | Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor NOTIFY labelColorChanged) | |
43 |
|
44 | |||
44 | public: |
|
45 | public: | |
45 | explicit QBarSet(const QString label, QObject *parent = 0); |
|
46 | explicit QBarSet(const QString label, QObject *parent = 0); | |
46 | virtual ~QBarSet(); |
|
47 | virtual ~QBarSet(); | |
47 |
|
48 | |||
48 | void setLabel(const QString label); |
|
49 | void setLabel(const QString label); | |
49 | QString label() const; |
|
50 | QString label() const; | |
50 |
|
51 | |||
51 | void append(const qreal value); |
|
52 | void append(const qreal value); | |
52 | void append(const QList<qreal> &values); |
|
53 | void append(const QList<qreal> &values); | |
53 |
|
54 | |||
54 | QBarSet &operator << (const qreal &value); |
|
55 | QBarSet &operator << (const qreal &value); | |
55 |
|
56 | |||
56 | void insert(const int index, const qreal value); |
|
57 | void insert(const int index, const qreal value); | |
57 | void remove(const int index, const int count = 1); |
|
58 | void remove(const int index, const int count = 1); | |
58 | void replace(const int index, const qreal value); |
|
59 | void replace(const int index, const qreal value); | |
59 | qreal at(const int index) const; |
|
60 | qreal at(const int index) const; | |
60 | qreal operator [](const int index) const; |
|
61 | qreal operator [](const int index) const; | |
61 | int count() const; |
|
62 | int count() const; | |
62 | qreal sum() const; |
|
63 | qreal sum() const; | |
63 |
|
64 | |||
64 | void setPen(const QPen &pen); |
|
65 | void setPen(const QPen &pen); | |
65 | QPen pen() const; |
|
66 | QPen pen() const; | |
66 |
|
67 | |||
67 | void setBrush(const QBrush &brush); |
|
68 | void setBrush(const QBrush &brush); | |
68 | QBrush brush() const; |
|
69 | QBrush brush() const; | |
69 |
|
70 | |||
70 | void setLabelBrush(const QBrush &brush); |
|
71 | void setLabelBrush(const QBrush &brush); | |
71 | QBrush labelBrush() const; |
|
72 | QBrush labelBrush() const; | |
72 |
|
73 | |||
73 | void setLabelFont(const QFont &font); |
|
74 | void setLabelFont(const QFont &font); | |
74 | QFont labelFont() const; |
|
75 | QFont labelFont() const; | |
75 |
|
76 | |||
76 | QColor color(); |
|
77 | QColor color(); | |
77 | void setColor(QColor color); |
|
78 | void setColor(QColor color); | |
78 |
|
79 | |||
79 | QColor borderColor(); |
|
80 | QColor borderColor(); | |
80 | void setBorderColor(QColor color); |
|
81 | void setBorderColor(QColor color); | |
81 |
|
82 | |||
82 | QColor labelColor(); |
|
83 | QColor labelColor(); | |
83 | void setLabelColor(QColor color); |
|
84 | void setLabelColor(QColor color); | |
84 |
|
85 | |||
85 | Q_SIGNALS: |
|
86 | Q_SIGNALS: | |
86 | void clicked(int index); |
|
87 | void clicked(int index); | |
87 | void hovered(bool status); |
|
88 | void hovered(bool status); | |
88 | void penChanged(); |
|
89 | void penChanged(); | |
89 | void brushChanged(); |
|
90 | void brushChanged(); | |
90 | void labelChanged(); |
|
91 | void labelChanged(); | |
91 | void labelBrushChanged(); |
|
92 | void labelBrushChanged(); | |
92 | void labelFontChanged(); |
|
93 | void labelFontChanged(); | |
93 | void colorChanged(QColor color); |
|
94 | void colorChanged(QColor color); | |
94 | void borderColorChanged(QColor color); |
|
95 | void borderColorChanged(QColor color); | |
95 | void labelColorChanged(QColor color); |
|
96 | void labelColorChanged(QColor color); | |
96 |
|
97 | |||
97 | void valuesAdded(int index, int count); |
|
98 | void valuesAdded(int index, int count); | |
98 | void valuesRemoved(int index, int count); |
|
99 | void valuesRemoved(int index, int count); | |
99 | void valueChanged(int index); |
|
100 | void valueChanged(int index); | |
100 |
|
101 | |||
101 | private: |
|
102 | private: | |
102 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
103 | QScopedPointer<QBarSetPrivate> d_ptr; | |
103 | Q_DISABLE_COPY(QBarSet) |
|
104 | Q_DISABLE_COPY(QBarSet) | |
104 | friend class QAbstractBarSeries; |
|
105 | friend class QAbstractBarSeries; | |
105 | friend class BarLegendMarker; |
|
106 | friend class BarLegendMarker; | |
106 | friend class AbstractBarChartItem; |
|
107 | friend class AbstractBarChartItem; | |
107 | friend class QAbstractBarSeriesPrivate; |
|
108 | friend class QAbstractBarSeriesPrivate; | |
108 | friend class StackedBarChartItem; |
|
109 | friend class StackedBarChartItem; | |
109 | friend class PercentBarChartItem; |
|
110 | friend class PercentBarChartItem; | |
110 | friend class BarChartItem; |
|
111 | friend class BarChartItem; | |
111 | friend class HorizontalBarChartItem; |
|
112 | friend class HorizontalBarChartItem; | |
112 | friend class HorizontalStackedBarChartItem; |
|
113 | friend class HorizontalStackedBarChartItem; | |
113 | friend class HorizontalPercentBarChartItem; |
|
114 | friend class HorizontalPercentBarChartItem; | |
114 | }; |
|
115 | }; | |
115 |
|
116 | |||
116 | QTCOMMERCIALCHART_END_NAMESPACE |
|
117 | QTCOMMERCIALCHART_END_NAMESPACE | |
117 |
|
118 | |||
118 | #endif // QBARSET_H |
|
119 | #endif // QBARSET_H |
@@ -1,925 +1,936 | |||||
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 "qpieseries.h" |
|
21 | #include "qpieseries.h" | |
22 | #include "qpieseries_p.h" |
|
22 | #include "qpieseries_p.h" | |
23 | #include "qpieslice.h" |
|
23 | #include "qpieslice.h" | |
24 | #include "qpieslice_p.h" |
|
24 | #include "qpieslice_p.h" | |
25 | #include "pieslicedata_p.h" |
|
25 | #include "pieslicedata_p.h" | |
26 | #include "chartdataset_p.h" |
|
26 | #include "chartdataset_p.h" | |
27 | #include "charttheme_p.h" |
|
27 | #include "charttheme_p.h" | |
28 | #include "qabstractaxis.h" |
|
28 | #include "qabstractaxis.h" | |
29 | #include "pieanimation_p.h" |
|
29 | #include "pieanimation_p.h" | |
|
30 | #include "charthelpers_p.h" | |||
30 |
|
31 | |||
31 | #include "qpielegendmarker.h" |
|
32 | #include "qpielegendmarker.h" | |
32 |
|
33 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
35 | |||
35 | /*! |
|
36 | /*! | |
36 | \class QPieSeries |
|
37 | \class QPieSeries | |
37 | \brief Pie series API for QtCommercial Charts |
|
38 | \brief Pie series API for QtCommercial Charts | |
38 |
|
39 | |||
39 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. |
|
40 | The pie series defines a pie chart which consists of pie slices which are defined as QPieSlice objects. | |
40 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
41 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. | |
41 | The actual slice size is determined by that relative value. |
|
42 | The actual slice size is determined by that relative value. | |
42 |
|
43 | |||
43 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 |
|
44 | Pie size and position on the chart is controlled by using relative values which range from 0.0 to 1.0 | |
44 | These relate to the actual chart rectangle. |
|
45 | These relate to the actual chart rectangle. | |
45 |
|
46 | |||
46 | By default the pie is defined as a full pie but it can also be a partial pie. |
|
47 | By default the pie is defined as a full pie but it can also be a partial pie. | |
47 | This can be done by setting a starting angle and angle span to the series. |
|
48 | This can be done by setting a starting angle and angle span to the series. | |
48 | Full pie is 360 degrees where 0 is at 12 a'clock. |
|
49 | Full pie is 360 degrees where 0 is at 12 a'clock. | |
49 |
|
50 | |||
50 | See the \l {PieChart Example} {pie chart example} or \l {DonutChart Example} {donut chart example} to learn how to use QPieSeries. |
|
51 | See the \l {PieChart Example} {pie chart example} or \l {DonutChart Example} {donut chart example} to learn how to use QPieSeries. | |
51 | \table 100% |
|
52 | \table 100% | |
52 | \row |
|
53 | \row | |
53 | \o \image examples_piechart.png |
|
54 | \o \image examples_piechart.png | |
54 | \o \image examples_donutchart.png |
|
55 | \o \image examples_donutchart.png | |
55 | \endtable |
|
56 | \endtable | |
56 | */ |
|
57 | */ | |
57 | /*! |
|
58 | /*! | |
58 | \qmlclass PieSeries QPieSeries |
|
59 | \qmlclass PieSeries QPieSeries | |
59 | \inherits AbstractSeries |
|
60 | \inherits AbstractSeries | |
60 |
|
61 | |||
61 | The following QML shows how to create a simple pie chart. |
|
62 | The following QML shows how to create a simple pie chart. | |
62 |
|
63 | |||
63 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 |
|
64 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 | |
64 |
|
65 | |||
65 | \beginfloatleft |
|
66 | \beginfloatleft | |
66 | \image demos_qmlchart1.png |
|
67 | \image demos_qmlchart1.png | |
67 | \endfloat |
|
68 | \endfloat | |
68 | \clearfloat |
|
69 | \clearfloat | |
69 | */ |
|
70 | */ | |
70 |
|
71 | |||
71 | /*! |
|
72 | /*! | |
72 | \property QPieSeries::horizontalPosition |
|
73 | \property QPieSeries::horizontalPosition | |
73 | \brief Defines the horizontal position of the pie. |
|
74 | \brief Defines the horizontal position of the pie. | |
74 |
|
75 | |||
75 | The value is a relative value to the chart rectangle where: |
|
76 | The value is a relative value to the chart rectangle where: | |
76 |
|
77 | |||
77 | \list |
|
78 | \list | |
78 | \o 0.0 is the absolute left. |
|
79 | \o 0.0 is the absolute left. | |
79 | \o 1.0 is the absolute right. |
|
80 | \o 1.0 is the absolute right. | |
80 | \endlist |
|
81 | \endlist | |
81 | Default value is 0.5 (center). |
|
82 | Default value is 0.5 (center). | |
82 | \sa verticalPosition |
|
83 | \sa verticalPosition | |
83 | */ |
|
84 | */ | |
84 |
|
85 | |||
85 | /*! |
|
86 | /*! | |
86 | \qmlproperty real PieSeries::horizontalPosition |
|
87 | \qmlproperty real PieSeries::horizontalPosition | |
87 |
|
88 | |||
88 | Defines the horizontal position of the pie. |
|
89 | Defines the horizontal position of the pie. | |
89 |
|
90 | |||
90 | The value is a relative value to the chart rectangle where: |
|
91 | The value is a relative value to the chart rectangle where: | |
91 |
|
92 | |||
92 | \list |
|
93 | \list | |
93 | \o 0.0 is the absolute left. |
|
94 | \o 0.0 is the absolute left. | |
94 | \o 1.0 is the absolute right. |
|
95 | \o 1.0 is the absolute right. | |
95 | \endlist |
|
96 | \endlist | |
96 | Default value is 0.5 (center). |
|
97 | Default value is 0.5 (center). | |
97 | \sa verticalPosition |
|
98 | \sa verticalPosition | |
98 | */ |
|
99 | */ | |
99 |
|
100 | |||
100 | /*! |
|
101 | /*! | |
101 | \property QPieSeries::verticalPosition |
|
102 | \property QPieSeries::verticalPosition | |
102 | \brief Defines the vertical position of the pie. |
|
103 | \brief Defines the vertical position of the pie. | |
103 |
|
104 | |||
104 | The value is a relative value to the chart rectangle where: |
|
105 | The value is a relative value to the chart rectangle where: | |
105 |
|
106 | |||
106 | \list |
|
107 | \list | |
107 | \o 0.0 is the absolute top. |
|
108 | \o 0.0 is the absolute top. | |
108 | \o 1.0 is the absolute bottom. |
|
109 | \o 1.0 is the absolute bottom. | |
109 | \endlist |
|
110 | \endlist | |
110 | Default value is 0.5 (center). |
|
111 | Default value is 0.5 (center). | |
111 | \sa horizontalPosition |
|
112 | \sa horizontalPosition | |
112 | */ |
|
113 | */ | |
113 |
|
114 | |||
114 | /*! |
|
115 | /*! | |
115 | \qmlproperty real PieSeries::verticalPosition |
|
116 | \qmlproperty real PieSeries::verticalPosition | |
116 |
|
117 | |||
117 | Defines the vertical position of the pie. |
|
118 | Defines the vertical position of the pie. | |
118 |
|
119 | |||
119 | The value is a relative value to the chart rectangle where: |
|
120 | The value is a relative value to the chart rectangle where: | |
120 |
|
121 | |||
121 | \list |
|
122 | \list | |
122 | \o 0.0 is the absolute top. |
|
123 | \o 0.0 is the absolute top. | |
123 | \o 1.0 is the absolute bottom. |
|
124 | \o 1.0 is the absolute bottom. | |
124 | \endlist |
|
125 | \endlist | |
125 | Default value is 0.5 (center). |
|
126 | Default value is 0.5 (center). | |
126 | \sa horizontalPosition |
|
127 | \sa horizontalPosition | |
127 | */ |
|
128 | */ | |
128 |
|
129 | |||
129 | /*! |
|
130 | /*! | |
130 | \property QPieSeries::size |
|
131 | \property QPieSeries::size | |
131 | \brief Defines the pie size. |
|
132 | \brief Defines the pie size. | |
132 |
|
133 | |||
133 | The value is a relative value to the chart rectangle where: |
|
134 | The value is a relative value to the chart rectangle where: | |
134 |
|
135 | |||
135 | \list |
|
136 | \list | |
136 | \o 0.0 is the minimum size (pie not drawn). |
|
137 | \o 0.0 is the minimum size (pie not drawn). | |
137 | \o 1.0 is the maximum size that can fit the chart. |
|
138 | \o 1.0 is the maximum size that can fit the chart. | |
138 | \endlist |
|
139 | \endlist | |
139 |
|
140 | |||
140 | When setting this property the holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the outer size. |
|
141 | When setting this property the holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the outer size. | |
141 |
|
142 | |||
142 | Default value is 0.7. |
|
143 | Default value is 0.7. | |
143 | */ |
|
144 | */ | |
144 |
|
145 | |||
145 | /*! |
|
146 | /*! | |
146 | \qmlproperty real PieSeries::size |
|
147 | \qmlproperty real PieSeries::size | |
147 |
|
148 | |||
148 | Defines the pie size. |
|
149 | Defines the pie size. | |
149 |
|
150 | |||
150 | The value is a relative value to the chart rectangle where: |
|
151 | The value is a relative value to the chart rectangle where: | |
151 |
|
152 | |||
152 | \list |
|
153 | \list | |
153 | \o 0.0 is the minimum size (pie not drawn). |
|
154 | \o 0.0 is the minimum size (pie not drawn). | |
154 | \o 1.0 is the maximum size that can fit the chart. |
|
155 | \o 1.0 is the maximum size that can fit the chart. | |
155 | \endlist |
|
156 | \endlist | |
156 |
|
157 | |||
157 | Default value is 0.7. |
|
158 | Default value is 0.7. | |
158 | */ |
|
159 | */ | |
159 |
|
160 | |||
160 | /*! |
|
161 | /*! | |
161 | \property QPieSeries::holeSize |
|
162 | \property QPieSeries::holeSize | |
162 | \brief Defines the donut hole size. |
|
163 | \brief Defines the donut hole size. | |
163 |
|
164 | |||
164 | The value is a relative value to the chart rectangle where: |
|
165 | The value is a relative value to the chart rectangle where: | |
165 |
|
166 | |||
166 | \list |
|
167 | \list | |
167 | \o 0.0 is the minimum size (full pie drawn, without any hole inside). |
|
168 | \o 0.0 is the minimum size (full pie drawn, without any hole inside). | |
168 | \o 1.0 is the maximum size that can fit the chart. (donut has no width) |
|
169 | \o 1.0 is the maximum size that can fit the chart. (donut has no width) | |
169 | \endlist |
|
170 | \endlist | |
170 |
|
171 | |||
171 | The value is never greater then size property. |
|
172 | The value is never greater then size property. | |
172 | Default value is 0.0. |
|
173 | Default value is 0.0. | |
173 | */ |
|
174 | */ | |
174 |
|
175 | |||
175 | /*! |
|
176 | /*! | |
176 | \qmlproperty real PieSeries::holeSize |
|
177 | \qmlproperty real PieSeries::holeSize | |
177 |
|
178 | |||
178 | Defines the donut hole size. |
|
179 | Defines the donut hole size. | |
179 |
|
180 | |||
180 | The value is a relative value to the chart rectangle where: |
|
181 | The value is a relative value to the chart rectangle where: | |
181 |
|
182 | |||
182 | \list |
|
183 | \list | |
183 | \o 0.0 is the minimum size (full pie drawn, without any hole inside). |
|
184 | \o 0.0 is the minimum size (full pie drawn, without any hole inside). | |
184 | \o 1.0 is the maximum size that can fit the chart. (donut has no width) |
|
185 | \o 1.0 is the maximum size that can fit the chart. (donut has no width) | |
185 | \endlist |
|
186 | \endlist | |
186 |
|
187 | |||
187 | When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size. |
|
188 | When setting this property the size property is adjusted if necessary, to ensure that the inner size is not greater than the outer size. | |
188 |
|
189 | |||
189 | Default value is 0.0. |
|
190 | Default value is 0.0. | |
190 | */ |
|
191 | */ | |
191 |
|
192 | |||
192 | /*! |
|
193 | /*! | |
193 | \property QPieSeries::startAngle |
|
194 | \property QPieSeries::startAngle | |
194 | \brief Defines the starting angle of the pie. |
|
195 | \brief Defines the starting angle of the pie. | |
195 |
|
196 | |||
196 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
197 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
197 |
|
198 | |||
198 | Default is value is 0. |
|
199 | Default is value is 0. | |
199 | */ |
|
200 | */ | |
200 |
|
201 | |||
201 | /*! |
|
202 | /*! | |
202 | \qmlproperty real PieSeries::startAngle |
|
203 | \qmlproperty real PieSeries::startAngle | |
203 |
|
204 | |||
204 | Defines the starting angle of the pie. |
|
205 | Defines the starting angle of the pie. | |
205 |
|
206 | |||
206 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
207 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
207 |
|
208 | |||
208 | Default is value is 0. |
|
209 | Default is value is 0. | |
209 | */ |
|
210 | */ | |
210 |
|
211 | |||
211 | /*! |
|
212 | /*! | |
212 | \property QPieSeries::endAngle |
|
213 | \property QPieSeries::endAngle | |
213 | \brief Defines the ending angle of the pie. |
|
214 | \brief Defines the ending angle of the pie. | |
214 |
|
215 | |||
215 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
216 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
216 |
|
217 | |||
217 | Default is value is 360. |
|
218 | Default is value is 360. | |
218 | */ |
|
219 | */ | |
219 |
|
220 | |||
220 | /*! |
|
221 | /*! | |
221 | \qmlproperty real PieSeries::endAngle |
|
222 | \qmlproperty real PieSeries::endAngle | |
222 |
|
223 | |||
223 | Defines the ending angle of the pie. |
|
224 | Defines the ending angle of the pie. | |
224 |
|
225 | |||
225 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
226 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
226 |
|
227 | |||
227 | Default is value is 360. |
|
228 | Default is value is 360. | |
228 | */ |
|
229 | */ | |
229 |
|
230 | |||
230 | /*! |
|
231 | /*! | |
231 | \property QPieSeries::count |
|
232 | \property QPieSeries::count | |
232 |
|
233 | |||
233 | Number of slices in the series. |
|
234 | Number of slices in the series. | |
234 | */ |
|
235 | */ | |
235 |
|
236 | |||
236 | /*! |
|
237 | /*! | |
237 | \qmlproperty int PieSeries::count |
|
238 | \qmlproperty int PieSeries::count | |
238 |
|
239 | |||
239 | Number of slices in the series. |
|
240 | Number of slices in the series. | |
240 | */ |
|
241 | */ | |
241 |
|
242 | |||
242 | /*! |
|
243 | /*! | |
243 | \fn void QPieSeries::countChanged() |
|
244 | \fn void QPieSeries::countChanged() | |
244 | Emitted when the slice count has changed. |
|
245 | Emitted when the slice count has changed. | |
245 | \sa count |
|
246 | \sa count | |
246 | */ |
|
247 | */ | |
247 | /*! |
|
248 | /*! | |
248 | \qmlsignal PieSeries::onCountChanged() |
|
249 | \qmlsignal PieSeries::onCountChanged() | |
249 | Emitted when the slice count has changed. |
|
250 | Emitted when the slice count has changed. | |
250 | */ |
|
251 | */ | |
251 |
|
252 | |||
252 | /*! |
|
253 | /*! | |
253 | \property QPieSeries::sum |
|
254 | \property QPieSeries::sum | |
254 |
|
255 | |||
255 | Sum of all slices. |
|
256 | Sum of all slices. | |
256 |
|
257 | |||
257 | The series keeps track of the sum of all slices it holds. |
|
258 | The series keeps track of the sum of all slices it holds. | |
258 | */ |
|
259 | */ | |
259 |
|
260 | |||
260 | /*! |
|
261 | /*! | |
261 | \qmlproperty real PieSeries::sum |
|
262 | \qmlproperty real PieSeries::sum | |
262 |
|
263 | |||
263 | Sum of all slices. |
|
264 | Sum of all slices. | |
264 |
|
265 | |||
265 | The series keeps track of the sum of all slices it holds. |
|
266 | The series keeps track of the sum of all slices it holds. | |
266 | */ |
|
267 | */ | |
267 |
|
268 | |||
268 | /*! |
|
269 | /*! | |
269 | \fn void QPieSeries::sumChanged() |
|
270 | \fn void QPieSeries::sumChanged() | |
270 | Emitted when the sum of all slices has changed. |
|
271 | Emitted when the sum of all slices has changed. | |
271 | \sa sum |
|
272 | \sa sum | |
272 | */ |
|
273 | */ | |
273 | /*! |
|
274 | /*! | |
274 | \qmlsignal PieSeries::onSumChanged() |
|
275 | \qmlsignal PieSeries::onSumChanged() | |
275 | Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you |
|
276 | Emitted when the sum of all slices has changed. This may happen for example if you add or remove slices, or if you | |
276 | change value of a slice. |
|
277 | change value of a slice. | |
277 | */ |
|
278 | */ | |
278 |
|
279 | |||
279 | /*! |
|
280 | /*! | |
280 | \fn void QPieSeries::added(QList<QPieSlice*> slices) |
|
281 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |
281 |
|
282 | |||
282 | This signal is emitted when \a slices have been added to the series. |
|
283 | This signal is emitted when \a slices have been added to the series. | |
283 |
|
284 | |||
284 | \sa append(), insert() |
|
285 | \sa append(), insert() | |
285 | */ |
|
286 | */ | |
286 | /*! |
|
287 | /*! | |
287 | \qmlsignal PieSeries::onAdded(PieSlice slice) |
|
288 | \qmlsignal PieSeries::onAdded(PieSlice slice) | |
288 | Emitted when \a slice has been added to the series. |
|
289 | Emitted when \a slice has been added to the series. | |
289 | */ |
|
290 | */ | |
290 |
|
291 | |||
291 | /*! |
|
292 | /*! | |
292 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) |
|
293 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |
293 | This signal is emitted when \a slices have been removed from the series. |
|
294 | This signal is emitted when \a slices have been removed from the series. | |
294 | \sa remove() |
|
295 | \sa remove() | |
295 | */ |
|
296 | */ | |
296 | /*! |
|
297 | /*! | |
297 | \qmlsignal PieSeries::onRemoved(PieSlice slice) |
|
298 | \qmlsignal PieSeries::onRemoved(PieSlice slice) | |
298 | Emitted when \a slice has been removed from the series. |
|
299 | Emitted when \a slice has been removed from the series. | |
299 | */ |
|
300 | */ | |
300 |
|
301 | |||
301 | /*! |
|
302 | /*! | |
302 | \fn void QPieSeries::clicked(QPieSlice* slice) |
|
303 | \fn void QPieSeries::clicked(QPieSlice* slice) | |
303 | This signal is emitted when a \a slice has been clicked. |
|
304 | This signal is emitted when a \a slice has been clicked. | |
304 | \sa QPieSlice::clicked() |
|
305 | \sa QPieSlice::clicked() | |
305 | */ |
|
306 | */ | |
306 | /*! |
|
307 | /*! | |
307 | \qmlsignal PieSeries::onClicked(PieSlice slice) |
|
308 | \qmlsignal PieSeries::onClicked(PieSlice slice) | |
308 | This signal is emitted when a \a slice has been clicked. |
|
309 | This signal is emitted when a \a slice has been clicked. | |
309 | */ |
|
310 | */ | |
310 |
|
311 | |||
311 | /*! |
|
312 | /*! | |
312 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) |
|
313 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) | |
313 | This signal is emitted when user has hovered over or away from the \a slice. |
|
314 | This signal is emitted when user has hovered over or away from the \a slice. | |
314 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. |
|
315 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
315 | \sa QPieSlice::hovered() |
|
316 | \sa QPieSlice::hovered() | |
316 | */ |
|
317 | */ | |
317 | /*! |
|
318 | /*! | |
318 | \qmlsignal PieSeries::onHovered(PieSlice slice, bool state) |
|
319 | \qmlsignal PieSeries::onHovered(PieSlice slice, bool state) | |
319 | This signal is emitted when user has hovered over or away from the \a slice. \a state is true when user has hovered |
|
320 | This signal is emitted when user has hovered over or away from the \a slice. \a state is true when user has hovered | |
320 | over the slice and false when hover has moved away from the slice. |
|
321 | over the slice and false when hover has moved away from the slice. | |
321 | */ |
|
322 | */ | |
322 |
|
323 | |||
323 | /*! |
|
324 | /*! | |
324 | \qmlmethod PieSlice PieSeries::at(int index) |
|
325 | \qmlmethod PieSlice PieSeries::at(int index) | |
325 | Returns slice at \a index. Returns null if the index is not valid. |
|
326 | Returns slice at \a index. Returns null if the index is not valid. | |
326 | */ |
|
327 | */ | |
327 |
|
328 | |||
328 | /*! |
|
329 | /*! | |
329 | \qmlmethod PieSlice PieSeries::find(string label) |
|
330 | \qmlmethod PieSlice PieSeries::find(string label) | |
330 | Returns the first slice with \a label. Returns null if the index is not valid. |
|
331 | Returns the first slice with \a label. Returns null if the index is not valid. | |
331 | */ |
|
332 | */ | |
332 |
|
333 | |||
333 | /*! |
|
334 | /*! | |
334 | \qmlmethod PieSlice PieSeries::append(string label, real value) |
|
335 | \qmlmethod PieSlice PieSeries::append(string label, real value) | |
335 | Adds a new slice with \a label and \a value to the pie. |
|
336 | Adds a new slice with \a label and \a value to the pie. | |
336 | */ |
|
337 | */ | |
337 |
|
338 | |||
338 | /*! |
|
339 | /*! | |
339 | \qmlmethod bool PieSeries::remove(PieSlice slice) |
|
340 | \qmlmethod bool PieSeries::remove(PieSlice slice) | |
340 | Removes the \a slice from the pie. Returns true if the removal was successful, false otherwise. |
|
341 | Removes the \a slice from the pie. Returns true if the removal was successful, false otherwise. | |
341 | */ |
|
342 | */ | |
342 |
|
343 | |||
343 | /*! |
|
344 | /*! | |
344 | \qmlmethod PieSeries::clear() |
|
345 | \qmlmethod PieSeries::clear() | |
345 | Removes all slices from the pie. |
|
346 | Removes all slices from the pie. | |
346 | */ |
|
347 | */ | |
347 |
|
348 | |||
348 | /*! |
|
349 | /*! | |
349 | Constructs a series object which is a child of \a parent. |
|
350 | Constructs a series object which is a child of \a parent. | |
350 | */ |
|
351 | */ | |
351 | QPieSeries::QPieSeries(QObject *parent) |
|
352 | QPieSeries::QPieSeries(QObject *parent) | |
352 | : QAbstractSeries(*new QPieSeriesPrivate(this), parent) |
|
353 | : QAbstractSeries(*new QPieSeriesPrivate(this), parent) | |
353 | { |
|
354 | { | |
354 | Q_D(QPieSeries); |
|
355 | Q_D(QPieSeries); | |
355 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); |
|
356 | QObject::connect(this, SIGNAL(countChanged()), d, SIGNAL(countChanged())); | |
356 | } |
|
357 | } | |
357 |
|
358 | |||
358 | /*! |
|
359 | /*! | |
359 | Destroys the series and its slices. |
|
360 | Destroys the series and its slices. | |
360 | */ |
|
361 | */ | |
361 | QPieSeries::~QPieSeries() |
|
362 | QPieSeries::~QPieSeries() | |
362 | { |
|
363 | { | |
363 | // NOTE: d_prt destroyed by QObject |
|
364 | // NOTE: d_prt destroyed by QObject | |
364 | } |
|
365 | } | |
365 |
|
366 | |||
366 | /*! |
|
367 | /*! | |
367 | Returns QChartSeries::SeriesTypePie. |
|
368 | Returns QChartSeries::SeriesTypePie. | |
368 | */ |
|
369 | */ | |
369 | QAbstractSeries::SeriesType QPieSeries::type() const |
|
370 | QAbstractSeries::SeriesType QPieSeries::type() const | |
370 | { |
|
371 | { | |
371 | return QAbstractSeries::SeriesTypePie; |
|
372 | return QAbstractSeries::SeriesTypePie; | |
372 | } |
|
373 | } | |
373 |
|
374 | |||
374 | /*! |
|
375 | /*! | |
375 | Appends a single \a slice to the series. |
|
376 | Appends a single \a slice to the series. | |
376 | Slice ownership is passed to the series. |
|
377 | Slice ownership is passed to the series. | |
377 |
|
378 | |||
378 | Returns true if append was succesfull. |
|
379 | Returns true if append was succesfull. | |
379 | */ |
|
380 | */ | |
380 | bool QPieSeries::append(QPieSlice *slice) |
|
381 | bool QPieSeries::append(QPieSlice *slice) | |
381 | { |
|
382 | { | |
382 | return append(QList<QPieSlice *>() << slice); |
|
383 | return append(QList<QPieSlice *>() << slice); | |
383 | } |
|
384 | } | |
384 |
|
385 | |||
385 | /*! |
|
386 | /*! | |
386 | Appends an array of \a slices to the series. |
|
387 | Appends an array of \a slices to the series. | |
387 | Slice ownership is passed to the series. |
|
388 | Slice ownership is passed to the series. | |
388 |
|
389 | |||
389 | Returns true if append was successful. |
|
390 | Returns true if append was successful. | |
390 | */ |
|
391 | */ | |
391 | bool QPieSeries::append(QList<QPieSlice *> slices) |
|
392 | bool QPieSeries::append(QList<QPieSlice *> slices) | |
392 | { |
|
393 | { | |
393 | Q_D(QPieSeries); |
|
394 | Q_D(QPieSeries); | |
394 |
|
395 | |||
395 | if (slices.count() == 0) |
|
396 | if (slices.count() == 0) | |
396 | return false; |
|
397 | return false; | |
397 |
|
398 | |||
398 | foreach (QPieSlice *s, slices) { |
|
399 | foreach (QPieSlice *s, slices) { | |
399 | if (!s || d->m_slices.contains(s)) |
|
400 | if (!s || d->m_slices.contains(s)) | |
400 | return false; |
|
401 | return false; | |
401 | if (s->series()) // already added to some series |
|
402 | if (s->series()) // already added to some series | |
402 | return false; |
|
403 | return false; | |
|
404 | if (!isValidValue(s->value())) | |||
|
405 | return false; | |||
403 | } |
|
406 | } | |
404 |
|
407 | |||
405 | foreach (QPieSlice *s, slices) { |
|
408 | foreach (QPieSlice *s, slices) { | |
406 | s->setParent(this); |
|
409 | s->setParent(this); | |
407 | QPieSlicePrivate::fromSlice(s)->m_series = this; |
|
410 | QPieSlicePrivate::fromSlice(s)->m_series = this; | |
408 | d->m_slices << s; |
|
411 | d->m_slices << s; | |
409 | } |
|
412 | } | |
410 |
|
413 | |||
411 | d->updateDerivativeData(); |
|
414 | d->updateDerivativeData(); | |
412 |
|
415 | |||
413 | foreach(QPieSlice * s, slices) { |
|
416 | foreach(QPieSlice * s, slices) { | |
414 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
417 | connect(s, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
415 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
418 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
416 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
419 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
417 | } |
|
420 | } | |
418 |
|
421 | |||
419 | emit added(slices); |
|
422 | emit added(slices); | |
420 | emit countChanged(); |
|
423 | emit countChanged(); | |
421 |
|
424 | |||
422 | return true; |
|
425 | return true; | |
423 | } |
|
426 | } | |
424 |
|
427 | |||
425 | /*! |
|
428 | /*! | |
426 | Appends a single \a slice to the series and returns a reference to the series. |
|
429 | Appends a single \a slice to the series and returns a reference to the series. | |
427 | Slice ownership is passed to the series. |
|
430 | Slice ownership is passed to the series. | |
428 | */ |
|
431 | */ | |
429 | QPieSeries &QPieSeries::operator << (QPieSlice *slice) |
|
432 | QPieSeries &QPieSeries::operator << (QPieSlice *slice) | |
430 | { |
|
433 | { | |
431 | append(slice); |
|
434 | append(slice); | |
432 | return *this; |
|
435 | return *this; | |
433 | } |
|
436 | } | |
434 |
|
437 | |||
435 |
|
438 | |||
436 | /*! |
|
439 | /*! | |
437 | Appends a single slice to the series with give \a value and \a label. |
|
440 | Appends a single slice to the series with give \a value and \a label. | |
438 | Slice ownership is passed to the series. |
|
441 | Slice ownership is passed to the series. | |
|
442 | Returns NULL if value is NaN, Inf or -Inf and no slice is added to the series. | |||
439 | */ |
|
443 | */ | |
440 | QPieSlice *QPieSeries::append(QString label, qreal value) |
|
444 | QPieSlice *QPieSeries::append(QString label, qreal value) | |
441 | { |
|
445 | { | |
442 | QPieSlice *slice = new QPieSlice(label, value); |
|
446 | if (isValidValue(value)) { | |
443 | append(slice); |
|
447 | QPieSlice *slice = new QPieSlice(label, value); | |
444 |
|
|
448 | append(slice); | |
|
449 | return slice; | |||
|
450 | } else { | |||
|
451 | return 0; | |||
|
452 | } | |||
445 | } |
|
453 | } | |
446 |
|
454 | |||
447 | /*! |
|
455 | /*! | |
448 | Inserts a single \a slice to the series before the slice at \a index position. |
|
456 | Inserts a single \a slice to the series before the slice at \a index position. | |
449 | Slice ownership is passed to the series. |
|
457 | Slice ownership is passed to the series. | |
450 |
|
458 | |||
451 | Returns true if insert was successful. |
|
459 | Returns true if insert was successful. | |
452 | */ |
|
460 | */ | |
453 | bool QPieSeries::insert(int index, QPieSlice *slice) |
|
461 | bool QPieSeries::insert(int index, QPieSlice *slice) | |
454 | { |
|
462 | { | |
455 | Q_D(QPieSeries); |
|
463 | Q_D(QPieSeries); | |
456 |
|
464 | |||
457 | if (index < 0 || index > d->m_slices.count()) |
|
465 | if (index < 0 || index > d->m_slices.count()) | |
458 | return false; |
|
466 | return false; | |
459 |
|
467 | |||
460 | if (!slice || d->m_slices.contains(slice)) |
|
468 | if (!slice || d->m_slices.contains(slice)) | |
461 | return false; |
|
469 | return false; | |
462 |
|
470 | |||
463 | if (slice->series()) // already added to some series |
|
471 | if (slice->series()) // already added to some series | |
464 | return false; |
|
472 | return false; | |
465 |
|
473 | |||
|
474 | if (!isValidValue(slice->value())) | |||
|
475 | return false; | |||
|
476 | ||||
466 | slice->setParent(this); |
|
477 | slice->setParent(this); | |
467 | QPieSlicePrivate::fromSlice(slice)->m_series = this; |
|
478 | QPieSlicePrivate::fromSlice(slice)->m_series = this; | |
468 | d->m_slices.insert(index, slice); |
|
479 | d->m_slices.insert(index, slice); | |
469 |
|
480 | |||
470 | d->updateDerivativeData(); |
|
481 | d->updateDerivativeData(); | |
471 |
|
482 | |||
472 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); |
|
483 | connect(slice, SIGNAL(valueChanged()), d, SLOT(sliceValueChanged())); | |
473 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
484 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
474 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); |
|
485 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
475 |
|
486 | |||
476 | emit added(QList<QPieSlice *>() << slice); |
|
487 | emit added(QList<QPieSlice *>() << slice); | |
477 | emit countChanged(); |
|
488 | emit countChanged(); | |
478 |
|
489 | |||
479 | return true; |
|
490 | return true; | |
480 | } |
|
491 | } | |
481 |
|
492 | |||
482 | /*! |
|
493 | /*! | |
483 | Removes a single \a slice from the series and deletes the slice. |
|
494 | Removes a single \a slice from the series and deletes the slice. | |
484 |
|
495 | |||
485 | Do not reference the pointer after this call. |
|
496 | Do not reference the pointer after this call. | |
486 |
|
497 | |||
487 | Returns true if remove was successful. |
|
498 | Returns true if remove was successful. | |
488 | */ |
|
499 | */ | |
489 | bool QPieSeries::remove(QPieSlice *slice) |
|
500 | bool QPieSeries::remove(QPieSlice *slice) | |
490 | { |
|
501 | { | |
491 | Q_D(QPieSeries); |
|
502 | Q_D(QPieSeries); | |
492 |
|
503 | |||
493 | if (!d->m_slices.removeOne(slice)) |
|
504 | if (!d->m_slices.removeOne(slice)) | |
494 | return false; |
|
505 | return false; | |
495 |
|
506 | |||
496 | d->updateDerivativeData(); |
|
507 | d->updateDerivativeData(); | |
497 |
|
508 | |||
498 | emit removed(QList<QPieSlice *>() << slice); |
|
509 | emit removed(QList<QPieSlice *>() << slice); | |
499 | emit countChanged(); |
|
510 | emit countChanged(); | |
500 |
|
511 | |||
501 | delete slice; |
|
512 | delete slice; | |
502 | slice = 0; |
|
513 | slice = 0; | |
503 |
|
514 | |||
504 | return true; |
|
515 | return true; | |
505 | } |
|
516 | } | |
506 |
|
517 | |||
507 | /*! |
|
518 | /*! | |
508 | Takes a single \a slice from the series. Does not destroy the slice object. |
|
519 | Takes a single \a slice from the series. Does not destroy the slice object. | |
509 |
|
520 | |||
510 | NOTE: The series remains as the slice's parent object. You must set the |
|
521 | NOTE: The series remains as the slice's parent object. You must set the | |
511 | parent object to take full ownership. |
|
522 | parent object to take full ownership. | |
512 |
|
523 | |||
513 | Returns true if take was successful. |
|
524 | Returns true if take was successful. | |
514 | */ |
|
525 | */ | |
515 | bool QPieSeries::take(QPieSlice *slice) |
|
526 | bool QPieSeries::take(QPieSlice *slice) | |
516 | { |
|
527 | { | |
517 | Q_D(QPieSeries); |
|
528 | Q_D(QPieSeries); | |
518 |
|
529 | |||
519 | if (!d->m_slices.removeOne(slice)) |
|
530 | if (!d->m_slices.removeOne(slice)) | |
520 | return false; |
|
531 | return false; | |
521 |
|
532 | |||
522 | QPieSlicePrivate::fromSlice(slice)->m_series = 0; |
|
533 | QPieSlicePrivate::fromSlice(slice)->m_series = 0; | |
523 | slice->disconnect(d); |
|
534 | slice->disconnect(d); | |
524 |
|
535 | |||
525 | d->updateDerivativeData(); |
|
536 | d->updateDerivativeData(); | |
526 |
|
537 | |||
527 | emit removed(QList<QPieSlice *>() << slice); |
|
538 | emit removed(QList<QPieSlice *>() << slice); | |
528 | emit countChanged(); |
|
539 | emit countChanged(); | |
529 |
|
540 | |||
530 | return true; |
|
541 | return true; | |
531 | } |
|
542 | } | |
532 |
|
543 | |||
533 | /*! |
|
544 | /*! | |
534 | Clears all slices from the series. |
|
545 | Clears all slices from the series. | |
535 | */ |
|
546 | */ | |
536 | void QPieSeries::clear() |
|
547 | void QPieSeries::clear() | |
537 | { |
|
548 | { | |
538 | Q_D(QPieSeries); |
|
549 | Q_D(QPieSeries); | |
539 | if (d->m_slices.count() == 0) |
|
550 | if (d->m_slices.count() == 0) | |
540 | return; |
|
551 | return; | |
541 |
|
552 | |||
542 | QList<QPieSlice *> slices = d->m_slices; |
|
553 | QList<QPieSlice *> slices = d->m_slices; | |
543 | foreach (QPieSlice *s, d->m_slices) |
|
554 | foreach (QPieSlice *s, d->m_slices) | |
544 | d->m_slices.removeOne(s); |
|
555 | d->m_slices.removeOne(s); | |
545 |
|
556 | |||
546 | d->updateDerivativeData(); |
|
557 | d->updateDerivativeData(); | |
547 |
|
558 | |||
548 | emit removed(slices); |
|
559 | emit removed(slices); | |
549 | emit countChanged(); |
|
560 | emit countChanged(); | |
550 |
|
561 | |||
551 | foreach (QPieSlice *s, slices) |
|
562 | foreach (QPieSlice *s, slices) | |
552 | delete s; |
|
563 | delete s; | |
553 | } |
|
564 | } | |
554 |
|
565 | |||
555 | /*! |
|
566 | /*! | |
556 | Returns a list of slices that belong to this series. |
|
567 | Returns a list of slices that belong to this series. | |
557 | */ |
|
568 | */ | |
558 | QList<QPieSlice *> QPieSeries::slices() const |
|
569 | QList<QPieSlice *> QPieSeries::slices() const | |
559 | { |
|
570 | { | |
560 | Q_D(const QPieSeries); |
|
571 | Q_D(const QPieSeries); | |
561 | return d->m_slices; |
|
572 | return d->m_slices; | |
562 | } |
|
573 | } | |
563 |
|
574 | |||
564 | /*! |
|
575 | /*! | |
565 | returns the number of the slices in this series. |
|
576 | returns the number of the slices in this series. | |
566 | */ |
|
577 | */ | |
567 | int QPieSeries::count() const |
|
578 | int QPieSeries::count() const | |
568 | { |
|
579 | { | |
569 | Q_D(const QPieSeries); |
|
580 | Q_D(const QPieSeries); | |
570 | return d->m_slices.count(); |
|
581 | return d->m_slices.count(); | |
571 | } |
|
582 | } | |
572 |
|
583 | |||
573 | /*! |
|
584 | /*! | |
574 | Returns true is the series is empty. |
|
585 | Returns true is the series is empty. | |
575 | */ |
|
586 | */ | |
576 | bool QPieSeries::isEmpty() const |
|
587 | bool QPieSeries::isEmpty() const | |
577 | { |
|
588 | { | |
578 | Q_D(const QPieSeries); |
|
589 | Q_D(const QPieSeries); | |
579 | return d->m_slices.isEmpty(); |
|
590 | return d->m_slices.isEmpty(); | |
580 | } |
|
591 | } | |
581 |
|
592 | |||
582 | /*! |
|
593 | /*! | |
583 | Returns the sum of all slice values in this series. |
|
594 | Returns the sum of all slice values in this series. | |
584 |
|
595 | |||
585 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() |
|
596 | \sa QPieSlice::value(), QPieSlice::setValue(), QPieSlice::percentage() | |
586 | */ |
|
597 | */ | |
587 | qreal QPieSeries::sum() const |
|
598 | qreal QPieSeries::sum() const | |
588 | { |
|
599 | { | |
589 | Q_D(const QPieSeries); |
|
600 | Q_D(const QPieSeries); | |
590 | return d->m_sum; |
|
601 | return d->m_sum; | |
591 | } |
|
602 | } | |
592 |
|
603 | |||
593 | void QPieSeries::setHoleSize(qreal holeSize) |
|
604 | void QPieSeries::setHoleSize(qreal holeSize) | |
594 | { |
|
605 | { | |
595 | Q_D(QPieSeries); |
|
606 | Q_D(QPieSeries); | |
596 | holeSize = qBound((qreal)0.0, holeSize, (qreal)1.0); |
|
607 | holeSize = qBound((qreal)0.0, holeSize, (qreal)1.0); | |
597 | d->setSizes(holeSize, qMax(d->m_pieRelativeSize, holeSize)); |
|
608 | d->setSizes(holeSize, qMax(d->m_pieRelativeSize, holeSize)); | |
598 | } |
|
609 | } | |
599 |
|
610 | |||
600 | qreal QPieSeries::holeSize() const |
|
611 | qreal QPieSeries::holeSize() const | |
601 | { |
|
612 | { | |
602 | Q_D(const QPieSeries); |
|
613 | Q_D(const QPieSeries); | |
603 | return d->m_holeRelativeSize; |
|
614 | return d->m_holeRelativeSize; | |
604 | } |
|
615 | } | |
605 |
|
616 | |||
606 | void QPieSeries::setHorizontalPosition(qreal relativePosition) |
|
617 | void QPieSeries::setHorizontalPosition(qreal relativePosition) | |
607 | { |
|
618 | { | |
608 | Q_D(QPieSeries); |
|
619 | Q_D(QPieSeries); | |
609 |
|
620 | |||
610 | if (relativePosition < 0.0) |
|
621 | if (relativePosition < 0.0) | |
611 | relativePosition = 0.0; |
|
622 | relativePosition = 0.0; | |
612 | if (relativePosition > 1.0) |
|
623 | if (relativePosition > 1.0) | |
613 | relativePosition = 1.0; |
|
624 | relativePosition = 1.0; | |
614 |
|
625 | |||
615 | if (!qFuzzyCompare(d->m_pieRelativeHorPos, relativePosition)) { |
|
626 | if (!qFuzzyCompare(d->m_pieRelativeHorPos, relativePosition)) { | |
616 | d->m_pieRelativeHorPos = relativePosition; |
|
627 | d->m_pieRelativeHorPos = relativePosition; | |
617 | emit d->horizontalPositionChanged(); |
|
628 | emit d->horizontalPositionChanged(); | |
618 | } |
|
629 | } | |
619 | } |
|
630 | } | |
620 |
|
631 | |||
621 | qreal QPieSeries::horizontalPosition() const |
|
632 | qreal QPieSeries::horizontalPosition() const | |
622 | { |
|
633 | { | |
623 | Q_D(const QPieSeries); |
|
634 | Q_D(const QPieSeries); | |
624 | return d->m_pieRelativeHorPos; |
|
635 | return d->m_pieRelativeHorPos; | |
625 | } |
|
636 | } | |
626 |
|
637 | |||
627 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
638 | void QPieSeries::setVerticalPosition(qreal relativePosition) | |
628 | { |
|
639 | { | |
629 | Q_D(QPieSeries); |
|
640 | Q_D(QPieSeries); | |
630 |
|
641 | |||
631 | if (relativePosition < 0.0) |
|
642 | if (relativePosition < 0.0) | |
632 | relativePosition = 0.0; |
|
643 | relativePosition = 0.0; | |
633 | if (relativePosition > 1.0) |
|
644 | if (relativePosition > 1.0) | |
634 | relativePosition = 1.0; |
|
645 | relativePosition = 1.0; | |
635 |
|
646 | |||
636 | if (!qFuzzyCompare(d->m_pieRelativeVerPos, relativePosition)) { |
|
647 | if (!qFuzzyCompare(d->m_pieRelativeVerPos, relativePosition)) { | |
637 | d->m_pieRelativeVerPos = relativePosition; |
|
648 | d->m_pieRelativeVerPos = relativePosition; | |
638 | emit d->verticalPositionChanged(); |
|
649 | emit d->verticalPositionChanged(); | |
639 | } |
|
650 | } | |
640 | } |
|
651 | } | |
641 |
|
652 | |||
642 | qreal QPieSeries::verticalPosition() const |
|
653 | qreal QPieSeries::verticalPosition() const | |
643 | { |
|
654 | { | |
644 | Q_D(const QPieSeries); |
|
655 | Q_D(const QPieSeries); | |
645 | return d->m_pieRelativeVerPos; |
|
656 | return d->m_pieRelativeVerPos; | |
646 | } |
|
657 | } | |
647 |
|
658 | |||
648 | void QPieSeries::setPieSize(qreal relativeSize) |
|
659 | void QPieSeries::setPieSize(qreal relativeSize) | |
649 | { |
|
660 | { | |
650 | Q_D(QPieSeries); |
|
661 | Q_D(QPieSeries); | |
651 | relativeSize = qBound((qreal)0.0, relativeSize, (qreal)1.0); |
|
662 | relativeSize = qBound((qreal)0.0, relativeSize, (qreal)1.0); | |
652 | d->setSizes(qMin(d->m_holeRelativeSize, relativeSize), relativeSize); |
|
663 | d->setSizes(qMin(d->m_holeRelativeSize, relativeSize), relativeSize); | |
653 |
|
664 | |||
654 | } |
|
665 | } | |
655 |
|
666 | |||
656 | qreal QPieSeries::pieSize() const |
|
667 | qreal QPieSeries::pieSize() const | |
657 | { |
|
668 | { | |
658 | Q_D(const QPieSeries); |
|
669 | Q_D(const QPieSeries); | |
659 | return d->m_pieRelativeSize; |
|
670 | return d->m_pieRelativeSize; | |
660 | } |
|
671 | } | |
661 |
|
672 | |||
662 |
|
673 | |||
663 | void QPieSeries::setPieStartAngle(qreal angle) |
|
674 | void QPieSeries::setPieStartAngle(qreal angle) | |
664 | { |
|
675 | { | |
665 | Q_D(QPieSeries); |
|
676 | Q_D(QPieSeries); | |
666 | if (qFuzzyCompare(d->m_pieStartAngle, angle)) |
|
677 | if (qFuzzyCompare(d->m_pieStartAngle, angle)) | |
667 | return; |
|
678 | return; | |
668 | d->m_pieStartAngle = angle; |
|
679 | d->m_pieStartAngle = angle; | |
669 | d->updateDerivativeData(); |
|
680 | d->updateDerivativeData(); | |
670 | emit d->pieStartAngleChanged(); |
|
681 | emit d->pieStartAngleChanged(); | |
671 | } |
|
682 | } | |
672 |
|
683 | |||
673 | qreal QPieSeries::pieStartAngle() const |
|
684 | qreal QPieSeries::pieStartAngle() const | |
674 | { |
|
685 | { | |
675 | Q_D(const QPieSeries); |
|
686 | Q_D(const QPieSeries); | |
676 | return d->m_pieStartAngle; |
|
687 | return d->m_pieStartAngle; | |
677 | } |
|
688 | } | |
678 |
|
689 | |||
679 | /*! |
|
690 | /*! | |
680 | Sets the end angle of the pie. |
|
691 | Sets the end angle of the pie. | |
681 |
|
692 | |||
682 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
693 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
683 |
|
694 | |||
684 | \a angle must be greater than start angle. |
|
695 | \a angle must be greater than start angle. | |
685 |
|
696 | |||
686 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
697 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() | |
687 | */ |
|
698 | */ | |
688 | void QPieSeries::setPieEndAngle(qreal angle) |
|
699 | void QPieSeries::setPieEndAngle(qreal angle) | |
689 | { |
|
700 | { | |
690 | Q_D(QPieSeries); |
|
701 | Q_D(QPieSeries); | |
691 | if (qFuzzyCompare(d->m_pieEndAngle, angle)) |
|
702 | if (qFuzzyCompare(d->m_pieEndAngle, angle)) | |
692 | return; |
|
703 | return; | |
693 | d->m_pieEndAngle = angle; |
|
704 | d->m_pieEndAngle = angle; | |
694 | d->updateDerivativeData(); |
|
705 | d->updateDerivativeData(); | |
695 | emit d->pieEndAngleChanged(); |
|
706 | emit d->pieEndAngleChanged(); | |
696 | } |
|
707 | } | |
697 |
|
708 | |||
698 | /*! |
|
709 | /*! | |
699 | Returns the end angle of the pie. |
|
710 | Returns the end angle of the pie. | |
700 |
|
711 | |||
701 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
712 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
702 |
|
713 | |||
703 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
714 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() | |
704 | */ |
|
715 | */ | |
705 | qreal QPieSeries::pieEndAngle() const |
|
716 | qreal QPieSeries::pieEndAngle() const | |
706 | { |
|
717 | { | |
707 | Q_D(const QPieSeries); |
|
718 | Q_D(const QPieSeries); | |
708 | return d->m_pieEndAngle; |
|
719 | return d->m_pieEndAngle; | |
709 | } |
|
720 | } | |
710 |
|
721 | |||
711 | /*! |
|
722 | /*! | |
712 | Sets the all the slice labels \a visible or invisible. |
|
723 | Sets the all the slice labels \a visible or invisible. | |
713 |
|
724 | |||
714 | Note that this affects only the current slices in the series. |
|
725 | Note that this affects only the current slices in the series. | |
715 | If user adds a new slice the default label visibility is false. |
|
726 | If user adds a new slice the default label visibility is false. | |
716 |
|
727 | |||
717 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
728 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() | |
718 | */ |
|
729 | */ | |
719 | void QPieSeries::setLabelsVisible(bool visible) |
|
730 | void QPieSeries::setLabelsVisible(bool visible) | |
720 | { |
|
731 | { | |
721 | Q_D(QPieSeries); |
|
732 | Q_D(QPieSeries); | |
722 | foreach (QPieSlice *s, d->m_slices) |
|
733 | foreach (QPieSlice *s, d->m_slices) | |
723 | s->setLabelVisible(visible); |
|
734 | s->setLabelVisible(visible); | |
724 | } |
|
735 | } | |
725 |
|
736 | |||
726 | /*! |
|
737 | /*! | |
727 | Sets the all the slice labels \a position |
|
738 | Sets the all the slice labels \a position | |
728 |
|
739 | |||
729 | Note that this affects only the current slices in the series. |
|
740 | Note that this affects only the current slices in the series. | |
730 | If user adds a new slice the default label position is LabelOutside |
|
741 | If user adds a new slice the default label position is LabelOutside | |
731 |
|
742 | |||
732 | \sa QPieSlice::labelPosition(), QPieSlice::setLabelPosition() |
|
743 | \sa QPieSlice::labelPosition(), QPieSlice::setLabelPosition() | |
733 | */ |
|
744 | */ | |
734 | void QPieSeries::setLabelsPosition(QPieSlice::LabelPosition position) |
|
745 | void QPieSeries::setLabelsPosition(QPieSlice::LabelPosition position) | |
735 | { |
|
746 | { | |
736 | Q_D(QPieSeries); |
|
747 | Q_D(QPieSeries); | |
737 | foreach (QPieSlice *s, d->m_slices) |
|
748 | foreach (QPieSlice *s, d->m_slices) | |
738 | s->setLabelPosition(position); |
|
749 | s->setLabelPosition(position); | |
739 | } |
|
750 | } | |
740 |
|
751 | |||
741 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
752 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
742 |
|
753 | |||
743 |
|
754 | |||
744 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : |
|
755 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) : | |
745 | QAbstractSeriesPrivate(parent), |
|
756 | QAbstractSeriesPrivate(parent), | |
746 | m_pieRelativeHorPos(0.5), |
|
757 | m_pieRelativeHorPos(0.5), | |
747 | m_pieRelativeVerPos(0.5), |
|
758 | m_pieRelativeVerPos(0.5), | |
748 | m_pieRelativeSize(0.7), |
|
759 | m_pieRelativeSize(0.7), | |
749 | m_pieStartAngle(0), |
|
760 | m_pieStartAngle(0), | |
750 | m_pieEndAngle(360), |
|
761 | m_pieEndAngle(360), | |
751 | m_sum(0), |
|
762 | m_sum(0), | |
752 | m_holeRelativeSize(0.0) |
|
763 | m_holeRelativeSize(0.0) | |
753 | { |
|
764 | { | |
754 | } |
|
765 | } | |
755 |
|
766 | |||
756 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
767 | QPieSeriesPrivate::~QPieSeriesPrivate() | |
757 | { |
|
768 | { | |
758 | } |
|
769 | } | |
759 |
|
770 | |||
760 | void QPieSeriesPrivate::updateDerivativeData() |
|
771 | void QPieSeriesPrivate::updateDerivativeData() | |
761 | { |
|
772 | { | |
762 | // calculate sum of all slices |
|
773 | // calculate sum of all slices | |
763 | qreal sum = 0; |
|
774 | qreal sum = 0; | |
764 | foreach (QPieSlice *s, m_slices) |
|
775 | foreach (QPieSlice *s, m_slices) | |
765 | sum += s->value(); |
|
776 | sum += s->value(); | |
766 |
|
777 | |||
767 | if (!qFuzzyCompare(m_sum, sum)) { |
|
778 | if (!qFuzzyCompare(m_sum, sum)) { | |
768 | m_sum = sum; |
|
779 | m_sum = sum; | |
769 | emit q_func()->sumChanged(); |
|
780 | emit q_func()->sumChanged(); | |
770 | } |
|
781 | } | |
771 |
|
782 | |||
772 | // nothing to show.. |
|
783 | // nothing to show.. | |
773 | if (qFuzzyCompare(m_sum, 0)) |
|
784 | if (qFuzzyCompare(m_sum, 0)) | |
774 | return; |
|
785 | return; | |
775 |
|
786 | |||
776 | // update slice attributes |
|
787 | // update slice attributes | |
777 | qreal sliceAngle = m_pieStartAngle; |
|
788 | qreal sliceAngle = m_pieStartAngle; | |
778 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
789 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; | |
779 | QVector<QPieSlice *> changed; |
|
790 | QVector<QPieSlice *> changed; | |
780 | foreach (QPieSlice *s, m_slices) { |
|
791 | foreach (QPieSlice *s, m_slices) { | |
781 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
792 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
782 | d->setPercentage(s->value() / m_sum); |
|
793 | d->setPercentage(s->value() / m_sum); | |
783 | d->setStartAngle(sliceAngle); |
|
794 | d->setStartAngle(sliceAngle); | |
784 | d->setAngleSpan(pieSpan * s->percentage()); |
|
795 | d->setAngleSpan(pieSpan * s->percentage()); | |
785 | sliceAngle += s->angleSpan(); |
|
796 | sliceAngle += s->angleSpan(); | |
786 | } |
|
797 | } | |
787 |
|
798 | |||
788 |
|
799 | |||
789 | emit calculatedDataChanged(); |
|
800 | emit calculatedDataChanged(); | |
790 | } |
|
801 | } | |
791 |
|
802 | |||
792 | void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize) |
|
803 | void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize) | |
793 | { |
|
804 | { | |
794 | bool changed = false; |
|
805 | bool changed = false; | |
795 |
|
806 | |||
796 | if (!qFuzzyCompare(m_holeRelativeSize, innerSize)) { |
|
807 | if (!qFuzzyCompare(m_holeRelativeSize, innerSize)) { | |
797 | m_holeRelativeSize = innerSize; |
|
808 | m_holeRelativeSize = innerSize; | |
798 | changed = true; |
|
809 | changed = true; | |
799 | } |
|
810 | } | |
800 |
|
811 | |||
801 | if (!qFuzzyCompare(m_pieRelativeSize, outerSize)) { |
|
812 | if (!qFuzzyCompare(m_pieRelativeSize, outerSize)) { | |
802 | m_pieRelativeSize = outerSize; |
|
813 | m_pieRelativeSize = outerSize; | |
803 | changed = true; |
|
814 | changed = true; | |
804 | } |
|
815 | } | |
805 |
|
816 | |||
806 | if (changed) |
|
817 | if (changed) | |
807 | emit pieSizeChanged(); |
|
818 | emit pieSizeChanged(); | |
808 | } |
|
819 | } | |
809 |
|
820 | |||
810 | QPieSeriesPrivate *QPieSeriesPrivate::fromSeries(QPieSeries *series) |
|
821 | QPieSeriesPrivate *QPieSeriesPrivate::fromSeries(QPieSeries *series) | |
811 | { |
|
822 | { | |
812 | return series->d_func(); |
|
823 | return series->d_func(); | |
813 | } |
|
824 | } | |
814 |
|
825 | |||
815 | void QPieSeriesPrivate::sliceValueChanged() |
|
826 | void QPieSeriesPrivate::sliceValueChanged() | |
816 | { |
|
827 | { | |
817 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
828 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
818 | updateDerivativeData(); |
|
829 | updateDerivativeData(); | |
819 | } |
|
830 | } | |
820 |
|
831 | |||
821 | void QPieSeriesPrivate::sliceClicked() |
|
832 | void QPieSeriesPrivate::sliceClicked() | |
822 | { |
|
833 | { | |
823 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
834 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
824 | Q_ASSERT(m_slices.contains(slice)); |
|
835 | Q_ASSERT(m_slices.contains(slice)); | |
825 | Q_Q(QPieSeries); |
|
836 | Q_Q(QPieSeries); | |
826 | emit q->clicked(slice); |
|
837 | emit q->clicked(slice); | |
827 | } |
|
838 | } | |
828 |
|
839 | |||
829 | void QPieSeriesPrivate::sliceHovered(bool state) |
|
840 | void QPieSeriesPrivate::sliceHovered(bool state) | |
830 | { |
|
841 | { | |
831 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); |
|
842 | QPieSlice *slice = qobject_cast<QPieSlice *>(sender()); | |
832 | Q_ASSERT(m_slices.contains(slice)); |
|
843 | Q_ASSERT(m_slices.contains(slice)); | |
833 | Q_Q(QPieSeries); |
|
844 | Q_Q(QPieSeries); | |
834 | emit q->hovered(slice, state); |
|
845 | emit q->hovered(slice, state); | |
835 | } |
|
846 | } | |
836 |
|
847 | |||
837 | void QPieSeriesPrivate::initializeDomain() |
|
848 | void QPieSeriesPrivate::initializeDomain() | |
838 | { |
|
849 | { | |
839 | // does not apply to pie |
|
850 | // does not apply to pie | |
840 | } |
|
851 | } | |
841 |
|
852 | |||
842 | void QPieSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
853 | void QPieSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
843 | { |
|
854 | { | |
844 | Q_Q(QPieSeries); |
|
855 | Q_Q(QPieSeries); | |
845 | PieChartItem *pie = new PieChartItem(q,parent); |
|
856 | PieChartItem *pie = new PieChartItem(q,parent); | |
846 | m_item.reset(pie); |
|
857 | m_item.reset(pie); | |
847 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
858 | QAbstractSeriesPrivate::initializeGraphics(parent); | |
848 | } |
|
859 | } | |
849 |
|
860 | |||
850 | void QPieSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) |
|
861 | void QPieSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
851 | { |
|
862 | { | |
852 | PieChartItem *item = static_cast<PieChartItem *>(m_item.data()); |
|
863 | PieChartItem *item = static_cast<PieChartItem *>(m_item.data()); | |
853 | Q_ASSERT(item); |
|
864 | Q_ASSERT(item); | |
854 | if (options.testFlag(QChart::SeriesAnimations)) { |
|
865 | if (options.testFlag(QChart::SeriesAnimations)) { | |
855 | item->setAnimation(new PieAnimation(item)); |
|
866 | item->setAnimation(new PieAnimation(item)); | |
856 | }else{ |
|
867 | }else{ | |
857 | item->setAnimation(0); |
|
868 | item->setAnimation(0); | |
858 | } |
|
869 | } | |
859 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
870 | QAbstractSeriesPrivate::initializeAnimations(options); | |
860 | } |
|
871 | } | |
861 |
|
872 | |||
862 | QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
873 | QList<QLegendMarker*> QPieSeriesPrivate::createLegendMarkers(QLegend* legend) | |
863 | { |
|
874 | { | |
864 | Q_Q(QPieSeries); |
|
875 | Q_Q(QPieSeries); | |
865 | QList<QLegendMarker*> markers; |
|
876 | QList<QLegendMarker*> markers; | |
866 | foreach(QPieSlice* slice, q->slices()) { |
|
877 | foreach(QPieSlice* slice, q->slices()) { | |
867 | QPieLegendMarker* marker = new QPieLegendMarker(q,slice,legend); |
|
878 | QPieLegendMarker* marker = new QPieLegendMarker(q,slice,legend); | |
868 | markers << marker; |
|
879 | markers << marker; | |
869 | } |
|
880 | } | |
870 | return markers; |
|
881 | return markers; | |
871 | } |
|
882 | } | |
872 |
|
883 | |||
873 | void QPieSeriesPrivate::initializeAxes() |
|
884 | void QPieSeriesPrivate::initializeAxes() | |
874 | { |
|
885 | { | |
875 |
|
886 | |||
876 | } |
|
887 | } | |
877 |
|
888 | |||
878 | QAbstractAxis::AxisType QPieSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
889 | QAbstractAxis::AxisType QPieSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
879 | { |
|
890 | { | |
880 | Q_UNUSED(orientation); |
|
891 | Q_UNUSED(orientation); | |
881 | return QAbstractAxis::AxisTypeNoAxis; |
|
892 | return QAbstractAxis::AxisTypeNoAxis; | |
882 | } |
|
893 | } | |
883 |
|
894 | |||
884 | QAbstractAxis* QPieSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
895 | QAbstractAxis* QPieSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
885 | { |
|
896 | { | |
886 | Q_UNUSED(orientation); |
|
897 | Q_UNUSED(orientation); | |
887 | return 0; |
|
898 | return 0; | |
888 | } |
|
899 | } | |
889 |
|
900 | |||
890 | void QPieSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) |
|
901 | void QPieSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
891 | { |
|
902 | { | |
892 | //Q_Q(QPieSeries); |
|
903 | //Q_Q(QPieSeries); | |
893 | //const QList<QColor>& colors = theme->seriesColors(); |
|
904 | //const QList<QColor>& colors = theme->seriesColors(); | |
894 | const QList<QGradient>& gradients = theme->seriesGradients(); |
|
905 | const QList<QGradient>& gradients = theme->seriesGradients(); | |
895 |
|
906 | |||
896 | for (int i(0); i < m_slices.count(); i++) { |
|
907 | for (int i(0); i < m_slices.count(); i++) { | |
897 |
|
908 | |||
898 | QColor penColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); |
|
909 | QColor penColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); | |
899 |
|
910 | |||
900 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient |
|
911 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient | |
901 | qreal pos = (qreal)(i + 1) / (qreal) m_slices.count(); |
|
912 | qreal pos = (qreal)(i + 1) / (qreal) m_slices.count(); | |
902 | QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), pos); |
|
913 | QColor brushColor = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), pos); | |
903 |
|
914 | |||
904 | QPieSlice *s = m_slices.at(i); |
|
915 | QPieSlice *s = m_slices.at(i); | |
905 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); |
|
916 | QPieSlicePrivate *d = QPieSlicePrivate::fromSlice(s); | |
906 |
|
917 | |||
907 | if (forced || d->m_data.m_slicePen.isThemed()) |
|
918 | if (forced || d->m_data.m_slicePen.isThemed()) | |
908 | d->setPen(penColor, true); |
|
919 | d->setPen(penColor, true); | |
909 |
|
920 | |||
910 | if (forced || d->m_data.m_sliceBrush.isThemed()) |
|
921 | if (forced || d->m_data.m_sliceBrush.isThemed()) | |
911 | d->setBrush(brushColor, true); |
|
922 | d->setBrush(brushColor, true); | |
912 |
|
923 | |||
913 | if (forced || d->m_data.m_labelBrush.isThemed()) |
|
924 | if (forced || d->m_data.m_labelBrush.isThemed()) | |
914 | d->setLabelBrush(theme->labelBrush().color(), true); |
|
925 | d->setLabelBrush(theme->labelBrush().color(), true); | |
915 |
|
926 | |||
916 | if (forced || d->m_data.m_labelFont.isThemed()) |
|
927 | if (forced || d->m_data.m_labelFont.isThemed()) | |
917 | d->setLabelFont(theme->labelFont(), true); |
|
928 | d->setLabelFont(theme->labelFont(), true); | |
918 | } |
|
929 | } | |
919 | } |
|
930 | } | |
920 |
|
931 | |||
921 |
|
932 | |||
922 | #include "moc_qpieseries.cpp" |
|
933 | #include "moc_qpieseries.cpp" | |
923 | #include "moc_qpieseries_p.cpp" |
|
934 | #include "moc_qpieseries_p.cpp" | |
924 |
|
935 | |||
925 | QTCOMMERCIALCHART_END_NAMESPACE |
|
936 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,254 +1,255 | |||||
1 | !include( ../config.pri ):error( "Couldn't find the config.pri file!" ) |
|
1 | !include( ../config.pri ):error( "Couldn't find the config.pri file!" ) | |
2 |
|
2 | |||
3 | ############################# BUILD CONFIG ###################################### |
|
3 | ############################# BUILD CONFIG ###################################### | |
4 |
|
4 | |||
5 | TARGET = $$LIBRARY_NAME |
|
5 | TARGET = $$LIBRARY_NAME | |
6 | DESTDIR = $$CHART_BUILD_LIB_DIR |
|
6 | DESTDIR = $$CHART_BUILD_LIB_DIR | |
7 | TEMPLATE = lib |
|
7 | TEMPLATE = lib | |
8 | QT = core gui |
|
8 | QT = core gui | |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
|
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |
10 | DEFINES += QTCOMMERCIALCHART_LIBRARY |
|
10 | DEFINES += QTCOMMERCIALCHART_LIBRARY | |
11 | win32:CONFIG += create_prl |
|
11 | win32:CONFIG += create_prl | |
12 | # treat warnings as errors |
|
12 | # treat warnings as errors | |
13 | win32-msvc*: { |
|
13 | win32-msvc*: { | |
14 | QMAKE_CXXFLAGS += /WX |
|
14 | QMAKE_CXXFLAGS += /WX | |
15 | } else { |
|
15 | } else { | |
16 | # QMAKE_CXXFLAGS += -Werror |
|
16 | # QMAKE_CXXFLAGS += -Werror | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | unix:{ |
|
19 | unix:{ | |
20 | QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden |
|
20 | QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | ############################# DEPEDENCES ######################################## |
|
23 | ############################# DEPEDENCES ######################################## | |
24 |
|
24 | |||
25 | win32-msvc*: LIBS += User32.lib |
|
25 | win32-msvc*: LIBS += User32.lib | |
26 | LIBS -= -l$$LIBRARY_NAME |
|
26 | LIBS -= -l$$LIBRARY_NAME | |
27 | INCLUDEPATH += ../include . |
|
27 | INCLUDEPATH += ../include . | |
28 |
|
28 | |||
29 | ############################# SOURCES ########################################## |
|
29 | ############################# SOURCES ########################################## | |
30 |
|
30 | |||
31 | SOURCES += \ |
|
31 | SOURCES += \ | |
32 | $$PWD/chartdataset.cpp \ |
|
32 | $$PWD/chartdataset.cpp \ | |
33 | $$PWD/chartpresenter.cpp \ |
|
33 | $$PWD/chartpresenter.cpp \ | |
34 | $$PWD/chartthememanager.cpp \ |
|
34 | $$PWD/chartthememanager.cpp \ | |
35 | $$PWD/qchart.cpp \ |
|
35 | $$PWD/qchart.cpp \ | |
36 | $$PWD/qchartview.cpp \ |
|
36 | $$PWD/qchartview.cpp \ | |
37 | $$PWD/qabstractseries.cpp \ |
|
37 | $$PWD/qabstractseries.cpp \ | |
38 | $$PWD/chartbackground.cpp \ |
|
38 | $$PWD/chartbackground.cpp \ | |
39 | $$PWD/chartelement.cpp \ |
|
39 | $$PWD/chartelement.cpp \ | |
40 | $$PWD/chartitem.cpp \ |
|
40 | $$PWD/chartitem.cpp \ | |
41 | $$PWD/scroller.cpp \ |
|
41 | $$PWD/scroller.cpp \ | |
42 | $$PWD/chartlayout.cpp \ |
|
42 | $$PWD/chartlayout.cpp \ | |
43 | $$PWD/charttitle.cpp |
|
43 | $$PWD/charttitle.cpp | |
44 | PRIVATE_HEADERS += \ |
|
44 | PRIVATE_HEADERS += \ | |
45 | $$PWD/chartdataset_p.h \ |
|
45 | $$PWD/chartdataset_p.h \ | |
46 | $$PWD/chartitem_p.h \ |
|
46 | $$PWD/chartitem_p.h \ | |
47 | $$PWD/chartpresenter_p.h \ |
|
47 | $$PWD/chartpresenter_p.h \ | |
48 | $$PWD/chartthememanager_p.h \ |
|
48 | $$PWD/chartthememanager_p.h \ | |
49 | $$PWD/chartbackground_p.h \ |
|
49 | $$PWD/chartbackground_p.h \ | |
50 | $$PWD/chartelement_p.h \ |
|
50 | $$PWD/chartelement_p.h \ | |
51 | $$PWD/chartconfig_p.h \ |
|
51 | $$PWD/chartconfig_p.h \ | |
52 | $$PWD/qchart_p.h \ |
|
52 | $$PWD/qchart_p.h \ | |
53 | $$PWD/qchartview_p.h \ |
|
53 | $$PWD/qchartview_p.h \ | |
54 | $$PWD/scroller_p.h \ |
|
54 | $$PWD/scroller_p.h \ | |
55 | $$PWD/qabstractseries_p.h \ |
|
55 | $$PWD/qabstractseries_p.h \ | |
56 | $$PWD/chartlayout_p.h \ |
|
56 | $$PWD/chartlayout_p.h \ | |
57 | $$PWD/charttitle_p.h |
|
57 | $$PWD/charttitle_p.h \ | |
|
58 | $$PWD/charthelpers_p.h | |||
58 | PUBLIC_HEADERS += \ |
|
59 | PUBLIC_HEADERS += \ | |
59 | $$PWD/qchart.h \ |
|
60 | $$PWD/qchart.h \ | |
60 | $$PWD/qchartglobal.h \ |
|
61 | $$PWD/qchartglobal.h \ | |
61 | $$PWD/qabstractseries.h \ |
|
62 | $$PWD/qabstractseries.h \ | |
62 | $$PWD/qchartview.h \ |
|
63 | $$PWD/qchartview.h \ | |
63 | $$PWD/chartsnamespace.h |
|
64 | $$PWD/chartsnamespace.h | |
64 |
|
65 | |||
65 | include(animations/animations.pri) |
|
66 | include(animations/animations.pri) | |
66 | include(areachart/areachart.pri) |
|
67 | include(areachart/areachart.pri) | |
67 | include(axis/axis.pri) |
|
68 | include(axis/axis.pri) | |
68 | include(domain/domain.pri) |
|
69 | include(domain/domain.pri) | |
69 | include(barchart/barchart.pri) |
|
70 | include(barchart/barchart.pri) | |
70 | include(legend/legend.pri) |
|
71 | include(legend/legend.pri) | |
71 | include(linechart/linechart.pri) |
|
72 | include(linechart/linechart.pri) | |
72 | include(piechart/piechart.pri) |
|
73 | include(piechart/piechart.pri) | |
73 | include(scatterchart/scatter.pri) |
|
74 | include(scatterchart/scatter.pri) | |
74 | include(splinechart/splinechart.pri) |
|
75 | include(splinechart/splinechart.pri) | |
75 | include(themes/themes.pri) |
|
76 | include(themes/themes.pri) | |
76 | include(xychart/xychart.pri) |
|
77 | include(xychart/xychart.pri) | |
77 |
|
78 | |||
78 | HEADERS += $$PUBLIC_HEADERS |
|
79 | HEADERS += $$PUBLIC_HEADERS | |
79 | HEADERS += $$PRIVATE_HEADERS |
|
80 | HEADERS += $$PRIVATE_HEADERS | |
80 | HEADERS += $$THEMES |
|
81 | HEADERS += $$THEMES | |
81 |
|
82 | |||
82 | ############################# BUILD PATH ########################################## |
|
83 | ############################# BUILD PATH ########################################## | |
83 |
|
84 | |||
84 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
|
85 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib | |
85 | MOC_DIR = $$CHART_BUILD_DIR/lib |
|
86 | MOC_DIR = $$CHART_BUILD_DIR/lib | |
86 | UI_DIR = $$CHART_BUILD_DIR/lib |
|
87 | UI_DIR = $$CHART_BUILD_DIR/lib | |
87 | RCC_DIR = $$CHART_BUILD_DIR/lib |
|
88 | RCC_DIR = $$CHART_BUILD_DIR/lib | |
88 |
|
89 | |||
89 | ############################# PUBLIC HEADERS GENERATOR ########################################## |
|
90 | ############################# PUBLIC HEADERS GENERATOR ########################################## | |
90 |
|
91 | |||
91 | !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal) |
|
92 | !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal) | |
92 | { |
|
93 | { | |
93 | system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR) |
|
94 | system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR) | |
94 | win32:{ |
|
95 | win32:{ | |
95 | command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" |
|
96 | command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" | |
96 | }else{ |
|
97 | }else{ | |
97 | command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" |
|
98 | command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal" | |
98 | } |
|
99 | } | |
99 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal |
|
100 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal | |
100 | system($$command) |
|
101 | system($$command) | |
101 | } |
|
102 | } | |
102 |
|
103 | |||
103 | for(file, PUBLIC_HEADERS) { |
|
104 | for(file, PUBLIC_HEADERS) { | |
104 | name = $$split(file,'/') |
|
105 | name = $$split(file,'/') | |
105 | name = $$last(name) |
|
106 | name = $$last(name) | |
106 | class = "$$cat($$file)" |
|
107 | class = "$$cat($$file)" | |
107 | class = $$find(class,class) |
|
108 | class = $$find(class,class) | |
108 | !isEmpty(class){ |
|
109 | !isEmpty(class){ | |
109 | class = $$split(class,QTCOMMERCIALCHART_EXPORT) |
|
110 | class = $$split(class,QTCOMMERCIALCHART_EXPORT) | |
110 | class = $$member(class,1) |
|
111 | class = $$member(class,1) | |
111 | class = $$split(class,' ') |
|
112 | class = $$split(class,' ') | |
112 | class = $$replace(class,' ','') |
|
113 | class = $$replace(class,' ','') | |
113 | class = $$member(class,0) |
|
114 | class = $$member(class,0) | |
114 | win32:{ |
|
115 | win32:{ | |
115 | command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" |
|
116 | command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" | |
116 | }else{ |
|
117 | }else{ | |
117 | command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" |
|
118 | command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class" | |
118 | } |
|
119 | } | |
119 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class |
|
120 | PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class | |
120 | system($$command) |
|
121 | system($$command) | |
121 | } |
|
122 | } | |
122 | } |
|
123 | } | |
123 |
|
124 | |||
124 | ############################# INSTALLERS ########################################## |
|
125 | ############################# INSTALLERS ########################################## | |
125 |
|
126 | |||
126 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart |
|
127 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart | |
127 | public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS |
|
128 | public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS | |
128 | INSTALLS += public_headers |
|
129 | INSTALLS += public_headers | |
129 |
|
130 | |||
130 | install_build_public_headers.name = build_public_headers |
|
131 | install_build_public_headers.name = build_public_headers | |
131 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
132 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
132 | install_build_public_headers.input = PUBLIC_HEADERS |
|
133 | install_build_public_headers.input = PUBLIC_HEADERS | |
133 | install_build_public_headers.commands = $$QMAKE_COPY \ |
|
134 | install_build_public_headers.commands = $$QMAKE_COPY \ | |
134 | ${QMAKE_FILE_NAME} \ |
|
135 | ${QMAKE_FILE_NAME} \ | |
135 | $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
136 | $$CHART_BUILD_PUBLIC_HEADER_DIR | |
136 | install_build_public_headers.CONFIG += target_predeps \ |
|
137 | install_build_public_headers.CONFIG += target_predeps \ | |
137 | no_link |
|
138 | no_link | |
138 |
|
139 | |||
139 | install_build_private_headers.name = build_private_headers |
|
140 | install_build_private_headers.name = build_private_headers | |
140 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
141 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
141 | install_build_private_headers.input = PRIVATE_HEADERS |
|
142 | install_build_private_headers.input = PRIVATE_HEADERS | |
142 | install_build_private_headers.commands = $$QMAKE_COPY \ |
|
143 | install_build_private_headers.commands = $$QMAKE_COPY \ | |
143 | ${QMAKE_FILE_NAME} \ |
|
144 | ${QMAKE_FILE_NAME} \ | |
144 | $$CHART_BUILD_PRIVATE_HEADER_DIR |
|
145 | $$CHART_BUILD_PRIVATE_HEADER_DIR | |
145 | install_build_private_headers.CONFIG += target_predeps \ |
|
146 | install_build_private_headers.CONFIG += target_predeps \ | |
146 | no_link |
|
147 | no_link | |
147 |
|
148 | |||
148 | QMAKE_EXTRA_COMPILERS += install_build_public_headers \ |
|
149 | QMAKE_EXTRA_COMPILERS += install_build_public_headers \ | |
149 | install_build_private_headers \ |
|
150 | install_build_private_headers \ | |
150 |
|
151 | |||
151 | win32:{ |
|
152 | win32:{ | |
152 | bintarget.CONFIG += no_check_exist |
|
153 | bintarget.CONFIG += no_check_exist | |
153 | !staticlib: { |
|
154 | !staticlib: { | |
154 | bintarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.dll |
|
155 | bintarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.dll | |
155 | } |
|
156 | } | |
156 | win32-msvc*:CONFIG(debug, debug|release): { |
|
157 | win32-msvc*:CONFIG(debug, debug|release): { | |
157 | bintarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.pdb |
|
158 | bintarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.pdb | |
158 | } |
|
159 | } | |
159 | bintarget.path = $$[QT_INSTALL_BINS] |
|
160 | bintarget.path = $$[QT_INSTALL_BINS] | |
160 |
|
161 | |||
161 | libtarget.CONFIG += no_check_exist |
|
162 | libtarget.CONFIG += no_check_exist | |
162 | libtarget.files = $$CHART_BUILD_LIB_DIR\\$${TARGET}.prl |
|
163 | libtarget.files = $$CHART_BUILD_LIB_DIR\\$${TARGET}.prl | |
163 | win32-msvc*: { |
|
164 | win32-msvc*: { | |
164 | libtarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.lib |
|
165 | libtarget.files += $$CHART_BUILD_LIB_DIR\\$${TARGET}.lib | |
165 | } else { |
|
166 | } else { | |
166 | libtarget.files += $$CHART_BUILD_LIB_DIR\\lib$${TARGET}.a |
|
167 | libtarget.files += $$CHART_BUILD_LIB_DIR\\lib$${TARGET}.a | |
167 | } |
|
168 | } | |
168 | libtarget.path = $$[QT_INSTALL_LIBS] |
|
169 | libtarget.path = $$[QT_INSTALL_LIBS] | |
169 |
|
170 | |||
170 | DLLDESTDIR = $$CHART_BUILD_BIN_DIR |
|
171 | DLLDESTDIR = $$CHART_BUILD_BIN_DIR | |
171 | INSTALLS += bintarget libtarget |
|
172 | INSTALLS += bintarget libtarget | |
172 | }else{ |
|
173 | }else{ | |
173 | target.path=$$[QT_INSTALL_LIBS] |
|
174 | target.path=$$[QT_INSTALL_LIBS] | |
174 | INSTALLS += target |
|
175 | INSTALLS += target | |
175 | } |
|
176 | } | |
176 |
|
177 | |||
177 | mac: !staticlib: { |
|
178 | mac: !staticlib: { | |
178 | # Update the name (id) of the library on OSX to point to the lib path |
|
179 | # Update the name (id) of the library on OSX to point to the lib path | |
179 | MAC_CHARTS_LIB_NAME = "lib"$$LIBRARY_NAME".1.dylib" |
|
180 | MAC_CHARTS_LIB_NAME = "lib"$$LIBRARY_NAME".1.dylib" | |
180 | QMAKE_POST_LINK += "install_name_tool -id $$CHART_BUILD_LIB_DIR"/"$$MAC_CHARTS_LIB_NAME $$CHART_BUILD_LIB_DIR"/"$$MAC_CHARTS_LIB_NAME" |
|
181 | QMAKE_POST_LINK += "install_name_tool -id $$CHART_BUILD_LIB_DIR"/"$$MAC_CHARTS_LIB_NAME $$CHART_BUILD_LIB_DIR"/"$$MAC_CHARTS_LIB_NAME" | |
181 |
|
182 | |||
182 | # Update the name (id) of the installed library on OSX to point to the installation path |
|
183 | # Update the name (id) of the installed library on OSX to point to the installation path | |
183 | postinstall.path = $$[QT_INSTALL_LIBS] |
|
184 | postinstall.path = $$[QT_INSTALL_LIBS] | |
184 | postinstall.extra = "install_name_tool -id $$[QT_INSTALL_LIBS]"/"$$MAC_CHARTS_LIB_NAME $$[QT_INSTALL_LIBS]"/"$$MAC_CHARTS_LIB_NAME" |
|
185 | postinstall.extra = "install_name_tool -id $$[QT_INSTALL_LIBS]"/"$$MAC_CHARTS_LIB_NAME $$[QT_INSTALL_LIBS]"/"$$MAC_CHARTS_LIB_NAME" | |
185 | INSTALLS += postinstall |
|
186 | INSTALLS += postinstall | |
186 | } |
|
187 | } | |
187 |
|
188 | |||
188 | ################################ DEVELOPMENT BUILD ########################################## |
|
189 | ################################ DEVELOPMENT BUILD ########################################## | |
189 | # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly. |
|
190 | # There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly. | |
190 | # This is the case at least with shadow builds. |
|
191 | # This is the case at least with shadow builds. | |
191 | # http://qt-project.org/wiki/jom |
|
192 | # http://qt-project.org/wiki/jom | |
192 |
|
193 | |||
193 | development_build:!win32-msvc*:{ |
|
194 | development_build:!win32-msvc*:{ | |
194 | chartversion.target = $$PWD/qchartversion_p.h |
|
195 | chartversion.target = $$PWD/qchartversion_p.h | |
195 |
|
196 | |||
196 | unix:{ |
|
197 | unix:{ | |
197 | chartversion.commands = @echo \ |
|
198 | chartversion.commands = @echo \ | |
198 | \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\ |
|
199 | \" $${LITERAL_HASH}ifndef QCHARTVERSION_P_H\\n\ | |
199 | $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\ |
|
200 | $${LITERAL_HASH}define QCHARTVERSION_P_H\\n\ | |
200 | const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\ |
|
201 | const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" ; \\n\ | |
201 | const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \ |
|
202 | const char *gitHead = \\\"`git rev-parse HEAD`\\\" ; \\n \ | |
202 | $${LITERAL_HASH}endif \" \ |
|
203 | $${LITERAL_HASH}endif \" \ | |
203 | > \ |
|
204 | > \ | |
204 | $$chartversion.target; |
|
205 | $$chartversion.target; | |
205 | }else{ |
|
206 | }else{ | |
206 | chartversion.commands = @echo \ |
|
207 | chartversion.commands = @echo \ | |
207 | "const char *buildTime = \"%date%_%time%\" ; \ |
|
208 | "const char *buildTime = \"%date%_%time%\" ; \ | |
208 | const char *gitHead = \"unknown\" ; " \ |
|
209 | const char *gitHead = \"unknown\" ; " \ | |
209 | > \ |
|
210 | > \ | |
210 | $$chartversion.target |
|
211 | $$chartversion.target | |
211 | } |
|
212 | } | |
212 |
|
213 | |||
213 | chartversion.depends = $$HEADERS \ |
|
214 | chartversion.depends = $$HEADERS \ | |
214 | $$SOURCES |
|
215 | $$SOURCES | |
215 |
|
216 | |||
216 | PRE_TARGETDEPS += $$chartversion.target |
|
217 | PRE_TARGETDEPS += $$chartversion.target | |
217 | QMAKE_CLEAN += $$PWD/qchartversion_p.h |
|
218 | QMAKE_CLEAN += $$PWD/qchartversion_p.h | |
218 | QMAKE_EXTRA_TARGETS += chartversion |
|
219 | QMAKE_EXTRA_TARGETS += chartversion | |
219 | } |
|
220 | } | |
220 |
|
221 | |||
221 | ############################### CLEAN ########################################### |
|
222 | ############################### CLEAN ########################################### | |
222 |
|
223 | |||
223 | unix:QMAKE_DISTCLEAN += -r \ |
|
224 | unix:QMAKE_DISTCLEAN += -r \ | |
224 | $$CHART_BUILD_HEADER_DIR \ |
|
225 | $$CHART_BUILD_HEADER_DIR \ | |
225 | $$CHART_BUILD_LIB_DIR |
|
226 | $$CHART_BUILD_LIB_DIR | |
226 | win32:QMAKE_DISTCLEAN += /Q \ |
|
227 | win32:QMAKE_DISTCLEAN += /Q \ | |
227 | $$CHART_BUILD_HEADER_DIR \ |
|
228 | $$CHART_BUILD_HEADER_DIR \ | |
228 | $$CHART_BUILD_LIB_DIR |
|
229 | $$CHART_BUILD_LIB_DIR | |
229 |
|
230 | |||
230 | ############################## COVERAGE ######################################### |
|
231 | ############################## COVERAGE ######################################### | |
231 |
|
232 | |||
232 | unix:coverage:{ |
|
233 | unix:coverage:{ | |
233 |
|
234 | |||
234 | QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage |
|
235 | QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage | |
235 | QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage |
|
236 | QMAKE_LDFLAGS += -fprofile-arcs -ftest-coverage | |
236 |
|
237 | |||
237 | LIBS += -lgcov |
|
238 | LIBS += -lgcov | |
238 |
|
239 | |||
239 | QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info |
|
240 | QMAKE_CLEAN += $$OBJECTS_DIR/*.gcda $$OBJECTS_DIR/*.gcno $$PWD/*.gcov ../coverage/*.info | |
240 | QMAKE_EXTRA_TARGETS += preparecoverage gencoverage |
|
241 | QMAKE_EXTRA_TARGETS += preparecoverage gencoverage | |
241 |
|
242 | |||
242 | preparecoverage.target = prepare_coverage |
|
243 | preparecoverage.target = prepare_coverage | |
243 | preparecoverage.depends = all |
|
244 | preparecoverage.depends = all | |
244 | preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\ |
|
245 | preparecoverage.commands = lcov --directory $$OBJECTS_DIR --zerocounters ;\ | |
245 | lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD; |
|
246 | lcov -i -d $$OBJECTS_DIR -c -o ../coverage/base.info -b $$PWD; | |
246 |
|
247 | |||
247 | gencoverage.target = gen_coverage |
|
248 | gencoverage.target = gen_coverage | |
248 | gencoverage.depends = all |
|
249 | gencoverage.depends = all | |
249 | gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\ |
|
250 | gencoverage.commands = lcov -d $$OBJECTS_DIR -c -o ../coverage/src.info -b $$PWD;\ | |
250 | lcov -e ../coverage/base.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/base.info;\ |
|
251 | lcov -e ../coverage/base.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/base.info;\ | |
251 | lcov -e ../coverage/src.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/src.info;\ |
|
252 | lcov -e ../coverage/src.info $$PWD/* $$PWD/animations/* $$PWD/areachart/* $$PWD/axis/* $$PWD/barchart/* $$PWD/legend/* $$PWD/linechart/* $$PWD/piechart/* $$PWD/scatterchart/* $$PWD/splinechart/* $$PWD/themes/* $$PWD/xychart/* -o ../coverage/src.info;\ | |
252 | lcov -a ../coverage/base.info -a ../coverage/src.info -o ../coverage/coverage.info; |
|
253 | lcov -a ../coverage/base.info -a ../coverage/src.info -o ../coverage/coverage.info; | |
253 | } |
|
254 | } | |
254 |
|
255 |
@@ -1,531 +1,539 | |||||
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 "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "abstractdomain_p.h" |
|
23 | #include "abstractdomain_p.h" | |
24 | #include "qvalueaxis.h" |
|
24 | #include "qvalueaxis.h" | |
25 | #include "xychart_p.h" |
|
25 | #include "xychart_p.h" | |
26 | #include "qxylegendmarker.h" |
|
26 | #include "qxylegendmarker.h" | |
|
27 | #include "charthelpers_p.h" | |||
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
30 | |||
30 | /*! |
|
31 | /*! | |
31 | \class QXYSeries |
|
32 | \class QXYSeries | |
32 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
33 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
33 | */ |
|
34 | */ | |
34 | /*! |
|
35 | /*! | |
35 | \qmlclass XYSeries |
|
36 | \qmlclass XYSeries | |
36 | \inherits AbstractSeries |
|
37 | \inherits AbstractSeries | |
37 | The XYSeries class is a base class for line, spline and scatter series. |
|
38 | The XYSeries class is a base class for line, spline and scatter series. | |
38 |
|
39 | |||
39 | The class cannot be instantiated directly. |
|
40 | The class cannot be instantiated directly. | |
40 | */ |
|
41 | */ | |
41 |
|
42 | |||
42 | /*! |
|
43 | /*! | |
43 | \qmlproperty AbstractAxis XYSeries::axisX |
|
44 | \qmlproperty AbstractAxis XYSeries::axisX | |
44 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for |
|
45 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for | |
45 | the series. |
|
46 | the series. | |
46 | \sa axisXTop |
|
47 | \sa axisXTop | |
47 | */ |
|
48 | */ | |
48 |
|
49 | |||
49 | /*! |
|
50 | /*! | |
50 | \qmlproperty AbstractAxis XYSeries::axisY |
|
51 | \qmlproperty AbstractAxis XYSeries::axisY | |
51 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for |
|
52 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for | |
52 | the series. |
|
53 | the series. | |
53 | \sa axisYRight |
|
54 | \sa axisYRight | |
54 | */ |
|
55 | */ | |
55 |
|
56 | |||
56 | /*! |
|
57 | /*! | |
57 | \qmlproperty AbstractAxis XYSeries::axisXTop |
|
58 | \qmlproperty AbstractAxis XYSeries::axisXTop | |
58 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or |
|
59 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or | |
59 | axisXTop, but not both. |
|
60 | axisXTop, but not both. | |
60 | \sa axisX |
|
61 | \sa axisX | |
61 | */ |
|
62 | */ | |
62 |
|
63 | |||
63 | /*! |
|
64 | /*! | |
64 | \qmlproperty AbstractAxis XYSeries::axisYRight |
|
65 | \qmlproperty AbstractAxis XYSeries::axisYRight | |
65 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY |
|
66 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY | |
66 | or axisYRight, but not both. |
|
67 | or axisYRight, but not both. | |
67 | \sa axisY |
|
68 | \sa axisY | |
68 | */ |
|
69 | */ | |
69 |
|
70 | |||
70 | /*! |
|
71 | /*! | |
71 | \property QXYSeries::pointsVisible |
|
72 | \property QXYSeries::pointsVisible | |
72 | Controls if the data points are visible and should be drawn. |
|
73 | Controls if the data points are visible and should be drawn. | |
73 | */ |
|
74 | */ | |
74 | /*! |
|
75 | /*! | |
75 | \qmlproperty bool XYSeries::pointsVisible |
|
76 | \qmlproperty bool XYSeries::pointsVisible | |
76 | Controls if the data points are visible and should be drawn. |
|
77 | Controls if the data points are visible and should be drawn. | |
77 | */ |
|
78 | */ | |
78 |
|
79 | |||
79 | /*! |
|
80 | /*! | |
80 | \fn QPen QXYSeries::pen() const |
|
81 | \fn QPen QXYSeries::pen() const | |
81 | \brief Returns pen used to draw points for series. |
|
82 | \brief Returns pen used to draw points for series. | |
82 | \sa setPen() |
|
83 | \sa setPen() | |
83 | */ |
|
84 | */ | |
84 |
|
85 | |||
85 | /*! |
|
86 | /*! | |
86 | \fn QBrush QXYSeries::brush() const |
|
87 | \fn QBrush QXYSeries::brush() const | |
87 | \brief Returns brush used to draw points for series. |
|
88 | \brief Returns brush used to draw points for series. | |
88 | \sa setBrush() |
|
89 | \sa setBrush() | |
89 | */ |
|
90 | */ | |
90 |
|
91 | |||
91 | /*! |
|
92 | /*! | |
92 | \property QXYSeries::color |
|
93 | \property QXYSeries::color | |
93 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
94 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and | |
94 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
95 | fill (brush) color in case of QScatterSeries or QAreaSeries. | |
95 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
96 | \sa QXYSeries::pen(), QXYSeries::brush() | |
96 | */ |
|
97 | */ | |
97 | /*! |
|
98 | /*! | |
98 | \qmlproperty color XYSeries::color |
|
99 | \qmlproperty color XYSeries::color | |
99 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
100 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and | |
100 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
101 | fill (brush) color in case of ScatterSeries or AreaSeries. | |
101 | */ |
|
102 | */ | |
102 |
|
103 | |||
103 | /*! |
|
104 | /*! | |
104 | \fn void QXYSeries::clicked(const QPointF& point) |
|
105 | \fn void QXYSeries::clicked(const QPointF& point) | |
105 | \brief Signal is emitted when user clicks the \a point on chart. |
|
106 | \brief Signal is emitted when user clicks the \a point on chart. | |
106 | */ |
|
107 | */ | |
107 | /*! |
|
108 | /*! | |
108 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
109 | \qmlsignal XYSeries::onClicked(QPointF point) | |
109 | Signal is emitted when user clicks the \a point on chart. For example: |
|
110 | Signal is emitted when user clicks the \a point on chart. For example: | |
110 | \code |
|
111 | \code | |
111 | LineSeries { |
|
112 | LineSeries { | |
112 | XYPoint { x: 0; y: 0 } |
|
113 | XYPoint { x: 0; y: 0 } | |
113 | XYPoint { x: 1.1; y: 2.1 } |
|
114 | XYPoint { x: 1.1; y: 2.1 } | |
114 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
115 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
115 | } |
|
116 | } | |
116 | \endcode |
|
117 | \endcode | |
117 | */ |
|
118 | */ | |
118 |
|
119 | |||
119 | /*! |
|
120 | /*! | |
120 | \fn void QXYSeries::hovered(const QPointF &point, bool state) |
|
121 | \fn void QXYSeries::hovered(const QPointF &point, bool state) | |
121 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
122 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |
122 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
123 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |
123 | the series. |
|
124 | the series. | |
124 | */ |
|
125 | */ | |
125 | /*! |
|
126 | /*! | |
126 | \qmlsignal XYSeries::onHovered(point point, bool state) |
|
127 | \qmlsignal XYSeries::onHovered(point point, bool state) | |
127 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) |
|
128 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |
128 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from |
|
129 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |
129 | the series. |
|
130 | the series. | |
130 | */ |
|
131 | */ | |
131 |
|
132 | |||
132 | /*! |
|
133 | /*! | |
133 | \fn void QXYSeries::pointReplaced(int index) |
|
134 | \fn void QXYSeries::pointReplaced(int index) | |
134 | Signal is emitted when a point has been replaced at \a index. |
|
135 | Signal is emitted when a point has been replaced at \a index. | |
135 | \sa replace() |
|
136 | \sa replace() | |
136 | */ |
|
137 | */ | |
137 | /*! |
|
138 | /*! | |
138 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
139 | \qmlsignal XYSeries::onPointReplaced(int index) | |
139 | Signal is emitted when a point has been replaced at \a index. |
|
140 | Signal is emitted when a point has been replaced at \a index. | |
140 | */ |
|
141 | */ | |
141 |
|
142 | |||
142 | /*! |
|
143 | /*! | |
143 | \fn void QXYSeries::pointsReplaced() |
|
144 | \fn void QXYSeries::pointsReplaced() | |
144 | Signal is emitted when all points have been replaced with another points. |
|
145 | Signal is emitted when all points have been replaced with another points. | |
145 | \sa replace() |
|
146 | \sa replace() | |
146 | */ |
|
147 | */ | |
147 | /*! |
|
148 | /*! | |
148 | \qmlsignal XYSeries::onPointsReplaced() |
|
149 | \qmlsignal XYSeries::onPointsReplaced() | |
149 | */ |
|
150 | */ | |
150 |
|
151 | |||
151 | /*! |
|
152 | /*! | |
152 | \fn void QXYSeries::pointAdded(int index) |
|
153 | \fn void QXYSeries::pointAdded(int index) | |
153 | Signal is emitted when a point has been added at \a index. |
|
154 | Signal is emitted when a point has been added at \a index. | |
154 | \sa append(), insert() |
|
155 | \sa append(), insert() | |
155 | */ |
|
156 | */ | |
156 | /*! |
|
157 | /*! | |
157 | \qmlsignal XYSeries::onPointAdded(int index) |
|
158 | \qmlsignal XYSeries::onPointAdded(int index) | |
158 | Signal is emitted when a point has been added at \a index. |
|
159 | Signal is emitted when a point has been added at \a index. | |
159 | */ |
|
160 | */ | |
160 |
|
161 | |||
161 | /*! |
|
162 | /*! | |
162 | \fn void QXYSeries::pointRemoved(int index) |
|
163 | \fn void QXYSeries::pointRemoved(int index) | |
163 | Signal is emitted when a point has been removed from \a index. |
|
164 | Signal is emitted when a point has been removed from \a index. | |
164 | \sa remove() |
|
165 | \sa remove() | |
165 | */ |
|
166 | */ | |
166 | /*! |
|
167 | /*! | |
167 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
168 | \qmlsignal XYSeries::onPointRemoved(int index) | |
168 | Signal is emitted when a point has been removed from \a index. |
|
169 | Signal is emitted when a point has been removed from \a index. | |
169 | */ |
|
170 | */ | |
170 |
|
171 | |||
171 | /*! |
|
172 | /*! | |
172 | \fn void QXYSeries::colorChanged(QColor color) |
|
173 | \fn void QXYSeries::colorChanged(QColor color) | |
173 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
174 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
174 | */ |
|
175 | */ | |
175 | /*! |
|
176 | /*! | |
176 | \qmlsignal XYSeries::onColorChanged(color color) |
|
177 | \qmlsignal XYSeries::onColorChanged(color color) | |
177 | Signal is emitted when the line (pen) color has changed to \a color. |
|
178 | Signal is emitted when the line (pen) color has changed to \a color. | |
178 | */ |
|
179 | */ | |
179 |
|
180 | |||
180 | /*! |
|
181 | /*! | |
181 | \fn void QXYSeriesPrivate::updated() |
|
182 | \fn void QXYSeriesPrivate::updated() | |
182 | \brief \internal |
|
183 | \brief \internal | |
183 | */ |
|
184 | */ | |
184 |
|
185 | |||
185 | /*! |
|
186 | /*! | |
186 | \qmlmethod XYSeries::append(real x, real y) |
|
187 | \qmlmethod XYSeries::append(real x, real y) | |
187 | Append point (\a x, \a y) to the series |
|
188 | Append point (\a x, \a y) to the series | |
188 | */ |
|
189 | */ | |
189 |
|
190 | |||
190 | /*! |
|
191 | /*! | |
191 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
192 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
192 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
193 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
193 | exist. |
|
194 | exist. | |
194 | */ |
|
195 | */ | |
195 |
|
196 | |||
196 | /*! |
|
197 | /*! | |
197 | \qmlmethod XYSeries::remove(real x, real y) |
|
198 | \qmlmethod XYSeries::remove(real x, real y) | |
198 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
199 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
199 | */ |
|
200 | */ | |
200 |
|
201 | |||
201 | /*! |
|
202 | /*! | |
202 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
203 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
203 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
204 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of | |
204 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
205 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
205 | */ |
|
206 | */ | |
206 |
|
207 | |||
207 | /*! |
|
208 | /*! | |
208 | \qmlmethod QPointF XYSeries::at(int index) |
|
209 | \qmlmethod QPointF XYSeries::at(int index) | |
209 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
210 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
210 | */ |
|
211 | */ | |
211 |
|
212 | |||
212 | /*! |
|
213 | /*! | |
213 | \internal |
|
214 | \internal | |
214 |
|
215 | |||
215 | Constructs empty series object which is a child of \a parent. |
|
216 | Constructs empty series object which is a child of \a parent. | |
216 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
217 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
217 | */ |
|
218 | */ | |
218 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) |
|
219 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) | |
219 | : QAbstractSeries(d, parent) |
|
220 | : QAbstractSeries(d, parent) | |
220 | { |
|
221 | { | |
221 | } |
|
222 | } | |
222 |
|
223 | |||
223 | /*! |
|
224 | /*! | |
224 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
225 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
225 | and are deleted when mentioned object are destroyed. |
|
226 | and are deleted when mentioned object are destroyed. | |
226 | */ |
|
227 | */ | |
227 | QXYSeries::~QXYSeries() |
|
228 | QXYSeries::~QXYSeries() | |
228 | { |
|
229 | { | |
229 | } |
|
230 | } | |
230 |
|
231 | |||
231 | /*! |
|
232 | /*! | |
232 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
233 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
233 | */ |
|
234 | */ | |
234 | void QXYSeries::append(qreal x, qreal y) |
|
235 | void QXYSeries::append(qreal x, qreal y) | |
235 | { |
|
236 | { | |
236 | append(QPointF(x, y)); |
|
237 | append(QPointF(x, y)); | |
237 | } |
|
238 | } | |
238 |
|
239 | |||
239 | /*! |
|
240 | /*! | |
240 | This is an overloaded function. |
|
241 | This is an overloaded function. | |
241 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
242 | Adds data \a point to the series. Points are connected with lines on the chart. | |
242 | */ |
|
243 | */ | |
243 | void QXYSeries::append(const QPointF &point) |
|
244 | void QXYSeries::append(const QPointF &point) | |
244 | { |
|
245 | { | |
245 | Q_D(QXYSeries); |
|
246 | Q_D(QXYSeries); | |
246 | d->m_points << point; |
|
247 | ||
247 | emit pointAdded(d->m_points.count() - 1); |
|
248 | if (isValidValue(point)) { | |
|
249 | d->m_points << point; | |||
|
250 | emit pointAdded(d->m_points.count() - 1); | |||
|
251 | } | |||
248 | } |
|
252 | } | |
249 |
|
253 | |||
250 | /*! |
|
254 | /*! | |
251 | This is an overloaded function. |
|
255 | This is an overloaded function. | |
252 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
256 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
253 | */ |
|
257 | */ | |
254 | void QXYSeries::append(const QList<QPointF> &points) |
|
258 | void QXYSeries::append(const QList<QPointF> &points) | |
255 | { |
|
259 | { | |
256 | foreach (const QPointF &point , points) |
|
260 | foreach (const QPointF &point , points) | |
257 | append(point); |
|
261 | append(point); | |
258 | } |
|
262 | } | |
259 |
|
263 | |||
260 | /*! |
|
264 | /*! | |
261 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
265 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
262 | \sa QXYSeries::pointReplaced() |
|
266 | \sa QXYSeries::pointReplaced() | |
263 | */ |
|
267 | */ | |
264 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
268 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
265 | { |
|
269 | { | |
266 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); |
|
270 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); | |
267 | } |
|
271 | } | |
268 |
|
272 | |||
269 | /*! |
|
273 | /*! | |
270 | Replaces \a oldPoint with \a newPoint. |
|
274 | Replaces \a oldPoint with \a newPoint. | |
271 | \sa QXYSeries::pointReplaced() |
|
275 | \sa QXYSeries::pointReplaced() | |
272 | */ |
|
276 | */ | |
273 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) |
|
277 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) | |
274 | { |
|
278 | { | |
275 | Q_D(QXYSeries); |
|
279 | Q_D(QXYSeries); | |
276 | int index = d->m_points.indexOf(oldPoint); |
|
280 | int index = d->m_points.indexOf(oldPoint); | |
277 | if (index == -1) |
|
281 | if (index == -1) | |
278 | return; |
|
282 | return; | |
279 | d->m_points[index] = newPoint; |
|
283 | if (isValidValue(newPoint)) { | |
280 | emit pointReplaced(index); |
|
284 | d->m_points[index] = newPoint; | |
|
285 | emit pointReplaced(index); | |||
|
286 | } | |||
281 | } |
|
287 | } | |
282 |
|
288 | |||
283 | /*! |
|
289 | /*! | |
284 | Replaces the current points with \a points. This is faster than replacing data points one by one, |
|
290 | Replaces the current points with \a points. This is faster than replacing data points one by one, | |
285 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
291 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() | |
286 | when the points have been replaced. |
|
292 | when the points have been replaced. | |
287 | \sa QXYSeries::pointsReplaced() |
|
293 | \sa QXYSeries::pointsReplaced() | |
288 | */ |
|
294 | */ | |
289 | void QXYSeries::replace(QList<QPointF> points) |
|
295 | void QXYSeries::replace(QList<QPointF> points) | |
290 | { |
|
296 | { | |
291 | Q_D(QXYSeries); |
|
297 | Q_D(QXYSeries); | |
292 | d->m_points = points.toVector(); |
|
298 | d->m_points = points.toVector(); | |
293 | emit pointsReplaced(); |
|
299 | emit pointsReplaced(); | |
294 | } |
|
300 | } | |
295 |
|
301 | |||
296 | /*! |
|
302 | /*! | |
297 | Removes current \a x and \a y value. |
|
303 | Removes current \a x and \a y value. | |
298 | */ |
|
304 | */ | |
299 | void QXYSeries::remove(qreal x, qreal y) |
|
305 | void QXYSeries::remove(qreal x, qreal y) | |
300 | { |
|
306 | { | |
301 | remove(QPointF(x, y)); |
|
307 | remove(QPointF(x, y)); | |
302 | } |
|
308 | } | |
303 |
|
309 | |||
304 | /*! |
|
310 | /*! | |
305 | Removes current \a point x value. |
|
311 | Removes current \a point x value. | |
306 |
|
312 | |||
307 | Note: point y value is ignored. |
|
313 | Note: point y value is ignored. | |
308 | */ |
|
314 | */ | |
309 | void QXYSeries::remove(const QPointF &point) |
|
315 | void QXYSeries::remove(const QPointF &point) | |
310 | { |
|
316 | { | |
311 | Q_D(QXYSeries); |
|
317 | Q_D(QXYSeries); | |
312 | int index = d->m_points.indexOf(point); |
|
318 | int index = d->m_points.indexOf(point); | |
313 | if (index == -1) |
|
319 | if (index == -1) | |
314 | return; |
|
320 | return; | |
315 | d->m_points.remove(index); |
|
321 | d->m_points.remove(index); | |
316 | emit pointRemoved(index); |
|
322 | emit pointRemoved(index); | |
317 | } |
|
323 | } | |
318 |
|
324 | |||
319 | /*! |
|
325 | /*! | |
320 | Inserts a \a point in the series at \a index position. |
|
326 | Inserts a \a point in the series at \a index position. | |
321 | */ |
|
327 | */ | |
322 | void QXYSeries::insert(int index, const QPointF &point) |
|
328 | void QXYSeries::insert(int index, const QPointF &point) | |
323 | { |
|
329 | { | |
324 | Q_D(QXYSeries); |
|
330 | Q_D(QXYSeries); | |
325 | d->m_points.insert(index, point); |
|
331 | if (isValidValue(point)) { | |
326 | emit pointAdded(index); |
|
332 | d->m_points.insert(index, point); | |
|
333 | emit pointAdded(index); | |||
|
334 | } | |||
327 | } |
|
335 | } | |
328 |
|
336 | |||
329 | /*! |
|
337 | /*! | |
330 | Removes all points from the series. |
|
338 | Removes all points from the series. | |
331 | */ |
|
339 | */ | |
332 | void QXYSeries::clear() |
|
340 | void QXYSeries::clear() | |
333 | { |
|
341 | { | |
334 | Q_D(QXYSeries); |
|
342 | Q_D(QXYSeries); | |
335 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
343 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
336 | remove(d->m_points.at(i)); |
|
344 | remove(d->m_points.at(i)); | |
337 | } |
|
345 | } | |
338 |
|
346 | |||
339 | /*! |
|
347 | /*! | |
340 | Returns list of points in the series. |
|
348 | Returns list of points in the series. | |
341 | */ |
|
349 | */ | |
342 | QList<QPointF> QXYSeries::points() const |
|
350 | QList<QPointF> QXYSeries::points() const | |
343 | { |
|
351 | { | |
344 | Q_D(const QXYSeries); |
|
352 | Q_D(const QXYSeries); | |
345 | return d->m_points.toList(); |
|
353 | return d->m_points.toList(); | |
346 | } |
|
354 | } | |
347 |
|
355 | |||
348 | /*! |
|
356 | /*! | |
349 | Returns number of data points within series. |
|
357 | Returns number of data points within series. | |
350 | */ |
|
358 | */ | |
351 | int QXYSeries::count() const |
|
359 | int QXYSeries::count() const | |
352 | { |
|
360 | { | |
353 | Q_D(const QXYSeries); |
|
361 | Q_D(const QXYSeries); | |
354 | return d->m_points.count(); |
|
362 | return d->m_points.count(); | |
355 | } |
|
363 | } | |
356 |
|
364 | |||
357 |
|
365 | |||
358 | /*! |
|
366 | /*! | |
359 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
367 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
360 | pen from chart theme is used. |
|
368 | pen from chart theme is used. | |
361 | \sa QChart::setTheme() |
|
369 | \sa QChart::setTheme() | |
362 | */ |
|
370 | */ | |
363 | void QXYSeries::setPen(const QPen &pen) |
|
371 | void QXYSeries::setPen(const QPen &pen) | |
364 | { |
|
372 | { | |
365 | Q_D(QXYSeries); |
|
373 | Q_D(QXYSeries); | |
366 | if (d->m_pen != pen) { |
|
374 | if (d->m_pen != pen) { | |
367 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
375 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |
368 | d->m_pen = pen; |
|
376 | d->m_pen = pen; | |
369 | emit d->updated(); |
|
377 | emit d->updated(); | |
370 | if (emitColorChanged) |
|
378 | if (emitColorChanged) | |
371 | emit colorChanged(pen.color()); |
|
379 | emit colorChanged(pen.color()); | |
372 | } |
|
380 | } | |
373 | } |
|
381 | } | |
374 |
|
382 | |||
375 | QPen QXYSeries::pen() const |
|
383 | QPen QXYSeries::pen() const | |
376 | { |
|
384 | { | |
377 | Q_D(const QXYSeries); |
|
385 | Q_D(const QXYSeries); | |
378 | return d->m_pen; |
|
386 | return d->m_pen; | |
379 | } |
|
387 | } | |
380 |
|
388 | |||
381 | /*! |
|
389 | /*! | |
382 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
390 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
383 | from chart theme setting is used. |
|
391 | from chart theme setting is used. | |
384 | \sa QChart::setTheme() |
|
392 | \sa QChart::setTheme() | |
385 | */ |
|
393 | */ | |
386 | void QXYSeries::setBrush(const QBrush &brush) |
|
394 | void QXYSeries::setBrush(const QBrush &brush) | |
387 | { |
|
395 | { | |
388 | Q_D(QXYSeries); |
|
396 | Q_D(QXYSeries); | |
389 | if (d->m_brush != brush) { |
|
397 | if (d->m_brush != brush) { | |
390 | d->m_brush = brush; |
|
398 | d->m_brush = brush; | |
391 | emit d->updated(); |
|
399 | emit d->updated(); | |
392 | } |
|
400 | } | |
393 | } |
|
401 | } | |
394 |
|
402 | |||
395 | QBrush QXYSeries::brush() const |
|
403 | QBrush QXYSeries::brush() const | |
396 | { |
|
404 | { | |
397 | Q_D(const QXYSeries); |
|
405 | Q_D(const QXYSeries); | |
398 | return d->m_brush; |
|
406 | return d->m_brush; | |
399 | } |
|
407 | } | |
400 |
|
408 | |||
401 | void QXYSeries::setColor(const QColor &color) |
|
409 | void QXYSeries::setColor(const QColor &color) | |
402 | { |
|
410 | { | |
403 | QPen p = pen(); |
|
411 | QPen p = pen(); | |
404 | if (p.color() != color) { |
|
412 | if (p.color() != color) { | |
405 | p.setColor(color); |
|
413 | p.setColor(color); | |
406 | setPen(p); |
|
414 | setPen(p); | |
407 | } |
|
415 | } | |
408 | } |
|
416 | } | |
409 |
|
417 | |||
410 | QColor QXYSeries::color() const |
|
418 | QColor QXYSeries::color() const | |
411 | { |
|
419 | { | |
412 | return pen().color(); |
|
420 | return pen().color(); | |
413 | } |
|
421 | } | |
414 |
|
422 | |||
415 | void QXYSeries::setPointsVisible(bool visible) |
|
423 | void QXYSeries::setPointsVisible(bool visible) | |
416 | { |
|
424 | { | |
417 | Q_D(QXYSeries); |
|
425 | Q_D(QXYSeries); | |
418 | if (d->m_pointsVisible != visible) { |
|
426 | if (d->m_pointsVisible != visible) { | |
419 | d->m_pointsVisible = visible; |
|
427 | d->m_pointsVisible = visible; | |
420 | emit d->updated(); |
|
428 | emit d->updated(); | |
421 | } |
|
429 | } | |
422 | } |
|
430 | } | |
423 |
|
431 | |||
424 | bool QXYSeries::pointsVisible() const |
|
432 | bool QXYSeries::pointsVisible() const | |
425 | { |
|
433 | { | |
426 | Q_D(const QXYSeries); |
|
434 | Q_D(const QXYSeries); | |
427 | return d->m_pointsVisible; |
|
435 | return d->m_pointsVisible; | |
428 | } |
|
436 | } | |
429 |
|
437 | |||
430 |
|
438 | |||
431 | /*! |
|
439 | /*! | |
432 | Stream operator for adding a data \a point to the series. |
|
440 | Stream operator for adding a data \a point to the series. | |
433 | \sa append() |
|
441 | \sa append() | |
434 | */ |
|
442 | */ | |
435 | QXYSeries &QXYSeries::operator<< (const QPointF &point) |
|
443 | QXYSeries &QXYSeries::operator<< (const QPointF &point) | |
436 | { |
|
444 | { | |
437 | append(point); |
|
445 | append(point); | |
438 | return *this; |
|
446 | return *this; | |
439 | } |
|
447 | } | |
440 |
|
448 | |||
441 |
|
449 | |||
442 | /*! |
|
450 | /*! | |
443 | Stream operator for adding a list of \a points to the series. |
|
451 | Stream operator for adding a list of \a points to the series. | |
444 | \sa append() |
|
452 | \sa append() | |
445 | */ |
|
453 | */ | |
446 |
|
454 | |||
447 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) |
|
455 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) | |
448 | { |
|
456 | { | |
449 | append(points); |
|
457 | append(points); | |
450 | return *this; |
|
458 | return *this; | |
451 | } |
|
459 | } | |
452 |
|
460 | |||
453 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
461 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
454 |
|
462 | |||
455 |
|
463 | |||
456 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) |
|
464 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) | |
457 | : QAbstractSeriesPrivate(q), |
|
465 | : QAbstractSeriesPrivate(q), | |
458 | m_pointsVisible(false) |
|
466 | m_pointsVisible(false) | |
459 | { |
|
467 | { | |
460 | } |
|
468 | } | |
461 |
|
469 | |||
462 | void QXYSeriesPrivate::initializeDomain() |
|
470 | void QXYSeriesPrivate::initializeDomain() | |
463 | { |
|
471 | { | |
464 | qreal minX(0); |
|
472 | qreal minX(0); | |
465 | qreal minY(0); |
|
473 | qreal minY(0); | |
466 | qreal maxX(1); |
|
474 | qreal maxX(1); | |
467 | qreal maxY(1); |
|
475 | qreal maxY(1); | |
468 |
|
476 | |||
469 | Q_Q(QXYSeries); |
|
477 | Q_Q(QXYSeries); | |
470 |
|
478 | |||
471 | const QList<QPointF>& points = q->points(); |
|
479 | const QList<QPointF>& points = q->points(); | |
472 |
|
480 | |||
473 | if (!points.isEmpty()) { |
|
481 | if (!points.isEmpty()) { | |
474 | minX = points[0].x(); |
|
482 | minX = points[0].x(); | |
475 | minY = points[0].y(); |
|
483 | minY = points[0].y(); | |
476 | maxX = minX; |
|
484 | maxX = minX; | |
477 | maxY = minY; |
|
485 | maxY = minY; | |
478 |
|
486 | |||
479 | for (int i = 0; i < points.count(); i++) { |
|
487 | for (int i = 0; i < points.count(); i++) { | |
480 | qreal x = points[i].x(); |
|
488 | qreal x = points[i].x(); | |
481 | qreal y = points[i].y(); |
|
489 | qreal y = points[i].y(); | |
482 | minX = qMin(minX, x); |
|
490 | minX = qMin(minX, x); | |
483 | minY = qMin(minY, y); |
|
491 | minY = qMin(minY, y); | |
484 | maxX = qMax(maxX, x); |
|
492 | maxX = qMax(maxX, x); | |
485 | maxY = qMax(maxY, y); |
|
493 | maxY = qMax(maxY, y); | |
486 | } |
|
494 | } | |
487 | } |
|
495 | } | |
488 |
|
496 | |||
489 | domain()->setRange(minX, maxX, minY, maxY); |
|
497 | domain()->setRange(minX, maxX, minY, maxY); | |
490 | } |
|
498 | } | |
491 |
|
499 | |||
492 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
500 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) | |
493 | { |
|
501 | { | |
494 | Q_Q(QXYSeries); |
|
502 | Q_Q(QXYSeries); | |
495 | QList<QLegendMarker*> list; |
|
503 | QList<QLegendMarker*> list; | |
496 | return list << new QXYLegendMarker(q,legend); |
|
504 | return list << new QXYLegendMarker(q,legend); | |
497 | } |
|
505 | } | |
498 |
|
506 | |||
499 | void QXYSeriesPrivate::initializeAxes() |
|
507 | void QXYSeriesPrivate::initializeAxes() | |
500 | { |
|
508 | { | |
501 |
|
509 | |||
502 | } |
|
510 | } | |
503 |
|
511 | |||
504 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
512 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
505 | { |
|
513 | { | |
506 | Q_UNUSED(orientation); |
|
514 | Q_UNUSED(orientation); | |
507 | return QAbstractAxis::AxisTypeValue; |
|
515 | return QAbstractAxis::AxisTypeValue; | |
508 | } |
|
516 | } | |
509 |
|
517 | |||
510 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
518 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
511 | { |
|
519 | { | |
512 | Q_UNUSED(orientation); |
|
520 | Q_UNUSED(orientation); | |
513 | return 0; |
|
521 | return 0; | |
514 | } |
|
522 | } | |
515 |
|
523 | |||
516 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) |
|
524 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
517 | { |
|
525 | { | |
518 | XYChart *item = static_cast<XYChart *>(m_item.data()); |
|
526 | XYChart *item = static_cast<XYChart *>(m_item.data()); | |
519 | Q_ASSERT(item); |
|
527 | Q_ASSERT(item); | |
520 | if (options.testFlag(QChart::SeriesAnimations)) { |
|
528 | if (options.testFlag(QChart::SeriesAnimations)) { | |
521 | item->setAnimation(new XYAnimation(item)); |
|
529 | item->setAnimation(new XYAnimation(item)); | |
522 | }else{ |
|
530 | }else{ | |
523 | item->setAnimation(0); |
|
531 | item->setAnimation(0); | |
524 | } |
|
532 | } | |
525 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
533 | QAbstractSeriesPrivate::initializeAnimations(options); | |
526 | } |
|
534 | } | |
527 |
|
535 | |||
528 | #include "moc_qxyseries.cpp" |
|
536 | #include "moc_qxyseries.cpp" | |
529 | #include "moc_qxyseries_p.cpp" |
|
537 | #include "moc_qxyseries_p.cpp" | |
530 |
|
538 | |||
531 | QTCOMMERCIALCHART_END_NAMESPACE |
|
539 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now