From 39ff78a6c3c819b0db9ef04fa7b4d6ac3311c02b Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 4 Apr 2017 14:52:50 +0100 Subject: Add value types for animation data Change-Id: I477559e20dd10115a8aba0a2845b0e4e003e07c8 Reviewed-by: Mike Krus --- src/animation/frontend/frontend.pri | 12 +- src/animation/frontend/qanimationclipdata.cpp | 136 ++++++++++++++++++++++ src/animation/frontend/qanimationclipdata.h | 99 ++++++++++++++++ src/animation/frontend/qchannel.cpp | 142 +++++++++++++++++++++++ src/animation/frontend/qchannel.h | 98 ++++++++++++++++ src/animation/frontend/qchannelcomponent.cpp | 142 +++++++++++++++++++++++ src/animation/frontend/qchannelcomponent.h | 98 ++++++++++++++++ src/animation/frontend/qkeyframe.cpp | 49 ++++++++ src/animation/frontend/qkeyframe.h | 160 ++++++++++++++++++++++++++ 9 files changed, 934 insertions(+), 2 deletions(-) create mode 100644 src/animation/frontend/qanimationclipdata.cpp create mode 100644 src/animation/frontend/qanimationclipdata.h create mode 100644 src/animation/frontend/qchannel.cpp create mode 100644 src/animation/frontend/qchannel.h create mode 100644 src/animation/frontend/qchannelcomponent.cpp create mode 100644 src/animation/frontend/qchannelcomponent.h create mode 100644 src/animation/frontend/qkeyframe.cpp create mode 100644 src/animation/frontend/qkeyframe.h (limited to 'src') diff --git a/src/animation/frontend/frontend.pri b/src/animation/frontend/frontend.pri index 439f204d1..86527ea00 100644 --- a/src/animation/frontend/frontend.pri +++ b/src/animation/frontend/frontend.pri @@ -38,7 +38,11 @@ HEADERS += \ $$PWD/qadditiveclipblend.h \ $$PWD/qadditiveclipblend_p.h \ $$PWD/qclipblendvalue.h \ - $$PWD/qclipblendvalue_p.h + $$PWD/qclipblendvalue_p.h \ + $$PWD/qanimationclipdata.h \ + $$PWD/qchannel.h \ + $$PWD/qchannelcomponent.h \ + $$PWD/qkeyframe.h SOURCES += \ $$PWD/qanimationaspect.cpp \ @@ -60,6 +64,10 @@ SOURCES += \ $$PWD/qanimationcliploader.cpp \ $$PWD/qlerpclipblend.cpp \ $$PWD/qadditiveclipblend.cpp \ - $$PWD/qclipblendvalue.cpp + $$PWD/qclipblendvalue.cpp \ + $$PWD/qanimationclipdata.cpp \ + $$PWD/qchannel.cpp \ + $$PWD/qchannelcomponent.cpp \ + $$PWD/qkeyframe.cpp INCLUDEPATH += $$PWD diff --git a/src/animation/frontend/qanimationclipdata.cpp b/src/animation/frontend/qanimationclipdata.cpp new file mode 100644 index 000000000..4ae9f36d7 --- /dev/null +++ b/src/animation/frontend/qanimationclipdata.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qanimationclipdata.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QAnimationClipDataPrivate +{ +public: + QVector m_channels; + QString m_name; +}; + +QAnimationClipData::QAnimationClipData() + : d(new QAnimationClipDataPrivate) +{ +} + +QAnimationClipData::QAnimationClipData(const QAnimationClipData &rhs) + : d(new QAnimationClipDataPrivate) +{ + *d = *(rhs.d); +} + +QAnimationClipData &QAnimationClipData::operator=(const QAnimationClipData &rhs) +{ + if (this != &rhs) + *d = *(rhs.d); + return *this; +} + +QAnimationClipData::~QAnimationClipData() +{ +} + +void QAnimationClipData::setName(const QString &name) +{ + d->m_name = name; +} + +QString QAnimationClipData::name() const +{ + return d->m_name; +} + +int QAnimationClipData::channelCount() const +{ + return d->m_channels.size(); +} + +void QAnimationClipData::appendChannel(const QChannel &c) +{ + d->m_channels.append(c); +} + +void QAnimationClipData::insertChannel(int index, const QChannel &c) +{ + d->m_channels.insert(index, c); +} + +void QAnimationClipData::removeChannel(int index) +{ + d->m_channels.remove(index); +} + +void QAnimationClipData::clearChannels() +{ + d->m_channels.clear(); +} + +QAnimationClipData::const_iterator QAnimationClipData::begin() const Q_DECL_NOTHROW +{ + return d->m_channels.begin(); +} + +QAnimationClipData::const_iterator QAnimationClipData::end() const Q_DECL_NOTHROW +{ + return d->m_channels.end(); +} + +bool operator==(const QAnimationClipData &lhs, const QAnimationClipData &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name == rhs.d->m_name && + lhs.d->m_channels == rhs.d->m_channels; +} + +bool operator!=(const QAnimationClipData &lhs, const QAnimationClipData &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name != rhs.d->m_name || + lhs.d->m_channels != rhs.d->m_channels; +} + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/animation/frontend/qanimationclipdata.h b/src/animation/frontend/qanimationclipdata.h new file mode 100644 index 000000000..433c80f94 --- /dev/null +++ b/src/animation/frontend/qanimationclipdata.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QANIMATIONCLIPDATA_H +#define QT3DANIMATION_QANIMATIONCLIPDATA_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QAnimationClipDataPrivate; + +class QT3DANIMATIONSHARED_EXPORT QAnimationClipData +{ +public: + QAnimationClipData(); + QAnimationClipData(const QAnimationClipData &); + QAnimationClipData &operator=(const QAnimationClipData &); + ~QAnimationClipData(); + + void setName(const QString &name); + QString name() const; + + int channelCount() const; + void appendChannel(const QChannel &c); + void insertChannel(int index, const QChannel &c); + void removeChannel(int index); + void clearChannels(); + + // Iterator API + typedef const QChannel *const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + const_iterator begin() const Q_DECL_NOTHROW; + const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } + const_iterator end() const Q_DECL_NOTHROW; + const_iterator cend() const Q_DECL_NOTHROW { return end(); } + const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } + const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + + friend bool operator==(const QAnimationClipData &, + const QAnimationClipData &) Q_DECL_NOTHROW; + friend bool operator!=(const QAnimationClipData &, + const QAnimationClipData &) Q_DECL_NOTHROW; + +private: + QScopedPointer d; +}; + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DAnimation::QAnimationClipData) + +#endif // QT3DANIMATION_QANIMATIONCLIPDATA_H diff --git a/src/animation/frontend/qchannel.cpp b/src/animation/frontend/qchannel.cpp new file mode 100644 index 000000000..9c74fad09 --- /dev/null +++ b/src/animation/frontend/qchannel.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qchannel.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QChannelPrivate +{ +public: + QVector m_channelComponents; + QString m_name; +}; + +QChannel::QChannel() + : d(new QChannelPrivate) +{ +} + +QChannel::QChannel(const QString &name) + : d(new QChannelPrivate) +{ + d->m_name = name; +} + +QChannel::QChannel(const QChannel &rhs) + : d(new QChannelPrivate) +{ + *d = *(rhs.d); +} + +QChannel &QChannel::operator=(const QChannel &rhs) +{ + if (this != &rhs) + *d = *(rhs.d); + return *this; +} + +QChannel::~QChannel() +{ +} + +void QChannel::setName(const QString &name) +{ + d->m_name = name; +} + +QString QChannel::name() const +{ + return d->m_name; +} + +int QChannel::channelComponentCount() const +{ + return d->m_channelComponents.size(); +} + +void QChannel::appendChannelComponent(const QChannelComponent &component) +{ + d->m_channelComponents.append(component); +} + +void QChannel::insertChannelComponent(int index, const QChannelComponent &component) +{ + d->m_channelComponents.insert(index, component); +} + +void QChannel::removeChannelComponent(int index) +{ + d->m_channelComponents.remove(index); +} + +void QChannel::clearChannelComponents() +{ + d->m_channelComponents.clear(); +} + +QChannel::const_iterator QChannel::begin() const Q_DECL_NOTHROW +{ + return d->m_channelComponents.begin(); +} + +QChannel::const_iterator QChannel::end() const Q_DECL_NOTHROW +{ + return d->m_channelComponents.end(); +} + +bool operator==(const QChannel &lhs, const QChannel &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name == rhs.d->m_name && + lhs.d->m_channelComponents == rhs.d->m_channelComponents; +} + +bool operator!=(const QChannel &lhs, const QChannel &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name != rhs.d->m_name || + lhs.d->m_channelComponents != rhs.d->m_channelComponents; +} + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/animation/frontend/qchannel.h b/src/animation/frontend/qchannel.h new file mode 100644 index 000000000..b94780689 --- /dev/null +++ b/src/animation/frontend/qchannel.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QCHANNEL_H +#define QT3DANIMATION_QCHANNEL_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QChannelPrivate; + +class QT3DANIMATIONSHARED_EXPORT QChannel +{ +public: + QChannel(); + explicit QChannel(const QString &name); + QChannel(const QChannel &); + QChannel &operator=(const QChannel &); + ~QChannel(); + + void setName(const QString &name); + QString name() const; + + int channelComponentCount() const; + void appendChannelComponent(const QChannelComponent &component); + void insertChannelComponent(int index, const QChannelComponent &component); + void removeChannelComponent(int index); + void clearChannelComponents(); + + // Iterator API + typedef const QChannelComponent *const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + const_iterator begin() const Q_DECL_NOTHROW; + const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } + const_iterator end() const Q_DECL_NOTHROW; + const_iterator cend() const Q_DECL_NOTHROW { return end(); } + const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } + const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + + friend bool operator==(const QChannel &, + const QChannel &) Q_DECL_NOTHROW; + friend bool operator!=(const QChannel &, + const QChannel &) Q_DECL_NOTHROW; + +private: + QScopedPointer d; +}; + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QCHANNEL_H diff --git a/src/animation/frontend/qchannelcomponent.cpp b/src/animation/frontend/qchannelcomponent.cpp new file mode 100644 index 000000000..1ecc5520c --- /dev/null +++ b/src/animation/frontend/qchannelcomponent.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qchannelcomponent.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QChannelComponentPrivate +{ +public: + QVector m_keyFrames; + QString m_name; +}; + +QChannelComponent::QChannelComponent() + : d(new QChannelComponentPrivate) +{ +} + +QChannelComponent::QChannelComponent(const QString &name) + : d(new QChannelComponentPrivate) +{ + d->m_name = name; +} + +QChannelComponent::QChannelComponent(const QChannelComponent &rhs) + : d(new QChannelComponentPrivate) +{ + *d = *(rhs.d); +} + +QChannelComponent &QChannelComponent::operator=(const QChannelComponent &rhs) +{ + if (this != &rhs) + *d = *(rhs.d); + return *this; +} + +QChannelComponent::~QChannelComponent() +{ +} + +void QChannelComponent::setName(const QString &name) +{ + d->m_name = name; +} + +QString QChannelComponent::name() const +{ + return d->m_name; +} + +int QChannelComponent::keyFrameCount() const +{ + return d->m_keyFrames.size(); +} + +void QChannelComponent::appendKeyFrame(const QKeyFrame &kf) +{ + d->m_keyFrames.append(kf); +} + +void QChannelComponent::insertKeyFrame(int index, const QKeyFrame &kf) +{ + d->m_keyFrames.insert(index, kf); +} + +void QChannelComponent::removeKeyFrame(int index) +{ + d->m_keyFrames.remove(index); +} + +void QChannelComponent::clearKeyFrames() +{ + d->m_keyFrames.clear(); +} + +QChannelComponent::const_iterator QChannelComponent::begin() const Q_DECL_NOTHROW +{ + return d->m_keyFrames.begin(); +} + +QChannelComponent::const_iterator QChannelComponent::end() const Q_DECL_NOTHROW +{ + return d->m_keyFrames.end(); +} + +bool operator==(const QChannelComponent &lhs, const QChannelComponent &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name == rhs.d->m_name && + lhs.d->m_keyFrames == rhs.d->m_keyFrames; +} + +bool operator!=(const QChannelComponent &lhs, const QChannelComponent &rhs) Q_DECL_NOTHROW +{ + return lhs.d->m_name != rhs.d->m_name || + lhs.d->m_keyFrames != rhs.d->m_keyFrames; +} + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/animation/frontend/qchannelcomponent.h b/src/animation/frontend/qchannelcomponent.h new file mode 100644 index 000000000..922073a85 --- /dev/null +++ b/src/animation/frontend/qchannelcomponent.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QCHANNELCOMPONENT_H +#define QT3DANIMATION_QCHANNELCOMPONENT_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QChannelComponentPrivate; + +class QT3DANIMATIONSHARED_EXPORT QChannelComponent +{ +public: + QChannelComponent(); + explicit QChannelComponent(const QString &name); + QChannelComponent(const QChannelComponent &); + QChannelComponent &operator=(const QChannelComponent &); + ~QChannelComponent(); + + void setName(const QString &name); + QString name() const; + + int keyFrameCount() const; + void appendKeyFrame(const QKeyFrame &kf); + void insertKeyFrame(int index, const QKeyFrame &kf); + void removeKeyFrame(int index); + void clearKeyFrames(); + + // Iterator API + typedef const QKeyFrame *const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + const_iterator begin() const Q_DECL_NOTHROW; + const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } + const_iterator end() const Q_DECL_NOTHROW; + const_iterator cend() const Q_DECL_NOTHROW { return end(); } + const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } + const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + + friend bool operator==(const QChannelComponent &, + const QChannelComponent &) Q_DECL_NOTHROW; + friend bool operator!=(const QChannelComponent &, + const QChannelComponent &) Q_DECL_NOTHROW; + +private: + QScopedPointer d; +}; + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QCHANNELCOMPONENT_H diff --git a/src/animation/frontend/qkeyframe.cpp b/src/animation/frontend/qkeyframe.cpp new file mode 100644 index 000000000..b3d339bf4 --- /dev/null +++ b/src/animation/frontend/qkeyframe.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qkeyframe.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/animation/frontend/qkeyframe.h b/src/animation/frontend/qkeyframe.h new file mode 100644 index 000000000..7eabbeb17 --- /dev/null +++ b/src/animation/frontend/qkeyframe.h @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QKEYFRAME_H +#define QT3DANIMATION_QKEYFRAME_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { + +class QT3DANIMATIONSHARED_EXPORT QKeyFrame +{ +public: + enum InterpolationType : quint8 { + ConstantInterpolation, + LinearInterpolation, + BezierInterpolation + }; + + Q_DECL_CONSTEXPR QKeyFrame() Q_DECL_NOTHROW + : m_coordinates() + , m_leftControlPoint() + , m_rightControlPoint() + , m_interpolationType(BezierInterpolation) + { + } + + Q_DECL_CONSTEXPR explicit QKeyFrame(QVector2D coords) Q_DECL_NOTHROW + : m_coordinates(coords) + , m_leftControlPoint() + , m_rightControlPoint() + , m_interpolationType(LinearInterpolation) + { + } + + Q_DECL_CONSTEXPR explicit QKeyFrame(QVector2D coords, + QVector2D lh, + QVector2D rh) Q_DECL_NOTHROW + : m_coordinates(coords) + , m_leftControlPoint(lh) + , m_rightControlPoint(rh) + , m_interpolationType(BezierInterpolation) + { + } + + void setCoordinates(QVector2D coords) Q_DECL_NOTHROW + { + m_coordinates = coords; + } + + Q_DECL_CONSTEXPR QVector2D coordinates() const Q_DECL_NOTHROW + { + return m_coordinates; + } + + void setLeftControlPoint(QVector2D lh) Q_DECL_NOTHROW + { + m_leftControlPoint = lh; + } + + Q_DECL_CONSTEXPR QVector2D leftControlPoint() const Q_DECL_NOTHROW + { + return m_leftControlPoint; + } + + void setRightControlPoint(QVector2D rh) Q_DECL_NOTHROW + { + m_rightControlPoint = rh; + } + + Q_DECL_CONSTEXPR QVector2D rightControlPoint() const Q_DECL_NOTHROW + { + return m_rightControlPoint; + } + + void setInterpolationType(InterpolationType interp) Q_DECL_NOTHROW + { + m_interpolationType = interp; + } + + Q_DECL_CONSTEXPR InterpolationType interpolationType() const Q_DECL_NOTHROW + { + return m_interpolationType; + } + + friend inline bool operator==(const QKeyFrame &, const QKeyFrame &) Q_DECL_NOTHROW; + friend inline bool operator!=(const QKeyFrame &, const QKeyFrame &) Q_DECL_NOTHROW; + +private: + QVector2D m_coordinates; + QVector2D m_leftControlPoint; + QVector2D m_rightControlPoint; + InterpolationType m_interpolationType; +}; + +QT3D_DECLARE_TYPEINFO(Qt3DAnimation, QKeyFrame, Q_PRIMITIVE_TYPE) + +inline bool operator==(const QKeyFrame &lhs, const QKeyFrame &rhs) Q_DECL_NOTHROW +{ + if (lhs.m_interpolationType != rhs.m_interpolationType) + return false; + + if (lhs.m_interpolationType == QKeyFrame::BezierInterpolation) { + return lhs.m_coordinates == rhs.m_coordinates && + lhs.m_leftControlPoint == rhs.m_leftControlPoint && + lhs.m_rightControlPoint == rhs.m_rightControlPoint; + } + + return lhs.m_coordinates == rhs.m_coordinates; +} + +inline bool operator!=(const QKeyFrame &lhs, const QKeyFrame &rhs) Q_DECL_NOTHROW +{ + return !(lhs == rhs); +} + +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QKEYFRAME_H -- cgit v1.2.3