예제 #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 );

}
예제 #2
0
static void loadCompoundNumericParameter( Gaffer::CompoundPlug *parametersPlug, const std::string &name, const typename PlugType::ValueType &defaultValue, const CompoundData *annotations )
{
	typename PlugType::ValueType minValue( Imath::limits<float>::min() );
	typename PlugType::ValueType maxValue( Imath::limits<float>::max() );

	const StringData *minValueData = annotations->member<StringData>( name + ".min" );
	if( minValueData )
	{
		minValue = typename PlugType::ValueType( boost::lexical_cast<float>( minValueData->readable() ) );
	}

	const StringData *maxValueData = annotations->member<StringData>( name + ".max" );
	if( maxValueData )
	{
		maxValue = typename PlugType::ValueType( boost::lexical_cast<float>( 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 )
	{
		for( size_t i = 0, e = existingPlug->children().size(); i < e; i++ )
		{
			FloatPlug *existingComponentPlug = static_cast<GraphComponent *>( existingPlug )->getChild<FloatPlug>( i );
			FloatPlug *componentPlug = static_cast<GraphComponent *>( plug.get() )->getChild<FloatPlug>( i );
			if( existingComponentPlug->getInput<Plug>() )
			{
				componentPlug->setInput( existingComponentPlug->getInput<Plug>() );
			}
			else
			{
				componentPlug->setValue( existingComponentPlug->getValue() );
			}
		}
	}

	parametersPlug->setChild( name, plug );
}
예제 #3
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;
}
예제 #4
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 );
}
예제 #5
0
static Plug *loadNumericParameter( const OSLQuery::Parameter *parameter, Gaffer::CompoundPlug *parent )
{
	typedef typename PlugType::ValueType ValueType;
	
	ValueType defaultValue( 0 );
	if( parameter->idefault.size() )
	{
		defaultValue = ValueType( parameter->idefault[0] );
	}
	else if( parameter->fdefault.size() )
	{
		defaultValue = ValueType( parameter->fdefault[0] );
	}

	/// \todo Get from metadata
	ValueType minValue( Imath::limits<ValueType>::min() );
	ValueType maxValue( Imath::limits<ValueType>::max() );

	const string name = plugName( parameter );
	PlugType *existingPlug = parent->getChild<PlugType>( name );
	if(	
		existingPlug &&
		existingPlug->defaultValue() == defaultValue &&
		existingPlug->minValue() == minValue &&
		existingPlug->maxValue() == maxValue 
	)
	{
		return existingPlug;
	}
	
	typename PlugType::Ptr plug = new PlugType( name, parent->direction(), defaultValue, minValue, maxValue, Plug::Default | Plug::Dynamic );
	
	transferConnectionOrValue( existingPlug, plug.get() );
	
	parent->setChild( name, plug );
	
	return plug;
}
예제 #6
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 );
}