1/****************************************************************************
2**
3** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qchannel.h"
41
42#include <QtCore/qvector.h>
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DAnimation {
47
48class QChannelPrivate
49{
50public:
51 QVector<QChannelComponent> m_channelComponents;
52 QString m_name;
53 int m_jointIndex = -1;
54};
55
56/*!
57 \class Qt3DAnimation::QChannel
58 \inmodule Qt3DAnimation
59 \brief Defines a channel for a QAnimationClipData.
60 The animation system interpolates each channel component independently
61 except in the case the QChannel is called "Rotation" (case sensitive),
62 it has four QChannelComponents and the same number of keyframes for
63 each QChannelComponent. In that case the interpolation will be performed
64 using SLERP.
65*/
66QChannel::QChannel()
67 : d(new QChannelPrivate)
68{
69}
70
71QChannel::QChannel(const QString &name)
72 : d(new QChannelPrivate)
73{
74 d->m_name = name;
75}
76
77QChannel::QChannel(const QChannel &rhs)
78 : d(new QChannelPrivate)
79{
80 *d = *(rhs.d);
81}
82
83QChannel &QChannel::operator=(const QChannel &rhs)
84{
85 if (this != &rhs)
86 *d = *(rhs.d);
87 return *this;
88}
89
90QChannel::~QChannel()
91{
92}
93
94void QChannel::setName(const QString &name)
95{
96 d->m_name = name;
97}
98
99QString QChannel::name() const
100{
101 return d->m_name;
102}
103
104void QChannel::setJointIndex(int jointIndex)
105{
106 d->m_jointIndex = jointIndex;
107}
108
109int QChannel::jointIndex() const
110{
111 return d->m_jointIndex;
112}
113
114int QChannel::channelComponentCount() const
115{
116 return d->m_channelComponents.size();
117}
118
119void QChannel::appendChannelComponent(const QChannelComponent &component)
120{
121 d->m_channelComponents.append(t: component);
122}
123
124void QChannel::insertChannelComponent(int index, const QChannelComponent &component)
125{
126 d->m_channelComponents.insert(i: index, t: component);
127}
128
129void QChannel::removeChannelComponent(int index)
130{
131 d->m_channelComponents.remove(i: index);
132}
133
134void QChannel::clearChannelComponents()
135{
136 d->m_channelComponents.clear();
137}
138
139QChannel::const_iterator QChannel::begin() const Q_DECL_NOTHROW
140{
141 return d->m_channelComponents.cbegin();
142}
143
144QChannel::const_iterator QChannel::end() const Q_DECL_NOTHROW
145{
146 return d->m_channelComponents.cend();
147}
148
149bool operator==(const QChannel &lhs, const QChannel &rhs) Q_DECL_NOTHROW
150{
151 return lhs.d->m_name == rhs.d->m_name && lhs.d->m_channelComponents == rhs.d->m_channelComponents;
152}
153
154bool operator!=(const QChannel &lhs, const QChannel &rhs) Q_DECL_NOTHROW
155{
156 return lhs.d->m_name != rhs.d->m_name || lhs.d->m_channelComponents != rhs.d->m_channelComponents;
157}
158
159} // namespace Qt3DAnimation
160
161QT_END_NAMESPACE
162

source code of qt3d/src/animation/frontend/qchannel.cpp