Commit d4d7a9df authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - moved some combiner functionality

parent 54426376
......@@ -47,6 +47,9 @@
#include "../../dataHandler/WEEG2.h"
#include "../../graphicsEngine/WROIBox.h"
#include "../../kernel/WKernel.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleCombiner.h"
#include "../../kernel/WModuleCombinerTypes.h"
#include "../../kernel/WProjectFile.h"
#include "../../modules/data/WMData.h"
#include "../../modules/navSlices/WMNavSlices.h"
......@@ -501,7 +504,7 @@ void WMainWindow::setCompatiblesToolbar( WQtCombinerToolbar* toolbar )
{
// ok, reset the toolbar
// So create a dummy to permanently reserve the space
m_currentCompatiblesToolbar = new WQtCombinerToolbar( this, WModuleFactory::CompatiblesList() );
m_currentCompatiblesToolbar = new WQtCombinerToolbar( this, WCompatiblesList() );
}
// optional toolbar break
......
......@@ -30,12 +30,14 @@
#include "QtGui/QMenu"
#include "../../common/WPreferences.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleCombiner.h"
#include "guiElements/WQtApplyModuleAction.h"
#include "WMainWindow.h"
#include "WQtCombinerActionList.h"
WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* icons, WModuleFactory::CompatiblesList compatibles ):
WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* icons, WCompatiblesList compatibles ):
QList< QAction* >()
{
// These modules will be allowed to be shown.
......@@ -44,7 +46,7 @@ WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* ico
std::vector< std::string > moduleWhiteList = string_utils::tokenize( moduleWhiteListString, "," );
// create an action for each group:
for ( WModuleFactory::CompatiblesList::const_iterator groups = compatibles.begin(); groups != compatibles.end(); ++groups )
for ( WCompatiblesList::iterator groups = compatibles.begin(); groups != compatibles.end(); ++groups )
{
// check current prototype against whitelist
if( moduleWhiteList.size()
......@@ -55,6 +57,7 @@ WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* ico
// create a new action for this group
WQtApplyModuleAction* group = new WQtApplyModuleAction( parent, icons, *( *groups ).second.begin() );
group->setIconVisibleInMenu( true );
push_back( group );
// only add a sub menu if there are more than 1 items in the group
......@@ -62,8 +65,8 @@ WQtCombinerActionList::WQtCombinerActionList( QWidget* parent, WIconManager* ico
{
QMenu* groupMenu = new QMenu( parent );
// iterate all the children
for ( WModuleFactory::CompatibleCombiners::const_iterator combiner = ( *groups ).second.begin();
combiner != ( *groups ).second.end(); ++combiner )
for ( WCompatibleCombiners::iterator combiner = ( *groups ).second.begin();
combiner != ( *groups ).second.end(); ++combiner )
{
WQtApplyModuleAction* a = new WQtApplyModuleAction( parent, icons, ( *combiner ), true );
a->setIconVisibleInMenu( true );
......
......@@ -29,12 +29,12 @@
#include <QtGui/QAction>
#include <QtGui/QWidget>
#include "../../kernel/WModuleFactory.h"
#include "../../kernel/WModuleCombinerTypes.h"
#include "WIconManager.h"
/**
* This class represents a list of actions to apply a bunch of modules to others. It basically interprets the WModuleFactory::CompatiblesList and
* This class represents a list of actions to apply a bunch of modules to others. It basically interprets the WCompatiblesList and
* builds a list of appropriate actions. It can be used to build menus, toolbars and so on.
*/
class WQtCombinerActionList: public QList< QAction* >
......@@ -47,7 +47,7 @@ public:
* \param icons the icon manager holding the right icons for all the prototypes
* \param compatibles the list of combiners
*/
WQtCombinerActionList( QWidget* parent, WIconManager* icons, WModuleFactory::CompatiblesList compatibles );
WQtCombinerActionList( QWidget* parent, WIconManager* icons, WCompatiblesList compatibles );
/**
* Destructor.
......
......@@ -29,6 +29,8 @@
#include <QtGui/QMenu>
#include "../../common/WPreferences.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleCombiner.h"
#include "WMainWindow.h"
#include "WQtToolBar.h"
......@@ -37,7 +39,7 @@
#include "WQtCombinerToolbar.h"
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, WModuleFactory::CompatiblesList compatibles )
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, WCompatiblesList compatibles )
: QToolBar( "Compatible Modules", parent )
{
// setup toolbar
......
......@@ -27,7 +27,7 @@
#include <QtGui/QToolBar>
#include "../../kernel/WModuleFactory.h"
#include "../../kernel/WModuleCombinerTypes.h"
class WMainWindow;
......@@ -44,7 +44,7 @@ public:
* \param parent the parent widget of this widget, i.e. the widget that manages it.
* \param compatibles the list of combiners
*/
explicit WQtCombinerToolbar( WMainWindow* parent, WModuleFactory::CompatiblesList compatibles );
explicit WQtCombinerToolbar( WMainWindow* parent, WCompatiblesList compatibles );
/**
* destructor
......
......@@ -37,6 +37,9 @@
#include "../../../common/WPreferences.h"
#include "../../../dataHandler/WDataSet.h"
#include "../../../kernel/WKernel.h"
#include "../../../kernel/WModule.h"
#include "../../../kernel/WModuleCombiner.h"
#include "../../../kernel/WModuleCombinerTypes.h"
#include "../../../kernel/WModuleFactory.h"
#include "../../../modules/data/WMData.h"
#include "../events/WEventTypes.h"
......@@ -711,7 +714,7 @@ WQtCombinerToolbar* WQtDatasetBrowser::createCompatibleButtons( boost::shared_pt
{
// 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)
WModuleFactory::CompatiblesList comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
WCompatiblesList comps = WModuleFactory::getModuleFactory()->getCompatiblePrototypes( module );
// build the prototype menu
QMenu* m = new QMenu( m_moduleTreeWidget );
......
......@@ -26,14 +26,14 @@
#include "WQtApplyModuleAction.h"
WQtApplyModuleAction::WQtApplyModuleAction( QWidget* parent, WIconManager* iconManager, boost::shared_ptr< WApplyPrototypeCombiner > combiner,
WQtApplyModuleAction::WQtApplyModuleAction( QWidget* parent, WIconManager* iconManager, boost::shared_ptr< WModuleCombiner > combiner,
bool advancedText ):
QAction( parent ),
m_combiner( combiner )
{
// nice tooltip
std::string from = "";
/*
// NOTE: all the tooltips and so on for this action are used from the first combiner in the group
// might be null ( for example if a module should be added that does not require an input)
......@@ -49,7 +49,7 @@ WQtApplyModuleAction::WQtApplyModuleAction( QWidget* parent, WIconManager* iconM
// we need to use released signal here, as the pushed signal also gets emitted on newly created buttons which are under the mouse pointer with
// pressed left button.
connect( this, SIGNAL( triggered() ), this, SLOT( applyCombiner() ) );
connect( this, SIGNAL( triggered() ), this, SLOT( applyCombiner() ) );*/
}
WQtApplyModuleAction::~WQtApplyModuleAction()
......
......@@ -31,9 +31,10 @@
#include <QtGui/QAction>
#include "../../../kernel/WModule.h"
#include "../../../kernel/WModuleCombiner.h"
#include "../WIconManager.h"
#include "../../../kernel/combiner/WApplyPrototypeCombiner.h"
#include "../../../kernel/WModuleFactory.h"
/**
* Implements a action which applies the specified combiners (of the specified group) if pressed.
......@@ -52,7 +53,7 @@ public:
* \param combiner the apply combiner which gets applied when triggered
* \param advancedText if true a more complex text showing the used connectors is used instead of the plane target-module name
*/
WQtApplyModuleAction( QWidget* parent, WIconManager* iconManager, boost::shared_ptr< WApplyPrototypeCombiner > combiner,
WQtApplyModuleAction( QWidget* parent, WIconManager* iconManager, boost::shared_ptr< WModuleCombiner > combiner,
bool advancedText = false );
/**
......@@ -65,7 +66,7 @@ protected:
/**
* The combiner of this action
*/
boost::shared_ptr< WApplyPrototypeCombiner > m_combiner;
boost::shared_ptr< WModuleCombiner > m_combiner;
private:
public slots:
......
......@@ -31,6 +31,7 @@
#include <utility>
#include "WModule.h"
#include "WModuleCombiner.h"
#include "exceptions/WModuleUninitialized.h"
#include "exceptions/WModuleAlreadyAssociated.h"
#include "exceptions/WModuleSignalSubscriptionFailed.h"
......@@ -370,7 +371,7 @@ boost::shared_ptr< WModule > WModuleContainer::applyModule( boost::shared_ptr< W
// get offered inputs
WModule::OutputConnectorList outs = applyOn->getOutputConnectors();
// TODO(ebaum): search best matching instead of simply connecting both
// connect the first connectors. For a more sophisticated way of connecting modules, use ModuleCombiners.
if ( !ins.empty() && !outs.empty() )
{
( *ins.begin() )->connect( ( *outs.begin() ) );
......@@ -438,3 +439,18 @@ WModuleContainer::ModuleSharedContainerType::ReadTicket WModuleContainer::getMod
return m_modules.getReadTicket();
}
WCompatiblesList WModuleContainer::getPossibleConnections( boost::shared_ptr< WModule > module )
{
WCompatiblesList complist;
// read lock the container
ModuleSharedContainerType::ReadTicket lock = m_modules.getReadTicket();
// handle each module
for( ModuleConstIterator listIter = lock->get().begin(); listIter != lock->get().end(); ++listIter )
{
}
return complist;
}
......@@ -38,6 +38,7 @@
#include "../common/WSharedObject.h"
#include "WModuleCombinerTypes.h"
#include "WModuleSignals.h"
class WThreadedRunner;
......@@ -253,6 +254,17 @@ public:
*/
ModuleSharedContainerType::ReadTicket getModules() const;
/**
* This method creates a list of combiner instances, for each possible connection that can be made between the specified module and the
* module currently inside the container. It might be possible that a module which is contained in the returned list is not associated
* anymore if the combiner gets applied.
*
* \param module the module to which the possible connections should be returned
*
* \return the possible combinations of connectors.
*/
WCompatiblesList getPossibleConnections( boost::shared_ptr< WModule > module );
protected:
/**
......
......@@ -29,6 +29,8 @@
#include <typeinfo>
#include <vector>
#include "WModule.h"
#include "WModuleCombiner.h"
#include "../common/WLogger.h"
#include "../modules/applyMask/WMApplyMask.h"
#include "../modules/arbitraryRois/WMArbitraryRois.h"
......@@ -244,20 +246,20 @@ WModuleFactory::PrototypeSharedContainerType::ReadTicket WModuleFactory::getProt
*
* \return true if lhs < rhs
*/
bool compatiblesSort( WModuleFactory::CompatiblesGroup lhs, WModuleFactory::CompatiblesGroup rhs )
bool compatiblesSort( WCompatiblesGroup lhs, WCompatiblesGroup rhs )
{
return ( lhs.first->getName() < rhs.first->getName() );
}
WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::shared_ptr< WModule > module )
WCompatiblesList WModuleFactory::getCompatiblePrototypes( boost::shared_ptr< WModule > module )
{
CompatiblesList compatibles;
WCompatiblesList compatibles;
// for this a read lock is sufficient, gets unlocked if it looses scope
PrototypeSharedContainerType::ReadTicket l = m_prototypes.getReadTicket();
// First, add all modules with no input connector.
for( PrototypeContainerConstIteratorType listIter = l->get().begin(); listIter != l->get().end();
for( PrototypeContainerIteratorType listIter = l->get().begin(); listIter != l->get().end();
++listIter )
{
// get connectors of this prototype
......@@ -265,13 +267,13 @@ WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::
if( pcons.size() == 0 )
{
// the modules which match every time need their own groups
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > lComp;
std::vector< boost::shared_ptr< WModuleCombiner > > lComp;
// 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
lComp.push_back( boost::shared_ptr< WApplyPrototypeCombiner >( new WApplyPrototypeCombiner( module, "", *listIter, "" ) ) );
lComp.push_back( boost::shared_ptr< WModuleCombiner >( new WApplyPrototypeCombiner( module, "", *listIter, "" ) ) );
// add this list
compatibles.push_back( CompatiblesGroup( ( *listIter ), lComp ) );
compatibles.push_back( WCompatiblesGroup( ( *listIter ), lComp ) );
}
}
......@@ -292,7 +294,7 @@ WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::
}
// go through every prototype
for( PrototypeContainerConstIteratorType listIter = l->get().begin(); listIter != l->get().end();
for( PrototypeContainerIteratorType listIter = l->get().begin(); listIter != l->get().end();
++listIter )
{
// get connectors of this prototype
......@@ -305,7 +307,7 @@ WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::
}
// this list contains all connections for the current module
std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > lComp;
std::vector< boost::shared_ptr< WModuleCombiner > > lComp;
// iterate connector list, first find all matches of the output connectors with all inputs
for ( WModule::OutputConnectorList::const_iterator outIter = cons.begin(); outIter != cons.end(); ++outIter )
......@@ -317,7 +319,7 @@ WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::
if ( ( *outIter )->connectable( *inIter ) && ( *inIter )->connectable( *outIter ) )
{
// create a apply-prototype combiner
lComp.push_back( boost::shared_ptr< WApplyPrototypeCombiner >(
lComp.push_back( boost::shared_ptr< WModuleCombiner >(
new WApplyPrototypeCombiner( module, ( *outIter )->getName(), *listIter, ( *inIter )->getName() ) )
);
......@@ -329,7 +331,7 @@ WModuleFactory::CompatiblesList WModuleFactory::getCompatiblePrototypes( boost::
// add the group
if ( lComp.size() != 0 )
{
compatibles.push_back( CompatiblesGroup( ( *listIter ), lComp ) );
compatibles.push_back( WCompatiblesGroup( ( *listIter ), lComp ) );
}
}
......
......@@ -35,7 +35,7 @@
#include "../modules/data/WMData.h" // this is the ONLY module with a special meaning. Every one knowing the factory also knows this
#include "../common/WSharedAssociativeContainer.h"
#include "combiner/WApplyPrototypeCombiner.h"
#include "WModuleCombinerTypes.h"
#include "WModule.h"
/**
......@@ -144,24 +144,6 @@ public:
template <typename T>
static bool isA( boost::shared_ptr< WModule > module );
/**
* A list of all combiners. Used in CompatiblesGroup.
*/
typedef std::vector< boost::shared_ptr< WApplyPrototypeCombiner > > CompatibleCombiners;
/**
* A group of compatibles connections to and from a specified module.
*/
typedef std::pair< boost::shared_ptr< WModule >, CompatibleCombiners > CompatiblesGroup;
/**
* A type used for defining lists of properties. It basically is a list of lists, each containing several ApplyPrototypeCombiner instances.
* The Idea is to group combiners by the module they target. The reason why this is a list of pairs is that the first item always is the
* prototype pointer to the target, as not every ApplyPrototypeCombiner Instance necessarily has the prototype as target (as source for
* example)
*/
typedef std::vector< CompatiblesGroup > CompatiblesList;
/**
* Returns a set of module combiners with module combinations compatible with the specified one.
*
......@@ -172,7 +154,9 @@ public:
*
* \return set of compatible combiners.
*/
CompatiblesList getCompatiblePrototypes( boost::shared_ptr< WModule > module = boost::shared_ptr< WModule >() );
WCompatiblesList 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
......
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