##// END OF EJS Templates
Fixed documentation of qmlchart demo
Fixed documentation of qmlchart demo

File last commit:

r1426:9cc71c12c6d0
r1520:a557edf16956
Show More
chartanimator.cpp
168 lines | 5.1 KiB | text/x-c | CppLexer
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
#include "chartanimator_p.h"
#include "axisanimation_p.h"
#include "xyanimation_p.h"
#include "splineanimation_p.h"
#include "xychart_p.h"
#include "pieanimation_p.h"
#include "baranimation_p.h"
#include "barchartitem_p.h"
#include "stackedbaranimation_p.h"
#include "stackedbarchartitem_p.h"
#include "percentbaranimation_p.h"
#include "percentbarchartitem_p.h"
#include "areachartitem_p.h"
#include "splinechartitem_p.h"
#include "scatterchartitem_p.h"
#include "chartaxis_p.h"
#include <QTimer>
Q_DECLARE_METATYPE(QVector<QPointF>)
Q_DECLARE_METATYPE(QVector<qreal>)
Q_DECLARE_METATYPE(QVector<QRectF>)
QTCOMMERCIALCHART_BEGIN_NAMESPACE
ChartAnimator::ChartAnimator(QObject *parent):QObject(parent)
{
}
ChartAnimator::~ChartAnimator()
{
}
void ChartAnimator::addAnimation(PieChartItem *item)
{
ChartAnimation *animation = m_animations.value(item);
if (!animation) {
animation = new PieAnimation(item);
m_animations.insert(item, animation);
}
item->setAnimator(this);
}
void ChartAnimator::addAnimation(BarChartItem *item)
{
// This can handle also GroupedBarChartItem because bars are side by side
ChartAnimation *animation = m_animations.value(item);
if (!animation) {
animation = new BarAnimation(item);
m_animations.insert(item, animation);
}
item->setAnimator(this);
}
void ChartAnimator::addAnimation(StackedBarChartItem *item)
{
ChartAnimation *animation = m_animations.value(item);
if (!animation) {
animation = new StackedBarAnimation(item);
m_animations.insert(item, animation);
}
item->setAnimator(this);
}
void ChartAnimator::addAnimation(PercentBarChartItem *item)
{
ChartAnimation *animation = m_animations.value(item);
if (!animation) {
animation = new PercentBarAnimation(item);
m_animations.insert(item, animation);
}
item->setAnimator(this);
}
void ChartAnimator::removeAnimation(Chart *item)
{
item->setAnimator(0);
m_animations.remove(item);
}
void ChartAnimator::addAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData, bool startupAnimation)
{
PieAnimation *animation = static_cast<PieAnimation *>(m_animations.value(item));
Q_ASSERT(animation);
animation->addSlice(sliceItem, sliceData, startupAnimation);
}
void ChartAnimator::removeAnimation(PieChartItem *item, PieSliceItem *sliceItem)
{
PieAnimation *animation = static_cast<PieAnimation *>(m_animations.value(item));
Q_ASSERT(animation);
animation->removeSlice(sliceItem);
}
void ChartAnimator::updateAnimation(PieChartItem *item, PieSliceItem *sliceItem, const PieSliceData &sliceData)
{
PieAnimation *animation = static_cast<PieAnimation *>(m_animations.value(item));
Q_ASSERT(animation);
animation->updateValue(sliceItem, sliceData);
}
void ChartAnimator::updateLayout(BarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
{
BarAnimation *animation = static_cast<BarAnimation *>(m_animations.value(item));
if (animation) {
m_animations.remove(item);
animation->deleteLater();
animation = 0;
addAnimation(item);
}
animation = static_cast<BarAnimation *>(m_animations.value(item));
animation->updateLayout(oldLayout,newLayout);
}
void ChartAnimator::updateLayout(StackedBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
{
StackedBarAnimation *animation = static_cast<StackedBarAnimation *>(m_animations.value(item));
if (animation) {
m_animations.remove(item);
animation->deleteLater();
animation = 0;
addAnimation(item);
}
animation = static_cast<StackedBarAnimation *>(m_animations.value(item));
animation->updateLayout(oldLayout,newLayout);
}
void ChartAnimator::updateLayout(PercentBarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
{
PercentBarAnimation *animation = static_cast<PercentBarAnimation *>(m_animations.value(item));
if (animation) {
m_animations.remove(item);
animation->deleteLater();
animation = 0;
addAnimation(item);
}
animation = static_cast<PercentBarAnimation *>(m_animations.value(item));
animation->updateLayout(oldLayout,newLayout);
}
#include "moc_chartanimator_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE