Example #1
0
void
ViewerNodePrivate::refreshInputChoiceMenu(int internalIndex, int groupInputIndex)
{
    KnobChoicePtr inputChoiceKnob = internalIndex == 0 ? aInputNodeChoiceKnob.lock() : bInputNodeChoiceKnob.lock();

    assert(groupInputIndex >= 0 && groupInputIndex < _publicInterface->getMaxInputCount());

    std::string groupInputID;
    {
        std::stringstream ss;
        ss << groupInputIndex;
        groupInputID = ss.str();
    }
    std::vector<ChoiceOption> entries = inputChoiceKnob->getEntries();
    for (std::size_t i = 0; i < entries.size(); ++i) {
        if (entries[i].id == groupInputID) {
            inputChoiceKnob->setValue(i);
            return;
        }
    }

    // Input is no longer connected fallback on first input in the list if any, otherwise on None ("-")

    inputChoiceKnob->setValue(entries.size() > 1 ? 1 : 0, ViewSetSpec::all(), DimIdx(0), eValueChangedReasonPluginEdited);


}
Example #2
0
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
Example #3
0
void
ViewerNodePrivate::toggleDownscaleLevel(int index)
{
    assert(index > 0);
    KnobChoicePtr downscaleChoice = downscaleChoiceKnob.lock();
    int curChoice_i = downscaleChoice->getValue();
    if (curChoice_i != index) {
        downscaleChoice->setValue(index);
    } else {
        // Reset back to auto
        downscaleChoice->setValue(0);
    }
}
Example #4
0
void
OneViewNode::onProjectViewsChanged()
{
    const std::vector<std::string>& views = getApp()->getProject()->getProjectViewNames();
    KnobChoicePtr viewKnob = _imp->viewKnob.lock();
    std::string currentView = viewKnob->getActiveEntryText_mt_safe();

    viewKnob->populateChoices(views);

    bool foundView = false;
    for (std::size_t i = 0; i < views.size(); ++i) {
        if (views[i] == currentView) {
            foundView = true;
            viewKnob->setValue(i);
            break;
        }
    }
    if (!foundView) {
        viewKnob->setValue(0);
    }
}
Example #5
0
void
ViewerNodePrivate::setDisplayChannels(int index, bool setBoth)
{

    for (int i = 0; i < 2; ++i) {
        if (i == 1 && !setBoth) {
            break;
        }
        KnobChoicePtr displayChoice = displayChannelsKnob[i].lock();
        displayChoice->setValue(index);
    }
}
Example #6
0
void
ViewerNodePrivate::setAlphaChannelFromLayerIfRGBA()
{

    ImagePlaneDesc selectedLayer, selectedAlphaLayer, selectedDisplayLayer;
    int alphaChannelIndex;
    ViewerInstancePtr internalViewer = internalViewerProcessNode[0].lock()->isEffectViewerInstance();
    internalViewer->getChannelOptions(_publicInterface->getTimelineCurrentTime(), &selectedLayer, &selectedAlphaLayer, &alphaChannelIndex, &selectedDisplayLayer);

    // Set the alpha channel to the selected layer's alpha channel if it is not pointing to anything
    if (selectedLayer.getNumComponents() == 4 && selectedAlphaLayer.getNumComponents() == 0) {

        ChoiceOption newOption = selectedLayer.getChannelOption(3);
        KnobChoicePtr alphaChoice = alphaChannelKnob.lock();
        std::vector<ChoiceOption> options = alphaChoice->getEntries();
        for (std::size_t i = 0; i < options.size(); ++i) {
            if (options[i].id == newOption.id) {
                alphaChoice->setValue(i);
                break;
            }
        }
    }

}