本文整理汇总了C++中Plug::setFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ Plug::setFlags方法的具体用法?C++ Plug::setFlags怎么用?C++ Plug::setFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plug
的用法示例。
在下文中一共展示了Plug::setFlags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadShader
void OSLShader::loadShader( const std::string &shaderName, bool keepExistingValues )
{
StringPlug *namePlug = this->namePlug()->source<StringPlug>();
StringPlug *typePlug = this->typePlug()->source<StringPlug>();
Plug *parametersPlug = this->parametersPlug()->source<Plug>();
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 = nullptr;
namePlug->source<StringPlug>()->setValue( shaderName );
typePlug->source<StringPlug>()->setValue( std::string( "osl:" ) + query.shadertype().c_str() );
const IECore::CompoundData *metadata = OSLShader::metadata();
const IECore::CompoundData *parameterMetadata = nullptr;
if( metadata )
{
parameterMetadata = metadata->member<IECore::CompoundData>( "parameter" );
}
loadShaderParameters( query, parametersPlug, parameterMetadata );
if( existingOut )
{
// \todo : This can be removed once old scripts have been updated, and we no longer have
// old out plugs set to Dynamic lying around
existingOut->setFlags( Gaffer::Plug::Dynamic, false );
}
if( !existingOut || existingOut->typeId() != Plug::staticTypeId() )
{
PlugPtr outPlug = new Plug( "out", Plug::Out, Plug::Default );
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() );
}
}