当前位置: 首页>>代码示例>>C++>>正文


C++ KnobIPtr类代码示例

本文整理汇总了C++中KnobIPtr的典型用法代码示例。如果您正苦于以下问题:C++ KnobIPtr类的具体用法?C++ KnobIPtr怎么用?C++ KnobIPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KnobIPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getProject

bool
GuiAppInstance::checkAllReadersModificationDate(bool errorAndWarn)
{
    NodesList allNodes;
    SequenceTime time = getProject()->getCurrentTime();

    getProject()->getNodes_recursive(allNodes, true);
    bool changed =  false;
    for (NodesList::iterator it = allNodes.begin(); it != allNodes.end(); ++it) {
        if ( (*it)->getEffectInstance()->isReader() ) {
            KnobIPtr fileKnobI = (*it)->getKnobByName(kOfxImageEffectFileParamName);
            if (!fileKnobI) {
                continue;
            }
            KnobGuiIPtr knobUi_i = fileKnobI->getKnobGuiPointer();
            KnobGuiFile* isFileKnob = dynamic_cast<KnobGuiFile*>( knobUi_i.get() );

            if (!isFileKnob) {
                continue;
            }
            changed |= isFileKnob->checkFileModificationAndWarn(time, errorAndWarn);
        }
    }

    return changed;
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:26,代码来源:GuiAppInstance.cpp

示例2: getOldExprForDimView

static void getOldExprForDimView(const KnobIPtr& knob, DimIdx dim, ViewIdx view, SetExpressionCommand::PerDimViewExprMap* ret)
{
    DimensionViewPair key = {dim, view};
    SetExpressionCommand::Expr& e = (*ret)[key];
    e.expression = knob->getExpression(dim, view);
    e.hasRetVar = knob->isExpressionUsingRetVariable(view, dim);
}
开发者ID:azerupi,项目名称:Natron,代码行数:7,代码来源:KnobUndoCommand.cpp

示例3: QUndoCommand

MultipleKnobEditsUndoCommand::MultipleKnobEditsUndoCommand(const KnobIPtr& knob,
                                                           const QString& commandName,
                                                           ValueChangedReasonEnum reason,
                                                           ValueChangedReturnCodeEnum setValueRetCode,
                                                           bool createNew,
                                                           bool setKeyFrame,
                                                           const PerDimViewVariantMap& oldValue,
                                                           const Variant & newValue,
                                                           DimSpec dimension,
                                                           double time,
                                                           ViewSetSpec view)
    : QUndoCommand()
    , knobs()
    , createNew(createNew)
    , firstRedoCalled(false)
{
    assert(knob);
    std::list<ValueToSet>& vlist = knobs[knob];
    vlist.push_back(ValueToSet());

    // Add the new value to set to the list (which may be not empty)
    ValueToSet &v = vlist.back();
    v.newValue = newValue;
    v.dimension = dimension;
    assert(dimension != -1);

    if (!setKeyFrame) {
        // Ensure the time is correct in case auto-keying is on and we add a keyframe
        v.time = knob->getCurrentTime();
    } else {
        v.time = time;
    }
    v.setKeyFrame = setKeyFrame;
    v.view = view;
    v.setValueRetCode = setValueRetCode;
    v.reason = reason;
    v.oldValues = oldValue;

    KnobHolderPtr holder = knob->getHolder();
    EffectInstancePtr effect = toEffectInstance(holder);
    QString holderName;
    if (effect) {
        holderName = QString::fromUtf8( effect->getNode()->getLabel().c_str() );
    }

    // Set the command name in the Edit menu
    if (!commandName.isEmpty()) {
        setText(QString::fromUtf8("%1: ").arg(holderName) + commandName);
    } else {
        // If no command name passed, make up a generic command name
        setText( tr("%1: Multiple Parameters Edits").arg(holderName) );
    }
}
开发者ID:azerupi,项目名称:Natron,代码行数:53,代码来源:KnobUndoCommand.cpp

示例4:

void
DSTransformKeysCommand::transformKey(const DSKeyPtr& key)
{
    DSKnobPtr knobContext = key->context.lock();

    if (!knobContext) {
        return;
    }

    KnobIPtr knob = knobContext->getKnobGui()->getKnob();
    knob->transformValueAtTime(eCurveChangeReasonDopeSheet, key->key.getTime(), ViewSpec::all(), knobContext->getDimension(), _transform, &key->key);
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:12,代码来源:DopeSheetEditorUndoRedo.cpp

示例5: title

void
EditExpressionDialog::setTitle()
{
    KnobIPtr k = _knob->getKnob();
    QString title( tr("Set expression on ") );

    title.append( QString::fromUtf8( k->getName().c_str() ) );
    if ( !_dimension.isAll() && (k->getNDimensions() > 1) ) {
        title.append( QLatin1Char('.') );
        title.append( QString::fromUtf8( k->getDimensionName(DimIdx(_dimension)).c_str() ) );
    }
    setWindowTitle(title);
}
开发者ID:MrKepzie,项目名称:Natron,代码行数:13,代码来源:EditExpressionDialog.cpp

示例6: deleteKnobAnimation

static void
deleteKnobAnimation(const std::set<double>& userKeyframes,
                    const KnobIPtr& knob,
                    DeleteKnobAnimationEnum type,
                    double currentTime)
{
    for (int i = 0; i < knob->getNDimensions(); ++i) {
        CurvePtr curve = knob->getAnimationCurve(ViewIdx(0), DimIdx(i));
        assert(curve);
        KeyFrameSet keys = curve->getKeyFrames_mt_safe();
        std::list<double> toRemove;
        switch (type) {
        case eDeleteKnobAnimationAll: {
            for (KeyFrameSet::iterator it = keys.begin(); it != keys.end(); ++it) {
                std::set<double>::iterator found = userKeyframes.find( it->getTime() );
                if ( found == userKeyframes.end() ) {
                    toRemove.push_back( it->getTime() );
                }
            }
            break;
        }
        case eDeleteKnobAnimationBeforeTime: {
            for (KeyFrameSet::iterator it = keys.begin(); it != keys.end(); ++it) {
                if (it->getTime() >= currentTime) {
                    break;
                }
                std::set<double>::iterator found = userKeyframes.find( it->getTime() );
                if ( found == userKeyframes.end() ) {
                    toRemove.push_back( it->getTime() );
                }
            }
            break;
        }
        case eDeleteKnobAnimationAfterTime: {
            for (KeyFrameSet::reverse_iterator it = keys.rbegin(); it != keys.rend(); ++it) {
                if (it->getTime() <= currentTime) {
                    break;
                }
                std::set<double>::iterator found = userKeyframes.find( it->getTime() );
                if ( found == userKeyframes.end() ) {
                    toRemove.push_back( it->getTime() );
                }
            }
            break;
        }
        }
        knob->deleteValuesAtTime(toRemove, ViewSetSpec::all(), DimIdx(i), eValueChangedReasonUserEdited);
    }
}
开发者ID:kcotugno,项目名称:Natron,代码行数:49,代码来源:TrackMarker.cpp

示例7: getKnobGui

std::string
KnobGuiWidgets::getDescriptionLabel() const
{
    std::string ret;
    KnobGuiPtr knob = getKnobGui();
    if (!knob) {
        return ret;
    }
    KnobIPtr internalKnob = knob->getKnob();
    if (!internalKnob) {
        return ret;
    }
    ret = internalKnob->getLabel();
    return ret;
}
开发者ID:azerupi,项目名称:Natron,代码行数:15,代码来源:KnobGuiWidgets.cpp

示例8: catch

void
SetExpressionCommand::redo()
{
    KnobIPtr knob = _knob.lock();

    if (!knob) {
        return;
    }
    try {
        // Don't fail if exception is invalid, it should have been tested prior to creating an undo/redo command, otherwise user is going
        // to hit CTRL-Z and nothing will happen
        knob->setExpression(_dimension, _view, _newExpr, _hasRetVar, /*failIfInvalid*/ false);
    } catch (...) {
        Dialogs::errorDialog( tr("Expression").toStdString(), tr("The expression is invalid.").toStdString() );
    }

}
开发者ID:azerupi,项目名称:Natron,代码行数:17,代码来源:KnobUndoCommand.cpp

示例9: setOldExprForDimView

static void setOldExprForDimView(const KnobIPtr& knob, DimIdx dim, ViewIdx view, const SetExpressionCommand::PerDimViewExprMap& ret)
{
    DimensionViewPair key = {dim, view};
    SetExpressionCommand::PerDimViewExprMap::const_iterator foundDimView = ret.find(key);
    if (foundDimView == ret.end()) {
        return;
    }
    knob->setExpression(dim, view, foundDimView->second.expression, foundDimView->second.hasRetVar, false /*failIfInvalid*/);

}
开发者ID:azerupi,项目名称:Natron,代码行数:10,代码来源:KnobUndoCommand.cpp

示例10: KnobGuiValue

KnobGuiColor::KnobGuiColor(KnobIPtr knob,
                           KnobGuiContainerI *container)
    : KnobGuiValue(knob, container)
    , _knob( toKnobColor(knob) )
    , _colorLabel(0)
    , _colorDialogButton(0)
    , _lastColor( knob->getDimension() )
    , _useSimplifiedUI( isViewerUIKnob() || _knob.lock()->isSimplified() )
{
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:10,代码来源:KnobGuiColor.cpp

示例11:

bool
AnimationModule::getNodeCanAnimate(const NodePtr &node)
{
    // A node with an items table such as Tracker or RotoPaint always animates
    if (node->getEffectInstance()->getItemsTable()) {
        return true;
    }

    // Check that it has at least one knob that can animate
    const KnobsVec &knobs = node->getKnobs();

    for (KnobsVec::const_iterator it = knobs.begin();
         it != knobs.end();
         ++it) {
        KnobIPtr knob = *it;

        if ( knob->isAnimationEnabled() ) {
            return true;
        }
    }

    return false;
}
开发者ID:kcotugno,项目名称:Natron,代码行数:23,代码来源:AnimationModule.cpp

示例12: setCursorPosition

void
KnobSpinBox::focusInEvent(QFocusEvent* e)
{
    _dnd->focusIn();
    SpinBox::focusInEvent(e);


    //Set the expression so the user can edit it easily
    KnobGuiPtr k = knob.lock();
    if (!k) {
        return;
    }
    KnobIPtr knob = k->getKnob();
    if (!knob) {
        return;
    }
    std::string expr = knob->getExpression(dimension, view);
    if ( expr.empty() ) {
        return;
    } else {
        QLineEdit::setText( QString::fromUtf8( expr.c_str() ) );
        setCursorPosition(expr.size() - 1);
    }
}
开发者ID:MrKepzie,项目名称:Natron,代码行数:24,代码来源:SpinBox.cpp

示例13: assert

void
RestoreDefaultsCommand::undo()
{
    assert( _serializations.size() == _knobs.size() );

    KnobIPtr first = _knobs.front().lock();
    AppInstancePtr app = first->getHolder()->getApp();
    assert(app);
    SERIALIZATION_NAMESPACE::KnobSerializationList::const_iterator itClone = _serializations.begin();
    for (std::list<KnobIWPtr >::const_iterator it = _knobs.begin(); it != _knobs.end(); ++it, ++itClone) {
        KnobIPtr itKnob = it->lock();
        if (!itKnob) {
            continue;
        }
       
        itKnob->fromSerialization(**itClone);
    }

    if ( first->getHolder()->getApp() ) {
        first->getHolder()->getApp()->redrawAllViewers();
    }

}
开发者ID:azerupi,项目名称:Natron,代码行数:23,代码来源:KnobUndoCommand.cpp

示例14: catch

void
NodePrivate::runChangedParamCallback(const std::string& cb, const KnobIPtr& k, bool userEdited)
{
    std::vector<std::string> args;
    std::string error;

    if ( !k || (k->getName() == "onParamChanged") ) {
        return;
    }

    std::string callbackFunction;
    if (!figureOutCallbackName(cb, &callbackFunction)) {
        return;
    }

    try {
        NATRON_PYTHON_NAMESPACE::getFunctionArguments(callbackFunction, &error, &args);
    } catch (const std::exception& e) {
        _publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( e.what() ) ).toStdString() );

        return;
    }

    if ( !error.empty() ) {
        _publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( error.c_str() ) ).toStdString() );

        return;
    }

    std::string signatureError;
    signatureError.append( tr("The param changed callback supports the following signature(s):").toStdString() );
    signatureError.append("\n- callback(thisParam,thisNode,thisGroup,app,userEdited)");
    if (args.size() != 5) {
        _publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( signatureError.c_str() ) ).toStdString() );

        return;
    }

    if ( ( (args[0] != "thisParam") || (args[1] != "thisNode") || (args[2] != "thisGroup") || (args[3] != "app") || (args[4] != "userEdited") ) ) {
        _publicInterface->getApp()->appendToScriptEditor( tr("Failed to run onParamChanged callback: %1").arg( QString::fromUtf8( signatureError.c_str() ) ).toStdString() );

        return;
    }

    std::string appID = _publicInterface->getApp()->getAppIDString();

    assert(k);
    std::string thisNodeVar = appID + ".";
    thisNodeVar.append( _publicInterface->getFullyQualifiedName() );

    NodeCollectionPtr collection = _publicInterface->getGroup();
    assert(collection);
    if (!collection) {
        return;
    }

    std::string thisGroupVar;
    NodeGroupPtr isParentGrp = toNodeGroup(collection);
    if (isParentGrp) {
        std::string nodeName = isParentGrp->getNode()->getFullyQualifiedName();
        std::string nodeFullName = appID + "." + nodeName;
        thisGroupVar = nodeFullName;
    } else {
        thisGroupVar = appID;
    }

    bool alreadyDefined = false;
    PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(thisNodeVar, NATRON_PYTHON_NAMESPACE::getMainModule(), &alreadyDefined);
    if (!nodeObj || !alreadyDefined) {
        return;
    }

    if (!PyObject_HasAttrString( nodeObj, k->getName().c_str() ) ) {
        return;
    }

    std::stringstream ss;
    ss << callbackFunction << "(" << thisNodeVar << "." << k->getName() << "," << thisNodeVar << "," << thisGroupVar << "," << appID
    << ",";
    if (userEdited) {
        ss << "True";
    } else {
        ss << "False";
    }
    ss << ")\n";

    std::string script = ss.str();
    std::string err;
    std::string output;
    if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) {
        _publicInterface->getApp()->appendToScriptEditor( tr("Failed to execute onParamChanged callback: %1").arg( QString::fromUtf8( err.c_str() ) ).toStdString() );
    } else {
        if ( !output.empty() ) {
            _publicInterface->getApp()->appendToScriptEditor(output);
        }
    }

} // runChangedParamCallback
开发者ID:kcotugno,项目名称:Natron,代码行数:98,代码来源:NodePythonInteraction.cpp

示例15: string

std::string
PasteKnobClipBoardUndoCommand::makeLinkExpression(const std::vector<std::string>& projectViewNames,
                                                  const KnobIPtr& targetKnob,
                                                  bool multCurve,
                                                  const KnobIPtr& fromKnob,
                                                  DimSpec fromDimension,
                                                  ViewSetSpec fromView,
                                                  DimSpec targetDimension,
                                                  ViewSetSpec targetView)
{
    EffectInstancePtr fromEffect = toEffectInstance( fromKnob->getHolder() );
    EffectInstancePtr toEffect = toEffectInstance( targetKnob->getHolder() );
    assert(fromEffect && toEffect);
    if (!fromEffect || !toEffect) {
        return std::string();
    }

    std::stringstream ss;
    if (fromEffect == toEffect) {
        // Same node, use thisNode
        ss << "thisNode.";
    } else {
        // If the container of the effect is a group, prepend thisGroup, otherwise use
        // the canonical app prefix
        NodeGroupPtr isEffectContainerGroup;
        {
            NodeCollectionPtr effectContainer = fromEffect->getNode()->getGroup();
            isEffectContainerGroup = toNodeGroup(effectContainer);
        }
        if (isEffectContainerGroup) {
            ss << "thisGroup.";
        } else {
            ss << fromEffect->getApp()->getAppIDString() << ".";
        }
        ss << fromEffect->getNode()->getScriptName_mt_safe() << ".";
    }

    // Call getValue on the fromKnob
    ss << fromKnob->getName();
    ss << ".getValue(";
    if (fromKnob->getNDimensions() > 1) {
        if (fromDimension.isAll()) {
            ss << "dimension";
        } else {
            ss << fromDimension;
        }
    }
    std::list<ViewIdx> sourceViews = fromKnob->getViewsList();
    if (sourceViews.size() > 1) {
        ss << ", ";
        if (fromView.isAll()) {
            ss << "view";
        } else {
            if (fromView >= 0 && fromView < (int)projectViewNames.size()) {
                ss << projectViewNames[fromView];
            } else {
                ss << "Main";
            }
        }
    }
    ss << ")";

    // Also check if we need to multiply by the target knob's curve
    if (multCurve) {
        ss << " * curve(frame, ";
        if (targetDimension.isAll()) {
            ss << "dimension";
        } else {
            ss << targetDimension;
        }

        std::list<ViewIdx> targetKnobViews = targetKnob->getViewsList();
        if (targetKnobViews.size() > 1) {
            ss << ", ";
            if (targetView.isAll()) {
                ss << "view";
            } else {

                if (targetView >= 0 && targetView < (int)projectViewNames.size()) {
                    ss << projectViewNames[targetView];
                } else {
                    ss << "Main";
                }
            }
        }

        ss << ")";
    }
    return ss.str();
} // makeLinkExpression
开发者ID:azerupi,项目名称:Natron,代码行数:90,代码来源:KnobUndoCommand.cpp


注:本文中的KnobIPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。