コード例 #1
0
static list gadgetsAt( ViewportGadget &v, const Imath::V2f &position )
{
	std::vector<GadgetPtr> gadgets;
	v.gadgetsAt( position, gadgets );
	
	boost::python::list result;
	for( std::vector<GadgetPtr>::const_iterator it=gadgets.begin(); it!=gadgets.end(); it++ )
	{
		result.append( *it );
	}
	return result;
}
コード例 #2
0
ファイル: GraphGadget.cpp プロジェクト: 7on7on/gaffer
bool GraphGadget::buttonPress( GadgetPtr gadget, const ButtonEvent &event )
{
	if( event.buttons==ButtonEvent::Left )
	{
		// selection/deselection
		
		if( !m_scriptNode )
		{
			return false;
		}
		
		ViewportGadget *viewportGadget = ancestor<ViewportGadget>();
				
		std::vector<GadgetPtr> gadgetsUnderMouse;
		viewportGadget->gadgetsAt(
			viewportGadget->gadgetToRasterSpace( event.line.p0, this ),
			gadgetsUnderMouse
		);
				
		if( !gadgetsUnderMouse.size() || gadgetsUnderMouse[0] == this )
		{
			// background click. clear selection unless shift is
			// held, in which case we're expecting a shift drag
			// to add to the selection.
			if( !(event.modifiers & ButtonEvent::Shift) )
			{
				m_scriptNode->selection()->clear();
			}
			return true;
		}
				
		NodeGadget *nodeGadget = runTimeCast<NodeGadget>( gadgetsUnderMouse[0] );
		if( !nodeGadget )
		{
			nodeGadget = gadgetsUnderMouse[0]->ancestor<NodeGadget>();
		}
				
		if( nodeGadget )
		{				
			Gaffer::NodePtr node = nodeGadget->node();
			bool shiftHeld = event.modifiers && ButtonEvent::Shift;
			bool nodeSelected = m_scriptNode->selection()->contains( node );

			std::vector<Gaffer::Node *> affectedNodes;
			if( const BackdropNodeGadget *backdrop = runTimeCast<BackdropNodeGadget>( nodeGadget ) )
			{
				backdrop->framed( affectedNodes );
			}
			
			if( event.modifiers & ButtonEvent::Alt )
			{
				std::vector<NodeGadget *> upstream;
				upstreamNodeGadgets( node, upstream );
				for( std::vector<NodeGadget *>::const_iterator it = upstream.begin(), eIt = upstream.end(); it != eIt; ++it )
				{
					affectedNodes.push_back( (*it)->node() );
				}
			}
			
			affectedNodes.push_back( node );

			if( nodeSelected )
			{
				if( shiftHeld )
				{
					m_scriptNode->selection()->remove( affectedNodes.begin(), affectedNodes.end() );
				}
			}
			else
			{
				if( !shiftHeld )
				{
					m_scriptNode->selection()->clear();
				}
				m_scriptNode->selection()->add( affectedNodes.begin(), affectedNodes.end() );			
			}

			return true;
		}
	}
	else if( event.buttons == ButtonEvent::Middle )
	{
		// potentially the start of a middle button drag on a node
		return nodeGadgetAt( event.line );		
	}
	
	return false;
}
コード例 #3
0
static IECore::CameraPtr getCamera( const ViewportGadget &v )
{
	return v.getCamera()->copy();
}