void ViewerNodePrivate::swapViewerProcessInputs() { NodePtr viewerProcessNodesInputs[2]; for (int i = 0; i < 2; ++i) { viewerProcessNodesInputs[i] = getInputRecursive(i); } NodePtr input0 = viewerProcessNodesInputs[0]->getInput(0); NodePtr input1 = viewerProcessNodesInputs[1]->getInput(0); viewerProcessNodesInputs[0]->swapInput(input1, 0); viewerProcessNodesInputs[1]->swapInput(input0, 0); try { KnobChoicePtr aChoice = aInputNodeChoiceKnob.lock(); KnobChoicePtr bChoice = bInputNodeChoiceKnob.lock(); ChoiceOption aCurChoice = aChoice->getActiveEntry(); ChoiceOption bCurChoice = bChoice->getActiveEntry(); aChoice->blockValueChanges(); aChoice->setValueFromID(bCurChoice.id); aChoice->unblockValueChanges(); bChoice->blockValueChanges(); bChoice->setValueFromID(aCurChoice.id); bChoice->unblockValueChanges(); } catch (...) { } }
void ViewerNodePrivate::refreshInputChoices(bool resetChoiceIfNotFound) { // Refresh the A and B input choices KnobChoicePtr aInputKnob = aInputNodeChoiceKnob.lock(); KnobChoicePtr bInputKnob = bInputNodeChoiceKnob.lock(); ViewerCompositingOperatorEnum operation = (ViewerCompositingOperatorEnum)blendingModeChoiceKnob.lock()->getValue(); bInputKnob->setEnabled(operation != eViewerCompositingOperatorNone); std::vector<ChoiceOption> entries; entries.push_back(ChoiceOption("-", "", "")); int nInputs = _publicInterface->getMaxInputCount(); for (int i = 0; i < nInputs; ++i) { NodePtr inputNode = _publicInterface->getNode()->getRealInput(i); if (!inputNode) { continue; } std::string optionID; { std::stringstream ss; ss << i; optionID = ss.str(); } entries.push_back(ChoiceOption(optionID, inputNode->getLabel(), "")); } ChoiceOption currentAChoice = aInputKnob->getActiveEntry(); ChoiceOption currentBChoice = bInputKnob->getActiveEntry(); aInputKnob->populateChoices(entries); bInputKnob->populateChoices(entries); if (resetChoiceIfNotFound) { if (currentAChoice.id == "-" || !aInputKnob->isActiveEntryPresentInEntries(ViewIdx(0))) { aInputKnob->setValue(entries.size() > 1 ? 1 : 0); } if (currentBChoice.id == "-" || !bInputKnob->isActiveEntryPresentInEntries(ViewIdx(0))) { bInputKnob->setValue(entries.size() > 1 ? 1 : 0); } } if (uiContext) { if ( (operation == eViewerCompositingOperatorNone) || !bInputKnob->isEnabled() || bInputKnob->getActiveEntry().id.empty() ) { uiContext->setInfoBarVisible(1, false); } else if (operation != eViewerCompositingOperatorNone) { uiContext->setInfoBarVisible(1, true); } } } // refreshInputChoices