1// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qchannel.h"
5
6#include <QtCore/qlist.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DAnimation {
11
12class QChannelPrivate
13{
14public:
15 QVector<QChannelComponent> m_channelComponents;
16 QString m_name;
17 int m_jointIndex = -1;
18};
19
20/*!
21 \class Qt3DAnimation::QChannel
22 \inmodule Qt3DAnimation
23 \brief Defines a channel for a QAnimationClipData.
24 The animation system interpolates each channel component independently
25 except in the case the QChannel is called "Rotation" (case sensitive),
26 it has four QChannelComponents and the same number of keyframes for
27 each QChannelComponent. In that case the interpolation will be performed
28 using SLERP.
29*/
30QChannel::QChannel()
31 : d(new QChannelPrivate)
32{
33}
34
35QChannel::QChannel(const QString &name)
36 : d(new QChannelPrivate)
37{
38 d->m_name = name;
39}
40
41QChannel::QChannel(const QChannel &rhs)
42 : d(new QChannelPrivate)
43{
44 *d = *(rhs.d);
45}
46
47QChannel &QChannel::operator=(const QChannel &rhs)
48{
49 if (this != &rhs)
50 *d = *(rhs.d);
51 return *this;
52}
53
54QChannel::~QChannel()
55{
56}
57
58void QChannel::setName(const QString &name)
59{
60 d->m_name = name;
61}
62
63QString QChannel::name() const
64{
65 return d->m_name;
66}
67
68void QChannel::setJointIndex(int jointIndex)
69{
70 d->m_jointIndex = jointIndex;
71}
72
73int QChannel::jointIndex() const
74{
75 return d->m_jointIndex;
76}
77
78int QChannel::channelComponentCount() const
79{
80 return d->m_channelComponents.size();
81}
82
83void QChannel::appendChannelComponent(const QChannelComponent &component)
84{
85 d->m_channelComponents.append(t: component);
86}
87
88void QChannel::insertChannelComponent(int index, const QChannelComponent &component)
89{
90 d->m_channelComponents.insert(i: index, t: component);
91}
92
93void QChannel::removeChannelComponent(int index)
94{
95 d->m_channelComponents.remove(i: index);
96}
97
98void QChannel::clearChannelComponents()
99{
100 d->m_channelComponents.clear();
101}
102
103QChannel::const_iterator QChannel::begin() const noexcept
104{
105 return d->m_channelComponents.cbegin().operator->();
106}
107
108QChannel::const_iterator QChannel::end() const noexcept
109{
110 return d->m_channelComponents.cend().operator->();
111}
112
113bool operator==(const QChannel &lhs, const QChannel &rhs) noexcept
114{
115 return lhs.d->m_name == rhs.d->m_name && lhs.d->m_channelComponents == rhs.d->m_channelComponents;
116}
117
118bool operator!=(const QChannel &lhs, const QChannel &rhs) noexcept
119{
120 return lhs.d->m_name != rhs.d->m_name || lhs.d->m_channelComponents != rhs.d->m_channelComponents;
121}
122
123} // namespace Qt3DAnimation
124
125QT_END_NAMESPACE
126

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