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

[CHANGE] - NAvslice toolbar buttons now available

parent bd3f0230
......@@ -45,6 +45,9 @@
#include "WQtGLWidget.h"
#include "WQtNavGLWidget.h"
#include "WQtCustomDockWidget.h"
#include "events/WModuleReadyEvent.h"
#include "events/WEventTypes.h"
#include "datasetbrowser/WPropertyBoolWidget.h"
#include "../../common/WColor.h"
#include "../../common/WPreferences.h"
#include "../../kernel/WKernel.h"
......@@ -174,41 +177,65 @@ void WMainWindow::setupPermanentToolBar()
m_permanentToolBar->addWidget( loadButton );
m_permanentToolBar->addWidget( roiButton );
m_permanentToolBar->addSeparator();
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
}
WQtPushButton* axialButton = new WQtPushButton( m_iconManager.getIcon( "axial" ), "showAxial", m_permanentToolBar );
WQtPushButton* coronalButton = new WQtPushButton( m_iconManager.getIcon( "coronal" ), "showCoronal", m_permanentToolBar );
WQtPushButton* sagittalButton = new WQtPushButton( m_iconManager.getIcon( "sagittal" ), "showSagittal", m_permanentToolBar );
axialButton->setMaximumSize( 24, 24 );
coronalButton->setMaximumSize( 24, 24 );
sagittalButton->setMaximumSize( 24, 24 );
axialButton->setCheckable( true );
coronalButton->setCheckable( true );
sagittalButton->setCheckable( true );
axialButton->setChecked( true );
coronalButton->setChecked( true );
sagittalButton->setChecked( true );
axialButton->setToolTip( "Axial" );
coronalButton->setToolTip( "Coronal" );
sagittalButton->setToolTip( "Sagittal" );
m_permanentToolBar->addWidget( axialButton );
m_permanentToolBar->addWidget( coronalButton );
m_permanentToolBar->addWidget( sagittalButton );
void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
{
// nav slices use separate buttons for slice on/off switching
if ( module->getName() == "Navigation Slice Module" )
{
boost::shared_ptr< WPropertyBase > prop = module->getProperties2()->findProperty( "showAxial" );
if ( !prop )
{
WLogger::getLogger()->
addLogMessage( "Navigation Slice Module does not provide the property \"showAxial\", which is required by the GUI.", "GUI",
LL_ERROR );
}
else
{
WPropertyBoolWidget* button = new WPropertyBoolWidget( prop->toPropBool(), NULL, m_permanentToolBar, true );
button->setToolTip( "Toggle Axial Slice" );
button->getButton()->setMaximumSize( 24, 24 );
button->getButton()->setIcon( m_iconManager.getIcon( "axial" ) );
m_permanentToolBar->addWidget( button );
}
// TODO(ebaum): adopt!
// connect( axialButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// connect( coronalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// connect( sagittalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
prop = module->getProperties2()->findProperty( "showCoronal" );
if ( !prop )
{
WLogger::getLogger()->
addLogMessage( "Navigation Slice Module does not provide the property \"showCoronal\", which is required by the GUI.", "GUI",
LL_ERROR );
}
else
{
WPropertyBoolWidget* button = new WPropertyBoolWidget( prop->toPropBool(), NULL, m_permanentToolBar, true );
button->setToolTip( "Toggle Coronal Slice" );
button->getButton()->setMaximumSize( 24, 24 );
button->getButton()->setIcon( m_iconManager.getIcon( "coronal" ) );
m_permanentToolBar->addWidget( button );
}
prop = module->getProperties2()->findProperty( "showSagittal" );
if ( !prop )
{
WLogger::getLogger()->
addLogMessage( "Navigation Slice Module does not provide the property \"showSagittal\", which is required by the GUI.", "GUI",
LL_ERROR );
}
else
{
WPropertyBoolWidget* button = new WPropertyBoolWidget( prop->toPropBool(), NULL, m_permanentToolBar, true );
button->setToolTip( "Toggle Sagittal Slice" );
button->getButton()->setMaximumSize( 24, 24 );
button->getButton()->setIcon( m_iconManager.getIcon( "sagittal" ) );
m_permanentToolBar->addWidget( button );
}
}
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
}
void WMainWindow::setupCompatiblesToolBar()
......@@ -382,6 +409,22 @@ void WMainWindow::customEvent( QEvent* event )
}
}
bool WMainWindow::event( QEvent* event )
{
// a module got associated with the root container -> add it to the list
if ( event->type() == WQT_READY_EVENT )
{
// convert event to ready event
WModuleReadyEvent* e1 = dynamic_cast< WModuleReadyEvent* >( event ); // NOLINT
if ( e1 )
{
moduleSpecificSetup( e1->getModule() );
}
}
return QMainWindow::event( event );
}
boost::shared_ptr< WQtCustomDockWidget > WMainWindow::getCustomDockWidget( std::string title )
{
boost::mutex::scoped_lock lock( m_customDockWidgetsLock );
......
......@@ -126,6 +126,13 @@ public:
protected:
/**
* Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
*
* \param module the module to setup the GUI for.
*/
void moduleSpecificSetup( boost::shared_ptr< WModule > module );
/**
* We want to react on close events.
*
......@@ -141,6 +148,17 @@ protected:
*/
virtual void customEvent( QEvent* event );
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
* processes several custom events, like WModuleAssocEvent.
*
* \note QT Doc says: use event() for custom events.
* \param event the event that got transmitted.
*
* \return true if the event got handled properly.
*/
virtual bool event( QEvent* event );
public slots:
/**
* gets called when menu option or toolbar button load is activated
......
......@@ -177,6 +177,7 @@ void WQt4Gui::slotActivateDatasetOrModuleInBrowser( boost::shared_ptr< WModule >
{
// create a new event for this and insert it into event queue
QCoreApplication::postEvent( m_mainWindow->getDatasetBrowser(), new WModuleReadyEvent( module ) );
QCoreApplication::postEvent( m_mainWindow, new WModuleReadyEvent( module ) );
}
std::vector< boost::shared_ptr< WDataSet > > WQt4Gui::getDataSetList( int subjectId, bool onlyTextures )
......
......@@ -26,21 +26,33 @@
#include "../../../common/WPropertyVariable.h"
WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* propertyGrid, QWidget* parent, bool asButton ):
WPropertyWidget( property, propertyGrid, parent ),
m_boolProperty( property ),
m_checkbox( this ),
m_layout()
m_button( this ),
m_layout(),
m_asButton( asButton )
{
// initialize members
m_button.setCheckable( true );
m_checkbox.setChecked( m_boolProperty->get() );
m_button.setChecked( m_boolProperty->get() );
// layout both against each other
m_layout.addWidget( &m_checkbox );
m_button.setVisible( asButton );
m_checkbox.setVisible( !asButton );
m_layout.addWidget( asButton ? static_cast< QWidget* >( &m_button ) : static_cast< QWidget* >( &m_checkbox ) );
if ( asButton )
{
m_layout.setContentsMargins( 1, 1, 1, 1 );
}
setLayout( &m_layout );
// connect the modification signal of m_checkbox with our callback
connect( &m_checkbox, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) );
connect( &m_button, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) );
}
WPropertyBoolWidget::~WPropertyBoolWidget()
......@@ -48,9 +60,21 @@ WPropertyBoolWidget::~WPropertyBoolWidget()
// cleanup
}
QPushButton* WPropertyBoolWidget::getButton()
{
return &m_button;
}
void WPropertyBoolWidget::changed()
{
// set the value
invalidate( !m_boolProperty->set( m_checkbox.isChecked() ) );
if ( m_asButton )
{
invalidate( !m_boolProperty->set( m_button.isChecked() ) );
}
else
{
invalidate( !m_boolProperty->set( m_checkbox.isChecked() ) );
}
}
......@@ -28,6 +28,7 @@
#include <string>
#include <QtGui/QCheckBox>
#include <QtGui/QPushButton>
#include <QtGui/QHBoxLayout>
#include "WPropertyWidget.h"
......@@ -46,14 +47,23 @@ public:
* \param property the property to handle
* \param parent the parent widget.
* \param propertyGrid the grid used to layout the labels and property widgets
* \param asButton display the property as toggle button.
*/
WPropertyBoolWidget( WPropBool property, QGridLayout* propertyGrid, QWidget* parent = 0 );
WPropertyBoolWidget( WPropBool property, QGridLayout* propertyGrid, QWidget* parent = 0, bool asButton = false );
/**
* Destructor.
*/
virtual ~WPropertyBoolWidget();
/**
* Returns the QT PushButton widget used if asButton has been true. It always returns a valid pointer. If asButtons has been false, the
* button is simply not visible.
*
* \return the button
*/
virtual QPushButton* getButton();
protected:
/**
......@@ -66,11 +76,21 @@ protected:
*/
QCheckBox m_checkbox;
/**
* If asButton is set to true: use this button instead of the m_checkbox
*/
QPushButton m_button;
/**
* Layout used to position the label and the checkbox
*/
QHBoxLayout m_layout;
/**
* Use the button instead of the checkbox to toggle the value.
*/
bool m_asButton;
private:
public slots:
......
......@@ -31,18 +31,22 @@ WPropertyWidget::WPropertyWidget( boost::shared_ptr< WPropertyBase > property,
m_property( property ),
m_propertyGrid( propertyGrid ),
m_label( this ),
m_useLabel( m_propertyGrid ),
m_invalid( false )
{
// initialize members
m_label.setText( property->getName().c_str() );
// set tooltips
m_label.setToolTip( getTooltip().c_str() );
setToolTip( m_label.toolTip() );
if ( m_useLabel )
{
// initialize members
m_label.setText( property->getName().c_str() );
// set tooltips
m_label.setToolTip( getTooltip().c_str() );
setToolTip( m_label.toolTip() );
// setup grid layout
int row = m_propertyGrid->rowCount();
m_propertyGrid->addWidget( &m_label, row, 0 );
m_propertyGrid->addWidget( this, row, 1 );
// setup grid layout
int row = m_propertyGrid->rowCount();
m_propertyGrid->addWidget( &m_label, row, 0 );
m_propertyGrid->addWidget( this, row, 1 );
}
}
WPropertyWidget::~WPropertyWidget()
......@@ -68,17 +72,20 @@ void WPropertyWidget::invalidate( bool invalid )
{
m_invalid = invalid;
// update tooltip
m_label.setToolTip( getTooltip().c_str() );
setToolTip( m_label.toolTip() );
if ( invalid )
if ( m_useLabel )
{
m_label.setText( ( "<font color=#FF0000><b>" + m_property->getName() + "</b></font>" ).c_str() );
}
else
{
m_label.setText( m_property->getName().c_str() );
// update tooltip
m_label.setToolTip( getTooltip().c_str() );
setToolTip( m_label.toolTip() );
if ( invalid )
{
m_label.setText( ( "<font color=#FF0000><b>" + m_property->getName() + "</b></font>" ).c_str() );
}
else
{
m_label.setText( m_property->getName().c_str() );
}
}
}
......@@ -97,6 +97,11 @@ protected:
*/
QLabel m_label;
/**
* If set to true, the widgets uses the control layout to combine the widget with a label
*/
bool m_useLabel;
/**
* Flag denoting whether the widget is set to an invalid value.
*/
......
......@@ -182,7 +182,7 @@ const std::set<boost::shared_ptr< WModuleOutputConnector > >& WModule::getOutput
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleInputConnector > >::iterator listIter = m_inputConnectors.begin();
for( std::set<boost::shared_ptr< WModuleInputConnector > >::const_iterator listIter = m_inputConnectors.begin();
listIter != m_inputConnectors.end(); ++listIter )
{
// try the canonical name
......@@ -198,7 +198,7 @@ boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::stri
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleOutputConnector > >::iterator listIter = m_outputConnectors.begin();
for( std::set<boost::shared_ptr< WModuleOutputConnector > >::const_iterator listIter = m_outputConnectors.begin();
listIter != m_outputConnectors.end(); ++listIter )
{
// try the canonical name
......
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