void
AnimationModuleSelectionModel::addAnimatedItemKeyframes(const AnimItemBasePtr& item,
                                                        DimSpec dim,
                                                        ViewSetSpec viewSpec,
                                                        AnimItemDimViewKeyFramesMap* result)
{
    std::list<ViewIdx> views = item->getViewsList();
    int nDims = item->getNDimensions();
    if (viewSpec.isAll()) {
        for (std::list<ViewIdx>::const_iterator it3 = views.begin(); it3 != views.end(); ++it3) {

            if (dim.isAll()) {
                for (int i = 0; i < nDims; ++i) {

                    QTreeWidgetItem* treeItem = item->getTreeItem(DimIdx(i), *it3);
                    if (AnimationModuleTreeView::isItemVisibleRecursive(treeItem)) {
                        AnimItemDimViewIndexID key(item, *it3, DimIdx(i));
                        KeyFrameWithStringSet &keysForItem = (*result)[key];
                        item->getKeyframes(DimIdx(i), *it3, AnimItemBase::eGetKeyframesTypeMerged, &keysForItem);
                    }
                }
            } else {

                QTreeWidgetItem* treeItem = item->getTreeItem(DimIdx(dim), *it3);
                if (AnimationModuleTreeView::isItemVisibleRecursive(treeItem)) {
                    AnimItemDimViewIndexID key(item, *it3, DimIdx(dim));
                    KeyFrameWithStringSet &keysForItem = (*result)[key];
                    item->getKeyframes(DimIdx(dim), *it3, AnimItemBase::eGetKeyframesTypeMerged, &keysForItem);
                }
            }
        }

    } else {
        if (dim.isAll()) {
            for (int i = 0; i < nDims; ++i) {

                QTreeWidgetItem* treeItem = item->getTreeItem(DimIdx(i), ViewIdx(viewSpec));
                if (AnimationModuleTreeView::isItemVisibleRecursive(treeItem)) {
                    AnimItemDimViewIndexID key(item, ViewIdx(viewSpec), DimIdx(i));
                    KeyFrameWithStringSet &keysForItem = (*result)[key];
                    item->getKeyframes(DimIdx(i), ViewIdx(viewSpec), AnimItemBase::eGetKeyframesTypeMerged, &keysForItem);
                }
            }
        } else {
            QTreeWidgetItem* treeItem = item->getTreeItem(DimIdx(dim), ViewIdx(viewSpec));
            if (AnimationModuleTreeView::isItemVisibleRecursive(treeItem)) {
                AnimItemDimViewIndexID key(item, ViewIdx(viewSpec), DimIdx(dim));
                KeyFrameWithStringSet &keysForItem = (*result)[key];
                item->getKeyframes(DimIdx(dim), ViewIdx(viewSpec), AnimItemBase::eGetKeyframesTypeMerged,&keysForItem);
            }
        }
    }

} // addAnimatedItemKeyframes
Example #2
0
SetExpressionCommand::SetExpressionCommand(const KnobIPtr & knob,
                                           bool hasRetVar,
                                           DimSpec dimension,
                                           ViewSetSpec view,
                                           const std::string& expr,
                                           QUndoCommand *parent)
: QUndoCommand(parent)
, _knob(knob)
, _oldExprs()
, _newExpr(expr)
, _hasRetVar(hasRetVar)
, _dimension(dimension)
, _view(view)
{
    int nDims = knob->getNDimensions();
    std::list<ViewIdx> allViews = knob->getViewsList();
    if (dimension.isAll()) {
        for (int i = 0; i < nDims; ++i) {
            if (view.isAll()) {
                for (std::list<ViewIdx>::const_iterator it = allViews.begin(); it!=allViews.end(); ++it) {
                    getOldExprForDimView(knob, DimIdx(i), *it, &_oldExprs);
                }
            } else {
                getOldExprForDimView(knob, DimIdx(i), ViewIdx(view), &_oldExprs);
            }
        }

    } else {
        if (view.isAll()) {
            for (std::list<ViewIdx>::const_iterator it = allViews.begin(); it!=allViews.end(); ++it) {
                getOldExprForDimView(knob, DimIdx(dimension), *it, &_oldExprs);
            }
        } else {
            getOldExprForDimView(knob, DimIdx(dimension), ViewIdx(view), &_oldExprs);
        }
    }

    setText( tr("Set Expression") );


}
Example #3
0
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