From d83087a4efa1afb56df79d5a2fb19e2812c5276d Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 8 Jul 2021 18:48:02 -0700 Subject: [PATCH] nodegraph: added more helper functions for contexts --- app/node/graph.cpp | 25 +++++++++++++++++++++++++ app/node/graph.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/app/node/graph.cpp b/app/node/graph.cpp index 0527b4d16..26bfe6937 100644 --- a/app/node/graph.cpp +++ b/app/node/graph.cpp @@ -58,6 +58,31 @@ qreal NodeGraph::GetNodeContextHeight(Node *context) return bottom - top; } +int NodeGraph::GetNumberOfContextsNodeIsIn(Node *node) const +{ + int count = 0; + + for (auto it=position_map_.cbegin(); it!=position_map_.cend(); it++) { + if (it.value().contains(node)) { + count++; + } + } + + return count; +} + +bool NodeGraph::NodeOutputsToContext(Node *node) const +{ + for (auto it=position_map_.cbegin(); it!=position_map_.cend(); it++) { + const PositionMap &pm = it.value(); + if (pm.contains(node) && node->OutputsTo(it.key(), true)) { + return true; + } + } + + return false; +} + void NodeGraph::childEvent(QChildEvent *event) { super::childEvent(event); diff --git a/app/node/graph.h b/app/node/graph.h index 9c67ed4bb..dbdfb990b 100644 --- a/app/node/graph.h +++ b/app/node/graph.h @@ -108,6 +108,10 @@ public: return position_map_; } + int GetNumberOfContextsNodeIsIn(Node *node) const; + + bool NodeOutputsToContext(Node *node) const; + signals: /** * @brief Signal emitted when a Node is added to the graph