MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / connectCurrentViewerToSelection

Method connectCurrentViewerToSelection

Gui/NodeGraph30.cpp:63–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61#include "Global/QtCompat.h"
62
63NATRON_NAMESPACE_ENTER
64void
65NodeGraph::connectCurrentViewerToSelection(int inputNB,
66 bool isASide)
67{
68 ViewerTab* lastUsedViewer = getLastSelectedViewer();
69
70 if (lastUsedViewer) {
71 NodeCollectionPtr collection = lastUsedViewer->getInternalNode()->getNode()->getGroup();
72 if ( collection && (collection->getNodeGraph() != this) ) {
73 //somehow the group doesn't belong to this nodegraph , pick another one
74 const std::list<ViewerTab*>& tabs = getGui()->getViewersList();
75 lastUsedViewer = 0;
76 for (std::list<ViewerTab*>::const_iterator it = tabs.begin(); it != tabs.end(); ++it) {
77 NodeCollectionPtr otherCollection = (*it)->getInternalNode()->getNode()->getGroup();
78 if ( otherCollection && (otherCollection->getNodeGraph() == this) ) {
79 lastUsedViewer = *it;
80 break;
81 }
82 }
83 }
84 }
85
86
87 InspectorNodePtr v;
88 if (lastUsedViewer) {
89 v = std::dynamic_pointer_cast<InspectorNode>( lastUsedViewer->
90 getInternalNode()->getNode() );
91 } else {
92 CreateNodeArgs args( PLUGINID_NATRON_VIEWER,
93 getGroup() );
94 NodePtr viewerNode = getGui()->getApp()->createNode(args);
95
96 if (!viewerNode) {
97 return;
98 }
99 v = std::dynamic_pointer_cast<InspectorNode>(viewerNode);
100 }
101
102 if (!v) {
103 return;
104 }
105
106 ///if the node is no longer active (i.e: it was deleted by the user), don't do anything.
107 if ( !v->isActivated() ) {
108 return;
109 }
110
111 ///get a ptr to the NodeGui
112 NodeGuiIPtr gui_i = v->getNodeGui();
113 NodeGuiPtr gui = std::dynamic_pointer_cast<NodeGui>(gui_i);
114 assert(gui);
115 ///if there's no selected node or the viewer is selected, then try refreshing that input nb if it is connected.
116 bool viewerAlreadySelected = std::find(_imp->_selection.begin(), _imp->_selection.end(), gui) != _imp->_selection.end();
117 if (_imp->_selection.empty() || (_imp->_selection.size() > 1) || viewerAlreadySelected) {
118 v->setActiveInputAndRefresh(inputNB, isASide);
119 gui->refreshEdges();
120

Callers 1

connectInputMethod · 0.80

Calls 15

getGuiFunction · 0.85
pushUndoCommandFunction · 0.85
emptyMethod · 0.80
refreshEdgesMethod · 0.80
getInputArrowMethod · 0.80
getSourceMethod · 0.80
getGroupMethod · 0.45
getNodeMethod · 0.45
getInternalNodeMethod · 0.45
getNodeGraphMethod · 0.45

Tested by

no test coverage detected