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