| 1 | // Copyright (C) 2014 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 | #ifndef QT3DCORE_QASPECTMANAGER_P_H |
| 5 | #define QT3DCORE_QASPECTMANAGER_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <Qt3DCore/qaspectengine.h> |
| 19 | #include <Qt3DCore/private/qabstractfrontendnodemanager_p.h> |
| 20 | #include <Qt3DCore/qnode.h> |
| 21 | #include <Qt3DCore/qnodeid.h> |
| 22 | #include <QtCore/QList> |
| 23 | #include <QtCore/QObject> |
| 24 | #include <QtCore/QScopedPointer> |
| 25 | #include <QtCore/QSemaphore> |
| 26 | #include <QtCore/QVariant> |
| 27 | |
| 28 | #include <Qt3DCore/private/qt3dcore_global_p.h> |
| 29 | |
| 30 | QT_BEGIN_NAMESPACE |
| 31 | |
| 32 | class QSurface; |
| 33 | |
| 34 | namespace Qt3DCore { |
| 35 | |
| 36 | class QEntity; |
| 37 | class QScheduler; |
| 38 | class QChangeArbiter; |
| 39 | class QAbstractAspect; |
| 40 | class QAbstractAspectJobManager; |
| 41 | class QAspectEngine; |
| 42 | class QServiceLocator; |
| 43 | class QScene; |
| 44 | class NodePostConstructorInit; |
| 45 | struct NodeTreeChange; |
| 46 | #if QT_CONFIG(animation) |
| 47 | class RequestFrameAnimation; |
| 48 | #endif |
| 49 | |
| 50 | class Q_3DCORE_PRIVATE_EXPORT QAspectManager : public QObject, public QAbstractFrontEndNodeManager |
| 51 | { |
| 52 | Q_OBJECT |
| 53 | public: |
| 54 | explicit QAspectManager(QAspectEngine *parent = nullptr); |
| 55 | ~QAspectManager(); |
| 56 | |
| 57 | QAspectEngine * engine() const { return m_engine; } |
| 58 | QScheduler *scheduler() const { return m_scheduler; } |
| 59 | |
| 60 | void setRunMode(QAspectEngine::RunMode mode); |
| 61 | void enterSimulationLoop(); |
| 62 | void exitSimulationLoop(); |
| 63 | |
| 64 | bool isShuttingDown() const; |
| 65 | |
| 66 | public Q_SLOTS: |
| 67 | void initialize(); |
| 68 | void shutdown(); |
| 69 | void processFrame(); |
| 70 | |
| 71 | void setRootEntity(Qt3DCore::QEntity *root, const QList<QNode *> &nodes); |
| 72 | void addNodes(const QList<QNode *> &nodes); |
| 73 | void removeNodes(const QList<QNode *> &nodes); |
| 74 | void registerAspect(Qt3DCore::QAbstractAspect *aspect); |
| 75 | void unregisterAspect(Qt3DCore::QAbstractAspect *aspect); |
| 76 | |
| 77 | public: |
| 78 | const QList<QAbstractAspect *> &aspects() const; |
| 79 | QAbstractAspect *aspect(const QString &name) const; |
| 80 | QAbstractAspect *aspect(const QMetaObject *metaType) const; |
| 81 | QAbstractAspectJobManager *jobManager() const; |
| 82 | QChangeArbiter *changeArbiter() const; |
| 83 | QServiceLocator *serviceLocator() const; |
| 84 | void setPostConstructorInit(NodePostConstructorInit *postConstructorInit); |
| 85 | |
| 86 | QNode *lookupNode(QNodeId id) const override; |
| 87 | QList<QNode *> lookupNodes(const QList<QNodeId> &ids) const override; |
| 88 | QScene *scene() const; |
| 89 | |
| 90 | int jobsInLastFrame() const { return m_jobsInLastFrame; } |
| 91 | void dumpJobsOnNextFrame(); |
| 92 | |
| 93 | private: |
| 94 | #if !QT_CONFIG(animation) |
| 95 | bool event(QEvent *event) override; |
| 96 | #endif |
| 97 | void requestNextFrame(); |
| 98 | |
| 99 | QAspectEngine *m_engine; |
| 100 | QList<QAbstractAspect *> m_aspects; |
| 101 | QEntity *m_root; |
| 102 | QVariantMap m_data; |
| 103 | QScheduler *m_scheduler; |
| 104 | QAbstractAspectJobManager *m_jobManager; |
| 105 | QChangeArbiter *m_changeArbiter; |
| 106 | QScopedPointer<QServiceLocator> m_serviceLocator; |
| 107 | bool m_simulationLoopRunning; |
| 108 | QAspectEngine::RunMode m_driveMode; |
| 109 | QList<NodeTreeChange> m_nodeTreeChanges; |
| 110 | NodePostConstructorInit* m_postConstructorInit; |
| 111 | |
| 112 | #if QT_CONFIG(animation) |
| 113 | RequestFrameAnimation *m_simulationAnimation; |
| 114 | #endif |
| 115 | int m_jobsInLastFrame; |
| 116 | bool m_dumpJobs; |
| 117 | }; |
| 118 | |
| 119 | } // namespace Qt3DCore |
| 120 | |
| 121 | QT_END_NAMESPACE |
| 122 | |
| 123 | #endif // QT3DCORE_QASPECTMANAGER_P_H |
| 124 |
