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 ) ); }
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(); }
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; }
ExecutableNode::ExecutableNode( const std::string &name ) : Node( name ) { storeIndexOfNextChild( g_firstPlugIndex ); addChild( new ArrayPlug( "requirements", Plug::In, new Plug( "requirement0" ) ) ); addChild( new Plug( "requirement", Plug::Out ) ); CompoundPlugPtr dispatcherPlug = new CompoundPlug( "dispatcher", Plug::In ); addChild( dispatcherPlug ); Dispatcher::setupPlugs( dispatcherPlug.get() ); }
void CompoundPlug::setInput( PlugPtr input ) { if( input.get() == getInput<Plug>() ) { return; } // unfortunately we have to duplicate the check in Plug::setInput() // ourselves as we delay calling Plug::setInput() until we've connected // the children, but need to do the check first. /// \todo I think there's a case for not having CompoundPlug at all, /// and having Plug have all its functionality. if( input && !acceptsInput( input ) ) { std::string what = boost::str( boost::format( "Plug \"%s\" rejects input \"%s\"." ) % fullName() % input->fullName() ); throw IECore::Exception( what ); } { // we use the plugInputChangedConnection to trigger calls to updateInputFromChildInputs() // when child inputs are changed by code elsewhere. it would be counterproductive for // us to call updateInputFromChildInputs() while we ourselves are changing those inputs, // so we temporarily block the connection. BlockedConnection block( m_plugInputChangedConnection ); if( !input ) { for( ChildContainer::const_iterator it = children().begin(); it!=children().end(); it++ ) { IECore::staticPointerCast<Plug>( *it )->setInput( 0 ); } } else { CompoundPlugPtr p = IECore::staticPointerCast<CompoundPlug>( input ); ChildContainer::const_iterator it1, it2; for( it1 = children().begin(), it2 = p->children().begin(); it1!=children().end(); it1++, it2++ ) { IECore::staticPointerCast<Plug>( *it1 )->setInput( IECore::staticPointerCast<Plug>( *it2 ) ); } } } // we connect ourselves last, so that all our child plugs are correctly connected // before we signal our own connection change. ValuePlug::setInput( input ); }
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 ); }
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(); }
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(); }
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(), /* useNameAsPlugName = */ true ); displayPlug->addChild( parametersPlug ); displaysPlug()->addChild( displayPlug ); return displayPlug.get(); }
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 ); }