##// END OF EJS Templates
refactored baranimations
sauimone -
r1673:4673b2d6daea
parent child
Show More
@@ -0,0 +1,66
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 #include "abstractbaranimation_p.h"
22 #include "barchartitem_p.h"
23 #include <QTimer>
24 #include <QDebug>
25
26 Q_DECLARE_METATYPE(QVector<QRectF>)
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 AbstractBarAnimation::AbstractBarAnimation(BarChartItem *item)
31 :ChartAnimation(item),
32 m_item(item)
33 {
34 setDuration(ChartAnimationDuration);
35 setEasingCurve(QEasingCurve::OutQuart);
36 }
37
38 AbstractBarAnimation::~AbstractBarAnimation()
39 {
40 }
41
42 QVariant AbstractBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
43 {
44 Q_UNUSED(from);
45 Q_UNUSED(to);
46 Q_UNUSED(progress);
47 qWarning() << "AbstractBarAnimation::interpolated called";
48 return to;
49 }
50
51 void AbstractBarAnimation::updateCurrentValue(const QVariant &value)
52 {
53 QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value);
54 m_item->setLayout(layout);
55 }
56
57 void AbstractBarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
58 {
59 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
60 setKeyValueAt(1.0, qVariantFromValue(newLayout));
61 }
62
63 #include "moc_abstractbaranimation_p.cpp"
64
65 QTCOMMERCIALCHART_END_NAMESPACE
66
@@ -0,0 +1,59
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef ABSTRACTBARANIMATION_P_H
31 #define ABSTRACTBARANIMATION_P_H
32
33 #include "chartanimation_p.h"
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
37 class BarChartItem;
38
39 class AbstractBarAnimation : public ChartAnimation
40 {
41 Q_OBJECT
42
43 public:
44 AbstractBarAnimation(BarChartItem *item);
45 ~AbstractBarAnimation();
46
47 public: // from QVariantAnimation
48 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
49 virtual void updateCurrentValue(const QVariant &value);
50
51 void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
52
53 protected:
54 BarChartItem *m_item;
55 };
56
57 QTCOMMERCIALCHART_END_NAMESPACE
58
59 #endif // ABSTRACTBARANIMATION_P_H
@@ -26,6 +26,7
26 #include <QAbstractBarSeries>
26 #include <QAbstractBarSeries>
27 #include <QPercentBarSeries>
27 #include <QPercentBarSeries>
28 #include <QStackedBarSeries>
28 #include <QStackedBarSeries>
29 #include <QBarSeries>
29 #include <QBarSet>
30 #include <QBarSet>
30 #include <QLineSeries>
31 #include <QLineSeries>
31 #include <QSplineSeries>
32 #include <QSplineSeries>
@@ -10,8 +10,8 SOURCES += \
10 $$PWD/splineanimation.cpp \
10 $$PWD/splineanimation.cpp \
11 $$PWD/baranimation.cpp \
11 $$PWD/baranimation.cpp \
12 $$PWD/stackedbaranimation.cpp \
12 $$PWD/stackedbaranimation.cpp \
13 $$PWD/percentbaranimation.cpp
13 $$PWD/percentbaranimation.cpp \
14
14 $$PWD/abstractbaranimation.cpp
15
15
16
16
17 PRIVATE_HEADERS += \
17 PRIVATE_HEADERS += \
@@ -24,4 +24,5 PRIVATE_HEADERS += \
24 $$PWD/splineanimation_p.h \
24 $$PWD/splineanimation_p.h \
25 $$PWD/baranimation_p.h \
25 $$PWD/baranimation_p.h \
26 $$PWD/stackedbaranimation_p.h \
26 $$PWD/stackedbaranimation_p.h \
27 $$PWD/percentbaranimation_p.h
27 $$PWD/percentbaranimation_p.h \
28 $$PWD/abstractbaranimation_p.h
@@ -27,9 +27,9 Q_DECLARE_METATYPE(QVector<QRectF>)
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 BarAnimation::BarAnimation(BarChartItem *item)
29 BarAnimation::BarAnimation(BarChartItem *item)
30 :ChartAnimation(item),
30 :AbstractBarAnimation(item)
31 m_item(item)
32 {
31 {
32 setDuration(ChartAnimationDuration);
33 setEasingCurve(QEasingCurve::OutQuart);
33 setEasingCurve(QEasingCurve::OutQuart);
34 }
34 }
35
35
@@ -57,20 +57,6 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qr
57 return qVariantFromValue(result);
57 return qVariantFromValue(result);
58 }
58 }
59
59
60 void BarAnimation::updateCurrentValue(const QVariant &value)
61 {
62 QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value);
63 m_item->setLayout(layout);
64 }
65
66 void BarAnimation::updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
67 {
68 setDuration(ChartAnimationDuration);
69 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
70 setKeyValueAt(1.0, qVariantFromValue(newLayout));
71 QTimer::singleShot(0, this, SLOT(start()));
72 }
73
74 #include "moc_baranimation_p.cpp"
60 #include "moc_baranimation_p.cpp"
75
61
76 QTCOMMERCIALCHART_END_NAMESPACE
62 QTCOMMERCIALCHART_END_NAMESPACE
@@ -30,16 +30,15
30 #ifndef BARANIMATION_P_H
30 #ifndef BARANIMATION_P_H
31 #define BARANIMATION_P_H
31 #define BARANIMATION_P_H
32
32
33 #include "abstractbaranimation_p.h"
33 #include "chartanimation_p.h"
34 #include "chartanimation_p.h"
34 #include "barchartitem_p.h"
35 #include "barchartitem_p.h"
35
36
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
38
38 class BarChartItem;
39 class BarChartItem;
39 class QBarSet;
40 class BarSetAnimation;
41
40
42 class BarAnimation : public ChartAnimation
41 class BarAnimation : public AbstractBarAnimation
43 {
42 {
44 Q_OBJECT
43 Q_OBJECT
45
44
@@ -49,12 +48,6 public:
49
48
50 public: // from QVariantAnimation
49 public: // from QVariantAnimation
51 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
50 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
52 virtual void updateCurrentValue(const QVariant &value);
53
54 void updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
55
56 private:
57 BarChartItem *m_item;
58 };
51 };
59
52
60 QTCOMMERCIALCHART_END_NAMESPACE
53 QTCOMMERCIALCHART_END_NAMESPACE
@@ -61,43 +61,6 void ChartAnimator::addAnimation(PieChartItem *item)
61 item->setAnimator(this);
61 item->setAnimator(this);
62 }
62 }
63
63
64 void ChartAnimator::addAnimation(BarChartItem *item)
65 {
66 // This can handle also GroupedBarChartItem because bars are side by side
67 ChartAnimation *animation = m_animations.value(item);
68
69 if (!animation) {
70 animation = new BarAnimation(item);
71 m_animations.insert(item, animation);
72 }
73
74 item->setAnimator(this);
75 }
76
77 void ChartAnimator::addAnimation(StackedBarChartItem *item)
78 {
79 ChartAnimation *animation = m_animations.value(item);
80
81 if (!animation) {
82 animation = new StackedBarAnimation(item);
83 m_animations.insert(item, animation);
84 }
85
86 item->setAnimator(this);
87 }
88
89 void ChartAnimator::addAnimation(PercentBarChartItem *item)
90 {
91 ChartAnimation *animation = m_animations.value(item);
92
93 if (!animation) {
94 animation = new PercentBarAnimation(item);
95 m_animations.insert(item, animation);
96 }
97
98 item->setAnimator(this);
99 }
100
101 void ChartAnimator::removeAnimation(Chart *item)
64 void ChartAnimator::removeAnimation(Chart *item)
102 {
65 {
103 item->setAnimator(0);
66 item->setAnimator(0);
@@ -125,44 +88,6 void ChartAnimator::updateAnimation(PieChartItem *item, PieSliceItem *sliceItem,
125 animation->updateValue(sliceItem, sliceData);
88 animation->updateValue(sliceItem, sliceData);
126 }
89 }
127
90
128 void ChartAnimator::updateLayout(BarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
129 {
130 BarAnimation *animation = static_cast<BarAnimation *>(m_animations.value(item));
131 if (animation) {
132 m_animations.remove(item);
133 animation->deleteLater();
134 animation = 0;
135 addAnimation(item);
136 }
137 animation = static_cast<BarAnimation *>(m_animations.value(item));
138 animation->updateLayout(oldLayout,newLayout);
139 }
140
141 void ChartAnimator::updateLayout(StackedBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
142 {
143 StackedBarAnimation *animation = static_cast<StackedBarAnimation *>(m_animations.value(item));
144 if (animation) {
145 m_animations.remove(item);
146 animation->deleteLater();
147 animation = 0;
148 addAnimation(item);
149 }
150 animation = static_cast<StackedBarAnimation *>(m_animations.value(item));
151 animation->updateLayout(oldLayout,newLayout);
152 }
153
154 void ChartAnimator::updateLayout(PercentBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
155 {
156 PercentBarAnimation *animation = static_cast<PercentBarAnimation *>(m_animations.value(item));
157 if (animation) {
158 m_animations.remove(item);
159 animation->deleteLater();
160 animation = 0;
161 addAnimation(item);
162 }
163 animation = static_cast<PercentBarAnimation *>(m_animations.value(item));
164 animation->updateLayout(oldLayout,newLayout);
165 }
166 #include "moc_chartanimator_p.cpp"
91 #include "moc_chartanimator_p.cpp"
167
92
168 QTCOMMERCIALCHART_END_NAMESPACE
93 QTCOMMERCIALCHART_END_NAMESPACE
@@ -55,19 +55,12 public:
55 virtual ~ChartAnimator();
55 virtual ~ChartAnimator();
56
56
57 void addAnimation(PieChartItem *item);
57 void addAnimation(PieChartItem *item);
58 void addAnimation(BarChartItem *item);
59 void addAnimation(StackedBarChartItem *item);
60 void addAnimation(PercentBarChartItem *item);
61 void removeAnimation(Chart *item);
58 void removeAnimation(Chart *item);
62
59
63 void addAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData, bool isEmpty);
60 void addAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData, bool isEmpty);
64 void removeAnimation(PieChartItem *item, PieSliceItem *sliceItem);
61 void removeAnimation(PieChartItem *item, PieSliceItem *sliceItem);
65 void updateAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData);
62 void updateAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData);
66
63
67 void updateLayout(BarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
68 void updateLayout(StackedBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
69 void updateLayout(PercentBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
70
71 private:
64 private:
72 QMap<Chart *, ChartAnimation *> m_animations;
65 QMap<Chart *, ChartAnimation *> m_animations;
73 };
66 };
@@ -26,10 +26,10 Q_DECLARE_METATYPE(QVector<QRectF>)
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 PercentBarAnimation::PercentBarAnimation(BarChartItem *item)
29 PercentBarAnimation::PercentBarAnimation(PercentBarChartItem *item)
30 :ChartAnimation(item),
30 :AbstractBarAnimation(item)
31 m_item(item)
32 {
31 {
32 setDuration(ChartAnimationDuration);
33 setEasingCurve(QEasingCurve::OutQuart);
33 setEasingCurve(QEasingCurve::OutQuart);
34 }
34 }
35
35
@@ -59,20 +59,6 QVariant PercentBarAnimation::interpolated(const QVariant &from, const QVariant
59 return qVariantFromValue(result);
59 return qVariantFromValue(result);
60 }
60 }
61
61
62 void PercentBarAnimation::updateCurrentValue(const QVariant &value)
63 {
64 QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value);
65 m_item->setLayout(layout);
66 }
67
68 void PercentBarAnimation::updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
69 {
70 setDuration(ChartAnimationDuration);
71 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
72 setKeyValueAt(1.0, qVariantFromValue(newLayout));
73 QTimer::singleShot(0, this, SLOT(start()));
74 }
75
76 #include "moc_percentbaranimation_p.cpp"
62 #include "moc_percentbaranimation_p.cpp"
77
63
78 QTCOMMERCIALCHART_END_NAMESPACE
64 QTCOMMERCIALCHART_END_NAMESPACE
@@ -11,6 +11,7
11 #define PERCENTBARANIMATION_P_H
11 #define PERCENTBARANIMATION_P_H
12
12
13 #include "chartanimation_p.h"
13 #include "chartanimation_p.h"
14 #include "abstractbaranimation_p.h"
14 #include "barchartitem_p.h"
15 #include "barchartitem_p.h"
15
16
16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
17 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -19,23 +20,14 class PercentBarChartItem;
19 class QBarSet;
20 class QBarSet;
20 class BarSetAnimation;
21 class BarSetAnimation;
21
22
22 class PercentBarAnimation : public ChartAnimation
23 class PercentBarAnimation : public AbstractBarAnimation
23 {
24 {
24 Q_OBJECT
25 Q_OBJECT
25 public:
26 public:
26 PercentBarAnimation(BarChartItem *item);
27 PercentBarAnimation(PercentBarChartItem *item);
27 ~PercentBarAnimation();
28 ~PercentBarAnimation();
28
29
29 public:
30 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
30 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
31 virtual void updateCurrentValue(const QVariant &value);
32
33 void updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
34
35 private:
36 BarChartItem *m_item;
37 QHash<QBarSet *, BarSetAnimation *> m_animations;
38
39 };
31 };
40
32
41 QTCOMMERCIALCHART_END_NAMESPACE
33 QTCOMMERCIALCHART_END_NAMESPACE
@@ -26,9 +26,8 Q_DECLARE_METATYPE(QVector<QRectF>)
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 StackedBarAnimation::StackedBarAnimation(BarChartItem *item)
29 StackedBarAnimation::StackedBarAnimation(StackedBarChartItem *item)
30 :ChartAnimation(item),
30 :AbstractBarAnimation(item)
31 m_item(item)
32 {
31 {
33 setEasingCurve(QEasingCurve::OutQuart);
32 setEasingCurve(QEasingCurve::OutQuart);
34 }
33 }
@@ -59,20 +58,6 QVariant StackedBarAnimation::interpolated(const QVariant &from, const QVariant
59 return qVariantFromValue(result);
58 return qVariantFromValue(result);
60 }
59 }
61
60
62 void StackedBarAnimation::updateCurrentValue(const QVariant &value)
63 {
64 QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value);
65 m_item->setLayout(layout);
66 }
67
68
69 void StackedBarAnimation::updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
70 {
71 setDuration(ChartAnimationDuration);
72 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
73 setKeyValueAt(1.0, qVariantFromValue(newLayout));
74 QTimer::singleShot(0, this, SLOT(start()));
75 }
76 #include "moc_stackedbaranimation_p.cpp"
61 #include "moc_stackedbaranimation_p.cpp"
77
62
78 QTCOMMERCIALCHART_END_NAMESPACE
63 QTCOMMERCIALCHART_END_NAMESPACE
@@ -12,6 +12,7
12
12
13 #include "chartanimation_p.h"
13 #include "chartanimation_p.h"
14 #include "barchartitem_p.h"
14 #include "barchartitem_p.h"
15 #include "abstractbaranimation_p.h"
15
16
16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
17 QTCOMMERCIALCHART_BEGIN_NAMESPACE
17
18
@@ -19,23 +20,14 class StackedBarChartItem;
19 class QBarSet;
20 class QBarSet;
20 class BarSetAnimation;
21 class BarSetAnimation;
21
22
22 class StackedBarAnimation : public ChartAnimation
23 class StackedBarAnimation : public AbstractBarAnimation
23 {
24 {
24 Q_OBJECT
25 Q_OBJECT
25 public:
26 public:
26 StackedBarAnimation(BarChartItem *item);
27 StackedBarAnimation(StackedBarChartItem *item);
27 ~StackedBarAnimation();
28 ~StackedBarAnimation();
28
29
29 public:
30 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
30 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
31 virtual void updateCurrentValue(const QVariant &value);
32
33 void updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
34
35 private:
36 BarChartItem *m_item;
37 QHash<QBarSet *, BarSetAnimation *> m_animations;
38
39 };
31 };
40
32
41 QTCOMMERCIALCHART_END_NAMESPACE
33 QTCOMMERCIALCHART_END_NAMESPACE
@@ -27,6 +27,7
27 #include "qchart.h"
27 #include "qchart.h"
28 #include "chartpresenter_p.h"
28 #include "chartpresenter_p.h"
29 #include "chartanimator_p.h"
29 #include "chartanimator_p.h"
30 #include "abstractbaranimation_p.h"
30 #include "chartdataset_p.h"
31 #include "chartdataset_p.h"
31 #include <QPainter>
32 #include <QPainter>
32
33
@@ -34,6 +35,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
35
35 BarChartItem::BarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
36 BarChartItem::BarChartItem(QAbstractBarSeries *series, ChartPresenter *presenter) :
36 ChartItem(presenter),
37 ChartItem(presenter),
38 m_animation(0),
37 m_series(series)
39 m_series(series)
38 {
40 {
39 setFlag(ItemClipsChildrenToShape);
41 setFlag(ItemClipsChildrenToShape);
@@ -121,14 +123,21 QVector<QRectF> BarChartItem::calculateLayout()
121
123
122 void BarChartItem::applyLayout(const QVector<QRectF> &layout)
124 void BarChartItem::applyLayout(const QVector<QRectF> &layout)
123 {
125 {
124 if (animator()) {
126 if (m_animation) {
125 animator()->updateLayout(this, m_layout, layout);
127 m_animation->setup(m_layout,layout);
128 presenter()->startAnimation(m_animation);
129
126 } else {
130 } else {
127 setLayout(layout);
131 setLayout(layout);
128 update();
132 update();
129 }
133 }
130 }
134 }
131
135
136 void BarChartItem::setAnimation(AbstractBarAnimation *animation)
137 {
138 m_animation = animation;
139 }
140
132 void BarChartItem::setLayout(const QVector<QRectF> &layout)
141 void BarChartItem::setLayout(const QVector<QRectF> &layout)
133 {
142 {
134 if (layout.count() != m_bars.count())
143 if (layout.count() != m_bars.count())
@@ -41,6 +41,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41 class Bar;
41 class Bar;
42 class QAxisCategories;
42 class QAxisCategories;
43 class QChart;
43 class QChart;
44 class AbstractBarAnimation;
44
45
45 class BarChartItem : public ChartItem
46 class BarChartItem : public ChartItem
46 {
47 {
@@ -55,9 +56,11 public:
55
56
56 virtual QVector<QRectF> calculateLayout();
57 virtual QVector<QRectF> calculateLayout();
57 virtual void applyLayout(const QVector<QRectF> &layout);
58 virtual void applyLayout(const QVector<QRectF> &layout);
59 virtual void setAnimation(AbstractBarAnimation* animation);
58 void setLayout(const QVector<QRectF> &layout);
60 void setLayout(const QVector<QRectF> &layout);
59 void updateLayout(const QVector<QRectF> &layout);
61 void updateLayout(const QVector<QRectF> &layout);
60
62
63
61 QRectF geometry() const { return m_rect;}
64 QRectF geometry() const { return m_rect;}
62
65
63 public Q_SLOTS:
66 public Q_SLOTS:
@@ -78,6 +81,8 protected:
78 QRectF m_rect;
81 QRectF m_rect;
79 QVector<QRectF> m_layout;
82 QVector<QRectF> m_layout;
80
83
84 AbstractBarAnimation *m_animation;
85
81 // Not owned.
86 // Not owned.
82 QAbstractBarSeries *m_series;
87 QAbstractBarSeries *m_series;
83 QList<Bar *> m_bars;
88 QList<Bar *> m_bars;
@@ -97,15 +97,6 QVector<QRectF> PercentBarChartItem::calculateLayout()
97 return layout;
97 return layout;
98 }
98 }
99
99
100 void PercentBarChartItem::applyLayout(const QVector<QRectF> &layout)
101 {
102 if (animator()) {
103 animator()->updateLayout(this, m_layout, layout);
104 } else {
105 setLayout(layout);
106 update();
107 }
108 }
109 #include "moc_percentbarchartitem_p.cpp"
100 #include "moc_percentbarchartitem_p.cpp"
110
101
111 QTCOMMERCIALCHART_END_NAMESPACE
102 QTCOMMERCIALCHART_END_NAMESPACE
@@ -46,7 +46,6 public:
46
46
47 private:
47 private:
48 virtual QVector<QRectF> calculateLayout();
48 virtual QVector<QRectF> calculateLayout();
49 virtual void applyLayout(const QVector<QRectF> &layout);
50 };
49 };
51
50
52 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
@@ -578,15 +578,9 void QAbstractBarSeriesPrivate::scaleDomain(Domain& domain)
578
578
579 Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
579 Chart* QAbstractBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
580 {
580 {
581 Q_Q(QAbstractBarSeries);
581 Q_UNUSED(presenter);
582
582 qWarning() << "QAbstractBarSeriesPrivate::createGraphics called";
583 BarChartItem* bar = new BarChartItem(q,presenter);
583 return 0;
584 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
585 presenter->animator()->addAnimation(bar);
586 }
587 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
588 return bar;
589
590 }
584 }
591
585
592 QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend)
586 QList<LegendMarker*> QAbstractBarSeriesPrivate::createLegendMarker(QLegend* legend)
@@ -24,6 +24,7
24 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27 #include "baranimation_p.h"
27 #include "qvaluesaxis.h"
28 #include "qvaluesaxis.h"
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -105,13 +106,13 Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
105
106
106 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
107 GroupedBarChartItem* bar = new GroupedBarChartItem(q,presenter);
107 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
108 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
108 presenter->animator()->addAnimation(bar);
109 bar->setAnimator(presenter->animator());
110 bar->setAnimation(new BarAnimation(bar));
109 }
111 }
110 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
112 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
111 return bar;
113 return bar;
112 }
114 }
113
115
114
115 #include "moc_qbarseries.cpp"
116 #include "moc_qbarseries.cpp"
116
117
117 QTCOMMERCIALCHART_END_NAMESPACE
118 QTCOMMERCIALCHART_END_NAMESPACE
@@ -25,6 +25,7
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27 #include "qvaluesaxis.h"
27 #include "qvaluesaxis.h"
28 #include "percentbaranimation_p.h"
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
@@ -104,7 +105,8 Chart* QPercentBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
104
105
105 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
106 PercentBarChartItem* bar = new PercentBarChartItem(q,presenter);
106 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
107 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
107 presenter->animator()->addAnimation(bar);
108 bar->setAnimator(presenter->animator());
109 bar->setAnimation(new PercentBarAnimation(bar));
108 }
110 }
109 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
111 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
110 return bar;
112 return bar;
@@ -25,6 +25,7
25 #include "charttheme_p.h"
25 #include "charttheme_p.h"
26 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
27 #include "qvaluesaxis.h"
27 #include "qvaluesaxis.h"
28 #include "stackedbaranimation_p.h"
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
@@ -106,7 +107,8 Chart* QStackedBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
106
107
107 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
108 StackedBarChartItem* bar = new StackedBarChartItem(q,presenter);
108 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
109 if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
109 presenter->animator()->addAnimation(bar);
110 bar->setAnimator(presenter->animator());
111 bar->setAnimation(new StackedBarAnimation(bar));
110 }
112 }
111 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
113 presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
112 return bar;
114 return bar;
@@ -90,16 +90,6 QVector<QRectF> StackedBarChartItem::calculateLayout()
90 return layout;
90 return layout;
91 }
91 }
92
92
93 void StackedBarChartItem::applyLayout(const QVector<QRectF> &layout)
94 {
95 if (animator()) {
96 animator()->updateLayout(this, m_layout, layout);
97 } else {
98 setLayout(layout);
99 update();
100 }
101 }
102
103 #include "moc_stackedbarchartitem_p.cpp"
93 #include "moc_stackedbarchartitem_p.cpp"
104
94
105 QTCOMMERCIALCHART_END_NAMESPACE
95 QTCOMMERCIALCHART_END_NAMESPACE
@@ -45,7 +45,6 public:
45
45
46 private:
46 private:
47 virtual QVector<QRectF> calculateLayout();
47 virtual QVector<QRectF> calculateLayout();
48 virtual void applyLayout(const QVector<QRectF> &layout);
49 };
48 };
50
49
51 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now