* @brief Returns a pointer to the first non disabled upstream node. * When cycling through the tree, we prefer non optional inputs and we span inputs * from last to first. **/
| 4899 | * from last to first. |
| 4900 | **/ |
| 4901 | EffectInstancePtr |
| 4902 | EffectInstance::getNearestNonDisabled() const |
| 4903 | { |
| 4904 | NodePtr node = getNode(); |
| 4905 | |
| 4906 | if ( !node->isNodeDisabled() ) { |
| 4907 | return node->getEffectInstance(); |
| 4908 | } else { |
| 4909 | ///Test all inputs recursively, going from last to first, preferring non optional inputs. |
| 4910 | std::list<EffectInstancePtr> nonOptionalInputs; |
| 4911 | std::list<EffectInstancePtr> optionalInputs; |
| 4912 | // the following is wrong, because the behavior of scripts or PyPlugs when rendering will then depend on the preferences! |
| 4913 | //bool useInputA = appPTR->getCurrentSettings()->useInputAForMergeAutoConnect() || (getPluginID() == PLUGINID_OFX_SHUFFLE && getMajorVersion() < 3); |
| 4914 | const bool useInputA = false || (getPluginID() == PLUGINID_OFX_SHUFFLE && getMajorVersion() < 3); |
| 4915 | |
| 4916 | ///Find an input named A |
| 4917 | std::string inputNameToFind, otherName; |
| 4918 | if (useInputA) { |
| 4919 | inputNameToFind = "A"; |
| 4920 | otherName = "B"; |
| 4921 | } else { |
| 4922 | inputNameToFind = "B"; |
| 4923 | otherName = "A"; |
| 4924 | } |
| 4925 | int foundOther = -1; |
| 4926 | int maxinputs = getNInputs(); |
| 4927 | for (int i = 0; i < maxinputs; ++i) { |
| 4928 | std::string inputLabel = getInputLabel(i); |
| 4929 | if (inputLabel == inputNameToFind) { |
| 4930 | EffectInstancePtr inp = getInput(i); |
| 4931 | if (inp) { |
| 4932 | nonOptionalInputs.push_front(inp); |
| 4933 | break; |
| 4934 | } |
| 4935 | } else if (inputLabel == otherName) { |
| 4936 | foundOther = i; |
| 4937 | } |
| 4938 | } |
| 4939 | |
| 4940 | if ( (foundOther != -1) && nonOptionalInputs.empty() ) { |
| 4941 | EffectInstancePtr inp = getInput(foundOther); |
| 4942 | if (inp) { |
| 4943 | nonOptionalInputs.push_front(inp); |
| 4944 | } |
| 4945 | } |
| 4946 | |
| 4947 | ///If we found A or B so far, cycle through them |
| 4948 | for (std::list<EffectInstancePtr> ::iterator it = nonOptionalInputs.begin(); it != nonOptionalInputs.end(); ++it) { |
| 4949 | EffectInstancePtr inputRet = (*it)->getNearestNonDisabled(); |
| 4950 | if (inputRet) { |
| 4951 | return inputRet; |
| 4952 | } |
| 4953 | } |
| 4954 | |
| 4955 | |
| 4956 | ///We cycle in reverse by default. It should be a setting of the application. |
| 4957 | ///In this case it will return input B instead of input A of a merge for example. |
| 4958 | for (int i = 0; i < maxinputs; ++i) { |
no test coverage detected