Commit 973f5e5c by Sebastian Eichelbaum

[FIX] - removed ugly hack to get compatible modules without any inputs. This…

[FIX] - removed ugly hack to get compatible modules without any inputs. This fixes the hack in the GUI and at the same time extened the factory to provide appropriate methods for this purpose.
parent bb01f998
......@@ -460,13 +460,9 @@ void WQtDatasetBrowser::selectTreeItem()
{
case SUBJECT:
case MODULEHEADER:
// Here we just take a prototype module with no output connectors
// to get the modules with no input connector.
module = WModuleFactory::getModuleFactory()->getPrototypeByName( "HUD" );
// deletion of headers and subjects is not allowed
m_deleteModuleAction->setEnabled( false );
createCompatibleButtons( module );
createCompatibleButtons( module ); // module is NULL at this point
break;
case DATASET:
module = ( static_cast< WQtDatasetTreeItem* >( m_moduleTreeWidget->selectedItems().at( 0 ) ) )->getModule();
......@@ -643,6 +639,7 @@ void WQtDatasetBrowser::buildPropTab( boost::shared_ptr< WProperties > props, bo
void WQtDatasetBrowser::createCompatibleButtons( boost::shared_ptr< WModule >module )
{
// every module may have compatibles: create ribbon menu entry
// NOTE: if module is NULL, getCompatiblePrototypes returns the list of modules without input connector (nav slices and so on)
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
for ( std::vector< boost::shared_ptr< WApplyPrototypeCombiner > >::const_iterator iter = comps.begin(); iter != comps.end(); ++iter )
......
......@@ -244,9 +244,6 @@ std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getC
// for this a read lock is sufficient
boost::shared_lock< boost::shared_mutex > slock = boost::shared_lock< boost::shared_mutex >( m_prototypesLock );
// get offered outputs
std::set<boost::shared_ptr<WModuleOutputConnector> > cons = module->getOutputConnectors();
// First, add all modules with no input connector.
for( std::set< boost::shared_ptr< WModule > >::iterator listIter = m_prototypes.begin(); listIter != m_prototypes.end(); ++listIter )
{
......@@ -254,10 +251,20 @@ std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getC
std::set<boost::shared_ptr<WModuleInputConnector> > pcons = ( *listIter )->getInputConnectors();
if( pcons.size() == 0 )
{
// NOTE: it is OK here to use the variable module even if it is NULL as the combiner in this case only adds the specified module
compatibles.push_back( boost::shared_ptr< WApplyPrototypeCombiner >( new WApplyPrototypeCombiner( module, "", *listIter, "" ) ) );
}
}
// if NULL was specified, only return all modules without any inputs
if ( !module )
{
return compatibles;
}
// get offered outputs
std::set<boost::shared_ptr<WModuleOutputConnector> > cons = module->getOutputConnectors();
// return early if we have no output connector, because the modules with no input connector
// are already added at this point.
if( cons.size() == 0 )
......@@ -265,6 +272,7 @@ std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getC
return compatibles;
}
// This warning was annoying
// if ( cons.size() > 1 )
// {
// wlog::warn( "ModuleFactory" ) << "Can not find compatibles for " << module->getName() << " module (more than 1 output connector). Using "
......@@ -283,6 +291,8 @@ std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > WModuleFactory::getC
{
continue;
}
// This warning was annoying
// if ( pcons.size() > 1 )
// {
// wlog::warn( "ModuleFactory" ) << "Can not find compatibles for " << ( *listIter )->getName()
......
......@@ -120,9 +120,14 @@ public:
*
* \param module the module to find the compatibles for.
*
* \note as the default parameter denotes, providing a NULL pointer (or calling the method without a parameter) returns the list of modules
* which are compatible to every other module. In other words, it returns all modules without input connectors.
*
* \return set of compatible combiners.
*/
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > getCompatiblePrototypes( boost::shared_ptr< WModule > module );
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > getCompatiblePrototypes(
boost::shared_ptr< WModule > module = boost::shared_ptr< WModule >()
);
/**
* This method uses a newly created instance of WModule and initializes it properly. After using this method, the module is
......
......@@ -100,12 +100,15 @@ void WApplyPrototypeCombiner::apply()
// NOTE: here, we assume the src module already to be in the container. If not, connect will fail with an exception -> so no need for a
// separate exception here
// wait
m_srcModule->isReadyOrCrashed().wait();
if ( m_srcModule->isCrashed()() )
// wait for the source module if there is any
if ( m_srcModule ) // specifying a NULL source module causes the combiner to only add the target
{
wlog::error( "Prototype Combiner" ) << "The source module \"" << m_srcModule->getName() << "\" has crashed. Abort.";
return;
m_srcModule->isReadyOrCrashed().wait();
if ( m_srcModule->isCrashed()() )
{
wlog::error( "Prototype Combiner" ) << "The source module \"" << m_srcModule->getName() << "\" has crashed. Abort.";
return;
}
}
targetModule->isReadyOrCrashed().wait();
......@@ -122,6 +125,9 @@ void WApplyPrototypeCombiner::apply()
}
// and connect them finally:
targetModule->getInputConnector( m_targetConnector )->connect( m_srcModule->getOutputConnector( m_srcConnector ) );
if ( m_srcModule )
{
targetModule->getInputConnector( m_targetConnector )->connect( m_srcModule->getOutputConnector( m_srcConnector ) );
}
}
......@@ -43,7 +43,10 @@ class WApplyPrototypeCombiner: public WModuleCombiner
public:
/**
* Creates a combiner which sets up the specified modules and prototype combination.
* Creates a combiner which sets up the specified modules and prototype combination. Specifying a NULL pointer to the srcModule parameter
* causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
* input which must be connected.
*
*
* \param target the target container
* \param srcModule the module whose output should be connected with the prototypes input
......@@ -57,7 +60,9 @@ public:
/**
* Creates a combiner which sets up the specified modules and prototype combination. This constructor automatically uses the kernel's root
* container as target container.
* container as target container. Specifying a NULL pointer to the srcModule parameter
* causes the combiner to only add the target module without any connections. This is especially useful for modules which do not provide any
* input which must be connected.
*
* \param srcModule the module whose output should be connected with the prototypes input
* \param srcConnector the output connector of the module
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment