Add accessor to retrieve frontend node from an id

Useful later to sync backend changes back to the frontend.

Change-Id: I874d140fc97462b8e186b66c882647db26d5678e
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
Mike Krus 2019-10-01 14:15:40 +01:00
parent 89392ac9ae
commit 2dabe5fc1e
2 changed files with 22 additions and 0 deletions

View File

@ -62,6 +62,7 @@
#include <Qt3DCore/private/qtickclockservice_p.h> #include <Qt3DCore/private/qtickclockservice_p.h>
#include <Qt3DCore/private/qnodevisitor_p.h> #include <Qt3DCore/private/qnodevisitor_p.h>
#include <Qt3DCore/private/qnode_p.h> #include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@ -379,6 +380,24 @@ void QAspectManager::setPostConstructorInit(NodePostConstructorInit *postConstru
m_postConstructorInit = postConstructorInit; m_postConstructorInit = postConstructorInit;
} }
QNode *QAspectManager::lookupNode(QNodeId id) const
{
if (!m_root)
return nullptr;
QNodePrivate *d = QNodePrivate::get(m_root);
return d->m_scene ? d->m_scene->lookupNode(id) : nullptr;
}
QVector<QNode *> QAspectManager::lookupNodes(const QVector<QNodeId> &ids) const
{
if (!m_root)
return {};
QNodePrivate *d = QNodePrivate::get(m_root);
return d->m_scene ? d->m_scene->lookupNodes(ids) : QVector<QNode *>{};
}
/*! /*!
\internal \internal
\brief Drives the Qt3D simulation loop in the main thread \brief Drives the Qt3D simulation loop in the main thread

View File

@ -108,6 +108,9 @@ public:
QServiceLocator *serviceLocator() const; QServiceLocator *serviceLocator() const;
void setPostConstructorInit(NodePostConstructorInit *postConstructorInit); void setPostConstructorInit(NodePostConstructorInit *postConstructorInit);
QNode *lookupNode(QNodeId id) const;
QVector<QNode *> lookupNodes(const QVector<QNodeId> &ids) const;
private: private:
bool event(QEvent *event) override; bool event(QEvent *event) override;
void requestNextFrame(); void requestNextFrame();