Exemplo n.º 1
0
bool GraphGadget::dragEnd( GadgetPtr gadget, const DragDropEvent &event )
{
	DragMode dragMode = m_dragMode;
	m_dragMode = None;
	Pointer::setCurrent( "" );

	if( !m_scriptNode )
	{
		return false;
	}

	V3f i;
	if( !event.line.intersect( Plane3f( V3f( 0, 0, 1 ), 0 ), i ) )
	{
		return false;
	}

	if( dragMode == Moving )
	{
		if ( m_dragReconnectCandidate )
		{
			if ( m_dragReconnectDstNodule || m_dragReconnectSrcNodule )
			{
				Gaffer::Plug *srcPlug = m_dragReconnectCandidate->srcNodule()->plug();
				Gaffer::Plug *dstPlug = m_dragReconnectCandidate->dstNodule()->plug();

				Gaffer::UndoContext undoContext( m_scriptNode );

				if ( m_dragReconnectDstNodule )
				{
					m_dragReconnectDstNodule->plug()->setInput( srcPlug );
					dstPlug->setInput( 0 );
				}

				if ( m_dragReconnectSrcNodule )
				{
					dstPlug->setInput( m_dragReconnectSrcNodule->plug() );
				}
			}
		}

		m_dragReconnectCandidate = 0;
		renderRequestSignal()( this );
	}
	else if( dragMode == Selecting )
	{
		updateDragSelection( true );
		renderRequestSignal()( this );
	}

	return true;
}
Exemplo n.º 2
0
bool GraphGadget::dragEnd( GadgetPtr gadget, const DragDropEvent &event )
{
	DragMode dragMode = m_dragMode;
	m_dragMode = None;
	Pointer::set( 0 );
	
	if( !m_scriptNode )
	{
		return false;
	}
	
	V3f i;
	if( !event.line.intersect( Plane3f( V3f( 0, 0, 1 ), 0 ), i ) )
	{
		return false;
	}
	
	if( dragMode == Moving )
	{
		if ( m_dragReconnectCandidate )
		{
			if ( m_dragReconnectDstNodule || m_dragReconnectSrcNodule )
			{
				Gaffer::Plug *srcPlug = m_dragReconnectCandidate->srcNodule()->plug();
				Gaffer::Plug *dstPlug = m_dragReconnectCandidate->dstNodule()->plug();
				
				Gaffer::UndoContext undoContext( m_scriptNode );
				
				if ( m_dragReconnectDstNodule )
				{
					m_dragReconnectDstNodule->plug()->setInput( srcPlug );
					dstPlug->setInput( 0 );
				}

				if ( m_dragReconnectSrcNodule )
				{
					dstPlug->setInput( m_dragReconnectSrcNodule->plug() );
				}
			}
		}
		
		m_dragReconnectCandidate = 0;
		renderRequestSignal()( this );
	}
	else if( dragMode == Selecting )
	{
		Box2f selectionBound;
		selectionBound.extendBy( m_dragStartPosition );
		selectionBound.extendBy( m_lastDragPosition );
	
		for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
		{
			NodeGadgetPtr nodeGadget = runTimeCast<NodeGadget>( *it );
			if( nodeGadget )
			{
				Box3f nodeBound3 = nodeGadget->transformedBound();
				Box2f nodeBound2( V2f( nodeBound3.min.x, nodeBound3.min.y ), V2f( nodeBound3.max.x, nodeBound3.max.y ) );
				if( boxContains( selectionBound, nodeBound2 ) )
				{
					m_scriptNode->selection()->add( nodeGadget->node() );
				}
			}
		}
	
		renderRequestSignal()( this );
	}

	return true;
}