Commit 955f2f16 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[FIX #470] nav slices remove their "show..." properties now from the main

window
parent 4dc1ec48
......@@ -59,6 +59,7 @@
#include "events/WEventTypes.h"
#include "events/WModuleCrashEvent.h"
#include "events/WModuleReadyEvent.h"
#include "events/WModuleRemovedEvent.h"
#include "events/WOpenCustomDockWidgetEvent.h"
#include "guiElements/WQtPropertyBoolAction.h"
#include "WQtCustomDockWidget.h"
......@@ -331,6 +332,27 @@ void WMainWindow::autoAdd( boost::shared_ptr< WModule > module, std::string prot
}
}
void WMainWindow::moduleSpecificCleanup( boost::shared_ptr< WModule > module )
{
// nav slices use separate buttons for slice on/off switching
if( module->getName() == "Navigation Slices" )
{
boost::shared_ptr< WPropertyBase > prop;
prop = module->getProperties()->findProperty( "showAxial" );
m_permanentToolBar->removeAction( propertyActionMap[prop] );
propertyActionMap.erase( prop );
prop = module->getProperties()->findProperty( "showCoronal" );
m_permanentToolBar->removeAction( propertyActionMap[prop] );
propertyActionMap.erase( prop );
prop = module->getProperties()->findProperty( "showSagittal" );
m_permanentToolBar->removeAction( propertyActionMap[prop] );
propertyActionMap.erase( prop );
}
}
void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
{
// Add all special handlings here. This method is called whenever a module is marked "ready". You can set up the gui for special modules,
......@@ -389,6 +411,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
a->setText( "Toggle Axial Slice" );
a->setIcon( m_iconManager.getIcon( "axial icon" ) );
m_permanentToolBar->addAction( a );
propertyActionMap[prop] = a;
}
prop = module->getProperties()->findProperty( "showCoronal" );
......@@ -405,6 +428,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
a->setText( "Toggle Coronal Slice" );
a->setIcon( m_iconManager.getIcon( "coronal icon" ) );
m_permanentToolBar->addAction( a );
propertyActionMap[prop] = a;
}
prop = module->getProperties()->findProperty( "showSagittal" );
......@@ -421,6 +445,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
a->setText( "Toggle Saggital Slice" );
a->setIcon( m_iconManager.getIcon( "sagittal icon" ) );
m_permanentToolBar->addAction( a );
propertyActionMap[prop] = a;
}
// now setup the nav widget sliders
......@@ -961,6 +986,16 @@ bool WMainWindow::event( QEvent* event )
}
}
if( event->type() == WQT_MODULE_REMOVE_EVENT )
{
// convert event to ready event
WModuleRemovedEvent* e1 = dynamic_cast< WModuleRemovedEvent* >( event ); // NOLINT
if( e1 )
{
moduleSpecificCleanup( e1->getModule() );
}
}
return QMainWindow::event( event );
}
......
......@@ -54,6 +54,7 @@
// forward declarations
class QMenuBar;
class WQtPropertyBoolAction;
/**
* This class contains the main window and the layout of the widgets within the window.
......@@ -177,6 +178,12 @@ protected:
* \param module the module to setup the GUI for.
*/
void moduleSpecificSetup( boost::shared_ptr< WModule > module );
/**
* Cleanup the GUI by handling special modules. NavSlices for example remove several toolbar buttons.
*
* \param module the module to setup the GUI for.
*/
void moduleSpecificCleanup( boost::shared_ptr< WModule > module );
/**
* We want to react on close events.
......@@ -353,6 +360,12 @@ private:
* \param proto the prototype to combine with the module.
*/
void autoAdd( boost::shared_ptr< WModule > module, std::string proto );
/**
* Map holding the actions for module properties added automatically. So they can be removed again automatically
* if the module is removed.
*/
std::map< boost::shared_ptr< WPropertyBase >, WQtPropertyBoolAction* > propertyActionMap;
};
#endif // WMAINWINDOW_H
......@@ -289,6 +289,7 @@ void WQt4Gui::slotRemoveDatasetOrModuleInTree( boost::shared_ptr< WModule > modu
WAssert( dataModule, "Internal failure." );
}
QCoreApplication::postEvent( m_mainWindow->getControlPanel(), new WModuleRemovedEvent( module ) );
QCoreApplication::postEvent( m_mainWindow, new WModuleRemovedEvent( module ) );
}
void WQt4Gui::slotConnectionEstablished( boost::shared_ptr<WModuleConnector> in, boost::shared_ptr<WModuleConnector> out )
......
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