Пример #1
0
ScriptNode::ScriptNode( const std::string &name )
	:
	Node( name ),
	m_selection( new StandardSet ),
	m_selectionOrphanRemover( m_selection ),
	m_undoIterator( m_undoList.end() ),
	m_currentActionStage( Action::Invalid ),
	m_context( new Context )
{
	storeIndexOfNextChild( g_firstPlugIndex );

	addChild( new StringPlug( "fileName", Plug::In, "", Plug::Default & ~Plug::Serialisable ) );
	addChild( new BoolPlug( "unsavedChanges", Plug::In, false, Plug::Default & ~Plug::Serialisable ) );

	CompoundPlugPtr frameRangePlug = new CompoundPlug( "frameRange", Plug::In );
	IntPlugPtr frameStartPlug = new IntPlug( "start", Plug::In, 1 );
	IntPlugPtr frameEndPlug = new IntPlug( "end", Plug::In, 100 );
	frameRangePlug->addChild( frameStartPlug );
	frameRangePlug->addChild( frameEndPlug );
	addChild( frameRangePlug );

	addChild( new CompoundDataPlug( "variables" ) );

	m_context->set( "script:name", std::string( "" ) );

	m_selection->memberAcceptanceSignal().connect( boost::bind( &ScriptNode::selectionSetAcceptor, this, ::_1, ::_2 ) );

	plugSetSignal().connect( boost::bind( &ScriptNode::plugSet, this, ::_1 ) );
}
Пример #2
0
		Grid( SceneView *view )
			:	m_view( view ), m_node( new GafferScene::Grid ), m_gadget( new RenderableGadget )
		{
			m_node->transformPlug()->rotatePlug()->setValue( V3f( 90, 0, 0 ) );

			CompoundPlugPtr plug = new CompoundPlug( "grid" );
			view->addChild( plug );
			
			plug->addChild( new BoolPlug( "visible", Plug::In, true ) );
			
			PlugPtr dimensionsPlug(
				m_node->dimensionsPlug()->createCounterpart(
					m_node->dimensionsPlug()->getName(),
					Plug::In
				)
			);
			plug->addChild( dimensionsPlug );
			
			m_node->dimensionsPlug()->setInput( dimensionsPlug );
			
			view->viewportGadget()->setChild( "__grid", m_gadget );
			
			view->plugDirtiedSignal().connect( boost::bind( &Grid::plugDirtied, this, ::_1 ) );
			
			update();
		}
Пример #3
0
PlugPtr CompoundPlug::createCounterpart( const std::string &name, Direction direction ) const
{
	CompoundPlugPtr result = new CompoundPlug( name, direction, getFlags() );
	for( PlugIterator it( this ); it != it.end(); it++ )
	{
		result->addChild( (*it)->createCounterpart( (*it)->getName(), direction ) );
	}
	return result;
}
Пример #4
0
void Expression::updatePlugs( const std::string &dstPlugPath, std::vector<std::string> &srcPlugPaths )
{
	Node *p = parent<Node>();

	// if the expression was invalid, remove our plugs
	if( !dstPlugPath.size() )
	{
		Plug *in = getChild<Plug>( "in" );
		if( in )
		{
			removeChild( in );
		}
		Plug *out = getChild<Plug>( "out" );
		if( out )
		{
			removeChild( out );
		}
		return;
	}

	// otherwise try to create connections to the plugs the expression wants

	ValuePlug *dstPlug = p->descendant<ValuePlug>( dstPlugPath );
	if( !dstPlug )
	{
		throw IECore::Exception( boost::str( boost::format( "Destination plug \"%s\" does not exist" ) % dstPlugPath ) );
	}

	CompoundPlugPtr inPlugs = new CompoundPlug( "in", Plug::In, Plug::Default | Plug::Dynamic );
	setChild( "in", inPlugs );
	for( std::vector<std::string>::const_iterator it = srcPlugPaths.begin(); it!=srcPlugPaths.end(); it++ )
	{
		ValuePlug *srcPlug = p->descendant<ValuePlug>( *it );
		if( !srcPlug )
		{
			throw IECore::Exception( boost::str( boost::format( "Source plug \"%s\" does not exist" ) % *it ) );
		}
		PlugPtr inPlug = srcPlug->createCounterpart( "plug", Plug::In );
		inPlugs->addChild( inPlug );
		inPlug->setInput( srcPlug );
	}

	PlugPtr outPlug = dstPlug->createCounterpart( "out", Plug::Out );
	setChild( "out", outPlug );
	dstPlug->setInput( outPlug );
}
Пример #5
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();
}
Пример #6
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->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();
}
Пример #7
0
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;
}
Пример #8
0
SceneView::SceneView( const std::string &name )
	:	View3D( name, new GafferScene::ScenePlug() ),
		m_renderableGadget( new RenderableGadget )
{

	// add plugs and signal handling for them
	
	storeIndexOfNextChild( g_firstPlugIndex );

	addChild( new IntPlug( "minimumExpansionDepth", Plug::In, 0, 0, Imath::limits<int>::max(), Plug::Default & ~Plug::AcceptsInputs ) );

	CompoundPlugPtr lookThrough = new CompoundPlug( "lookThrough", Plug::In, Plug::Default & ~Plug::AcceptsInputs );
	lookThrough->addChild( new BoolPlug( "enabled", Plug::In, false, Plug::Default & ~Plug::AcceptsInputs ) );
	lookThrough->addChild( new StringPlug( "camera", Plug::In, "", Plug::Default & ~Plug::AcceptsInputs ) );
	addChild( lookThrough );
	
	plugSetSignal().connect( boost::bind( &SceneView::plugSet, this, ::_1 ) );

	// set up our gadgets

	viewportGadget()->setPrimaryChild( m_renderableGadget );
	
	m_selectionChangedConnection = m_renderableGadget->selectionChangedSignal().connect( boost::bind( &SceneView::selectionChanged, this, ::_1 ) );
	viewportGadget()->keyPressSignal().connect( boost::bind( &SceneView::keyPress, this, ::_1, ::_2 ) );

	m_renderableGadget->baseState()->add( const_cast<IECoreGL::State *>( baseState() ) );
	baseStateChangedSignal().connect( boost::bind( &SceneView::baseStateChanged, this ) );

	m_grid = boost::shared_ptr<Grid>( new Grid( this ) );
	
	//////////////////////////////////////////////////////////////////////////
	// add a preprocessor which monkeys with the scene before it is displayed.
	//////////////////////////////////////////////////////////////////////////

	NodePtr preprocessor = new Node();
	ScenePlugPtr preprocessorInput = new ScenePlug( "in" );
	preprocessor->addChild( preprocessorInput );
	
	// remove motion blur, because the opengl renderer doesn't support it.
	
	StandardOptionsPtr standardOptions = new StandardOptions( "disableBlur" );
	standardOptions->optionsPlug()->getChild<CompoundPlug>( "transformBlur" )->getChild<BoolPlug>( "enabled" )->setValue( true );
	standardOptions->optionsPlug()->getChild<CompoundPlug>( "transformBlur" )->getChild<BoolPlug>( "value" )->setValue( false );
	standardOptions->optionsPlug()->getChild<CompoundPlug>( "deformationBlur" )->getChild<BoolPlug>( "enabled" )->setValue( true );
	standardOptions->optionsPlug()->getChild<CompoundPlug>( "deformationBlur" )->getChild<BoolPlug>( "value" )->setValue( false );
	
	preprocessor->addChild( standardOptions );
	standardOptions->inPlug()->setInput( preprocessorInput );
	
	// add a node for hiding things
	
	StandardAttributesPtr hide = new StandardAttributes( "hide" );
	hide->attributesPlug()->getChild<CompoundPlug>( "visibility" )->getChild<BoolPlug>( "enabled" )->setValue( true );
	hide->attributesPlug()->getChild<CompoundPlug>( "visibility" )->getChild<BoolPlug>( "value" )->setValue( false );
	
	preprocessor->addChild( hide );
	hide->inPlug()->setInput( standardOptions->outPlug() );

	PathFilterPtr hideFilter = new PathFilter( "hideFilter" );
	preprocessor->addChild( hideFilter );
	hide->filterPlug()->setInput( hideFilter->matchPlug() );

	// make the output for the preprocessor

	ScenePlugPtr preprocessorOutput = new ScenePlug( "out", Plug::Out );
	preprocessor->addChild( preprocessorOutput );
	preprocessorOutput->setInput( hide->outPlug() );
	
	setPreprocessor( preprocessor );
}