예제 #1
0
Gaffer::CompoundPlug *Outputs::addOutput( const std::string &name, const IECore::Display *output )
{
	CompoundPlugPtr outputPlug = new CompoundPlug( "output1" );
	outputPlug->setFlags( Plug::Dynamic, true );

	StringPlugPtr namePlug = new StringPlug( "name" );
	namePlug->setValue( name );
	namePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( namePlug );

	BoolPlugPtr activePlug = new BoolPlug( "active", Plug::In, true );
	activePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( activePlug );

	StringPlugPtr fileNamePlug = new StringPlug( "fileName" );
	fileNamePlug->setValue( output->getName() );
	fileNamePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( fileNamePlug );

	StringPlugPtr typePlug = new StringPlug( "type" );
	typePlug->setValue( output->getType() );
	typePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( typePlug );

	StringPlugPtr dataPlug = new StringPlug( "data" );
	dataPlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( dataPlug );

	CompoundDataPlugPtr parametersPlug = new CompoundDataPlug( "parameters" );
	parametersPlug->setFlags( Plug::Dynamic, true );
	parametersPlug->addMembers( const_cast<Display *>( output )->parametersData(), /* useNameAsPlugName = */ true );
	outputPlug->addChild( parametersPlug );

	outputsPlug()->addChild( outputPlug );

	// set one of the values _after_ adding the plug, otherwise
	// affects() is not called and we have no opportunity to
	// propagate dirtiness to our output globals.
	dataPlug->setValue( output->getData() );

	return outputPlug.get();
}
예제 #2
0
파일: Outputs.cpp 프로젝트: CRiant/gaffer
Gaffer::CompoundPlug *Outputs::addOutput( const std::string &name, const IECore::Display *output )
{
	CompoundPlugPtr outputPlug = new CompoundPlug( "output1" );
	outputPlug->setFlags( Plug::Dynamic, true );

	StringPlugPtr namePlug = new StringPlug( "name" );
	namePlug->setValue( name );
	namePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( namePlug );

	BoolPlugPtr activePlug = new BoolPlug( "active", Plug::In, true );
	activePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( activePlug );

	StringPlugPtr fileNamePlug = new StringPlug( "fileName" );
	fileNamePlug->setValue( output->getName() );
	fileNamePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( fileNamePlug );

	StringPlugPtr typePlug = new StringPlug( "type" );
	typePlug->setValue( output->getType() );
	typePlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( typePlug );

	StringPlugPtr dataPlug = new StringPlug( "data" );
	dataPlug->setValue( output->getData() );
	dataPlug->setFlags( Plug::Dynamic, true );
	outputPlug->addChild( dataPlug );

	CompoundDataPlugPtr parametersPlug = new CompoundDataPlug( "parameters" );
	parametersPlug->setFlags( Plug::Dynamic, true );
	parametersPlug->addMembers( const_cast<Display *>( output )->parametersData(), /* useNameAsPlugName = */ true );
	outputPlug->addChild( parametersPlug );

	outputsPlug()->addChild( outputPlug );

	return outputPlug.get();
}
예제 #3
0
파일: Displays.cpp 프로젝트: 7on7on/gaffer
Gaffer::CompoundPlug *Displays::addDisplay( const std::string &label, const IECore::Display *display )
{
	CompoundPlugPtr displayPlug = new CompoundPlug( "display1" );
	displayPlug->setFlags( Plug::Dynamic, true );
	
	StringPlugPtr labelPlug = new StringPlug( "label" );
	labelPlug->setValue( label );
	labelPlug->setFlags( Plug::Dynamic, true );
	displayPlug->addChild( labelPlug );
	
	BoolPlugPtr activePlug = new BoolPlug( "active", Plug::In, true );
	activePlug->setFlags( Plug::Dynamic, true );
	displayPlug->addChild( activePlug );
	
	StringPlugPtr namePlug = new StringPlug( "name" );
	namePlug->setValue( display->getName() );
	namePlug->setFlags( Plug::Dynamic, true );
	displayPlug->addChild( namePlug );

	StringPlugPtr typePlug = new StringPlug( "type" );
	typePlug->setValue( display->getType() );
	typePlug->setFlags( Plug::Dynamic, true );
	displayPlug->addChild( typePlug );
	
	StringPlugPtr dataPlug = new StringPlug( "data" );
	dataPlug->setValue( display->getData() );
	dataPlug->setFlags( Plug::Dynamic, true );
	displayPlug->addChild( dataPlug );
	
	CompoundDataPlugPtr parametersPlug = new CompoundDataPlug( "parameters" );
	parametersPlug->setFlags( Plug::Dynamic, true );
	parametersPlug->addMembers( const_cast<Display *>( display )->parametersData() );
	displayPlug->addChild( parametersPlug );
	
	displaysPlug()->addChild( displayPlug );
	
	return displayPlug;
}
예제 #4
0
CompoundDataPlug::MemberPlug *CompoundDataPlug::addMember( const std::string &name, ValuePlug *valuePlug, const std::string &plugName )
{
	MemberPlugPtr plug = new MemberPlug( plugName, direction(), valuePlug->getFlags() );
	
	StringPlugPtr namePlug = new StringPlug( "name", direction(), "", valuePlug->getFlags() );
	namePlug->setValue( name );
	plug->addChild( namePlug );
	
	valuePlug->setName( "value" );
	plug->addChild( valuePlug );
	
	addChild( plug );
	return plug;

}
예제 #5
0
ValuePlugPtr CompoundDataPlug::createPlugFromData( const std::string &name, Plug::Direction direction, unsigned flags, const IECore::Data *value )
{
	switch( value->typeId() )
	{
		case FloatDataTypeId :
		{
			FloatPlugPtr valuePlug = new FloatPlug(
				name,
				direction,
				0,
				Imath::limits<float>::min(),
				Imath::limits<float>::max(),
				flags
			);
			valuePlug->setValue( static_cast<const FloatData *>( value )->readable() );
			return valuePlug;
		}
		case IntDataTypeId :
		{
			IntPlugPtr valuePlug = new IntPlug(
				name,
				direction,
				0,
				Imath::limits<int>::min(),
				Imath::limits<int>::max(),
				flags
			);
			valuePlug->setValue( static_cast<const IntData *>( value )->readable() );
			return valuePlug;
		}
		case StringDataTypeId :
		{
			StringPlugPtr valuePlug = new StringPlug(
				name,
				direction,
				"",
				flags
			);
			valuePlug->setValue( static_cast<const StringData *>( value )->readable() );
			return valuePlug;
		}
		case BoolDataTypeId :
		{
			BoolPlugPtr valuePlug = new BoolPlug(
				name,
				direction,
				false,
				flags
			);
			valuePlug->setValue( static_cast<const BoolData *>( value )->readable() );
			return valuePlug;
		}
		case V2iDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const V2iData *>( value ) );
		}
		case V3iDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const V3iData *>( value ) );
		}
		case V2fDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const V2fData *>( value ) );
		}
		case V3fDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const V3fData *>( value ) );
		}
		case Color3fDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const Color3fData *>( value ) );
		}
		case Color4fDataTypeId :
		{
			return compoundNumericValuePlug( name, direction, flags, static_cast<const Color4fData *>( value ) );
		}
		case FloatVectorDataTypeId :
		{
			return typedObjectValuePlug( name, direction, flags, static_cast<const FloatVectorData *>( value ) );
		}
		case IntVectorDataTypeId :
		{
			return typedObjectValuePlug( name, direction, flags, static_cast<const IntVectorData *>( value ) );
		}
		case StringVectorDataTypeId :
		{
			return typedObjectValuePlug( name, direction, flags, static_cast<const StringVectorData *>( value ) );
		}
		case V3fVectorDataTypeId :
		{
			return typedObjectValuePlug( name, direction, flags, static_cast<const V3fVectorData *>( value ) );
		}
		case Color3fVectorDataTypeId :
		{
			return typedObjectValuePlug( name, direction, flags, static_cast<const Color3fVectorData *>( value ) );
		}
		default :
			throw IECore::Exception(
				boost::str( boost::format( "Data for \"%s\" has unsupported value data type \"%s\"" ) % name % value->typeName() )
			);
	}
}