本文整理汇总了C++中Plug::acceptsChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Plug::acceptsChild方法的具体用法?C++ Plug::acceptsChild怎么用?C++ Plug::acceptsChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plug
的用法示例。
在下文中一共展示了Plug::acceptsChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parentChanging
void Plug::parentChanging( Gaffer::GraphComponent *newParent )
{
if( getFlags( Dynamic ) )
{
// When a dynamic plug is removed from a node, we
// need to propagate dirtiness based on that. We
// must call DependencyNode::affects() now, while the
// plug is still a child of the node, but we push
// scope so that the emission of plugDirtiedSignal()
// is deferred until parentChanged() when the operation
// is complete. It is essential that exceptions don't
// prevent us getting to parentChanged() where we pop
// scope, so propateDirtiness() takes care of handling
// exceptions thrown by DependencyNode::affects().
pushDirtyPropagationScope();
if( node() )
{
propagateDirtinessForParentChange( this );
}
}
// This method manages the connections between plugs when
// additional child plugs are added or removed. We only
// want to react to these changes when they are first made -
// after this our own actions will have been recorded in the
// undo buffer anyway and will be undone/redone automatically.
// So here we early out if we're in such an Undo/Redo situation.
ScriptNode *scriptNode = ancestor<ScriptNode>();
scriptNode = scriptNode ? scriptNode : ( newParent ? newParent->ancestor<ScriptNode>() : NULL );
if( scriptNode && ( scriptNode->currentActionStage() == Action::Undo || scriptNode->currentActionStage() == Action::Redo ) )
{
return;
}
// Now we can take the actions we need to based on the new parent
// we're getting.
if( !newParent )
{
// We're losing our parent - remove all our connections first.
// this must be done here (rather than in a parentChangedSignal() slot)
// because we need a current parent for the operation to be undoable.
setInput( 0 );
// Deal with outputs whose parent is an output of our parent.
// For these we actually remove the destination plug itself,
// so that the parent plugs may remain connected.
if( Plug *oldParent = parent<Plug>() )
{
for( OutputContainer::iterator it = m_outputs.begin(); it!=m_outputs.end(); )
{
Plug *output = *it++;
Plug *outputParent = output->parent<Plug>();
if( outputParent && outputParent->getInput<Plug>() == oldParent )
{
// We're removing the child precisely so that the parent connection
// remains valid, so we can block its updateInputFromChildInputs() call.
assert( outputParent->m_skipNextUpdateInputFromChildInputs == false );
ScopedAssignment<bool> blocker( outputParent->m_skipNextUpdateInputFromChildInputs, true );
outputParent->removeChild( output );
}
}
}
// Remove any remaining output connections.
removeOutputs();
}
else if( Plug *newParentPlug = IECore::runTimeCast<Plug>( newParent ) )
{
// we're getting a new parent - update its input connection from
// all the children including the pending one.
newParentPlug->updateInputFromChildInputs( this );
// and add a new child plug to any of its outputs to maintain
// the output connections.
const OutputContainer &outputs = newParentPlug->outputs();
for( OutputContainer::const_iterator it = outputs.begin(), eIt = outputs.end(); it != eIt; ++it )
{
Plug *output = *it;
if( output->acceptsChild( this ) )
{
PlugPtr outputChildPlug = createCounterpart( getName(), direction() );
{
// We're adding the child so that the parent connection remains valid,
// but the parent connection wouldn't be considered valid until the
// child has both been added and had its input connected. We therefore
// block the call to updateInputFromChildInputs() to keep the parent
// connection intact.
assert( output->m_skipNextUpdateInputFromChildInputs == false );
ScopedAssignment<bool> blocker( output->m_skipNextUpdateInputFromChildInputs, true );
output->addChild( outputChildPlug );
}
outputChildPlug->setInput( this, /* setChildInputs = */ true, /* updateParentInput = */ false );
}
}
}
}