diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-01-07 17:14:28 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-01-09 12:55:29 +0000 |
commit | 35919326b4c1b7803cd68a38c4d7d3c8d710a04a (patch) | |
tree | c4a4e1624e0e61bfe525ec6dc376172186e38eb7 /src/core/nodes | |
parent | 1fa9c59f7eda5f8435ecb961a55c9a60cd4f7c67 (diff) |
Add commands to dump frame graph and scene graph
prints to the console, also dump the list of paths in the frame graph
to help understand render views.
Change-Id: Ic4756e09545971b224a239fafc6667b0ca3d4572
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/nodes')
-rw-r--r-- | src/core/nodes/qentity.cpp | 50 | ||||
-rw-r--r-- | src/core/nodes/qentity_p.h | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index 93601901f..1199dfc4b 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -53,6 +53,50 @@ QT_BEGIN_NAMESPACE +namespace { + +QString dumpNode(const Qt3DCore::QEntity *n) { + auto formatNode = [](const Qt3DCore::QNode *n) { + QString res = QString(QLatin1String("%1{%2}")) + .arg(QLatin1String(n->metaObject()->className())) + .arg(n->id().id()); + if (!n->objectName().isEmpty()) + res += QString(QLatin1String(" (%1)")).arg(n->objectName()); + if (!n->isEnabled()) + res += QLatin1String(" [D]"); + return res; + }; + + QString res = formatNode(n); + const auto &components = n->components(); + if (components.size()) { + QStringList componentNames; + for (const auto &c : components) + componentNames += formatNode(c); + res += QString(QLatin1String(" [ %1 ]")).arg(componentNames.join(QLatin1String(", "))); + } + + return res; +} + +QStringList dumpSG(const Qt3DCore::QEntity *n, int level = 0) +{ + QStringList reply; + QString res = dumpNode(n); + reply += res.rightJustified(res.length() + level * 2, ' '); + + const auto children = n->childNodes(); + for (auto *child: children) { + auto *childFGNode = qobject_cast<Qt3DCore::QEntity *>(child); + if (childFGNode != nullptr) + reply += dumpSG(childFGNode, level + 1); + } + + return reply; +} + +} + namespace Qt3DCore { /*! @@ -244,6 +288,12 @@ QNodeId QEntityPrivate::parentEntityId() const return m_parentEntityId; } +QString QEntityPrivate::dumpSceneGraph() const +{ + Q_Q(const QEntity); + return dumpSG(q).join('\n'); +} + QNodeCreatedChangeBasePtr QEntity::createNodeCreationChange() const { auto creationChange = QNodeCreatedChangePtr<QEntityData>::create(this); diff --git a/src/core/nodes/qentity_p.h b/src/core/nodes/qentity_p.h index 803754c87..992f81931 100644 --- a/src/core/nodes/qentity_p.h +++ b/src/core/nodes/qentity_p.h @@ -82,6 +82,7 @@ public : return typedComponents; } + QString dumpSceneGraph() const; void removeDestroyedComponent(QComponent *comp); QComponentVector m_components; |