Esempio n. 1
0
 QString viewToString(ViewIdx view) const
 {
     EffectInstancePtr e = effect.lock();
     if (!e) {
         return QString::fromUtf8(kPyParamViewIdxMain);
     }
     return QString::fromUtf8(e->getApp()->getProject()->getViewName(view).c_str());
 }
Esempio n. 2
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