Esempio 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 );

}
Esempio n. 2
0
ValuePlugPtr CompoundDataPlug::compoundNumericValuePlug( const std::string &name, Plug::Direction direction, unsigned flags, const T *value )
{
	typedef typename T::ValueType ValueType;
	typedef typename ValueType::BaseType BaseType;
	typedef CompoundNumericPlug<ValueType> PlugType;
	
	typename PlugType::Ptr result = new PlugType(
		name,
		direction,
		ValueType( 0 ),
		ValueType( Imath::limits<BaseType>::min() ),
		ValueType( Imath::limits<BaseType>::max() ),
		flags
	);
	
	result->setValue( value->readable() );
	return result;
}
Esempio n. 3
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 );
}
Esempio n. 4
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 );
}