diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-03-09 08:19:22 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-04-07 07:55:46 +0000 |
commit | 3d8dbf99ae9f70a74be39acccdf60203a74b0588 (patch) | |
tree | 6b69736f7c1a106d125b0d4ecc33fbe48f06d347 /src/core | |
parent | a1d2f784dc508eeb1fdbd613f4c9e077633501da (diff) |
Introduce abstract API to lookup front end nodes
Useful later to write simpler tests
Change-Id: I164b0e46eed5f341629895d7f7b0c3af75999fbd
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/aspects/qaspectengine.h | 7 | ||||
-rw-r--r-- | src/core/aspects/qaspectmanager_p.h | 7 | ||||
-rw-r--r-- | src/core/core.pri | 6 | ||||
-rw-r--r-- | src/core/qabstractfrontendnodemanager.cpp | 67 | ||||
-rw-r--r-- | src/core/qabstractfrontendnodemanager.h | 80 | ||||
-rw-r--r-- | src/core/qscene_p.h | 7 |
6 files changed, 163 insertions, 11 deletions
diff --git a/src/core/aspects/qaspectengine.h b/src/core/aspects/qaspectengine.h index 71662a27e..04eede9d3 100644 --- a/src/core/aspects/qaspectengine.h +++ b/src/core/aspects/qaspectengine.h @@ -41,6 +41,7 @@ #define QT3DCORE_QASPECTENGINE_H #include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/qabstractfrontendnodemanager.h> #include <Qt3DCore/qnodeid.h> #include <QtCore/QObject> #include <QtCore/QVector> @@ -57,7 +58,7 @@ class QNode; typedef QSharedPointer<QEntity> QEntityPtr; -class Q_3DCORESHARED_EXPORT QAspectEngine : public QObject +class Q_3DCORESHARED_EXPORT QAspectEngine : public QObject, public QAbstractFrontEndNodeManager { Q_OBJECT public: @@ -88,8 +89,8 @@ public: void processFrame(); - QNode *lookupNode(QNodeId id) const; - QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const; + QNode *lookupNode(QNodeId id) const override; + QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const override; private: Q_DECLARE_PRIVATE(QAspectEngine) diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h index b9982ab96..9d2e01938 100644 --- a/src/core/aspects/qaspectmanager_p.h +++ b/src/core/aspects/qaspectmanager_p.h @@ -52,6 +52,7 @@ // #include <Qt3DCore/qaspectengine.h> +#include <Qt3DCore/qabstractfrontendnodemanager.h> #include <Qt3DCore/qnodeid.h> #include <QtCore/QObject> #include <QtCore/QScopedPointer> @@ -82,7 +83,7 @@ struct NodeTreeChange; class RequestFrameAnimation; #endif -class Q_3DCORE_PRIVATE_EXPORT QAspectManager : public QObject +class Q_3DCORE_PRIVATE_EXPORT QAspectManager : public QObject, public QAbstractFrontEndNodeManager { Q_OBJECT public: @@ -117,8 +118,8 @@ public: QServiceLocator *serviceLocator() const; void setPostConstructorInit(NodePostConstructorInit *postConstructorInit); - QNode *lookupNode(QNodeId id) const; - QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const; + QNode *lookupNode(QNodeId id) const override; + QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const override; QScene *scene() const; int jobsInLastFrame() const { return m_jobsInLastFrame; } diff --git a/src/core/core.pri b/src/core/core.pri index 5bc6e38d9..6cf431164 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -8,7 +8,8 @@ HEADERS += \ $$PWD/qchangearbiter_p.h \ $$PWD/qt3dcore_global_p.h \ $$PWD/qurlhelper_p.h \ - $$PWD/qscene_p.h + $$PWD/qscene_p.h \ + $$PWD/qabstractfrontendnodemanager.h SOURCES += \ $$PWD/qtickclock.cpp \ @@ -16,4 +17,5 @@ SOURCES += \ $$PWD/qchangearbiter.cpp \ $$PWD/corelogging.cpp \ $$PWD/qurlhelper.cpp \ - $$PWD/qscene.cpp + $$PWD/qscene.cpp \ + $$PWD/qabstractfrontendnodemanager.cpp diff --git a/src/core/qabstractfrontendnodemanager.cpp b/src/core/qabstractfrontendnodemanager.cpp new file mode 100644 index 000000000..9c8b8eceb --- /dev/null +++ b/src/core/qabstractfrontendnodemanager.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 "qabstractfrontendnodemanager.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +QAbstractFrontEndNodeManager::QAbstractFrontEndNodeManager() = default; + +QAbstractFrontEndNodeManager::~QAbstractFrontEndNodeManager() = default; + +/* +\fn QNode *Qt3DCore::QAbstractFrontEndNodeManager::lookupNode(QNodeId id) const + +Returns the node instance matching the id, or nullptr if not found. + +*/ + +/* +\fn QVector<QNode *> Qt3DCore::QAbstractFrontEndNodeManager::lookupNodes(const QVector<QNodeId> &ids) const + +Returns the vector of node instance matching the ids. + +*/ + + +} // Qt3DCore + +QT_END_NAMESPACE diff --git a/src/core/qabstractfrontendnodemanager.h b/src/core/qabstractfrontendnodemanager.h new file mode 100644 index 000000000..4b47e7761 --- /dev/null +++ b/src/core/qabstractfrontendnodemanager.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 QT3DCORE_QABSTRACTFRONTENDNODEMANAGER_P_H +#define QT3DCORE_QABSTRACTFRONTENDNODEMANAGER_P_H + +#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DCore/qnodeid.h> + +#include <QtCore/qvector.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { + +class QNode; + +class Q_3DCORESHARED_EXPORT QAbstractFrontEndNodeManager +{ +public: + // Changes made to backend nodes are reported to the Renderer + enum DirtyNodeFlag { + TransformDirty = 1 << 0, + GeometryDirty = 1 << 1, + EntityEnabledDirty = 1 << 2, + BuffersDirty = 1 << 3, + AllDirty = 0xffffff + }; + Q_DECLARE_FLAGS(DirtyNodeSet, DirtyNodeFlag) + + virtual ~QAbstractFrontEndNodeManager(); + + virtual QNode *lookupNode(QNodeId id) const = 0; + virtual QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const = 0; + +protected: + QAbstractFrontEndNodeManager(); +}; + +} // Qt3DCore + +QT_END_NAMESPACE + +#endif // QT3DCORE_QABSTRACTFRONTENDNODEMANAGER_P_H diff --git a/src/core/qscene_p.h b/src/core/qscene_p.h index 7b3037180..78c40904c 100644 --- a/src/core/qscene_p.h +++ b/src/core/qscene_p.h @@ -54,6 +54,7 @@ #include <QtCore/QScopedPointer> #include <Qt3DCore/qnode.h> +#include <Qt3DCore/qabstractfrontendnodemanager.h> #include <QtCore/qscopedpointer.h> #include <Qt3DCore/private/qt3dcore_global_p.h> @@ -66,7 +67,7 @@ class QAspectEngine; class NodePostConstructorInit; class QChangeArbiter; -class Q_3DCORE_PRIVATE_EXPORT QScene +class Q_3DCORE_PRIVATE_EXPORT QScene : public QAbstractFrontEndNodeManager { public: // Changes made to backend nodes are reported to the Renderer @@ -87,8 +88,8 @@ public: void addObservable(QNode *observable); void removeObservable(QNode *observable); - QNode *lookupNode(QNodeId id) const; - QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const; + QNode *lookupNode(QNodeId id) const override; + QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const override; QNode *rootNode() const; |