示例#1
0
PlugPtr ArrayPlug::createCounterpart( const std::string &name, Direction direction ) const
{
	ArrayPlugPtr result = new ArrayPlug( name, direction, NULL, m_minSize, m_maxSize, getFlags() );
	for( PlugIterator it( this ); !it.done(); ++it )
	{
		result->addChild( (*it)->createCounterpart( (*it)->getName(), direction ) );
	}
	return result;
}
示例#2
0
static void loadCoshaderArrayParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name, const StringVectorData *defaultValue )
{
	const size_t minSize = std::max( defaultValue->readable().size(), (size_t)1 );
	const size_t maxSize = defaultValue->readable().size() ? defaultValue->readable().size() : Imath::limits<size_t>::max();
	
	PlugPtr existingPlug = parametersPlug->getChild<Plug>( name );
	ArrayPlug *existingArrayPlug = runTimeCast<ArrayPlug>( existingPlug );
	if( existingArrayPlug && existingArrayPlug->minSize() == minSize && existingArrayPlug->maxSize() == maxSize )
	{
		return;
	}

	std::string elementName = name;
	if( isdigit( *elementName.rbegin() ) )
	{
		elementName += "_0";
	}
	else
	{
		elementName += "0";		
	}
	
	ArrayPlugPtr plug = new ArrayPlug( name, Plug::In, new Plug( elementName ), minSize, maxSize, Plug::Default | Plug::Dynamic );
	parametersPlug->setChild( name, plug );
	
	if( existingPlug )
	{
		for( size_t i = 0, e = std::min( existingPlug->children().size(), maxSize ); i < e; ++i )
		{
			if( i < plug->children().size() )
			{
				plug->getChild<Plug>( i )->setInput( existingPlug->getChild<Plug>( i )->getInput<Plug>() );
			}
			else
			{
				plug->addChild( existingPlug->getChild<Plug>( i ) );
			}
		}
	}
}