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

Method getPreferredInputInternal

Engine/NodeInputs.cpp:1393–1506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1391}
1392
1393int
1394Node::getPreferredInputInternal(bool connected) const
1395{
1396 int nInputs = getNInputs();
1397
1398 if (nInputs == 0) {
1399 return -1;
1400 }
1401 std::vector<NodePtr> inputs(nInputs);
1402 std::vector<std::string> inputLabels(nInputs);
1403 int inputA = -1;
1404 int inputB = -1;
1405 {
1406 // fill input labels, and if one is called "Source", return it
1407 // if it's "A" or "B", keep the index.
1408 for (int i = 0; i < nInputs; ++i) {
1409 std::string inputLabel = getInputLabel(i);
1410 //printf("%d->%s\n", i, inputLabel.c_str());
1411 if (inputLabel == kOfxImageEffectSimpleSourceClipName) {
1412 inputs[i] = getInput(i);
1413 if ( (connected && inputs[i]) || (!connected && !inputs[i]) ) {
1414 return i;
1415 }
1416 } else if (inputLabel == "A") {
1417 inputA = i;
1418 } else if (inputLabel == "B") {
1419 inputB = i;
1420 }
1421 }
1422 }
1423 bool useInputA = false;
1424 if (!connected) {
1425 // For the merge node, use the preference (only when not connected)
1426 useInputA = appPTR->getCurrentSettings()->useInputAForMergeAutoConnect();
1427 }
1428
1429 ///Find an input named A
1430 int inputToFind = -1, foundOther = -1;
1431 if ( useInputA || (getPluginID() == PLUGINID_OFX_SHUFFLE && getMajorVersion() < 3) ) {
1432 inputToFind = inputA;
1433 foundOther = inputB;
1434 } else {
1435 inputToFind = inputB;
1436 foundOther = inputA;
1437 }
1438 if (inputToFind != -1) {
1439 inputs[inputToFind] = getInput(inputToFind);
1440 if ( (connected && inputs[inputToFind]) || (!connected && !inputs[inputToFind]) ) {
1441 return inputToFind;
1442 }
1443 }
1444 if (foundOther != -1) {
1445 inputs[foundOther] = getInput(foundOther);
1446 if ( (connected && inputs[foundOther]) || (!connected && !inputs[foundOther]) ) {
1447 return foundOther;
1448 }
1449 }
1450

Callers

nothing calls this directly

Calls 11

getMajorVersionFunction · 0.85
getCurrentSettingsMethod · 0.80
isInputRotoBrushMethod · 0.80
emptyMethod · 0.80
getPluginIDFunction · 0.50
isInputOptionalMethod · 0.45
isInputMaskMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected