void BackdropNodeGadget::frame( const std::vector<Gaffer::Node *> &nodes )
{
	GraphGadget *graph = ancestor<GraphGadget>();
	if( !graph )
	{
		return;
	}
	
	Box3f b;
	for( std::vector<Node *>::const_iterator it = nodes.begin(), eIt = nodes.end(); it != eIt; ++it )
	{
		NodeGadget *nodeGadget = graph->nodeGadget( *it );
		if( nodeGadget )
		{
			b.extendBy( nodeGadget->transformedBound( NULL ) );
		}
	}
	
	if( b.isEmpty() )
	{
		return;
	}
	
	graph->setNodePosition( node(), V2f( b.center().x, b.center().y ) );
	
	V2f s( b.size().x / 2.0f, b.size().y / 2.0f );
	
	boundPlug()->setValue(
		Box2f( 
			V2f( -s ) - V2f( g_margin ),
			V2f( s ) + V2f( g_margin + 2.0f * g_margin )
		)
	);
}
Beispiel #2
0
void GraphGadget::updateDragSelection( bool dragEnd )
{
	Box2f selectionBound;
	selectionBound.extendBy( m_dragStartPosition );
	selectionBound.extendBy( m_lastDragPosition );

	for( NodeGadgetMap::const_iterator it = m_nodeGadgets.begin(), eIt = m_nodeGadgets.end(); it != eIt; ++it )
	{
		NodeGadget *nodeGadget = it->second.gadget;
		const Box3f nodeBound3 = nodeGadget->transformedBound();
		const Box2f nodeBound2( V2f( nodeBound3.min.x, nodeBound3.min.y ), V2f( nodeBound3.max.x, nodeBound3.max.y ) );
		if( boxContains( selectionBound, nodeBound2 ) )
		{
			nodeGadget->setHighlighted( true );
			if( dragEnd )
			{
				m_scriptNode->selection()->add( const_cast<Gaffer::Node *>( it->first ) );
			}
		}
		else
		{
			nodeGadget->setHighlighted( m_scriptNode->selection()->contains( it->first ) );
		}
	}
}