| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt Charts module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 or (at your option) any later version | 
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by | 
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 | 
| 22 | ** included in the packaging of this file. Please review the following | 
| 23 | ** information to ensure the GNU General Public License requirements will | 
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 25 | ** | 
| 26 | ** $QT_END_LICENSE$ | 
| 27 | ** | 
| 28 | ****************************************************************************/ | 
| 29 |  | 
| 30 | #include <private/boxplotanimation_p.h> | 
| 31 | #include <private/boxplotchartitem_p.h> | 
| 32 | #include <private/boxwhiskersdata_p.h> | 
| 33 | #include <private/boxwhiskersanimation_p.h> | 
| 34 |  | 
| 35 | QT_CHARTS_BEGIN_NAMESPACE | 
| 36 |  | 
| 37 | BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item, int duration, QEasingCurve &curve) | 
| 38 |     : QObject(item), | 
| 39 |     m_item(item), | 
| 40 |     m_animationDuration(duration), | 
| 41 |     m_animationCurve(curve) | 
| 42 | { | 
| 43 | } | 
| 44 |  | 
| 45 | BoxPlotAnimation::~BoxPlotAnimation() | 
| 46 | { | 
| 47 | } | 
| 48 |  | 
| 49 | void BoxPlotAnimation::addBox(BoxWhiskers *box) | 
| 50 | { | 
| 51 |     BoxWhiskersAnimation *animation = m_animations.value(akey: box); | 
| 52 |     if (!animation) { | 
| 53 |         animation = new BoxWhiskersAnimation(box, this, m_animationDuration, m_animationCurve); | 
| 54 |         m_animations.insert(akey: box, avalue: animation); | 
| 55 |         BoxWhiskersData start; | 
| 56 |         start.m_lowerExtreme = box->m_data.m_median; | 
| 57 |         start.m_lowerQuartile = box->m_data.m_median; | 
| 58 |         start.m_median = box->m_data.m_median; | 
| 59 |         start.m_upperQuartile = box->m_data.m_median; | 
| 60 |         start.m_upperExtreme = box->m_data.m_median; | 
| 61 |         animation->setup(startData: start, endData: box->m_data); | 
| 62 |  | 
| 63 |     } else { | 
| 64 |         animation->stop(); | 
| 65 |         animation->setEndData(box->m_data); | 
| 66 |     } | 
| 67 | } | 
| 68 |  | 
| 69 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) | 
| 70 | { | 
| 71 |     BoxWhiskersAnimation *animation = m_animations.value(akey: box); | 
| 72 |     if (animation) | 
| 73 |         animation->m_changeAnimation = false; | 
| 74 |  | 
| 75 |     return animation; | 
| 76 | } | 
| 77 |  | 
| 78 | ChartAnimation *BoxPlotAnimation::boxChangeAnimation(BoxWhiskers *box) | 
| 79 | { | 
| 80 |     BoxWhiskersAnimation *animation = m_animations.value(akey: box); | 
| 81 |     animation->m_changeAnimation = true; | 
| 82 |     animation->setEndData(box->m_data); | 
| 83 |  | 
| 84 |     return animation; | 
| 85 | } | 
| 86 |  | 
| 87 | void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) | 
| 88 | { | 
| 89 |     BoxWhiskersAnimation *animation = m_animations.value(akey: box); | 
| 90 |     animation->setStartData(box->m_data); | 
| 91 | } | 
| 92 |  | 
| 93 | void BoxPlotAnimation::stopAll() | 
| 94 | { | 
| 95 |     foreach (BoxWhiskers *box, m_animations.keys()) { | 
| 96 |         BoxWhiskersAnimation *animation = m_animations.value(akey: box); | 
| 97 |         animation->stopAndDestroyLater(); | 
| 98 |         m_animations.remove(akey: box); | 
| 99 |     } | 
| 100 | } | 
| 101 |  | 
| 102 | void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box) | 
| 103 | { | 
| 104 |     m_animations.remove(akey: box); | 
| 105 | } | 
| 106 |  | 
| 107 | QT_CHARTS_END_NAMESPACE | 
| 108 |  | 
| 109 | #include "moc_boxplotanimation_p.cpp" | 
| 110 |  |