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


C++ KnobIPtr::getHolder方法代码示例

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


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

示例1: toEffectInstance

void
RestoreDefaultsCommand::redo()
{
    KnobIPtr first = _knobs.front().lock();
    AppInstancePtr app;
    KnobHolderPtr holder = first->getHolder();
    EffectInstancePtr isEffect = toEffectInstance(holder);

    if (holder) {
        app = holder->getApp();
        holder->beginChanges();
    }

     //  First reset all knobs values, this will not call instanceChanged action
    for (std::list<KnobIWPtr >::iterator it = _knobs.begin(); it != _knobs.end(); ++it) {
        KnobIPtr itKnob = it->lock();
        if (!itKnob) {
            continue;
        }
        if ( itKnob->getHolder() ) {
            itKnob->getHolder()->beginChanges();
        }
        itKnob->resetToDefaultValue(_targetDim, _targetView);
        if ( itKnob->getHolder() ) {
            itKnob->getHolder()->endChanges(true);
        }

    }

    //   Call instanceChange on all knobs afterwards to put back the plug-in
    //   in a correct state
    double time = 0;
    if (app) {
        time = app->getTimeLine()->currentFrame();
    }
    for (std::list<KnobIWPtr >::iterator it = _knobs.begin(); it != _knobs.end(); ++it) {
        KnobIPtr itKnob = it->lock();
        if (!itKnob) {
            continue;
        }
        if ( itKnob->getHolder() ) {
            itKnob->getHolder()->onKnobValueChanged_public(itKnob, eValueChangedReasonRestoreDefault, time, ViewIdx(0), true);
        }
    }


    if ( holder && holder->getApp() ) {
        holder->endChanges();
    }


    if ( first->getHolder() ) {
        if ( first->getHolder()->getApp() ) {
            first->getHolder()->getApp()->redrawAllViewers();
        }
    }
} // RestoreDefaultsCommand::redo
开发者ID:azerupi,项目名称:Natron,代码行数:57,代码来源:KnobUndoCommand.cpp

示例2: 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

示例3: 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

示例4: 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

示例5: fromCurve

void
PasteKnobClipBoardUndoCommand::copyFrom(const SERIALIZATION_NAMESPACE::KnobSerializationPtr& serializedKnob,
                           const KnobIPtr& fromKnob,
                           bool isRedo)
{
    KnobIPtr internalKnob = _imp->knob.lock();
    if (!internalKnob) {
        return;
    }

    // Get the target type
    KnobIntBasePtr isInt = toKnobIntBase( internalKnob );
    KnobBoolBasePtr isBool = toKnobBoolBase( internalKnob );
    KnobDoubleBasePtr isDouble = toKnobDoubleBase( internalKnob );
    KnobStringBasePtr isString = toKnobStringBase( internalKnob );


    // Get view names
    std::vector<std::string> projectViewNames;
    if (internalKnob->getHolder() && internalKnob->getHolder()->getApp()) {
        projectViewNames = internalKnob->getHolder()->getApp()->getProject()->getProjectViewNames();
    }

    // group changes under the same evaluation
    internalKnob->beginChanges();


    std::list<ViewIdx> targetKnobViews = internalKnob->getViewsList();


    StringAnimationManagerPtr fromAnimString;
    if (fromKnob) {
        fromAnimString = fromKnob->getStringAnimation();
    }

    for (std::list<ViewIdx>::const_iterator it = targetKnobViews.begin(); it != targetKnobViews.end(); ++it) {
        if ( ( !_imp->targetView.isAll()) && ( *it != _imp->targetView) ) {
            continue;
        }

        // If dimensions are folded, expand them when linking
        if (_imp->targetDimension.isAll() && !internalKnob->getAllDimensionsVisible(*it)) {
            internalKnob->setAllDimensionsVisible(*it, true);
        }
        
        for (int i = 0; i < internalKnob->getNDimensions(); ++i) {
            if ( ( !_imp->targetDimension.isAll()) && ( i != _imp->targetDimension) ) {
                continue;
            }

            ViewIdx fromView;
            DimIdx fromDim;

            if ( !_imp->targetDimension.all() && !_imp->fromDimension.isAll() ) {
                fromDim = DimIdx(_imp->fromDimension);
            } else {
                // If the source knob dimension is all or target dimension is all copy dimension to dimension respectively
                fromDim = DimIdx(i);
            }

            if ( !_imp->targetView.isAll() && !_imp->fromView.isAll() ) {
                fromView = ViewIdx(_imp->fromView);
            } else {
                // If the source knob view is all or target view is all copy view to view respectively
                fromView = *it;
            }


            switch (_imp->type) {
                case eKnobClipBoardTypeCopyAnim: {
                    std::string fromViewName;
                    if (fromView >= 0 && fromView < (int)projectViewNames.size()) {
                        fromViewName = projectViewNames[_imp->fromView];
                    } else {
                        fromViewName = "Main";
                    }
                    SERIALIZATION_NAMESPACE::KnobSerialization::PerViewValueSerializationMap::const_iterator foundFromView = serializedKnob->_values.find(fromViewName);
                    if (foundFromView == serializedKnob->_values.end()) {
                        continue;
                    }
                    if (fromDim < 0 || fromDim >= (int) foundFromView->second.size()) {
                        continue;
                    }


                    // Read the curve from the clipboard
                    CurvePtr fromCurve(new Curve());
                    

                    if (!foundFromView->second[_imp->fromDimension]._animationCurve.keys.empty()) {
                        fromCurve->fromSerialization(foundFromView->second[_imp->fromDimension]._animationCurve);
                    }
                    internalKnob->cloneCurve(*it, DimIdx(i), *fromCurve, 0 /*offset*/, 0 /*range*/, fromAnimString.get());

                    break;
                }
                case eKnobClipBoardTypeCopyValue: {
                    std::string fromViewName;
                    if (fromView >= 0 && fromView < (int)projectViewNames.size()) {
                        fromViewName = projectViewNames[_imp->fromView];
//.........这里部分代码省略.........
开发者ID:azerupi,项目名称:Natron,代码行数:101,代码来源:KnobUndoCommand.cpp


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