@@ -1,374 +1,384 | |||||
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 "qlogvalueaxis.h" |
|
21 | #include "qlogvalueaxis.h" | |
22 | #include "qlogvalueaxis_p.h" |
|
22 | #include "qlogvalueaxis_p.h" | |
23 | #include "chartlogvalueaxisx_p.h" |
|
23 | #include "chartlogvalueaxisx_p.h" | |
24 | #include "chartlogvalueaxisy_p.h" |
|
24 | #include "chartlogvalueaxisy_p.h" | |
25 | #include "abstractdomain_p.h" |
|
25 | #include "abstractdomain_p.h" | |
26 | #include <float.h> |
|
26 | #include <float.h> | |
27 | #include <cmath> |
|
27 | #include <cmath> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | /*! |
|
30 | /*! | |
31 | \class QLogValueAxis |
|
31 | \class QLogValueAxis | |
32 | \brief The QLogValueAxis class is used for manipulating chart's axis. |
|
32 | \brief The QLogValueAxis class is used for manipulating chart's axis. | |
33 | \mainclass |
|
33 | \mainclass | |
|
34 | ||||
|
35 | \note If a QLogValueAxis is attached to a series with one or more points with | |||
|
36 | negative or zero values on the associated dimension, the series will not be | |||
|
37 | plotted at all. This is particularly relevant when XYModelMappers are used, | |||
|
38 | since empty cells in models typically contain zero values. | |||
34 | */ |
|
39 | */ | |
35 |
|
40 | |||
36 | /*! |
|
41 | /*! | |
37 | \qmlclass LogValuesAxis QLogValueAxis |
|
42 | \qmlclass LogValuesAxis QLogValueAxis | |
38 | \brief The LogValueAxis element is used for manipulating chart's axes |
|
43 | \brief The LogValueAxis element is used for manipulating chart's axes | |
39 | \inherits AbstractAxis |
|
44 | \inherits AbstractAxis | |
|
45 | ||||
|
46 | \note If a LogValueAxis is attached to a series with one or more points with | |||
|
47 | negative or zero values on the associated dimension, the series will not be | |||
|
48 | plotted at all. This is particularly relevant when XYModelMappers are used, | |||
|
49 | since empty cells in models typically contain zero values. | |||
40 | */ |
|
50 | */ | |
41 |
|
51 | |||
42 | /*! |
|
52 | /*! | |
43 | \property QLogValueAxis::min |
|
53 | \property QLogValueAxis::min | |
44 | Defines the minimum value on the axis. |
|
54 | Defines the minimum value on the axis. | |
45 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
55 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |
46 | Value has to be greater then 0. |
|
56 | Value has to be greater then 0. | |
47 | */ |
|
57 | */ | |
48 | /*! |
|
58 | /*! | |
49 | \qmlproperty real LogValuesAxis::min |
|
59 | \qmlproperty real LogValuesAxis::min | |
50 | Defines the minimum value on the axis. |
|
60 | Defines the minimum value on the axis. | |
51 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. |
|
61 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |
52 | Value has to be greater then 0. |
|
62 | Value has to be greater then 0. | |
53 | */ |
|
63 | */ | |
54 |
|
64 | |||
55 | /*! |
|
65 | /*! | |
56 | \property QLogValueAxis::max |
|
66 | \property QLogValueAxis::max | |
57 | Defines the maximum value on the axis. |
|
67 | Defines the maximum value on the axis. | |
58 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
68 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |
59 | Value has to be greater then 0. |
|
69 | Value has to be greater then 0. | |
60 | */ |
|
70 | */ | |
61 | /*! |
|
71 | /*! | |
62 | \qmlproperty real LogValuesAxis::max |
|
72 | \qmlproperty real LogValuesAxis::max | |
63 | Defines the maximum value on the axis. |
|
73 | Defines the maximum value on the axis. | |
64 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. |
|
74 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |
65 | Value has to be greater then 0. |
|
75 | Value has to be greater then 0. | |
66 | */ |
|
76 | */ | |
67 |
|
77 | |||
68 | /*! |
|
78 | /*! | |
69 | \property QLogValueAxis::base |
|
79 | \property QLogValueAxis::base | |
70 | Defines the base of the logarithm. |
|
80 | Defines the base of the logarithm. | |
71 | Value has to be greater then 0 and not equal 1 |
|
81 | Value has to be greater then 0 and not equal 1 | |
72 | */ |
|
82 | */ | |
73 | /*! |
|
83 | /*! | |
74 | \qmlproperty real LogValuesAxis::base |
|
84 | \qmlproperty real LogValuesAxis::base | |
75 | Defines the maximum value on the axis. |
|
85 | Defines the maximum value on the axis. | |
76 | Defines the base of the logarithm. |
|
86 | Defines the base of the logarithm. | |
77 | Value has to be greater then 0 and not equal 1 |
|
87 | Value has to be greater then 0 and not equal 1 | |
78 | */ |
|
88 | */ | |
79 |
|
89 | |||
80 | /*! |
|
90 | /*! | |
81 | \property QLogValueAxis::labelFormat |
|
91 | \property QLogValueAxis::labelFormat | |
82 | Defines the label format of the axis. |
|
92 | Defines the label format of the axis. | |
83 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c |
|
93 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c | |
84 | See QString::sprintf() for additional details. |
|
94 | See QString::sprintf() for additional details. | |
85 | */ |
|
95 | */ | |
86 | /*! |
|
96 | /*! | |
87 | \qmlproperty real LogValuesAxis::labelFormat |
|
97 | \qmlproperty real LogValuesAxis::labelFormat | |
88 | Defines the label format of the axis. |
|
98 | Defines the label format of the axis. | |
89 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c |
|
99 | Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c | |
90 | See QString::sprintf() for additional details. |
|
100 | See QString::sprintf() for additional details. | |
91 | */ |
|
101 | */ | |
92 |
|
102 | |||
93 | /*! |
|
103 | /*! | |
94 | \fn void QLogValueAxis::minChanged(qreal min) |
|
104 | \fn void QLogValueAxis::minChanged(qreal min) | |
95 | Axis emits signal when \a min of axis has changed. |
|
105 | Axis emits signal when \a min of axis has changed. | |
96 | */ |
|
106 | */ | |
97 | /*! |
|
107 | /*! | |
98 | \qmlsignal LogValuesAxis::onMinChanged(qreal min) |
|
108 | \qmlsignal LogValuesAxis::onMinChanged(qreal min) | |
99 | Axis emits signal when \a min of axis has changed. |
|
109 | Axis emits signal when \a min of axis has changed. | |
100 | */ |
|
110 | */ | |
101 |
|
111 | |||
102 | /*! |
|
112 | /*! | |
103 | \fn void QLogValueAxis::maxChanged(qreal max) |
|
113 | \fn void QLogValueAxis::maxChanged(qreal max) | |
104 | Axis emits signal when \a max of axis has changed. |
|
114 | Axis emits signal when \a max of axis has changed. | |
105 | */ |
|
115 | */ | |
106 | /*! |
|
116 | /*! | |
107 | \qmlsignal LogValuesAxis::onMaxChanged(qreal max) |
|
117 | \qmlsignal LogValuesAxis::onMaxChanged(qreal max) | |
108 | Axis emits signal when \a max of axis has changed. |
|
118 | Axis emits signal when \a max of axis has changed. | |
109 | */ |
|
119 | */ | |
110 |
|
120 | |||
111 | /*! |
|
121 | /*! | |
112 | \fn void QLogValueAxis::rangeChanged(qreal min, qreal max) |
|
122 | \fn void QLogValueAxis::rangeChanged(qreal min, qreal max) | |
113 | Axis emits signal when \a min or \a max of axis has changed. |
|
123 | Axis emits signal when \a min or \a max of axis has changed. | |
114 | */ |
|
124 | */ | |
115 |
|
125 | |||
116 | /*! |
|
126 | /*! | |
117 | \fn void QLogValueAxis::labelFormatChanged(const QString &format) |
|
127 | \fn void QLogValueAxis::labelFormatChanged(const QString &format) | |
118 | Axis emits signal when \a format of axis labels has changed. |
|
128 | Axis emits signal when \a format of axis labels has changed. | |
119 | */ |
|
129 | */ | |
120 | /*! |
|
130 | /*! | |
121 | \qmlsignal LogValueAxis::labelFormatChanged(const QString &format) |
|
131 | \qmlsignal LogValueAxis::labelFormatChanged(const QString &format) | |
122 | Axis emits signal when \a format of axis labels has changed. |
|
132 | Axis emits signal when \a format of axis labels has changed. | |
123 | */ |
|
133 | */ | |
124 |
|
134 | |||
125 | /*! |
|
135 | /*! | |
126 | \fn void QLogValueAxis::baseChanged(qreal base) |
|
136 | \fn void QLogValueAxis::baseChanged(qreal base) | |
127 | Axis emits signal when \a base of logarithm of the axis has changed. |
|
137 | Axis emits signal when \a base of logarithm of the axis has changed. | |
128 | */ |
|
138 | */ | |
129 | /*! |
|
139 | /*! | |
130 | \qmlsignal LogValuesAxis::baseChanged(qreal base) |
|
140 | \qmlsignal LogValuesAxis::baseChanged(qreal base) | |
131 | Axis emits signal when \a base of logarithm of the axis has changed. |
|
141 | Axis emits signal when \a base of logarithm of the axis has changed. | |
132 | */ |
|
142 | */ | |
133 |
|
143 | |||
134 | /*! |
|
144 | /*! | |
135 | Constructs an axis object which is a child of \a parent. |
|
145 | Constructs an axis object which is a child of \a parent. | |
136 | */ |
|
146 | */ | |
137 | QLogValueAxis::QLogValueAxis(QObject *parent) : |
|
147 | QLogValueAxis::QLogValueAxis(QObject *parent) : | |
138 | QAbstractAxis(*new QLogValueAxisPrivate(this), parent) |
|
148 | QAbstractAxis(*new QLogValueAxisPrivate(this), parent) | |
139 | { |
|
149 | { | |
140 |
|
150 | |||
141 | } |
|
151 | } | |
142 |
|
152 | |||
143 | /*! |
|
153 | /*! | |
144 | \internal |
|
154 | \internal | |
145 | */ |
|
155 | */ | |
146 | QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent) |
|
156 | QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent) | |
147 | { |
|
157 | { | |
148 |
|
158 | |||
149 | } |
|
159 | } | |
150 |
|
160 | |||
151 | /*! |
|
161 | /*! | |
152 | Destroys the object |
|
162 | Destroys the object | |
153 | */ |
|
163 | */ | |
154 | QLogValueAxis::~QLogValueAxis() |
|
164 | QLogValueAxis::~QLogValueAxis() | |
155 | { |
|
165 | { | |
156 | Q_D(QLogValueAxis); |
|
166 | Q_D(QLogValueAxis); | |
157 | if (d->m_chart) |
|
167 | if (d->m_chart) | |
158 | d->m_chart->removeAxis(this); |
|
168 | d->m_chart->removeAxis(this); | |
159 | } |
|
169 | } | |
160 |
|
170 | |||
161 | void QLogValueAxis::setMin(qreal min) |
|
171 | void QLogValueAxis::setMin(qreal min) | |
162 | { |
|
172 | { | |
163 | Q_D(QLogValueAxis); |
|
173 | Q_D(QLogValueAxis); | |
164 | setRange(min, qMax(d->m_max, min)); |
|
174 | setRange(min, qMax(d->m_max, min)); | |
165 | } |
|
175 | } | |
166 |
|
176 | |||
167 | qreal QLogValueAxis::min() const |
|
177 | qreal QLogValueAxis::min() const | |
168 | { |
|
178 | { | |
169 | Q_D(const QLogValueAxis); |
|
179 | Q_D(const QLogValueAxis); | |
170 | return d->m_min; |
|
180 | return d->m_min; | |
171 | } |
|
181 | } | |
172 |
|
182 | |||
173 | void QLogValueAxis::setMax(qreal max) |
|
183 | void QLogValueAxis::setMax(qreal max) | |
174 | { |
|
184 | { | |
175 | Q_D(QLogValueAxis); |
|
185 | Q_D(QLogValueAxis); | |
176 | setRange(qMin(d->m_min, max), max); |
|
186 | setRange(qMin(d->m_min, max), max); | |
177 | } |
|
187 | } | |
178 |
|
188 | |||
179 | qreal QLogValueAxis::max() const |
|
189 | qreal QLogValueAxis::max() const | |
180 | { |
|
190 | { | |
181 | Q_D(const QLogValueAxis); |
|
191 | Q_D(const QLogValueAxis); | |
182 | return d->m_max; |
|
192 | return d->m_max; | |
183 | } |
|
193 | } | |
184 |
|
194 | |||
185 | /*! |
|
195 | /*! | |
186 | Sets range from \a min to \a max on the axis. |
|
196 | Sets range from \a min to \a max on the axis. | |
187 | If min is greater than max then this function returns without making any changes. |
|
197 | If min is greater than max then this function returns without making any changes. | |
188 | */ |
|
198 | */ | |
189 | void QLogValueAxis::setRange(qreal min, qreal max) |
|
199 | void QLogValueAxis::setRange(qreal min, qreal max) | |
190 | { |
|
200 | { | |
191 | Q_D(QLogValueAxis); |
|
201 | Q_D(QLogValueAxis); | |
192 | bool changed = false; |
|
202 | bool changed = false; | |
193 |
|
203 | |||
194 | if (min > max) |
|
204 | if (min > max) | |
195 | return; |
|
205 | return; | |
196 |
|
206 | |||
197 | if (min > 0) { |
|
207 | if (min > 0) { | |
198 | if (!qFuzzyCompare(d->m_min, min)) { |
|
208 | if (!qFuzzyCompare(d->m_min, min)) { | |
199 | d->m_min = min; |
|
209 | d->m_min = min; | |
200 | changed = true; |
|
210 | changed = true; | |
201 | emit minChanged(min); |
|
211 | emit minChanged(min); | |
202 | } |
|
212 | } | |
203 |
|
213 | |||
204 | if (!qFuzzyCompare(d->m_max, max)) { |
|
214 | if (!qFuzzyCompare(d->m_max, max)) { | |
205 | d->m_max = max; |
|
215 | d->m_max = max; | |
206 | changed = true; |
|
216 | changed = true; | |
207 | emit maxChanged(max); |
|
217 | emit maxChanged(max); | |
208 | } |
|
218 | } | |
209 |
|
219 | |||
210 | if (changed) { |
|
220 | if (changed) { | |
211 | emit rangeChanged(min, max); |
|
221 | emit rangeChanged(min, max); | |
212 | emit d->rangeChanged(min,max); |
|
222 | emit d->rangeChanged(min,max); | |
213 | } |
|
223 | } | |
214 | } |
|
224 | } | |
215 | } |
|
225 | } | |
216 |
|
226 | |||
217 | void QLogValueAxis::setLabelFormat(const QString &format) |
|
227 | void QLogValueAxis::setLabelFormat(const QString &format) | |
218 | { |
|
228 | { | |
219 | Q_D(QLogValueAxis); |
|
229 | Q_D(QLogValueAxis); | |
220 | d->m_format = format; |
|
230 | d->m_format = format; | |
221 | emit labelFormatChanged(format); |
|
231 | emit labelFormatChanged(format); | |
222 | } |
|
232 | } | |
223 |
|
233 | |||
224 | QString QLogValueAxis::labelFormat() const |
|
234 | QString QLogValueAxis::labelFormat() const | |
225 | { |
|
235 | { | |
226 | Q_D(const QLogValueAxis); |
|
236 | Q_D(const QLogValueAxis); | |
227 | return d->m_format; |
|
237 | return d->m_format; | |
228 | } |
|
238 | } | |
229 |
|
239 | |||
230 | void QLogValueAxis::setBase(qreal base) |
|
240 | void QLogValueAxis::setBase(qreal base) | |
231 | { |
|
241 | { | |
232 | // check if base is correct |
|
242 | // check if base is correct | |
233 | if (qFuzzyCompare(base, 1)) |
|
243 | if (qFuzzyCompare(base, 1)) | |
234 | return; |
|
244 | return; | |
235 |
|
245 | |||
236 | if (base > 0) { |
|
246 | if (base > 0) { | |
237 | Q_D(QLogValueAxis); |
|
247 | Q_D(QLogValueAxis); | |
238 | d->m_base = base; |
|
248 | d->m_base = base; | |
239 | emit baseChanged(base); |
|
249 | emit baseChanged(base); | |
240 | } |
|
250 | } | |
241 | } |
|
251 | } | |
242 |
|
252 | |||
243 | qreal QLogValueAxis::base() const |
|
253 | qreal QLogValueAxis::base() const | |
244 | { |
|
254 | { | |
245 | Q_D(const QLogValueAxis); |
|
255 | Q_D(const QLogValueAxis); | |
246 | return d->m_base; |
|
256 | return d->m_base; | |
247 | } |
|
257 | } | |
248 |
|
258 | |||
249 | /*! |
|
259 | /*! | |
250 | Returns the type of the axis |
|
260 | Returns the type of the axis | |
251 | */ |
|
261 | */ | |
252 | QAbstractAxis::AxisType QLogValueAxis::type() const |
|
262 | QAbstractAxis::AxisType QLogValueAxis::type() const | |
253 | { |
|
263 | { | |
254 | return AxisTypeLogValue; |
|
264 | return AxisTypeLogValue; | |
255 | } |
|
265 | } | |
256 |
|
266 | |||
257 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
267 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
258 |
|
268 | |||
259 | QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q) |
|
269 | QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q) | |
260 | : QAbstractAxisPrivate(q), |
|
270 | : QAbstractAxisPrivate(q), | |
261 | m_min(1), |
|
271 | m_min(1), | |
262 | m_max(1), |
|
272 | m_max(1), | |
263 | m_base(10), |
|
273 | m_base(10), | |
264 | m_format(QString::null) |
|
274 | m_format(QString::null) | |
265 | { |
|
275 | { | |
266 | } |
|
276 | } | |
267 |
|
277 | |||
268 | QLogValueAxisPrivate::~QLogValueAxisPrivate() |
|
278 | QLogValueAxisPrivate::~QLogValueAxisPrivate() | |
269 | { |
|
279 | { | |
270 |
|
280 | |||
271 | } |
|
281 | } | |
272 |
|
282 | |||
273 | void QLogValueAxisPrivate::setMin(const QVariant &min) |
|
283 | void QLogValueAxisPrivate::setMin(const QVariant &min) | |
274 | { |
|
284 | { | |
275 | Q_Q(QLogValueAxis); |
|
285 | Q_Q(QLogValueAxis); | |
276 | bool ok; |
|
286 | bool ok; | |
277 | qreal value = min.toReal(&ok); |
|
287 | qreal value = min.toReal(&ok); | |
278 | if (ok) |
|
288 | if (ok) | |
279 | q->setMin(value); |
|
289 | q->setMin(value); | |
280 | } |
|
290 | } | |
281 |
|
291 | |||
282 | void QLogValueAxisPrivate::setMax(const QVariant &max) |
|
292 | void QLogValueAxisPrivate::setMax(const QVariant &max) | |
283 | { |
|
293 | { | |
284 |
|
294 | |||
285 | Q_Q(QLogValueAxis); |
|
295 | Q_Q(QLogValueAxis); | |
286 | bool ok; |
|
296 | bool ok; | |
287 | qreal value = max.toReal(&ok); |
|
297 | qreal value = max.toReal(&ok); | |
288 | if (ok) |
|
298 | if (ok) | |
289 | q->setMax(value); |
|
299 | q->setMax(value); | |
290 | } |
|
300 | } | |
291 |
|
301 | |||
292 | void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) |
|
302 | void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
293 | { |
|
303 | { | |
294 | Q_Q(QLogValueAxis); |
|
304 | Q_Q(QLogValueAxis); | |
295 | bool ok1; |
|
305 | bool ok1; | |
296 | bool ok2; |
|
306 | bool ok2; | |
297 | qreal value1 = min.toReal(&ok1); |
|
307 | qreal value1 = min.toReal(&ok1); | |
298 | qreal value2 = max.toReal(&ok2); |
|
308 | qreal value2 = max.toReal(&ok2); | |
299 | if (ok1 && ok2) |
|
309 | if (ok1 && ok2) | |
300 | q->setRange(value1, value2); |
|
310 | q->setRange(value1, value2); | |
301 | } |
|
311 | } | |
302 |
|
312 | |||
303 | void QLogValueAxisPrivate::setRange(qreal min, qreal max) |
|
313 | void QLogValueAxisPrivate::setRange(qreal min, qreal max) | |
304 | { |
|
314 | { | |
305 | Q_Q(QLogValueAxis); |
|
315 | Q_Q(QLogValueAxis); | |
306 | bool changed = false; |
|
316 | bool changed = false; | |
307 |
|
317 | |||
308 | if (min > max) |
|
318 | if (min > max) | |
309 | return; |
|
319 | return; | |
310 |
|
320 | |||
311 | if (min > 0) { |
|
321 | if (min > 0) { | |
312 | if (!qFuzzyCompare(m_min, min)) { |
|
322 | if (!qFuzzyCompare(m_min, min)) { | |
313 | m_min = min; |
|
323 | m_min = min; | |
314 | changed = true; |
|
324 | changed = true; | |
315 | emit q->minChanged(min); |
|
325 | emit q->minChanged(min); | |
316 | } |
|
326 | } | |
317 |
|
327 | |||
318 | if (!qFuzzyCompare(m_max, max)) { |
|
328 | if (!qFuzzyCompare(m_max, max)) { | |
319 | m_max = max; |
|
329 | m_max = max; | |
320 | changed = true; |
|
330 | changed = true; | |
321 | emit q->maxChanged(max); |
|
331 | emit q->maxChanged(max); | |
322 | } |
|
332 | } | |
323 |
|
333 | |||
324 | if (changed) { |
|
334 | if (changed) { | |
325 | emit rangeChanged(min,max); |
|
335 | emit rangeChanged(min,max); | |
326 | emit q->rangeChanged(min, max); |
|
336 | emit q->rangeChanged(min, max); | |
327 | } |
|
337 | } | |
328 | } |
|
338 | } | |
329 | } |
|
339 | } | |
330 |
|
340 | |||
331 | void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem* parent) |
|
341 | void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem* parent) | |
332 | { |
|
342 | { | |
333 | Q_Q(QLogValueAxis); |
|
343 | Q_Q(QLogValueAxis); | |
334 | ChartAxis* axis(0); |
|
344 | ChartAxis* axis(0); | |
335 | if (orientation() == Qt::Vertical) |
|
345 | if (orientation() == Qt::Vertical) | |
336 | axis = new ChartLogValueAxisY(q,parent); |
|
346 | axis = new ChartLogValueAxisY(q,parent); | |
337 | if (orientation() == Qt::Horizontal) |
|
347 | if (orientation() == Qt::Horizontal) | |
338 | axis = new ChartLogValueAxisX(q,parent); |
|
348 | axis = new ChartLogValueAxisX(q,parent); | |
339 |
|
349 | |||
340 | m_item.reset(axis); |
|
350 | m_item.reset(axis); | |
341 | QAbstractAxisPrivate::initializeGraphics(parent); |
|
351 | QAbstractAxisPrivate::initializeGraphics(parent); | |
342 | } |
|
352 | } | |
343 |
|
353 | |||
344 |
|
354 | |||
345 | void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain) |
|
355 | void QLogValueAxisPrivate::initializeDomain(AbstractDomain *domain) | |
346 | { |
|
356 | { | |
347 | if (orientation() == Qt::Vertical) { |
|
357 | if (orientation() == Qt::Vertical) { | |
348 | if(!qFuzzyCompare(m_max, m_min)) { |
|
358 | if(!qFuzzyCompare(m_max, m_min)) { | |
349 | domain->setRangeY(m_min, m_max); |
|
359 | domain->setRangeY(m_min, m_max); | |
350 | } else if ( domain->minY() > 0) { |
|
360 | } else if ( domain->minY() > 0) { | |
351 | setRange(domain->minY(), domain->maxY()); |
|
361 | setRange(domain->minY(), domain->maxY()); | |
352 | } else if (domain->maxY() > 0) { |
|
362 | } else if (domain->maxY() > 0) { | |
353 | domain->setRangeY(m_min, domain->maxY()); |
|
363 | domain->setRangeY(m_min, domain->maxY()); | |
354 | } else { |
|
364 | } else { | |
355 | domain->setRangeY(1, 10); |
|
365 | domain->setRangeY(1, 10); | |
356 | } |
|
366 | } | |
357 | } |
|
367 | } | |
358 | if (orientation() == Qt::Horizontal) { |
|
368 | if (orientation() == Qt::Horizontal) { | |
359 | if(!qFuzzyCompare(m_max, m_min)) { |
|
369 | if(!qFuzzyCompare(m_max, m_min)) { | |
360 | domain->setRangeX(m_min, m_max); |
|
370 | domain->setRangeX(m_min, m_max); | |
361 | } else if (domain->minX() > 0){ |
|
371 | } else if (domain->minX() > 0){ | |
362 | setRange(domain->minX(), domain->maxX()); |
|
372 | setRange(domain->minX(), domain->maxX()); | |
363 | } else if (domain->maxX() > 0) { |
|
373 | } else if (domain->maxX() > 0) { | |
364 | domain->setRangeX(m_min, domain->maxX()); |
|
374 | domain->setRangeX(m_min, domain->maxX()); | |
365 | } else { |
|
375 | } else { | |
366 | domain->setRangeX(1, 10); |
|
376 | domain->setRangeX(1, 10); | |
367 | } |
|
377 | } | |
368 | } |
|
378 | } | |
369 | } |
|
379 | } | |
370 |
|
380 | |||
371 | #include "moc_qlogvalueaxis.cpp" |
|
381 | #include "moc_qlogvalueaxis.cpp" | |
372 | #include "moc_qlogvalueaxis_p.cpp" |
|
382 | #include "moc_qlogvalueaxis_p.cpp" | |
373 |
|
383 | |||
374 | QTCOMMERCIALCHART_END_NAMESPACE |
|
384 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now