@@ -1,66 +1,68 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "abstractbaranimation_p.h" |
|
22 | 22 | #include "abstractbarchartitem_p.h" |
|
23 | 23 | #include <QTimer> |
|
24 | 24 | #include <QDebug> |
|
25 | 25 | |
|
26 | 26 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | 30 | AbstractBarAnimation::AbstractBarAnimation(AbstractBarChartItem *item) |
|
31 | 31 | :ChartAnimation(item), |
|
32 | 32 | m_item(item) |
|
33 | 33 | { |
|
34 | 34 | setDuration(ChartAnimationDuration); |
|
35 | 35 | setEasingCurve(QEasingCurve::OutQuart); |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | AbstractBarAnimation::~AbstractBarAnimation() |
|
39 | 39 | { |
|
40 | 40 | } |
|
41 | 41 | |
|
42 | 42 | QVariant AbstractBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
43 | 43 | { |
|
44 | 44 | Q_UNUSED(from); |
|
45 | 45 | Q_UNUSED(to); |
|
46 | 46 | Q_UNUSED(progress); |
|
47 | 47 | qWarning() << "AbstractBarAnimation::interpolated called"; |
|
48 | 48 | return to; |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | void AbstractBarAnimation::updateCurrentValue(const QVariant &value) |
|
52 | 52 | { |
|
53 | 53 | QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value); |
|
54 | 54 | m_item->setLayout(layout); |
|
55 | 55 | } |
|
56 | 56 | |
|
57 | 57 | void AbstractBarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout) |
|
58 | 58 | { |
|
59 | QVariantAnimation::KeyValues value; | |
|
60 | setKeyValues(value); //workaround for wrong interpolation call | |
|
59 | 61 | setKeyValueAt(0.0, qVariantFromValue(oldLayout)); |
|
60 | 62 | setKeyValueAt(1.0, qVariantFromValue(newLayout)); |
|
61 | 63 | } |
|
62 | 64 | |
|
63 | 65 | #include "moc_abstractbaranimation_p.cpp" |
|
64 | 66 | |
|
65 | 67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
66 | 68 |
@@ -1,62 +1,61 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "baranimation_p.h" |
|
22 | 22 | #include "abstractbarchartitem_p.h" |
|
23 | 23 | #include <QTimer> |
|
24 | 24 | |
|
25 | 25 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | BarAnimation::BarAnimation(AbstractBarChartItem *item) |
|
30 | 30 | :AbstractBarAnimation(item) |
|
31 | 31 | { |
|
32 | setDuration(ChartAnimationDuration); | |
|
33 | setEasingCurve(QEasingCurve::OutQuart); | |
|
32 | ||
|
34 | 33 | } |
|
35 | 34 | |
|
36 | 35 | BarAnimation::~BarAnimation() |
|
37 | 36 | { |
|
38 | 37 | } |
|
39 | 38 | |
|
40 | 39 | QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
41 | 40 | { |
|
42 | 41 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); |
|
43 | 42 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); |
|
44 | 43 | QVector<QRectF> result; |
|
45 | 44 | |
|
46 | 45 | Q_ASSERT(startVector.count() == endVector.count()); |
|
47 | 46 | |
|
48 | 47 | for(int i = 0; i < startVector.count(); i++) { |
|
49 | 48 | qreal w = endVector[i].width(); |
|
50 | 49 | qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); |
|
51 | 50 | qreal x = endVector[i].topLeft().x(); |
|
52 | 51 | qreal y = endVector[i].topLeft().y() + endVector[i].height() - h; |
|
53 | 52 | |
|
54 | 53 | QRectF value(x,y,w,h); |
|
55 | 54 | result << value; |
|
56 | 55 | } |
|
57 | 56 | return qVariantFromValue(result); |
|
58 | 57 | } |
|
59 | 58 | |
|
60 | 59 | #include "moc_baranimation_p.cpp" |
|
61 | 60 | |
|
62 | 61 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,372 +1,371 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "chartaxis_p.h" |
|
22 | 22 | #include "qabstractaxis.h" |
|
23 | 23 | #include "qabstractaxis_p.h" |
|
24 | 24 | #include "chartpresenter_p.h" |
|
25 | 25 | #include "chartanimator_p.h" |
|
26 | 26 | #include "domain_p.h" |
|
27 | 27 | #include <qmath.h> |
|
28 | 28 | #include <QDateTime> |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(presenter), |
|
33 | 33 | m_chartAxis(axis), |
|
34 | 34 | m_labelsAngle(0), |
|
35 | 35 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), |
|
36 | 36 | m_shades(new QGraphicsItemGroup(presenter->rootItem())), |
|
37 | 37 | m_labels(new QGraphicsItemGroup(presenter->rootItem())), |
|
38 | 38 | m_arrow(new QGraphicsItemGroup(presenter->rootItem())), |
|
39 | 39 | m_min(0), |
|
40 | 40 | m_max(0), |
|
41 | 41 | m_animation(0), |
|
42 | 42 | m_minWidth(0), |
|
43 | 43 | m_minHeight(0) |
|
44 | 44 | { |
|
45 | 45 | //initial initialization |
|
46 | 46 | m_arrow->setZValue(ChartPresenter::AxisZValue); |
|
47 | 47 | m_arrow->setHandlesChildEvents(false); |
|
48 | 48 | |
|
49 | 49 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
50 | 50 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
51 | 51 | |
|
52 | 52 | QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated())); |
|
53 | 53 | |
|
54 | 54 | QGraphicsSimpleTextItem item; |
|
55 | 55 | m_font = item.font(); |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | ChartAxis::~ChartAxis() |
|
59 | 59 | { |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | void ChartAxis::setAnimation(AxisAnimation* animation) |
|
63 | 63 | { |
|
64 | 64 | m_animation=animation; |
|
65 | 65 | } |
|
66 | 66 | |
|
67 | 67 | void ChartAxis::setLayout(QVector<qreal> &layout) |
|
68 | 68 | { |
|
69 | 69 | m_layoutVector=layout; |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | void ChartAxis::createItems(int count) |
|
73 | 73 | { |
|
74 | 74 | if (m_arrow->children().size() == 0) |
|
75 | 75 | m_arrow->addToGroup(new AxisItem(this)); |
|
76 | 76 | for (int i = 0; i < count; ++i) { |
|
77 | 77 | m_grid->addToGroup(new QGraphicsLineItem()); |
|
78 | 78 | m_labels->addToGroup(new QGraphicsSimpleTextItem()); |
|
79 | 79 | m_arrow->addToGroup(new QGraphicsLineItem()); |
|
80 | 80 | if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem()); |
|
81 | 81 | } |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | void ChartAxis::deleteItems(int count) |
|
85 | 85 | { |
|
86 | 86 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
87 | 87 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
88 | 88 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
89 | 89 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
90 | 90 | |
|
91 | 91 | for (int i = 0; i < count; ++i) { |
|
92 | 92 | if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast()); |
|
93 | 93 | delete(lines.takeLast()); |
|
94 | 94 | delete(labels.takeLast()); |
|
95 | 95 | delete(axis.takeLast()); |
|
96 | 96 | } |
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | void ChartAxis::updateLayout(QVector<qreal> &layout) |
|
100 | 100 | { |
|
101 | 101 | int diff = m_layoutVector.size() - layout.size(); |
|
102 | 102 | |
|
103 | 103 | if (diff>0) { |
|
104 | 104 | deleteItems(diff); |
|
105 | 105 | } |
|
106 | 106 | else if (diff<0) { |
|
107 | 107 | createItems(-diff); |
|
108 | 108 | } |
|
109 | 109 | |
|
110 | 110 | if(diff<0) handleAxisUpdated(); |
|
111 | 111 | |
|
112 | 112 | if (m_animation) { |
|
113 | 113 | switch(presenter()->state()){ |
|
114 | 114 | case ChartPresenter::ZoomInState: |
|
115 | 115 | m_animation->setAnimationType(AxisAnimation::ZoomInAnimation); |
|
116 | 116 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
117 | 117 | break; |
|
118 | 118 | case ChartPresenter::ZoomOutState: |
|
119 | 119 | m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation); |
|
120 | 120 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
121 | 121 | break; |
|
122 | 122 | case ChartPresenter::ScrollUpState: |
|
123 | 123 | case ChartPresenter::ScrollLeftState: |
|
124 | 124 | m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation); |
|
125 | 125 | break; |
|
126 | 126 | case ChartPresenter::ScrollDownState: |
|
127 | 127 | case ChartPresenter::ScrollRightState: |
|
128 | 128 | m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation); |
|
129 | 129 | break; |
|
130 | 130 | case ChartPresenter::ShowState: |
|
131 | 131 | m_animation->setAnimationType(AxisAnimation::DefaultAnimation); |
|
132 | 132 | break; |
|
133 | 133 | } |
|
134 | 134 | m_animation->setValues(m_layoutVector,layout); |
|
135 | 135 | presenter()->startAnimation(m_animation); |
|
136 | 136 | } |
|
137 | 137 | else { |
|
138 | 138 | setLayout(layout); |
|
139 | 139 | updateGeometry(); |
|
140 | 140 | } |
|
141 | 141 | } |
|
142 | 142 | |
|
143 | 143 | void ChartAxis::setArrowOpacity(qreal opacity) |
|
144 | 144 | { |
|
145 | 145 | m_arrow->setOpacity(opacity); |
|
146 | 146 | } |
|
147 | 147 | |
|
148 | 148 | qreal ChartAxis::arrowOpacity() const |
|
149 | 149 | { |
|
150 | 150 | return m_arrow->opacity(); |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | void ChartAxis::setArrowVisibility(bool visible) |
|
154 | 154 | { |
|
155 | 155 | m_arrow->setOpacity(visible); |
|
156 | 156 | } |
|
157 | 157 | |
|
158 | 158 | void ChartAxis::setGridOpacity(qreal opacity) |
|
159 | 159 | { |
|
160 | 160 | m_grid->setOpacity(opacity); |
|
161 | 161 | } |
|
162 | 162 | |
|
163 | 163 | qreal ChartAxis::gridOpacity() const |
|
164 | 164 | { |
|
165 | 165 | return m_grid->opacity(); |
|
166 | 166 | } |
|
167 | 167 | |
|
168 | 168 | void ChartAxis::setGridVisibility(bool visible) |
|
169 | 169 | { |
|
170 | 170 | m_grid->setOpacity(visible); |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | void ChartAxis::setLabelsOpacity(qreal opacity) |
|
174 | 174 | { |
|
175 | 175 | m_labels->setOpacity(opacity); |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | qreal ChartAxis::labelsOpacity() const |
|
179 | 179 | { |
|
180 | 180 | return m_labels->opacity(); |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | void ChartAxis::setLabelsVisibility(bool visible) |
|
184 | 184 | { |
|
185 | 185 | m_labels->setOpacity(visible); |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | void ChartAxis::setShadesOpacity(qreal opacity) |
|
189 | 189 | { |
|
190 | 190 | m_shades->setOpacity(opacity); |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | qreal ChartAxis::shadesOpacity() const |
|
194 | 194 | { |
|
195 | 195 | return m_shades->opacity(); |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | void ChartAxis::setShadesVisibility(bool visible) |
|
199 | 199 | { |
|
200 | 200 | m_shades->setVisible(visible); |
|
201 | 201 | } |
|
202 | 202 | |
|
203 | 203 | void ChartAxis::setLabelsAngle(int angle) |
|
204 | 204 | { |
|
205 | 205 | foreach(QGraphicsItem* item , m_labels->childItems()) { |
|
206 | 206 | item->setRotation(angle); |
|
207 | 207 | } |
|
208 | 208 | |
|
209 | 209 | m_labelsAngle=angle; |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | void ChartAxis::setLabelsPen(const QPen &pen) |
|
213 | 213 | { |
|
214 | 214 | foreach(QGraphicsItem* item , m_labels->childItems()) { |
|
215 | 215 | static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen); |
|
216 | 216 | } |
|
217 | 217 | } |
|
218 | 218 | |
|
219 | 219 | void ChartAxis::setLabelsBrush(const QBrush &brush) |
|
220 | 220 | { |
|
221 | 221 | foreach(QGraphicsItem* item , m_labels->childItems()) { |
|
222 | 222 | static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush); |
|
223 | 223 | } |
|
224 | 224 | } |
|
225 | 225 | |
|
226 | 226 | void ChartAxis::setLabelsFont(const QFont &font) |
|
227 | 227 | { |
|
228 | 228 | foreach(QGraphicsItem* item , m_labels->childItems()) { |
|
229 | 229 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
230 | 230 | } |
|
231 | 231 | m_font = font; |
|
232 | 232 | } |
|
233 | 233 | |
|
234 | 234 | void ChartAxis::setShadesBrush(const QBrush &brush) |
|
235 | 235 | { |
|
236 | 236 | foreach(QGraphicsItem* item , m_shades->childItems()) { |
|
237 | 237 | static_cast<QGraphicsRectItem*>(item)->setBrush(brush); |
|
238 | 238 | } |
|
239 | 239 | } |
|
240 | 240 | |
|
241 | 241 | void ChartAxis::setShadesPen(const QPen &pen) |
|
242 | 242 | { |
|
243 | 243 | foreach(QGraphicsItem* item , m_shades->childItems()) { |
|
244 | 244 | static_cast<QGraphicsRectItem*>(item)->setPen(pen); |
|
245 | 245 | } |
|
246 | 246 | } |
|
247 | 247 | |
|
248 | 248 | void ChartAxis::setArrowPen(const QPen &pen) |
|
249 | 249 | { |
|
250 | 250 | foreach(QGraphicsItem* item , m_arrow->childItems()) { |
|
251 | 251 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
252 | 252 | } |
|
253 | 253 | } |
|
254 | 254 | |
|
255 | 255 | void ChartAxis::setGridPen(const QPen &pen) |
|
256 | 256 | { |
|
257 | 257 | foreach(QGraphicsItem* item , m_grid->childItems()) { |
|
258 | 258 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
259 | 259 | } |
|
260 | 260 | } |
|
261 | 261 | |
|
262 | 262 | bool ChartAxis::isEmpty() |
|
263 | 263 | { |
|
264 | 264 | return m_rect.isEmpty() || qFuzzyIsNull(m_min - m_max); |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | void ChartAxis::handleDomainUpdated() |
|
268 | 268 | { |
|
269 | 269 | Domain* domain = qobject_cast<Domain*>(sender()); |
|
270 | 270 | qreal min(0); |
|
271 | 271 | qreal max(0); |
|
272 | 272 | |
|
273 | 273 | if(m_chartAxis->orientation()==Qt::Horizontal) { |
|
274 | 274 | min = domain->minX(); |
|
275 | 275 | max = domain->maxX(); |
|
276 | 276 | } |
|
277 | 277 | else if (m_chartAxis->orientation()==Qt::Vertical) |
|
278 | 278 | { |
|
279 | 279 | min = domain->minY(); |
|
280 | 280 | max = domain->maxY(); |
|
281 | 281 | } |
|
282 | 282 | |
|
283 | 283 | if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) |
|
284 | 284 | { |
|
285 | 285 | m_min = min; |
|
286 | 286 | m_max = max; |
|
287 | 287 | |
|
288 | 288 | if (!isEmpty()) { |
|
289 | 289 | QVector<qreal> layout = calculateLayout(); |
|
290 | 290 | updateLayout(layout); |
|
291 | 291 | } |
|
292 | 292 | } |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | void ChartAxis::handleAxisUpdated() |
|
296 | 296 | { |
|
297 | 297 | if(isEmpty()) return; |
|
298 | 298 | |
|
299 | 299 | |
|
300 | 300 | bool visible = m_chartAxis->isVisible(); |
|
301 | 301 | |
|
302 | 302 | setArrowVisibility(visible && m_chartAxis->isArrowVisible()); |
|
303 | 303 | setGridVisibility(visible && m_chartAxis->isGridLineVisible()); |
|
304 | 304 | setLabelsVisibility(visible && m_chartAxis->labelsVisible()); |
|
305 | 305 | setShadesVisibility(visible && m_chartAxis->shadesVisible()); |
|
306 | ||
|
307 | 306 | setLabelsAngle(m_chartAxis->labelsAngle()); |
|
308 | 307 | setArrowPen(m_chartAxis->axisPen()); |
|
309 | 308 | setLabelsPen(m_chartAxis->labelsPen()); |
|
310 | 309 | setLabelsBrush(m_chartAxis->labelsBrush()); |
|
311 | 310 | setLabelsFont(m_chartAxis->labelsFont()); |
|
312 | 311 | setGridPen(m_chartAxis->gridLinePen()); |
|
313 | 312 | setShadesPen(m_chartAxis->shadesPen()); |
|
314 | 313 | setShadesBrush(m_chartAxis->shadesBrush()); |
|
315 | 314 | |
|
316 | 315 | } |
|
317 | 316 | |
|
318 | 317 | void ChartAxis::hide() |
|
319 | 318 | { |
|
320 | 319 | setArrowVisibility(false); |
|
321 | 320 | setGridVisibility(false); |
|
322 | 321 | setLabelsVisibility(false); |
|
323 | 322 | setShadesVisibility(false); |
|
324 | 323 | } |
|
325 | 324 | |
|
326 | 325 | void ChartAxis::handleGeometryChanged(const QRectF &rect) |
|
327 | 326 | { |
|
328 | 327 | if(m_rect != rect) |
|
329 | 328 | { |
|
330 | 329 | m_rect = rect; |
|
331 | 330 | if (isEmpty()) return; |
|
332 | 331 | QVector<qreal> layout = calculateLayout(); |
|
333 | 332 | updateLayout(layout); |
|
334 | 333 | } |
|
335 | 334 | } |
|
336 | 335 | |
|
337 | 336 | |
|
338 | 337 | qreal ChartAxis::minimumWidth() |
|
339 | 338 | { |
|
340 | 339 | if(m_minWidth == 0) updateGeometry(); |
|
341 | 340 | return m_minWidth; |
|
342 | 341 | } |
|
343 | 342 | |
|
344 | 343 | qreal ChartAxis::minimumHeight() |
|
345 | 344 | { |
|
346 | 345 | if(m_minHeight == 0) updateGeometry(); |
|
347 | 346 | return m_minHeight; |
|
348 | 347 | } |
|
349 | 348 | |
|
350 | 349 | |
|
351 | 350 | void ChartAxis::axisSelected() |
|
352 | 351 | { |
|
353 | 352 | qDebug()<<"TODO: axis clicked"; |
|
354 | 353 | } |
|
355 | 354 | |
|
356 | 355 | |
|
357 | 356 | void ChartAxis::createNumberLabels(QStringList &labels,qreal min, qreal max, int ticks) const |
|
358 | 357 | { |
|
359 | 358 | Q_ASSERT(max>min); |
|
360 | 359 | Q_ASSERT(ticks>1); |
|
361 | 360 | |
|
362 | 361 | int n = qMax(int(-qFloor(log10((max-min)/(ticks-1)))),0); |
|
363 | 362 | n++; |
|
364 | 363 | for (int i=0; i< ticks; i++) { |
|
365 | 364 | qreal value = min + (i * (max - min)/ (ticks-1)); |
|
366 | 365 | labels << QString::number(value,'f',n); |
|
367 | 366 | } |
|
368 | 367 | } |
|
369 | 368 | |
|
370 | 369 | #include "moc_chartaxis_p.cpp" |
|
371 | 370 | |
|
372 | 371 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now