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


C++ Plug::typeId方法代码示例

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


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

示例1: 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

示例2: plugName

static Plug *loadClosureParameter( const OSLQuery::Parameter *parameter, Gaffer::CompoundPlug *parent )
{	
	const string name = plugName( parameter );
	Plug *existingPlug = parent->getChild<Plug>( name );
	if(	existingPlug && existingPlug->typeId() == Plug::staticTypeId() )
	{
		return existingPlug;
	}
	
	PlugPtr plug = new Plug( name, parent->direction(), Plug::Default | Plug::Dynamic );
	
	transferConnectionOrValue( existingPlug, plug.get() );
	
	parent->setChild( name, plug );
	
	return plug;
}
开发者ID:JohanAberg,项目名称:gaffer,代码行数:17,代码来源:OSLShader.cpp

示例3: loadShader

void OSLShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
	const char *searchPath = getenv( "OSL_SHADER_PATHS" );

	OSLQuery query;
	if( !query.open( shaderName, searchPath ? searchPath : "" ) )
	{
		throw Exception( query.error() );
	}
	
	loadShaderParameters( query, parametersPlug(), keepExistingValues );
	
	if( query.shadertype() == "shader" )
	{
		CompoundPlug *existingOut = getChild<CompoundPlug>( "out" );
		if( !existingOut || existingOut->typeId() != CompoundPlug::staticTypeId() )
		{
			CompoundPlugPtr outPlug = new CompoundPlug( "out", Plug::Out, Plug::Default | Plug::Dynamic );
			setChild( "out", outPlug );
		}
		loadShaderParameters( query, getChild<CompoundPlug>( "out" ), keepExistingValues );		
	}
	else
	{
		Plug *existingOut = getChild<Plug>( "out" );
		if( !existingOut || existingOut->typeId() != Plug::staticTypeId() )
		{
			PlugPtr outPlug = new Plug( "out", Plug::Out, Plug::Default | Plug::Dynamic );
			setChild( "out", outPlug );
		}
	}
	
	namePlug()->setValue( shaderName );
	typePlug()->setValue( "osl:" + query.shadertype() );
	
	m_metadata = NULL;
}
开发者ID:JohanAberg,项目名称:gaffer,代码行数:37,代码来源:OSLShader.cpp

示例4: loadShader

void OSLShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
	Plug *existingOut = outPlug();
	if( shaderName.empty() )
	{
		parametersPlug()->clearChildren();
		namePlug()->setValue( "" );
		typePlug()->setValue( "" );
		if( existingOut )
		{
			existingOut->clearChildren();
		}
		return;
	}

	const char *searchPath = getenv( "OSL_SHADER_PATHS" );

	OSLQuery query;
	if( !query.open( shaderName, searchPath ? searchPath : "" ) )
	{
		throw Exception( query.geterror() );
	}

	const bool outPlugHadChildren = existingOut ? existingOut->children().size() : false;
	if( !keepExistingValues )
	{
		// If we're not preserving existing values then remove all existing
		// parameter plugs - the various plug creators above know that if a
		// plug exists then they should preserve its values.
		parametersPlug()->clearChildren();
		if( existingOut )
		{
			existingOut->clearChildren();
		}
	}

	m_metadata = NULL;
	namePlug()->setValue( shaderName );
	typePlug()->setValue( std::string( "osl:" ) + query.shadertype().c_str() );

	const IECore::CompoundData *metadata = OSLShader::metadata();
	const IECore::CompoundData *parameterMetadata = NULL;
	if( metadata )
	{
		parameterMetadata = metadata->member<IECore::CompoundData>( "parameter" );
	}


	loadShaderParameters( query, parametersPlug(), parameterMetadata );

	if( !existingOut || existingOut->typeId() != Plug::staticTypeId() )
	{
		PlugPtr outPlug = new Plug( "out", Plug::Out, Plug::Default | Plug::Dynamic );
		if( existingOut )
		{
			// We had an out plug but it was the wrong type (we used
			// to use a CompoundPlug before that was deprecated). Move
			// over any existing child plugs onto our replacement.
			for( PlugIterator it( existingOut ); !it.done(); ++it )
			{
				outPlug->addChild( *it );
			}
		}
		setChild( "out", outPlug );
	}

	if( query.shadertype() == "shader" )
	{
		loadShaderParameters( query, outPlug(), parameterMetadata );
	}
	else
	{
		outPlug()->clearChildren();
	}

	if( static_cast<bool>( outPlug()->children().size() ) != outPlugHadChildren )
	{
		// OSLShaderUI registers a dynamic metadata entry which depends on whether or
		// not the plug has children, so we must notify the world that the value will
		// have changed.
		Metadata::plugValueChangedSignal()( staticTypeId(), "out", "nodule:type", outPlug() );
	}
}
开发者ID:HughMacdonald,项目名称:gaffer,代码行数:83,代码来源:OSLShader.cpp


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