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


C++ Plug类代码示例

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


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

示例1: removeChildren

void Expression::updatePlug( ValuePlug *parentPlug, size_t childIndex, ValuePlug *plug )
{
	if( parentPlug->children().size() > childIndex )
	{
		// See if we can reuse the existing plug
		Plug *existingChildPlug = parentPlug->getChild<Plug>( childIndex );
		if(
			( existingChildPlug->direction() == Plug::In && existingChildPlug->getInput<Plug>() == plug ) ||
			( existingChildPlug->direction() == Plug::Out && plug->getInput<Plug>() == existingChildPlug )
		)
		{
			return;
		}
	}

	// Existing plug not OK, so we need to create one. First we must remove all
	// plugs from childIndex onwards, so that when we add the new plug it gets
	// the right index.
	removeChildren( parentPlug, childIndex );

	// Finally we can add the plug we need.

	PlugPtr childPlug = plug->createCounterpart( "p0", parentPlug->direction() );
	childPlug->setFlags( Plug::Dynamic, true );
	parentPlug->addChild( childPlug );
	if( childPlug->direction() == Plug::In )
	{
		childPlug->setInput( plug );
	}
	else
	{
		plug->setInput( childPlug );
	}
}
开发者ID:Kthulhu,项目名称:gaffer,代码行数:34,代码来源:Expression.cpp

示例2: undoEnabler

bool DotNodeGadget::drop( const DragDropEvent &event )
{
	if( dotNode()->inPlug<Plug>() )
	{
		// We've already got our plugs set up - StandardNodeGadget
		// behaviour will take care of everything.
		return false;
	}

	Plug *plug = runTimeCast<Plug>( event.data.get() );
	if( !plug )
	{
		return false;
	}

	Gaffer::UndoScope undoEnabler( node()->ancestor<ScriptNode>() );

	dotNode()->setup( plug );
	if( plug->direction() == Plug::In )
	{
		plug->setInput( dotNode()->outPlug<Plug>() );
	}
	else
	{
		dotNode()->inPlug<Plug>()->setInput( plug );
	}

	return true;
}
开发者ID:boberfly,项目名称:gaffer,代码行数:29,代码来源:DotNodeGadget.cpp

示例3: PROFILER

void ScriptingKeyframesBool::set_key (void)
{
	PROFILER(SCRIPTING);

	const std::vector<PlugBase*> &outgoing = _out.outgoing_connections();
	if (outgoing.size() > 0) {
		// get first connected plug
		Plug<DTboolean> *outplug = static_cast<Plug<DTboolean>*>(*(outgoing.begin()));
		
		// get the value of the first connected plug
		DTboolean val = outplug->value_without_compute();
				
		// clear any existing key
		clear_key();
		
		// add the keyframe
		keyframe k;
		k._time = _t;
		k._value = val;
		k._id = _id++;
		_keyframes.push_back(k);
		
		std::sort(_keyframes.begin(), _keyframes.end());
	}
}
开发者ID:9heart,项目名称:DT3,代码行数:25,代码来源:ScriptingKeyframesBool.cpp

示例4: removeOutputs

void Plug::removeOutputs()
{
    for( OutputContainer::iterator it = m_outputs.begin(); it!=m_outputs.end();  )
    {
        Plug *p = *it++;
        p->setInput( 0 );
    }
}
开发者ID:TRiGGER80,项目名称:gaffer,代码行数:8,代码来源:Plug.cpp

示例5: dotNode

Gaffer::Node *DotNodeGadget::upstreamNode()
{
	Plug *plug = dotNode()->inPlug<Plug>();
	while( plug && runTimeCast<Dot>( plug->node() ) )
	{
		plug = plug->getInput<Plug>();
	}
	return plug ? plug->node() : NULL;
}
开发者ID:boberfly,项目名称:gaffer,代码行数:9,代码来源:DotNodeGadget.cpp

示例6: inPlugInternal

void BoxIO::setupPromotedPlug()
{
	Plug *toPromote = m_direction == Plug::In ? inPlugInternal() : outPlugInternal();
	if( toPromote && parent<Box>() )
	{
		Plug *promoted = PlugAlgo::promoteWithName( toPromote, namePlug()->getValue() );
		namePlug()->setValue( promoted->getName() );
	}
}
开发者ID:ImageEngine,项目名称:gaffer,代码行数:9,代码来源:BoxIO.cpp

示例7: customGadgetRegex

std::vector<NoduleLayout::GadgetKey> NoduleLayout::layoutOrder()
{
	typedef pair<int, GadgetKey> SortItem;
	vector<SortItem> toSort;

	// Add any plugs which should be visible

	for( PlugIterator plugIt( m_parent.get() ); !plugIt.done(); ++plugIt )
	{
		Plug *plug = plugIt->get();
		if( boost::starts_with( plug->getName().string(), "__" ) )
		{
			continue;
		}
		if( !::visible( plug, m_section ) )
		{
			continue;
		}

		toSort.push_back( SortItem( index( plug, toSort.size() ), plug ) );
	}

	// Then any custom gadgets specified by the metadata

	vector<InternedString> metadata;
	Metadata::registeredValues( m_parent.get(), metadata );
	boost::regex customGadgetRegex( "noduleLayout:customGadget:(.+):gadgetType" );
	for( vector<InternedString>::const_iterator it = metadata.begin(), eIt = metadata.end(); it != eIt; ++it )
	{
		boost::cmatch match;
		if( !boost::regex_match( it->c_str(), match, customGadgetRegex ) )
		{
			continue;
		}
		const InternedString name = match[1].str();
		if( !::visible( m_parent.get(), name, m_section ) )
		{
			continue;
		}

		toSort.push_back( SortItem( index( m_parent.get(), name, toSort.size() ), name ) );
	}

	// Sort and return the result

	sort( toSort.begin(), toSort.end() );

	vector<GadgetKey> result;
	result.reserve( toSort.size() );
	for( vector<SortItem>::const_iterator it = toSort.begin(), eIt = toSort.end(); it != eIt; ++it )
	{
		result.push_back( it->second );
	}

	return result;
}
开发者ID:boberfly,项目名称:gaffer,代码行数:56,代码来源:NoduleLayout.cpp

示例8: arnoldUniverse

void ArnoldShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
	IECoreArnold::UniverseBlock arnoldUniverse( /* writable = */ false );

	const AtNodeEntry *shader = AiNodeEntryLookUp( AtString( shaderName.c_str() ) );
	if( !shader )
	{
		throw Exception( str( format( "Shader \"%s\" not found" ) % shaderName ) );
	}

	Plug *parametersPlug = this->parametersPlug()->source<Plug>();

	if( !keepExistingValues )
	{
		parametersPlug->clearChildren();
		if( Plug *out = outPlug() )
		{
			removeChild( out );
		}
	}

	const bool isLightShader = AiNodeEntryGetType( shader ) == AI_NODE_LIGHT;
	namePlug()->setValue( AiNodeEntryGetName( shader ) );

	int aiOutputType = AI_TYPE_POINTER;
	string type = "ai:light";
	if( !isLightShader )
	{
		const CompoundData *metadata = ArnoldShader::metadata();
		const StringData *shaderTypeData = static_cast<const StringData*>( metadata->member<IECore::CompoundData>( "shader" )->member<IECore::Data>( "shaderType" ) );
		if( shaderTypeData )
		{
			type = "ai:" + shaderTypeData->readable();
		}
		else
		{
			type = "ai:surface";
		}

		if( type == "ai:surface" )
		{
			aiOutputType = AiNodeEntryGetOutputType( shader );
		}
	}

	if( !keepExistingValues && type == "ai:lightFilter" )
	{
		attributeSuffixPlug()->setValue( shaderName );
	}

	typePlug()->setValue( type );

	ParameterHandler::setupPlugs( shader, parametersPlug );
	ParameterHandler::setupPlug( "out", aiOutputType, this, Plug::Out );

}
开发者ID:ImageEngine,项目名称:gaffer,代码行数:56,代码来源:ArnoldShader.cpp

示例9: while

void ScriptNode::deleteNodes( Node *parent, const Set *filter, bool reconnect )
{
	parent = parent ? parent : this;
	// because children are stored as a vector, it's
	// much more efficient to delete those at the end before
	// those at the beginning.
	int i = (int)(parent->children().size()) - 1;
	while( i >= 0 )
	{
		Node *node = parent->getChild<Node>( i );
		if( node && ( !filter || filter->contains( node ) ) )
		{
			// reconnect the inputs and outputs as though the node was disabled
			DependencyNode *dependencyNode = IECore::runTimeCast<DependencyNode>( node );
			if( reconnect && dependencyNode )
			{
				for( OutputPlugIterator it( node ); it != it.end(); ++it )
				{
					Plug *inPlug = dependencyNode->correspondingInput( it->get() );
					if ( !inPlug )
					{
						continue;
					}

					Plug *srcPlug = inPlug->getInput<Plug>();
					if ( !srcPlug )
					{
						continue;
					}

					// record this plug's current outputs, and reconnect them. This is a copy of (*it)->outputs() rather
					// than a reference, as reconnection can modify (*it)->outputs()...
					Plug::OutputContainer outputs = (*it)->outputs();
					for ( Plug::OutputContainer::const_iterator oIt = outputs.begin(); oIt != outputs.end(); )
					{
						Plug *dstPlug = *oIt;
						if ( dstPlug && dstPlug->acceptsInput( srcPlug ) && this->isAncestorOf( dstPlug ) )
						{
							oIt++;
							dstPlug->setInput( srcPlug );
						}
						else
						{
							oIt++;
						}
					}
				}
			}

			parent->removeChild( node );
		}
		i--;
	}
}
开发者ID:espennordahl,项目名称:gaffer,代码行数:54,代码来源:ScriptNode.cpp

示例10: insert

void BoxIO::insert( Box *box )
{
	// Must take a copy of children because adding a child
	// would invalidate our PlugIterator.
	GraphComponent::ChildContainer children = box->children();
	for( PlugIterator it( children ); !it.done(); ++it )
	{
		Plug *plug = it->get();
		if( plug->direction() == Plug::In )
		{
			std::vector<Plug *> outputsNeedingBoxIn;
			const Plug::OutputContainer &outputs = plug->outputs();
			for( Plug::OutputContainer::const_iterator oIt = outputs.begin(), oeIt = outputs.end(); oIt != oeIt; ++oIt )
			{
				if( hasNodule( *oIt ) && !runTimeCast<BoxIO>( (*oIt)->node() ) )
				{
					outputsNeedingBoxIn.push_back( *oIt );
				}
			}

			if( outputsNeedingBoxIn.empty() )
			{
				continue;
			}

			BoxInPtr boxIn = new BoxIn;
			boxIn->namePlug()->setValue( plug->getName() );
			boxIn->setup( plug );
			box->addChild( boxIn );

			boxIn->inPlugInternal()->setInput( plug );
			for( std::vector<Plug *>::const_iterator oIt = outputsNeedingBoxIn.begin(), oeIt = outputsNeedingBoxIn.end(); oIt != oeIt; ++oIt )
			{
				(*oIt)->setInput( boxIn->plug() );
			}
		}
		else
		{
			// Output plug

			Plug *input = plug->getInput();
			if( !input || !hasNodule( input ) || runTimeCast<BoxIO>( input->node() ) )
			{
				continue;
			}

			BoxOutPtr boxOut = new BoxOut;
			boxOut->namePlug()->setValue( plug->getName() );
			boxOut->setup( plug );
			box->addChild( boxOut );

			boxOut->plug()->setInput( input );
			plug->setInput( boxOut->outPlugInternal() );
		}
	}

}
开发者ID:ImageEngine,项目名称:gaffer,代码行数:57,代码来源:BoxIO.cpp

示例11: postTasks

void TaskNode::postTasks( const Context *context, Tasks &tasks ) const
{
	for( PlugIterator cIt( postTasksPlug() ); !cIt.done(); ++cIt )
	{
		Plug *source = (*cIt)->source();
		if( source != *cIt && source->direction() == Plug::Out )
		{
			if( TaskNodePtr n = runTimeCast<TaskNode>( source->node() ) )
			{
				tasks.push_back( Task( n, context ) );
			}
		}
	}
}
开发者ID:appleseedhq,项目名称:gaffer,代码行数:14,代码来源:TaskNode.cpp

示例12: getChild

void CompoundNumericPlug<T>::ungang()
{
	for( size_t i = 1, e = children().size(); i < e; ++i )
	{
		Plug *child = getChild( i );
		if( const Plug *input = child->getInput<Plug>() )
		{
			if( input->parent<Plug>() == this )
			{
				child->setInput( 0 );
			}
		}
	}
}
开发者ID:cedriclaunay,项目名称:gaffer,代码行数:14,代码来源:CompoundNumericPlug.cpp

示例13: preTasks

void TaskNode::preTasks( const Context *context, Tasks &tasks ) const
{
	for( PlugIterator cIt( preTasksPlug() ); !cIt.done(); ++cIt )
	{
		Plug *source = (*cIt)->source<Plug>();
		if( source != *cIt )
		{
			if( TaskNodePtr n = runTimeCast<TaskNode>( source->node() ) )
			{
				tasks.push_back( Task( n, context ) );
			}
		}
	}
}
开发者ID:boberfly,项目名称:gaffer,代码行数:14,代码来源:TaskNode.cpp

示例14: loadCoshaderParameter

static void loadCoshaderParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name )
{
	Plug *existingPlug = parametersPlug->getChild<Plug>( name );
	if( existingPlug && existingPlug->typeId() == Plug::staticTypeId() )
	{
		return;
	}
	
	PlugPtr plug = new Plug( name, Plug::In, Plug::Default | Plug::Dynamic );
	if( existingPlug && existingPlug->getInput<Plug>() )
	{
		plug->setInput( existingPlug->getInput<Plug>() );
	}
	
	parametersPlug->setChild( name, plug );
}
开发者ID:danieldresser,项目名称:gaffer,代码行数:16,代码来源:RenderManShader.cpp

示例15: requirements

void ExecutableNode::requirements( const Context *context, Tasks &requirements ) const
{
	for( PlugIterator cIt( requirementsPlug() ); cIt != cIt.end(); ++cIt )
	{
		Plug *p = (*cIt)->source<Plug>();
		if( p != *cIt )
		{
			if( ExecutableNode *n = runTimeCast<ExecutableNode>( p->node() ) )
			{
				/// \todo Can we not just reuse the context? Maybe we need to make
				/// the context in Task const?
				requirements.push_back( Task( n, new Context( *context ) ) );
			}
		}
	}
}
开发者ID:nicoduce,项目名称:gaffer,代码行数:16,代码来源:ExecutableNode.cpp


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