コード例 #1
0
ファイル: GraphGadget.cpp プロジェクト: 7on7on/gaffer
size_t GraphGadget::connectionGadgets( const Gaffer::Plug *plug, std::vector<ConnectionGadget *> &connections, const Gaffer::Set *excludedNodes )
{
	if( plug->direction() == Gaffer::Plug::In )
	{
		const Gaffer::Plug *input = plug->getInput<Gaffer::Plug>();
		if( input )
		{
			if( !excludedNodes || !excludedNodes->contains( input->node() ) )
			{
				ConnectionGadget *connection = connectionGadget( plug );
				if( connection && connection->srcNodule() )
				{
					connections.push_back( connection );
				}
			}
		}
	}
	else
	{
		const Gaffer::Plug::OutputContainer &outputs = plug->outputs();
		for( Gaffer::Plug::OutputContainer::const_iterator it = outputs.begin(), eIt = outputs.end(); it != eIt; ++it )
		{
			if( excludedNodes && excludedNodes->contains( (*it)->node() ) )
			{
				continue;
			}
			ConnectionGadget *connection = connectionGadget( *it );
			if( connection && connection->srcNodule() )
			{
				connections.push_back( connection );
			}
		}
	}
	return connections.size();
}
コード例 #2
0
ファイル: GraphGadget.cpp プロジェクト: 7on7on/gaffer
void GraphGadget::removeConnectionGadgets( const Gaffer::GraphComponent *plugParent )
{
	
	/// \todo I think this could be faster if we could iterate over just the nodules rather than all the plugs. Perhaps
	/// we could make it easy to recurse over all the Nodules of a NodeGadget if we had a RecursiveChildIterator for GraphComponents?

	for( Gaffer::PlugIterator pIt( plugParent->children().begin(), plugParent->children().end() ); pIt!=pIt.end(); pIt++ )
	{
		if( (*pIt)->direction() == Gaffer::Plug::In )
		{
			// remove input connection gadgets
			{
				removeConnectionGadget( pIt->get() );
			}
		}
		else
		{
			// make output connection gadgets dangle
			for( Gaffer::Plug::OutputContainer::const_iterator oIt( (*pIt)->outputs().begin() ); oIt!= (*pIt)->outputs().end(); oIt++ )
			{
				ConnectionGadget *connection = findConnectionGadget( *oIt );
				if( connection )
				{
					connection->setNodules( 0, connection->dstNodule() );
				}
			}
		}
		
		if( (*pIt)->isInstanceOf( Gaffer::CompoundPlug::staticTypeId() ) )
		{
			removeConnectionGadgets( pIt->get() );
		}
	}
	
}
コード例 #3
0
ファイル: GraphGadget.cpp プロジェクト: 7on7on/gaffer
void GraphGadget::addConnectionGadgets( Gaffer::GraphComponent *plugParent )
{
	/// \todo I think this could be faster if we could iterate over just the nodules rather than all the plugs. Perhaps
	/// we could make it easy to recurse over all the Nodules of a NodeGadget if we had a RecursiveChildIterator for GraphComponents?
	Gaffer::Node *node = plugParent->isInstanceOf( Gaffer::Node::staticTypeId() ) ? static_cast<Gaffer::Node *>( plugParent ) : plugParent->ancestor<Gaffer::Node>();
	
	NodeGadget *nodeGadget = findNodeGadget( node );
	if( !nodeGadget )
	{
		return;
	}

	for( Gaffer::PlugIterator pIt( plugParent->children().begin(), plugParent->children().end() ); pIt!=pIt.end(); pIt++ )
	{
		if( (*pIt)->direction() == Gaffer::Plug::In )
		{
			// add connections for input plugs
			if( !findConnectionGadget( pIt->get() ) )
			{
				addConnectionGadget( pIt->get() );
			}
		}
		else
		{
			// reconnect any old output connections which may have been dangling
			Nodule *srcNodule = nodeGadget->nodule( *pIt );
			if( srcNodule )
			{
				for( Gaffer::Plug::OutputContainer::const_iterator oIt( (*pIt)->outputs().begin() ); oIt!= (*pIt)->outputs().end(); oIt++ )
				{
					ConnectionGadget *connection = findConnectionGadget( *oIt );
					if( connection && !connection->srcNodule() )
					{
						assert( connection->dstNodule()->plug()->getInput<Gaffer::Plug>() == *pIt ); 
						connection->setNodules( srcNodule, connection->dstNodule() );
					}
				}
			}
		}
		
		if( (*pIt)->isInstanceOf( Gaffer::CompoundPlug::staticTypeId() ) )
		{
			addConnectionGadgets( pIt->get() );
		}
	}
	
}
コード例 #4
0
ファイル: GraphGadget.cpp プロジェクト: 7on7on/gaffer
void GraphGadget::doRender( const Style *style ) const
{
	glDisable( GL_DEPTH_TEST );
	
	// render backdrops before anything else
	/// \todo Perhaps we need a more general layering system as part
	/// of the Gadget system, to allow Gadgets to choose their own layering,
	/// and perhaps to also allow one gadget to draw into multiple layers.
	for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
	{
		if( (*it)->isInstanceOf( (IECore::TypeId)BackdropNodeGadgetTypeId ) )
		{
			static_cast<const Gadget *>( it->get() )->render( style );		
		}
	}	
	
	// then render connections so they go underneath the nodes
	for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
	{
		ConnectionGadget *c = IECore::runTimeCast<ConnectionGadget>( it->get() );
		if ( c && c != m_dragReconnectCandidate )
		{
			c->render( style );
		}
	}

	// render the new drag connections if they exist
	if ( m_dragReconnectCandidate )
	{
		if ( m_dragReconnectDstNodule )
		{
			const Nodule *srcNodule = m_dragReconnectCandidate->srcNodule();
			const NodeGadget *srcNodeGadget = nodeGadget( srcNodule->plug()->node() );
			const Imath::V3f srcP = srcNodule->fullTransform( this ).translation();
			const Imath::V3f dstP = m_dragReconnectDstNodule->fullTransform( this ).translation();
			const Imath::V3f dstTangent = nodeGadget( m_dragReconnectDstNodule->plug()->node() )->noduleTangent( m_dragReconnectDstNodule );
			/// \todo: can there be a highlighted/dashed state?
			style->renderConnection( srcP, srcNodeGadget->noduleTangent( srcNodule ), dstP, dstTangent, Style::HighlightedState );
		}
		
		if ( m_dragReconnectSrcNodule )
		{
			const Nodule *dstNodule = m_dragReconnectCandidate->dstNodule();
			const NodeGadget *dstNodeGadget = nodeGadget( dstNodule->plug()->node() );
			const Imath::V3f srcP = m_dragReconnectSrcNodule->fullTransform( this ).translation();
			const Imath::V3f dstP = dstNodule->fullTransform( this ).translation();
			const Imath::V3f srcTangent = nodeGadget( m_dragReconnectSrcNodule->plug()->node() )->noduleTangent( m_dragReconnectSrcNodule );
			/// \todo: can there be a highlighted/dashed state?
			style->renderConnection( srcP, srcTangent, dstP, dstNodeGadget->noduleTangent( dstNodule ), Style::HighlightedState );
		}
	}
	
	// then render the rest on top
	for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
	{
		if( !((*it)->isInstanceOf( ConnectionGadget::staticTypeId() )) && !((*it)->isInstanceOf( (IECore::TypeId)BackdropNodeGadgetTypeId )) )
		{
			static_cast<const Gadget *>( it->get() )->render( style );
		}
	}

	// render drag select thing if needed
	if( m_dragMode == Selecting )
	{
		const ViewportGadget *viewportGadget = ancestor<ViewportGadget>();
		ViewportGadget::RasterScope rasterScope( viewportGadget );

		Box2f b;
		b.extendBy( viewportGadget->gadgetToRasterSpace( V3f( m_dragStartPosition.x, m_dragStartPosition.y, 0 ), this ) );
		b.extendBy( viewportGadget->gadgetToRasterSpace( V3f( m_lastDragPosition.x, m_lastDragPosition.y, 0 ), this ) );
		style->renderSelectionBox( b );		
	}
	
}
コード例 #5
0
static NodulePtr dstNodule( ConnectionGadget &c )
{
	return c.dstNodule();
}
コード例 #6
0
static NodulePtr srcNodule( ConnectionGadget &c )
{
	return c.srcNodule();
}