summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-08-23 15:24:27 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-09-02 15:33:50 +0000
commit2574584da4c6ad2ce96103e39bce2dbd84f5a8df (patch)
tree92d50e0ca53ce81b73f8b70f5eca06b7bef1cb1f /src
parentb8f309338ceb7c24834bb1a41084fa8f85d6659b (diff)
Create backend nodes for any QAbstractChannelMapping subclass
Introduces a new creation change type to distinguish between the frontend node triggering the creation. Following commits will add the new channel mapping types and populate the backend node appropriately. Change-Id: I09b3cbcd3d716c9e9c18873066b9f282222ab783 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/animation/backend/channelmapping.cpp35
-rw-r--r--src/animation/frontend/frontend.pri7
-rw-r--r--src/animation/frontend/qabstractchannelmapping.cpp6
-rw-r--r--src/animation/frontend/qabstractchannelmapping_p.h7
-rw-r--r--src/animation/frontend/qanimationaspect.cpp4
-rw-r--r--src/animation/frontend/qchannelmapping.cpp4
-rw-r--r--src/animation/frontend/qchannelmappingcreatedchange.cpp75
-rw-r--r--src/animation/frontend/qchannelmappingcreatedchange_p.h101
-rw-r--r--src/animation/frontend/qchannelmappingcreatedchange_p_p.h72
9 files changed, 296 insertions, 15 deletions
diff --git a/src/animation/backend/channelmapping.cpp b/src/animation/backend/channelmapping.cpp
index 82e6a95a8..79abe11f5 100644
--- a/src/animation/backend/channelmapping.cpp
+++ b/src/animation/backend/channelmapping.cpp
@@ -38,6 +38,7 @@
#include <Qt3DAnimation/qchannelmapping.h>
#include <Qt3DAnimation/private/qchannelmapping_p.h>
#include <Qt3DAnimation/private/animationlogging_p.h>
+#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
QT_BEGIN_NAMESPACE
@@ -59,15 +60,31 @@ ChannelMapping::ChannelMapping()
void ChannelMapping::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QChannelMappingData>>(change);
- const auto &data = typedChange->data;
- m_channelName = data.channelName;
- m_targetId = data.targetId;
- m_property = data.property;
- m_type = data.type;
- m_propertyName = data.propertyName;
- m_callback = data.callback;
- m_callbackFlags = data.callbackFlags;
+ const auto createdChange = qSharedPointerCast<QChannelMappingCreatedChangeBase>(change);
+ switch (createdChange->type()) {
+ case QChannelMappingCreatedChangeBase::ChannelMapping: {
+ const auto typedChange = qSharedPointerCast<QChannelMappingCreatedChange<QChannelMappingData>>(change);
+ const auto &data = typedChange->data;
+ m_channelName = data.channelName;
+ m_targetId = data.targetId;
+ m_property = data.property;
+ m_type = data.type;
+ m_propertyName = data.propertyName;
+ m_callback = data.callback;
+ m_callbackFlags = data.callbackFlags;
+ break;
+ }
+
+ case QChannelMappingCreatedChangeBase::SkeletonMapping: {
+ // TODO: Add support for QSkeletonChannelMapping
+ break;
+ }
+
+ case QChannelMappingCreatedChangeBase::CallbackMapping: {
+ // TODO: Refactor callback support out of QChannelMapping and into its own type
+ break;
+ }
+ }
}
void ChannelMapping::cleanup()
diff --git a/src/animation/frontend/frontend.pri b/src/animation/frontend/frontend.pri
index 55208b640..6735b75c3 100644
--- a/src/animation/frontend/frontend.pri
+++ b/src/animation/frontend/frontend.pri
@@ -50,7 +50,9 @@ HEADERS += \
$$PWD/qclock.h \
$$PWD/qclock_p.h \
$$PWD/qabstractchannelmapping.h \
- $$PWD/qabstractchannelmapping_p.h
+ $$PWD/qabstractchannelmapping_p.h \
+ $$PWD/qchannelmappingcreatedchange_p.h \
+ $$PWD/qchannelmappingcreatedchange_p_p.h
SOURCES += \
$$PWD/qanimationaspect.cpp \
@@ -80,6 +82,7 @@ SOURCES += \
$$PWD/qanimationclip.cpp \
$$PWD/qanimationcallbacktrigger.cpp \
$$PWD/qclock.cpp \
- $$PWD/qabstractchannelmapping.cpp
+ $$PWD/qabstractchannelmapping.cpp \
+ $$PWD/qchannelmappingcreatedchange.cpp \
INCLUDEPATH += $$PWD
diff --git a/src/animation/frontend/qabstractchannelmapping.cpp b/src/animation/frontend/qabstractchannelmapping.cpp
index d77efc0c0..3249e6876 100644
--- a/src/animation/frontend/qabstractchannelmapping.cpp
+++ b/src/animation/frontend/qabstractchannelmapping.cpp
@@ -49,6 +49,12 @@ QAbstractChannelMappingPrivate::QAbstractChannelMappingPrivate()
{
}
+/*! \internal */
+const QAbstractChannelMappingPrivate *QAbstractChannelMappingPrivate::get(const QAbstractChannelMapping *q)
+{
+ return q->d_func();
+}
+
QAbstractChannelMapping::QAbstractChannelMapping(QAbstractChannelMappingPrivate &dd, Qt3DCore::QNode *parent)
: Qt3DCore::QNode(dd, parent)
{
diff --git a/src/animation/frontend/qabstractchannelmapping_p.h b/src/animation/frontend/qabstractchannelmapping_p.h
index f5d165cdf..1a1de4ba9 100644
--- a/src/animation/frontend/qabstractchannelmapping_p.h
+++ b/src/animation/frontend/qabstractchannelmapping_p.h
@@ -52,19 +52,24 @@
//
#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
QT_BEGIN_NAMESPACE
namespace Qt3DAnimation {
+class QAbstractChannelMapping;
+
class QAbstractChannelMappingPrivate : public Qt3DCore::QNodePrivate
{
public:
QAbstractChannelMappingPrivate();
+ static const QAbstractChannelMappingPrivate *get(const Qt3DAnimation::QAbstractChannelMapping *q);
+
Q_DECLARE_PUBLIC(QAbstractChannelMapping)
- // TODO Add member variables
+ QChannelMappingCreatedChangeBase::MappingType m_mappingType;
};
struct QAbstractChannelMappingData
diff --git a/src/animation/frontend/qanimationaspect.cpp b/src/animation/frontend/qanimationaspect.cpp
index 44f54fda6..14a0c4f8c 100644
--- a/src/animation/frontend/qanimationaspect.cpp
+++ b/src/animation/frontend/qanimationaspect.cpp
@@ -40,10 +40,10 @@
#include "qanimationaspect.h"
#include "qanimationaspect_p.h"
#include <Qt3DAnimation/qabstractanimationclip.h>
+#include <Qt3DAnimation/qabstractchannelmapping.h>
#include <Qt3DAnimation/qclock.h>
#include <Qt3DAnimation/qblendedclipanimator.h>
#include <Qt3DAnimation/qclipanimator.h>
-#include <Qt3DAnimation/qchannelmapping.h>
#include <Qt3DAnimation/qchannelmapper.h>
#include <Qt3DAnimation/qlerpclipblend.h>
#include <Qt3DAnimation/qadditiveclipblend.h>
@@ -108,7 +108,7 @@ QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent)
registerBackendType<QBlendedClipAnimator>(
QSharedPointer<Animation::NodeFunctor<Animation::BlendedClipAnimator, Animation::BlendedClipAnimatorManager>>::create(d->m_handler.data(),
d->m_handler->blendedClipAnimatorManager()));
- registerBackendType<QChannelMapping>(
+ registerBackendType<QAbstractChannelMapping>(
QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapping, Animation::ChannelMappingManager>>::create(d->m_handler.data(),
d->m_handler->channelMappingManager()));
registerBackendType<QChannelMapper>(
diff --git a/src/animation/frontend/qchannelmapping.cpp b/src/animation/frontend/qchannelmapping.cpp
index b97961edc..cb7b0739f 100644
--- a/src/animation/frontend/qchannelmapping.cpp
+++ b/src/animation/frontend/qchannelmapping.cpp
@@ -37,6 +37,7 @@
#include "qchannelmapping.h"
#include "qchannelmapping_p.h"
+#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <QtCore/qmetaobject.h>
@@ -56,6 +57,7 @@ QChannelMappingPrivate::QChannelMappingPrivate()
, m_callback(nullptr)
, m_callbackFlags(0)
{
+ m_mappingType = QChannelMappingCreatedChangeBase::ChannelMapping;
}
/*!
@@ -250,7 +252,7 @@ void QChannelMapping::setCallback(int type, QAnimationCallback *callback, QAnima
Qt3DCore::QNodeCreatedChangeBasePtr QChannelMapping::createNodeCreationChange() const
{
- auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QChannelMappingData>::create(this);
+ auto creationChange = QChannelMappingCreatedChangePtr<QChannelMappingData>::create(this);
auto &data = creationChange->data;
Q_D(const QChannelMapping);
data.channelName = d->m_channelName;
diff --git a/src/animation/frontend/qchannelmappingcreatedchange.cpp b/src/animation/frontend/qchannelmappingcreatedchange.cpp
new file mode 100644
index 000000000..6da1eb23e
--- /dev/null
+++ b/src/animation/frontend/qchannelmappingcreatedchange.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qchannelmappingcreatedchange_p.h"
+#include "qchannelmappingcreatedchange_p_p.h"
+#include <Qt3DAnimation/private/qabstractchannelmapping_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DAnimation {
+
+QChannelMappingCreatedChangeBasePrivate::QChannelMappingCreatedChangeBasePrivate(const QAbstractChannelMapping *mapping)
+ : Qt3DCore::QNodeCreatedChangeBasePrivate(mapping)
+ , m_mappingType(QAbstractChannelMappingPrivate::get(mapping)->m_mappingType)
+{
+}
+
+/*!
+ \class QChannelmappingCreatedChangeBase
+ \inmodule Qt3DCore
+ \brief Base class for handling creation changes for QAbstractSkeleton sub-classes
+*/
+QChannelMappingCreatedChangeBase::QChannelMappingCreatedChangeBase(const QAbstractChannelMapping *mapping)
+ : Qt3DCore::QNodeCreatedChangeBase(*new QChannelMappingCreatedChangeBasePrivate(mapping), mapping)
+{
+}
+
+/*! \internal */
+QChannelMappingCreatedChangeBase::~QChannelMappingCreatedChangeBase()
+{
+}
+
+/*! \internal */
+QChannelMappingCreatedChangeBase::MappingType QChannelMappingCreatedChangeBase::type() const
+{
+ Q_D(const QChannelMappingCreatedChangeBase);
+ return d->m_mappingType;
+}
+
+} // namespace Qt3DAnimation
+
+QT_END_NAMESPACE
diff --git a/src/animation/frontend/qchannelmappingcreatedchange_p.h b/src/animation/frontend/qchannelmappingcreatedchange_p.h
new file mode 100644
index 000000000..b01a97acc
--- /dev/null
+++ b/src/animation/frontend/qchannelmappingcreatedchange_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_H
+#define QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/qnodecreatedchange.h>
+#include <Qt3DAnimation/qabstractchannelmapping.h>
+#include <Qt3DAnimation/private/qt3danimation_global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DAnimation {
+
+class QChannelMappingCreatedChangeBasePrivate;
+
+class QT3DANIMATIONSHARED_PRIVATE_EXPORT QChannelMappingCreatedChangeBase : public Qt3DCore::QNodeCreatedChangeBase
+{
+public:
+ explicit QChannelMappingCreatedChangeBase(const QAbstractChannelMapping *mapping);
+ ~QChannelMappingCreatedChangeBase();
+
+ enum MappingType {
+ ChannelMapping = 0,
+ SkeletonMapping,
+ CallbackMapping
+ };
+
+ MappingType type() const;
+
+private:
+ Q_DECLARE_PRIVATE(QChannelMappingCreatedChangeBase)
+};
+
+typedef QSharedPointer<QChannelMappingCreatedChangeBase> QChannelMappingCreatedChangeBasePtr;
+
+template<typename T>
+class QChannelMappingCreatedChange : public QChannelMappingCreatedChangeBase
+{
+public:
+ explicit QChannelMappingCreatedChange(const QAbstractChannelMapping *_mapping)
+ : QChannelMappingCreatedChangeBase(_mapping)
+ , data()
+ {
+ }
+
+ T data;
+};
+
+template<typename T>
+using QChannelMappingCreatedChangePtr = QSharedPointer<QChannelMappingCreatedChange<T>>;
+
+} // namespace Qt3DAnimation
+
+QT_END_NAMESPACE
+
+#endif // QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_H
diff --git a/src/animation/frontend/qchannelmappingcreatedchange_p_p.h b/src/animation/frontend/qchannelmappingcreatedchange_p_p.h
new file mode 100644
index 000000000..8a89104a8
--- /dev/null
+++ b/src/animation/frontend/qchannelmappingcreatedchange_p_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_P_H
+#define QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/private/qnodecreatedchange_p.h>
+#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DAnimation {
+
+class QAbstractChannelMapping;
+
+class QChannelMappingCreatedChangeBasePrivate : public Qt3DCore::QNodeCreatedChangeBasePrivate
+{
+public:
+ QChannelMappingCreatedChangeBasePrivate(const QAbstractChannelMapping *mapping);
+
+ QChannelMappingCreatedChangeBase::MappingType m_mappingType;
+};
+
+} // namespace Qt3DAnimation
+
+QT_END_NAMESPACE
+
+#endif // QT3DANIMATION_QCHANNELMAPPINGCREATEDCHANGE_P_P_H