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

Method autoConnectNodes

Engine/NodeGroup.cpp:648–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

646}
647
648bool
649NodeCollection::autoConnectNodes(const NodePtr& selected,
650 const NodePtr& created)
651{
652 ///We follow this rule:
653 // 1) selected is output
654 // a) created is output --> fail
655 // b) created is input --> connect input
656 // c) created is regular --> connect input
657 // 2) selected is input
658 // a) created is output --> connect output
659 // b) created is input --> fail
660 // c) created is regular --> connect output
661 // 3) selected is regular
662 // a) created is output--> connect output
663 // b) created is input --> connect input
664 // c) created is regular --> connect output
665
666 ///if true if will connect 'created' as input of 'selected',
667 ///otherwise as output.
668 bool connectAsInput = false;
669
670 ///cannot connect 2 input nodes together: case 2-b)
671 if ( (selected->getNInputs() == 0) && (created->getNInputs() == 0) ) {
672 return false;
673 }
674 ///cannot connect 2 output nodes together: case 1-a)
675 if ( selected->isOutputNode() && created->isOutputNode() ) {
676 return false;
677 }
678
679 ///1)
680 if ( selected->isOutputNode() ) {
681 ///assert we're not in 1-a)
682 assert( !created->isOutputNode() );
683
684 ///for either cases 1-b) or 1-c) we just connect the created node as input of the selected node.
685 connectAsInput = true;
686 }
687 ///2) and 3) are similar exceptfor case b)
688 else {
689 ///case 2 or 3- a): connect the created node as output of the selected node.
690 if ( created->isOutputNode() ) {
691 connectAsInput = false;
692 }
693 ///case b)
694 else if (created->getNInputs() == 0) {
695 assert(selected->getNInputs() != 0);
696 ///case 3-b): connect the created node as input of the selected node
697 connectAsInput = true;
698 }
699 ///case c) connect created as output of the selected node
700 else {
701 connectAsInput = false;
702 }
703 }
704
705 bool ret = false;

Callers

nothing calls this directly

Calls 10

isOutputNodeMethod · 0.80
emptyMethod · 0.80
hasViewersConnectedMethod · 0.80
getNInputsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
renderCurrentFrameMethod · 0.45

Tested by

no test coverage detected