Пример #1
0
BackdropNodeGadget::BackdropNodeGadget( Gaffer::NodePtr node )
	:	NodeGadget( node ), m_hovered( false ), m_horizontalDragEdge( 0 ), m_verticalDragEdge( 0 )
{
	if( !runTimeCast<Backdrop>( node ) )
	{
		throw Exception( "BackdropNodeGadget requires a Backdrop" );
	}
	
	if( !node->getChild<Box2fPlug>( g_boundPlugName ) )
	{
		node->addChild(
			new Box2fPlug(
				g_boundPlugName,
				Plug::In,
				Box2f( V2f( -10 ), V2f( 10 ) ),
				Plug::Default | Plug::Dynamic
			)
		);
	}
	
	node->plugDirtiedSignal().connect( boost::bind( &BackdropNodeGadget::plugDirtied, this, ::_1 ) );
	
	mouseMoveSignal().connect( boost::bind( &BackdropNodeGadget::mouseMove, this, ::_1, ::_2 ) );
	buttonPressSignal().connect( boost::bind( &BackdropNodeGadget::buttonPress, this, ::_1, ::_2 ) );
	dragBeginSignal().connect( boost::bind( &BackdropNodeGadget::dragBegin, this, ::_1, ::_2 ) );
	dragEnterSignal().connect( boost::bind( &BackdropNodeGadget::dragEnter, this, ::_1, ::_2 ) );
	dragMoveSignal().connect( boost::bind( &BackdropNodeGadget::dragMove, this, ::_1, ::_2 ) );
	dragEndSignal().connect( boost::bind( &BackdropNodeGadget::dragEnd, this, ::_1, ::_2 ) );
	leaveSignal().connect( boost::bind( &BackdropNodeGadget::leave, this, ::_1, ::_2 ) );
}
Пример #2
0
void GraphGadget::setRoot( Gaffer::NodePtr root, Gaffer::SetPtr filter )
{
	if( root == m_root && filter == m_filter )
	{
		return;
	}

	bool rootChanged = false;
	Gaffer::NodePtr previousRoot = m_root;
	if( root != m_root )
	{
		rootChanged = true;
		m_root = root;
		m_rootChildAddedConnection = m_root->childAddedSignal().connect( boost::bind( &GraphGadget::rootChildAdded, this, ::_1, ::_2 ) );
		m_rootChildRemovedConnection = m_root->childRemovedSignal().connect( boost::bind( &GraphGadget::rootChildRemoved, this, ::_1, ::_2 ) );
	}

	Gaffer::ScriptNodePtr scriptNode = runTimeCast<Gaffer::ScriptNode>( m_root );
	if( !scriptNode )
	{
		scriptNode = m_root->scriptNode();
	}

	if( scriptNode != m_scriptNode )
	{
		m_scriptNode = scriptNode;
		if( m_scriptNode )
		{
			m_selectionMemberAddedConnection = m_scriptNode->selection()->memberAddedSignal().connect(
				boost::bind( &GraphGadget::selectionMemberAdded, this, ::_1, ::_2 )
			);
			m_selectionMemberRemovedConnection = m_scriptNode->selection()->memberRemovedSignal().connect(
				boost::bind( &GraphGadget::selectionMemberRemoved, this, ::_1, ::_2 )
			);
		}
		else
		{
			m_selectionMemberAddedConnection.disconnect();
			m_selectionMemberAddedConnection.disconnect();
		}
	}

	if( filter != m_filter )
	{
		setFilter( filter );
		// setFilter() will call updateGraph() for us.
	}
	else
	{
		updateGraph();
	}

	if( rootChanged )
	{
		m_rootChangedSignal( this, previousRoot.get() );
	}
}
Пример #3
0
DotNodeGadget::DotNodeGadget( Gaffer::NodePtr node )
	:	StandardNodeGadget( node )
{
	if( !runTimeCast<Dot>( node ) )
	{
		throw Exception( "DotNodeGadget requires a Dot" );
	}

	// Set the contents to have a small size, so the size of the Dot is controlled
	// largely by the nodeGadget:padding Metadata.
	setContents( new SpacerGadget( Box3f( V3f( -0.25 ), V3f( 0.25 ) ) ) );

	node->plugDirtiedSignal().connect( boost::bind( &DotNodeGadget::plugDirtied, this, ::_1 ) );
	node->nameChangedSignal().connect( boost::bind( &DotNodeGadget::nameChanged, this, ::_1 ) );

	dragEnterSignal().connect( boost::bind( &DotNodeGadget::dragEnter, this, ::_2 ) );
	dropSignal().connect( boost::bind( &DotNodeGadget::drop, this, ::_2 ) );

	updateUpstreamNameChangedConnection();
	updateLabel();
}
Пример #4
0
NodeGadgetPtr NodeGadget::create( Gaffer::NodePtr node )
{
    const CreatorMap &cr = creators();

    IECore::TypeId typeId = node->typeId();
    while( typeId != IECore::InvalidTypeId )
    {
        const CreatorMap::const_iterator it = cr.find( typeId );
        if( it != cr.end() )
        {
            return it->second( node );
        }
        typeId = IECore::RunTimeTyped::baseTypeId( typeId );
    }

    return NULL;
}
Пример #5
0
NodeGadgetPtr NodeGadget::create( Gaffer::NodePtr node )
{
	IECore::ConstStringDataPtr nodeGadgetType = Gaffer::Metadata::value<IECore::StringData>( node.get(), "nodeGadget:type" );
	if( nodeGadgetType )
	{
		if( nodeGadgetType->readable() == "" )
		{
			return nullptr;
		}
		const TypeCreatorMap &m = typeCreators();
		TypeCreatorMap::const_iterator it = m.find( nodeGadgetType->readable() );
		if( it != m.end() )
		{
			return it->second( node );
		}
		else
		{
			IECore::msg( IECore::Msg::Warning, "NodeGadget::create", boost::format( "Nonexistent type \"%s\" requested for node \"%s\"" ) % nodeGadgetType->readable() % node->fullName() );
		}
	}

	const NodeCreatorMap &cr = nodeCreators();

	IECore::TypeId typeId = node->typeId();
	while( typeId != IECore::InvalidTypeId )
	{
		const NodeCreatorMap::const_iterator it = cr.find( typeId );
		if( it != cr.end() )
		{
			return it->second( node );
		}
		typeId = IECore::RunTimeTyped::baseTypeId( typeId );
	}

	return nullptr;
}
Пример #6
0
StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node, LinearContainer::Orientation orientation )
	:	NodeGadget( node ), m_nodeEnabled( true ), m_labelsVisibleOnHover( true ), m_dragDestinationProxy( 0 )
{
	LinearContainer::Orientation oppositeOrientation = orientation == LinearContainer::X ? LinearContainer::Y : LinearContainer::X;

	LinearContainerPtr mainContainer = new LinearContainer(
		"mainContainer",
		oppositeOrientation,
		LinearContainer::Centre,
		g_spacing,
		orientation == LinearContainer::X ? LinearContainer::Increasing : LinearContainer::Decreasing
	);

	const float noduleSpacing = orientation == LinearContainer::X ? 2.0f : 0.2f;
	LinearContainer::Direction noduleDirection = orientation == LinearContainer::X ? LinearContainer::Increasing : LinearContainer::Decreasing;
	LinearContainerPtr inputNoduleContainer = new LinearContainer( "inputNoduleContainer", orientation, LinearContainer::Centre, noduleSpacing, noduleDirection );
	LinearContainerPtr outputNoduleContainer = new LinearContainer( "outputNoduleContainer", orientation, LinearContainer::Centre, noduleSpacing, noduleDirection );

	mainContainer->addChild( outputNoduleContainer );
	
	IndividualContainerPtr contentsContainer = new IndividualContainer();
	contentsContainer->setName( "contentsContainer" );
	contentsContainer->setPadding( Box3f( V3f( -g_borderWidth ), V3f( g_borderWidth ) ) );
	
	mainContainer->addChild( contentsContainer );
	mainContainer->addChild( inputNoduleContainer );

	setChild( mainContainer );
	setContents( new NameGadget( node ) );
	
	Gaffer::ScriptNodePtr script = node->scriptNode();
	if( script )
	{
		script->selection()->memberAddedSignal().connect( boost::bind( &StandardNodeGadget::selectionChanged, this, ::_1,  ::_2 ) );
		script->selection()->memberRemovedSignal().connect( boost::bind( &StandardNodeGadget::selectionChanged, this, ::_1,  ::_2 ) );
	}
	
	node->childAddedSignal().connect( boost::bind( &StandardNodeGadget::childAdded, this, ::_1,  ::_2 ) );
	node->childRemovedSignal().connect( boost::bind( &StandardNodeGadget::childRemoved, this, ::_1,  ::_2 ) );
	
	for( Gaffer::PlugIterator it( node ); it!=it.end(); it++ )
	{
		addNodule( *it );
	}
	
	if( DependencyNode *dependencyNode = IECore::runTimeCast<DependencyNode>( node ) )
	{
		const Gaffer::BoolPlug *enabledPlug = dependencyNode->enabledPlug();
		if( enabledPlug )
		{
			m_nodeEnabled = enabledPlug->getValue();
			node->plugDirtiedSignal().connect( boost::bind( &StandardNodeGadget::plugDirtied, this, ::_1 ) );
		}
	}
	
	
	dragEnterSignal().connect( boost::bind( &StandardNodeGadget::dragEnter, this, ::_1, ::_2 ) );
	dragMoveSignal().connect( boost::bind( &StandardNodeGadget::dragMove, this, ::_1, ::_2 ) );
	dragLeaveSignal().connect( boost::bind( &StandardNodeGadget::dragLeave, this, ::_1, ::_2 ) );
	dropSignal().connect( boost::bind( &StandardNodeGadget::drop, this, ::_1, ::_2 ) );
	
	inputNoduleContainer->enterSignal().connect( boost::bind( &StandardNodeGadget::enter, this, ::_1 ) );
	inputNoduleContainer->leaveSignal().connect( boost::bind( &StandardNodeGadget::leave, this, ::_1 ) );

	outputNoduleContainer->enterSignal().connect( boost::bind( &StandardNodeGadget::enter, this, ::_1 ) );
	outputNoduleContainer->leaveSignal().connect( boost::bind( &StandardNodeGadget::leave, this, ::_1 ) );
}
Пример #7
0
void View::setPreprocessor( Gaffer::NodePtr preprocessor )
{
	setChild( "__preprocessor", preprocessor );
	preprocessor->getChild<Plug>( "in" )->setInput( inPlug<Plug>() );
	m_preprocessorPlugDirtiedConnection = preprocessor->plugDirtiedSignal().connect( boost::bind( &View::plugDirtied, this, ::_1 ) );
}
Пример #8
0
StandardNodeGadget::StandardNodeGadget( Gaffer::NodePtr node )
	:	NodeGadget( node ),
		m_nodeEnabled( true ),
		m_labelsVisibleOnHover( true ),
		m_dragDestination( nullptr ),
		m_userColor( 0 ),
		m_oval( false )
{

	// build our ui structure
	////////////////////////////////////////////////////////

	float minWidth = 10.0f;
	if( IECore::ConstFloatDataPtr d = Metadata::value<IECore::FloatData>( node.get(), g_minWidthKey ) )
	{
		minWidth = d->readable();
	}

	// four containers for nodules - one each for the top, bottom, left and right.
	// these contain spacers at either end to prevent nodules being placed in
	// the corners of the node gadget, and also to guarantee a minimim width for the
	// vertical containers and a minimum height for the horizontal ones.

	LinearContainerPtr topNoduleContainer = new LinearContainer( "topNoduleContainer", LinearContainer::X );
	topNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 2, 1, 0 ) ) ) );
	topNoduleContainer->addChild( new NoduleLayout( node, "top" ) );
	topNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 2, 1, 0 ) ) ) );

	LinearContainerPtr bottomNoduleContainer = new LinearContainer( "bottomNoduleContainer", LinearContainer::X );
	bottomNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 2, 1, 0 ) ) ) );
	bottomNoduleContainer->addChild( new NoduleLayout( node, "bottom" ) );
	bottomNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 2, 1, 0 ) ) ) );

	LinearContainerPtr leftNoduleContainer = new LinearContainer( "leftNoduleContainer", LinearContainer::Y, LinearContainer::Centre, 0.0f, LinearContainer::Decreasing );
	leftNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 1, 0.2, 0 ) ) ) );
	leftNoduleContainer->addChild( new NoduleLayout( node, "left" ) );
	leftNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 1, 0.2, 0 ) ) ) );

	LinearContainerPtr rightNoduleContainer = new LinearContainer( "rightNoduleContainer", LinearContainer::Y, LinearContainer::Centre, 0.0f, LinearContainer::Decreasing );
	rightNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 1, 0.2, 0 ) ) ) );
	rightNoduleContainer->addChild( new NoduleLayout( node, "right" ) );
	rightNoduleContainer->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( 1, 0.2, 0 ) ) ) );

	// column - this is our outermost structuring container

	LinearContainerPtr column = new LinearContainer(
		"column",
		LinearContainer::Y,
		LinearContainer::Centre,
		0.0f,
		LinearContainer::Decreasing
	);

	column->addChild( topNoduleContainer );

	LinearContainerPtr row = new LinearContainer(
		"row",
		LinearContainer::X,
		LinearContainer::Centre,
		0.0f
	);

	column->addChild( row );

	// central row - this holds our main contents, with the
	// nodule containers surrounding it.

	row->addChild( leftNoduleContainer );

	LinearContainerPtr contentsColumn = new LinearContainer(
		"contentsColumn",
		LinearContainer::Y,
		LinearContainer::Centre,
		0.0f,
		LinearContainer::Decreasing
	);
	row->addChild( contentsColumn );

	LinearContainerPtr contentsRow = new LinearContainer(
		"paddingRow",
		LinearContainer::X,
		LinearContainer::Centre,
		0.5f
	);

	IndividualContainerPtr iconContainer = new IndividualContainer();
	iconContainer->setName( "iconContainer" );
	contentsRow->addChild( iconContainer );

	IndividualContainerPtr contentsContainer = new IndividualContainer();
	contentsContainer->setName( "contentsContainer" );
	contentsRow->addChild( contentsContainer );

	contentsColumn->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( minWidth, 0, 0 ) ) ) );
	contentsColumn->addChild( contentsRow );
	contentsColumn->addChild( new SpacerGadget( Box3f( V3f( 0 ), V3f( minWidth, 0, 0 ) ) ) );

	row->addChild( rightNoduleContainer );
	column->addChild( bottomNoduleContainer );

	addChild( column );
	setContents( new NameGadget( node ) );

	// connect to the signals we need in order to operate
	////////////////////////////////////////////////////////

	node->errorSignal().connect( boost::bind( &StandardNodeGadget::error, this, ::_1, ::_2, ::_3 ) );
	node->plugDirtiedSignal().connect( boost::bind( &StandardNodeGadget::plugDirtied, this, ::_1 ) );

	dragEnterSignal().connect( boost::bind( &StandardNodeGadget::dragEnter, this, ::_1, ::_2 ) );
	dragMoveSignal().connect( boost::bind( &StandardNodeGadget::dragMove, this, ::_1, ::_2 ) );
	dragLeaveSignal().connect( boost::bind( &StandardNodeGadget::dragLeave, this, ::_1, ::_2 ) );
	dropSignal().connect( boost::bind( &StandardNodeGadget::drop, this, ::_1, ::_2 ) );

	for( int e = FirstEdge; e <= LastEdge; e++ )
	{
		NoduleLayout *l = noduleLayout( (Edge)e );
		l->enterSignal().connect( boost::bind( &StandardNodeGadget::enter, this, ::_1 ) );
		l->leaveSignal().connect( boost::bind( &StandardNodeGadget::leave, this, ::_1 ) );
	}

	Metadata::nodeValueChangedSignal().connect( boost::bind( &StandardNodeGadget::nodeMetadataChanged, this, ::_1, ::_2, ::_3 ) );

	// do our first update
	////////////////////////////////////////////////////////

	updateUserColor();
	updatePadding();
	updateNodeEnabled();
	updateIcon();
	updateShape();
}
Пример #9
0
NodeGadget::NodeGadget( Gaffer::NodePtr node )
	:	m_node( node.get() )
{
}