本文整理汇总了C++中KnobIPtr::getNDimensions方法的典型用法代码示例。如果您正苦于以下问题:C++ KnobIPtr::getNDimensions方法的具体用法?C++ KnobIPtr::getNDimensions怎么用?C++ KnobIPtr::getNDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KnobIPtr
的用法示例。
在下文中一共展示了KnobIPtr::getNDimensions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: DimIdx
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);
}
}
示例3: QUndoCommand
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") );
}
示例4: setOldExprForDimView
void
SetExpressionCommand::undo()
{
KnobIPtr knob = _knob.lock();
if (!knob) {
return;
}
knob->beginChanges();
try {
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) {
setOldExprForDimView(knob, DimIdx(i), *it, _oldExprs);
}
} else {
setOldExprForDimView(knob, DimIdx(i), ViewIdx(_view), _oldExprs);
}
}
} else {
if (_view.isAll()) {
for (std::list<ViewIdx>::const_iterator it = allViews.begin(); it!=allViews.end(); ++it) {
setOldExprForDimView(knob, DimIdx(_dimension), *it, _oldExprs);
}
} else {
setOldExprForDimView(knob, DimIdx(_dimension), ViewIdx(_view), _oldExprs);
}
}
} catch (...) {
Dialogs::errorDialog( tr("Expression").toStdString(), tr("The expression is invalid.").toStdString() );
}
knob->endChanges();
}
示例5: assert
void
MultipleKnobEditsUndoCommand::undo()
{
assert( !knobs.empty() );
KnobHolderPtr holder = knobs.begin()->first.lock()->getHolder();
if (holder) {
holder->beginChanges();
}
for (ParamsMap::iterator it = knobs.begin(); it != knobs.end(); ++it) {
KnobIPtr knob = it->first.lock();
if (!knob) {
continue;
}
if (it->second.empty()) {
continue;
}
// All knobs must belong to the same node!
assert(knob->getHolder() == holder);
KnobIntBasePtr isInt = toKnobIntBase(knob);
KnobBoolBasePtr isBool = toKnobBoolBase(knob);
KnobDoubleBasePtr isDouble = toKnobDoubleBase(knob);
KnobStringBasePtr isString = toKnobStringBase(knob);
bool hasChanged = false;
std::list<ValueToSet>::iterator next = it->second.begin();
++next;
if (it->second.size() > 1) {
// block knobChanged handler for this knob until the last change so we don't clutter the main-thread with useless action calls
knob->blockValueChanges();
}
for (std::list<ValueToSet>::reverse_iterator it2 = it->second.rbegin(); it2 != it->second.rend(); ++it2) {
if (next == it->second.end() && it->second.size() > 1) {
// Re-enable knobChanged for the last change on this knob
knob->unblockValueChanges();
}
// If we added a keyframe (due to auto-keying or not) remove it
if (it2->setValueRetCode == eValueChangedReturnCodeKeyframeAdded) {
knob->deleteValueAtTime(it2->time, it2->view, it2->dimension, eValueChangedReasonUserEdited);
}
int nDims = knob->getNDimensions();
std::list<ViewIdx> allViews = knob->getViewsList();
if (it2->dimension.isAll()) {
for (int i = 0; i < nDims; ++i) {
if (it2->view.isAll()) {
for (std::list<ViewIdx>::const_iterator it3 = allViews.begin(); it3!=allViews.end(); ++it3) {
hasChanged |= setOldValueForDimView(isInt, isBool, isDouble, isString, it2->reason, it2->setKeyFrame, it2->time, hasChanged, it2->setValueRetCode, DimIdx(i), *it3, it2->oldValues) != eValueChangedReturnCodeNothingChanged;
}
} else {
ViewIdx view_i = knob->getViewIdxFromGetSpec(ViewGetSpec(it2->view));
hasChanged |= setOldValueForDimView(isInt, isBool, isDouble, isString, it2->reason, it2->setKeyFrame, it2->time, hasChanged, it2->setValueRetCode, DimIdx(i), view_i, it2->oldValues) != eValueChangedReturnCodeNothingChanged;
}
}
} else {
if (it2->view.isAll()) {
for (std::list<ViewIdx>::const_iterator it3 = allViews.begin(); it3!=allViews.end(); ++it3) {
hasChanged |= setOldValueForDimView(isInt, isBool, isDouble, isString, it2->reason, it2->setKeyFrame, it2->time, hasChanged, it2->setValueRetCode, DimIdx(it2->dimension), *it3, it2->oldValues) != eValueChangedReturnCodeNothingChanged;
}
} else {
ViewIdx view_i = knob->getViewIdxFromGetSpec(ViewGetSpec(it2->view));
hasChanged |= setOldValueForDimView(isInt, isBool, isDouble, isString, it2->reason, it2->setKeyFrame, it2->time, hasChanged, it2->setValueRetCode, DimIdx(it2->dimension), view_i, it2->oldValues) != eValueChangedReturnCodeNothingChanged;
}
}
if (next != it->second.end()) {
++next;
}
}
} // for all knobs
if (holder) {
holder->endChanges();
}
} // MultipleKnobEditsUndoCommand::undo
示例6: 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
示例7: 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];
//.........这里部分代码省略.........