Ejemplo n.º 1
0
static void loadArrayParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name, const Data *defaultValue, const CompoundData *annotations )
{
	const typename PlugType::ValueType *typedDefaultValue = static_cast<const typename PlugType::ValueType *>( defaultValue );

	PlugType *existingPlug = parametersPlug->getChild<PlugType>( name );
	if( existingPlug && existingPlug->defaultValue()->isEqualTo( defaultValue ) )
	{
		return;
	}
	
	typename PlugType::Ptr plug = new PlugType( name, Plug::In, typedDefaultValue, Plug::Default | Plug::Dynamic );
	if( existingPlug )
	{
		if( existingPlug->template getInput<PlugType>() )
		{
			plug->setInput( existingPlug->template getInput<PlugType>() );
		}
		else
		{
			plug->setValue( existingPlug->getValue() );
		}
	}
	
	parametersPlug->setChild( name, plug );

}
Ejemplo n.º 2
0
static void loadNumericParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name, typename PlugType::ValueType defaultValue, const CompoundData *annotations )
{	
	typename PlugType::ValueType minValue( Imath::limits<typename PlugType::ValueType>::min() );
	typename PlugType::ValueType maxValue( Imath::limits<typename PlugType::ValueType>::max() );
	
	const StringData *minValueData = annotations->member<StringData>( name + ".min" );
	if( minValueData )
	{
		minValue = typename PlugType::ValueType( boost::lexical_cast<typename PlugType::ValueType>( minValueData->readable() ) );
	}
	
	const StringData *maxValueData = annotations->member<StringData>( name + ".max" );
	if( maxValueData )
	{
		maxValue = typename PlugType::ValueType( boost::lexical_cast<typename PlugType::ValueType>( maxValueData->readable() ) );
	}
	
	PlugType *existingPlug = parametersPlug->getChild<PlugType>( name );
	if(	
		existingPlug &&
		existingPlug->defaultValue() == defaultValue &&
		existingPlug->minValue() == minValue &&
		existingPlug->maxValue() == maxValue 
	)
	{
		return;
	}
	
	typename PlugType::Ptr plug = new PlugType( name, Plug::In, defaultValue, minValue, maxValue, Plug::Default | Plug::Dynamic );
		
	if( existingPlug )
	{
		if( existingPlug->template getInput<Plug>() )
		{
			plug->setInput( existingPlug->template getInput<Plug>() );
		}
		else
		{
			plug->setValue( existingPlug->getValue() );
		}
	}
	
	parametersPlug->setChild( name, plug );
}
Ejemplo n.º 3
0
static void loadParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name, const typename PlugType::ValueType &defaultValue )
{
	PlugType *existingPlug = parametersPlug->getChild<PlugType>( name );
	if( existingPlug && existingPlug->defaultValue() == defaultValue )
	{
		return;
	}
	
	typename PlugType::Ptr plug = new PlugType( name, Plug::In, defaultValue, Plug::Default | Plug::Dynamic );
	if( existingPlug )
	{
		if( existingPlug->template getInput<PlugType>() )
		{
			plug->setInput( existingPlug->template getInput<PlugType>() );
		}
		else
		{
			plug->setValue( existingPlug->getValue() );
		}
	}
	
	parametersPlug->setChild( name, plug );
}