Display the tool selection state of a mitk::ToolManager. More...
#include <QmitkToolSelectionBox.h>
Display the tool selection state of a mitk::ToolManager.
There is a separate page describing the general design of QmitkInteractiveSegmentation: QmitkInteractiveSegmentationTechnicalPage
This widget graphically displays the active tool of a mitk::ToolManager as a set of toggle buttons. Each button show the identification of a Tool (icon and name). When a button's toggle state is "down", the tool is activated. When a different button is clicked, the active tool is switched. When you click an already active button, the associated tool is deactivated with no replacement, which means that no tool is active then.
When this widget is enabled/disabled it (normally) also enables/disables the tools. There could be cases where two QmitkToolSelectionBox widgets are associated to the same ToolManager, but if this happens, please look deeply into the code.
Last contributor:
Definition at line 57 of file QmitkToolSelectionBox.h.
EnabledWithReferenceAndWorkingData | |
EnabledWithReferenceData | |
EnabledWithWorkingData | |
AlwaysEnabled |
Definition at line 64 of file QmitkToolSelectionBox.h.
QmitkToolSelectionBox::QmitkToolSelectionBox | ( | QWidget * | parent = 0 , |
mitk::DataStorage * | storage = 0 |
||
) |
Definition at line 32 of file QmitkToolSelectionBox.cpp.
References m_ToolButtonGroup, m_ToolManager, mitk::ToolManager::New(), OnToolManagerReferenceDataModified(), OnToolManagerToolModified(), OnToolManagerWorkingDataModified(), RecreateButtons(), setEnabled(), SetOrUnsetButtonForActiveTool(), and toolButtonClicked().
:QWidget(parent), m_SelfCall(false), m_DisplayedGroups("default"), m_LayoutColumns(2), m_ShowNames(true), m_GenerateAccelerators(false), m_ToolGUIWidget(NULL), m_LastToolGUI(NULL), m_ToolButtonGroup(NULL), m_ButtonLayout(NULL), m_EnabledMode(EnabledWithReferenceAndWorkingData) { QFont currentFont = QWidget::font(); currentFont.setBold(true); QWidget::setFont( currentFont ); m_ToolManager = mitk::ToolManager::New( storage ); // muellerm // QButtonGroup m_ToolButtonGroup = new QButtonGroup(this); // some features of QButtonGroup m_ToolButtonGroup->setExclusive( false ); // mutually exclusive toggle buttons RecreateButtons(); QWidget::setContentsMargins(0, 0, 0, 0); if ( layout() != NULL ) { layout()->setContentsMargins(0, 0, 0, 0); } // reactions to signals connect( m_ToolButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(toolButtonClicked(int)) ); // reactions to ToolManager events m_ToolManager->ActiveToolChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); // show active tool SetOrUnsetButtonForActiveTool(); QWidget::setEnabled( false ); }
QmitkToolSelectionBox::~QmitkToolSelectionBox | ( | ) | [virtual] |
Definition at line 80 of file QmitkToolSelectionBox.cpp.
References m_ToolManager, OnToolManagerReferenceDataModified(), OnToolManagerToolModified(), and OnToolManagerWorkingDataModified().
{ m_ToolManager->ActiveToolChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); }
mitk::ToolManager * QmitkToolSelectionBox::GetToolManager | ( | ) |
Definition at line 94 of file QmitkToolSelectionBox.cpp.
References m_ToolManager.
Referenced by QmitkSegmentationView::CheckImageAlignment(), QmitkSegmentationView::CreateNewSegmentation(), QmitkSegmentationView::CreateQtPartControl(), QmitkSegmentationView::CreateSegmentationFromSurface(), QmitkSegmentationView::Deactivated(), QmitkSegmentationView::ForceDisplayPreferencesUponAllImages(), QmitkSegmentationView::NewNodeObjectsGenerated(), QmitkSegmentationView::SetMultiWidget(), QmitkSegmentationView::SetToolManagerSelection(), and QmitkSegmentationView::ToolboxStackPageChanged().
{ return m_ToolManager; }
void QmitkToolSelectionBox::hideEvent | ( | QHideEvent * | e ) | [protected] |
Definition at line 628 of file QmitkToolSelectionBox.cpp.
References SetGUIEnabledAccordingToToolManagerState().
void QmitkToolSelectionBox::OnGeneralToolMessage | ( | std::string | s ) |
Definition at line 560 of file QmitkToolSelectionBox.cpp.
Referenced by RecreateButtons().
{
QMessageBox::information(NULL, "MITK", QString( s.c_str() ), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
}
void QmitkToolSelectionBox::OnToolErrorMessage | ( | std::string | s ) |
Definition at line 555 of file QmitkToolSelectionBox.cpp.
Referenced by RecreateButtons().
{
QMessageBox::critical(NULL, "MITK", QString( s.c_str() ), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
}
void QmitkToolSelectionBox::OnToolGUIProcessEventsMessage | ( | ) |
Definition at line 550 of file QmitkToolSelectionBox.cpp.
Referenced by RecreateButtons().
{ qApp->processEvents(); }
void QmitkToolSelectionBox::OnToolManagerReferenceDataModified | ( | ) |
Definition at line 271 of file QmitkToolSelectionBox.cpp.
References m_SelfCall, MITK_DEBUG, and SetGUIEnabledAccordingToToolManagerState().
Referenced by QmitkToolSelectionBox(), SetToolManager(), and ~QmitkToolSelectionBox().
{ if (m_SelfCall) return; MITK_DEBUG << "OnToolManagerReferenceDataModified()"; SetGUIEnabledAccordingToToolManagerState(); }
void QmitkToolSelectionBox::OnToolManagerToolModified | ( | ) |
Definition at line 159 of file QmitkToolSelectionBox.cpp.
References SetOrUnsetButtonForActiveTool().
Referenced by QmitkToolSelectionBox(), SetToolManager(), and ~QmitkToolSelectionBox().
void QmitkToolSelectionBox::OnToolManagerWorkingDataModified | ( | ) |
Definition at line 280 of file QmitkToolSelectionBox.cpp.
References m_SelfCall, MITK_DEBUG, and SetGUIEnabledAccordingToToolManagerState().
Referenced by QmitkToolSelectionBox(), SetToolManager(), and ~QmitkToolSelectionBox().
{ if (m_SelfCall) return; MITK_DEBUG << "OnToolManagerWorkingDataModified()"; SetGUIEnabledAccordingToToolManagerState(); }
void QmitkToolSelectionBox::RecreateButtons | ( | ) | [protected] |
Definition at line 348 of file QmitkToolSelectionBox.cpp.
References mitk::Tool::ErrorMessage, mitk::Tool::GeneralMessage, mitk::Tool::GetGroup(), mitk::Tool::GetName(), mitk::Tool::GetXPM(), mitk::Tool::GUIProcessEventsMessage, m_ButtonIDForToolID, m_ButtonLayout, m_DisplayedGroups, m_GenerateAccelerators, m_LayoutColumns, m_ShowNames, m_ToolButtonGroup, m_ToolIDForButtonID, m_ToolManager, MITK_DEBUG, OnGeneralToolMessage(), OnToolErrorMessage(), and OnToolGUIProcessEventsMessage().
Referenced by QmitkToolSelectionBox(), SetDisplayedToolGroups(), SetGenerateAccelerators(), SetLayoutColumns(), SetShowNames(), and SetToolManager().
{ if (m_ToolManager.IsNull()) return; /* // remove all buttons that are there QObjectList *l = Q3ButtonGroup::queryList( "QButton" ); QObjectListIt it( *l ); // iterate over all buttons QObject *obj; while ( (obj = it.current()) != 0 ) { ++it; QButton* button = dynamic_cast<QButton*>(obj); if (button) { Q3ButtonGroup::remove(button); delete button; } } delete l; // delete the list, not the objects */ // mmueller Qt4 impl QList<QAbstractButton *> l = m_ToolButtonGroup->buttons(); // remove all buttons that are there QList<QAbstractButton *>::iterator it; QAbstractButton * btn; for(it=l.begin(); it!=l.end();++it) { btn = *it; m_ToolButtonGroup->removeButton(btn); //this->removeChild(btn); delete btn; } // end mmueller Qt4 impl mitk::ToolManager::ToolVectorTypeConst allPossibleTools = m_ToolManager->GetTools(); mitk::ToolManager::ToolVectorTypeConst allTools; typedef std::pair< std::string::size_type, const mitk::Tool* > SortPairType; typedef std::priority_queue< SortPairType > SortedToolQueueType; SortedToolQueueType toolPositions; // clear and sort all tools // step one: find name/group of all tools in m_DisplayedGroups string. remember these positions for all tools. for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allPossibleTools.begin(); iter != allPossibleTools.end(); ++iter) { const mitk::Tool* tool = *iter; std::string::size_type namePos = m_DisplayedGroups.find( std::string("'") + tool->GetName() + "'" ); std::string::size_type groupPos = m_DisplayedGroups.find( std::string("'") + tool->GetGroup() + "'" ); if ( !m_DisplayedGroups.empty() && namePos == std::string::npos && groupPos == std::string::npos ) continue; // skip if ( m_DisplayedGroups.empty() && std::string(tool->GetName()).length() > 0 ) { namePos = static_cast<std::string::size_type> (tool->GetName()[0]); } SortPairType thisPair = std::make_pair( namePos < groupPos ? namePos : groupPos, *iter ); toolPositions.push( thisPair ); } // step two: sort tools according to previously found positions in m_DisplayedGroups MITK_DEBUG << "Sorting order of tools (lower number --> earlier in button group)"; while ( !toolPositions.empty() ) { SortPairType thisPair = toolPositions.top(); MITK_DEBUG << "Position " << thisPair.first << " : " << thisPair.second->GetName(); allTools.push_back( thisPair.second ); toolPositions.pop(); } std::reverse( allTools.begin(), allTools.end() ); MITK_DEBUG << "Sorted tools:"; for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter) { MITK_DEBUG << (*iter)->GetName(); } // try to change layout... bad? //Q3GroupBox::setColumnLayout ( m_LayoutColumns, Qt::Horizontal ); // mmueller using gridlayout instead of Q3GroupBox //this->setLayout(0); if(m_ButtonLayout == NULL) m_ButtonLayout = new QGridLayout; /*else delete m_ButtonLayout;*/ int row(0); int column(-1); int currentButtonID(0); m_ButtonIDForToolID.clear(); m_ToolIDForButtonID.clear(); QToolButton* button = 0; MITK_DEBUG << "Creating buttons for tools"; // fill group box with buttons for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter) { const mitk::Tool* tool = *iter; int currentToolID( m_ToolManager->GetToolID( tool ) ); ++column; // new line if we are at the maximum columns if(column == m_LayoutColumns) { ++row; column = 0; } button = new QToolButton; button->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); // add new button to the group MITK_DEBUG << "Adding button with ID " << currentToolID; m_ToolButtonGroup->addButton(button, currentButtonID); // ... and to the layout MITK_DEBUG << "Adding button in row/column " << row << "/" << column; m_ButtonLayout->addWidget(button, row, column); if (m_LayoutColumns == 1) { //button->setTextPosition( QToolButton::BesideIcon ); // mmueller button->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); } else { //button->setTextPosition( QToolButton::BelowIcon ); // mmueller button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); } //button->setToggleButton( true ); // mmueller button->setCheckable ( true ); QString label; if (m_GenerateAccelerators) { label += "&"; } label += tool->GetName(); QString tooltip = tool->GetName(); MITK_DEBUG << tool->GetName() << ", " << label.toLocal8Bit().constData() << ", '" << tooltip.toLocal8Bit().constData(); if ( m_ShowNames ) { /* button->setUsesTextLabel(true); button->setTextLabel( label ); // a label QToolTip::add( button, tooltip ); */ // mmueller Qt4 button->setText( label ); // a label button->setToolTip( tooltip ); // mmueller QFont currentFont = button->font(); currentFont.setBold(false); button->setFont( currentFont ); } //button->setPixmap( QPixmap( tool->GetXPM() ) ); // an icon // mmueller button->setIcon( QIcon( QPixmap( tool->GetXPM() ) ) ); // an icon if (m_GenerateAccelerators) { QString firstLetter = QString( tool->GetName() ); firstLetter.truncate( 1 ); button->setShortcut( firstLetter ); // a keyboard shortcut (just the first letter of the given name w/o any CTRL or something) } m_ButtonIDForToolID[currentToolID] = currentButtonID; m_ToolIDForButtonID[currentButtonID] = currentToolID; MITK_DEBUG << "m_ButtonIDForToolID[" << currentToolID << "] == " << currentButtonID; MITK_DEBUG << "m_ToolIDForButtonID[" << currentButtonID << "] == " << currentToolID; tool->GUIProcessEventsMessage += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolGUIProcessEventsMessage ); // will never add a listener twice, so we don't have to check here tool->ErrorMessage += mitk::MessageDelegate1<QmitkToolSelectionBox, std::string>( this, &QmitkToolSelectionBox::OnToolErrorMessage ); // will never add a listener twice, so we don't have to check here tool->GeneralMessage += mitk::MessageDelegate1<QmitkToolSelectionBox, std::string>( this, &QmitkToolSelectionBox::OnGeneralToolMessage ); ++currentButtonID; } // setting grid layout for this groupbox this->setLayout(m_ButtonLayout); //this->update(); }
void QmitkToolSelectionBox::SetDisplayedToolGroups | ( | const std::string & | toolGroups = 0 ) |
You may specify a list of tool "groups" that should be displayed in this widget. Every Tool can report its group as a string. This method will try to find the tool's group inside the supplied string
toolGroups. | If there is a match, the tool is displayed. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff". |
Definition at line 566 of file QmitkToolSelectionBox.cpp.
References m_DisplayedGroups, MITK_DEBUG, RecreateButtons(), and SetOrUnsetButtonForActiveTool().
Referenced by QmitkSegmentationView::CreateQtPartControl().
{ if (m_DisplayedGroups != toolGroups) { QString q_DisplayedGroups = toolGroups.c_str(); // quote all unquoted single words q_DisplayedGroups = q_DisplayedGroups.replace( QRegExp("\\b(\\w+)\\b|'([^']+)'"), "'\\1\\2'" ); MITK_DEBUG << "m_DisplayedGroups was \"" << toolGroups << "\""; m_DisplayedGroups = q_DisplayedGroups.toLocal8Bit().constData(); MITK_DEBUG << "m_DisplayedGroups is \"" << m_DisplayedGroups << "\""; RecreateButtons(); SetOrUnsetButtonForActiveTool(); } }
void QmitkToolSelectionBox::setEnabled | ( | bool | enable ) | [virtual, slot] |
External enableization...
Definition at line 341 of file QmitkToolSelectionBox.cpp.
References SetGUIEnabledAccordingToToolManagerState().
Referenced by QmitkSegmentationView::Activated(), QmitkSegmentationView::Deactivated(), QmitkToolSelectionBox(), and SetGUIEnabledAccordingToToolManagerState().
{ QWidget::setEnabled(enable); SetGUIEnabledAccordingToToolManagerState(); }
void QmitkToolSelectionBox::SetEnabledMode | ( | EnabledMode | mode ) | [virtual, slot] |
Definition at line 88 of file QmitkToolSelectionBox.cpp.
References m_EnabledMode, and SetGUIEnabledAccordingToToolManagerState().
Referenced by QmitkSegmentationView::CreateQtPartControl().
{ m_EnabledMode = mode; SetGUIEnabledAccordingToToolManagerState(); }
void QmitkToolSelectionBox::SetGenerateAccelerators | ( | bool | accel ) | [virtual, slot] |
Definition at line 602 of file QmitkToolSelectionBox.cpp.
References m_GenerateAccelerators, and RecreateButtons().
Referenced by QmitkSegmentationView::CreateQtPartControl().
{ if (accel != m_GenerateAccelerators) { m_GenerateAccelerators = accel; RecreateButtons(); } }
void QmitkToolSelectionBox::SetGUIEnabledAccordingToToolManagerState | ( | ) | [protected, slot] |
Implementes the logic, which decides, when tools are activated/deactivated.
Definition at line 292 of file QmitkToolSelectionBox.cpp.
References AlwaysEnabled, EnabledWithReferenceAndWorkingData, EnabledWithReferenceData, EnabledWithWorkingData, m_EnabledMode, m_ToolManager, setEnabled(), and ToolSelected().
Referenced by hideEvent(), OnToolManagerReferenceDataModified(), OnToolManagerWorkingDataModified(), setEnabled(), SetEnabledMode(), and showEvent().
{ mitk::DataNode* referenceNode = m_ToolManager->GetReferenceData(0); mitk::DataNode* workingNode = m_ToolManager->GetWorkingData(0); //MITK_DEBUG << this->name() << ": SetGUIEnabledAccordingToToolManagerState: referenceNode " << (void*)referenceNode << " workingNode " << (void*)workingNode << " isVisible() " << isVisible(); bool enabled = true; switch ( m_EnabledMode ) { default: case EnabledWithReferenceAndWorkingData: enabled = referenceNode && workingNode && isVisible(); break; case EnabledWithReferenceData: enabled = referenceNode && isVisible(); break; case EnabledWithWorkingData: enabled = workingNode && isVisible(); break; case AlwaysEnabled: enabled = isVisible(); break; } if ( QWidget::isEnabled() == enabled ) return; // nothing to change QWidget::setEnabled( enabled ); if (enabled) { m_ToolManager->RegisterClient(); int id = m_ToolManager->GetActiveToolID(); emit ToolSelected(id); } else { m_ToolManager->ActivateTool(-1); m_ToolManager->UnregisterClient(); emit ToolSelected(-1); } }
void QmitkToolSelectionBox::SetLayoutColumns | ( | int | columns ) | [virtual, slot] |
Definition at line 583 of file QmitkToolSelectionBox.cpp.
References m_LayoutColumns, and RecreateButtons().
{ if (columns > 0 && columns != m_LayoutColumns) { m_LayoutColumns = columns; RecreateButtons(); } }
void QmitkToolSelectionBox::SetOrUnsetButtonForActiveTool | ( | ) | [protected] |
Definition at line 164 of file QmitkToolSelectionBox.cpp.
References mitk::Tool::GetGroup(), mitk::Tool::GetGUI(), m_ButtonIDForToolID, m_LastToolGUI, m_ToolButtonGroup, m_ToolGUIWidget, m_ToolManager, QmitkToolGUI::SetTool(), and ToolSelected().
Referenced by OnToolManagerToolModified(), QmitkToolSelectionBox(), SetDisplayedToolGroups(), and SetToolManager().
{ // we want to emit a signal in any case, whether we selected ourselves or somebody else changes "our" tool manager. --> emit before check on m_SelfCall int id = m_ToolManager->GetActiveToolID(); // don't emit signal for shape model tools bool emitSignal = true; mitk::Tool* tool = m_ToolManager->GetActiveTool(); if(tool && std::string(tool->GetGroup()) == "organ_segmentation") emitSignal = false; if(emitSignal) emit ToolSelected(id); // delete old GUI (if any) if ( m_LastToolGUI && m_ToolGUIWidget ) { if (m_ToolGUIWidget->layout()) { m_ToolGUIWidget->layout()->removeWidget(m_LastToolGUI); } //m_LastToolGUI->reparent(NULL, QPoint(0,0)); // TODO: reparent <-> setParent, Daniel fragen m_LastToolGUI->setParent(0); delete m_LastToolGUI; // will hopefully notify parent and layouts m_LastToolGUI = NULL; QLayout* layout = m_ToolGUIWidget->layout(); if (layout) { layout->activate(); } } QToolButton* toolButton(NULL); //mitk::Tool* tool = m_ToolManager->GetActiveTool(); if (m_ButtonIDForToolID.find(id) != m_ButtonIDForToolID.end()) // if this tool is in our box { //toolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( m_ButtonIDForToolID[id] ) ); toolButton = dynamic_cast<QToolButton*>( m_ToolButtonGroup->buttons().at( m_ButtonIDForToolID[id] ) ); } if ( toolButton ) { // mmueller // uncheck all other buttons QAbstractButton* tmpBtn = 0; QList<QAbstractButton*>::iterator it; for(int i=0; i < m_ToolButtonGroup->buttons().size(); ++i) { tmpBtn = m_ToolButtonGroup->buttons().at(i); if(tmpBtn != toolButton) dynamic_cast<QToolButton*>( tmpBtn )->setChecked(false); } toolButton->setChecked(true); if (m_ToolGUIWidget && tool) { // create and reparent new GUI (if any) itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI").GetPointer(); // prefix and postfix QmitkToolGUI* gui = dynamic_cast<QmitkToolGUI*>( possibleGUI.GetPointer() ); m_LastToolGUI = gui; if (gui) { gui->SetTool( tool ); // mmueller //gui->reparent(m_ToolGUIWidget, gui->geometry().topLeft(), true ); gui->setParent(m_ToolGUIWidget); gui->move(gui->geometry().topLeft()); gui->show(); QLayout* layout = m_ToolGUIWidget->layout(); if (!layout) { layout = new QVBoxLayout( m_ToolGUIWidget ); } if (layout) { // mmueller layout->addWidget( gui ); //layout->add( gui ); layout->activate(); } } } } else { // disable all buttons QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( m_ToolButtonGroup->checkedButton() ); //QToolButton* selectedToolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find( Q3ButtonGroup::selectedId() ) ); if (selectedToolButton) { // mmueller selectedToolButton->setChecked(false); //selectedToolButton->setOn(false); } } }
void QmitkToolSelectionBox::SetShowNames | ( | bool | show ) | [virtual, slot] |
Definition at line 592 of file QmitkToolSelectionBox.cpp.
References m_ShowNames, and RecreateButtons().
{ if (show != m_ShowNames) { m_ShowNames = show; RecreateButtons(); } }
void QmitkToolSelectionBox::setTitle | ( | const QString & | title ) |
Definition at line 617 of file QmitkToolSelectionBox.cpp.
{ }
void QmitkToolSelectionBox::SetToolGUIArea | ( | QWidget * | parentWidget ) | [virtual, slot] |
Definition at line 612 of file QmitkToolSelectionBox.cpp.
References m_ToolGUIWidget.
Referenced by QmitkSegmentationView::CreateQtPartControl().
{ m_ToolGUIWidget = parentWidget; }
void QmitkToolSelectionBox::SetToolManager | ( | mitk::ToolManager & | newManager ) |
Definition at line 99 of file QmitkToolSelectionBox.cpp.
References m_ToolManager, OnToolManagerReferenceDataModified(), OnToolManagerToolModified(), OnToolManagerWorkingDataModified(), RecreateButtons(), and SetOrUnsetButtonForActiveTool().
Referenced by QmitkSegmentationView::CreateQtPartControl().
{ // say bye to the old manager m_ToolManager->ActiveToolChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged -= mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); if ( QWidget::isEnabled() ) { m_ToolManager->UnregisterClient(); } m_ToolManager = &newManager; RecreateButtons(); // greet the new one m_ToolManager->ActiveToolChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerToolModified ); m_ToolManager->ReferenceDataChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerReferenceDataModified ); m_ToolManager->WorkingDataChanged += mitk::MessageDelegate<QmitkToolSelectionBox>( this, &QmitkToolSelectionBox::OnToolManagerWorkingDataModified ); if ( QWidget::isEnabled() ) { m_ToolManager->RegisterClient(); } // ask the new one what the situation is like SetOrUnsetButtonForActiveTool(); }
void QmitkToolSelectionBox::showEvent | ( | QShowEvent * | e ) | [protected] |
Definition at line 621 of file QmitkToolSelectionBox.cpp.
References SetGUIEnabledAccordingToToolManagerState().
void QmitkToolSelectionBox::toolButtonClicked | ( | int | id ) | [protected, slot] |
Definition at line 128 of file QmitkToolSelectionBox.cpp.
References m_ButtonIDForToolID, m_SelfCall, m_ToolButtonGroup, m_ToolIDForButtonID, m_ToolManager, and MITK_DEBUG.
Referenced by QmitkToolSelectionBox().
{ if ( !QWidget::isEnabled() ) return; // this method could be triggered from the constructor, when we are still disabled MITK_DEBUG << "toolButtonClicked(" << id << "): id translates to tool ID " << m_ToolIDForButtonID[id]; //QToolButton* toolButton = dynamic_cast<QToolButton*>( Q3ButtonGroup::find(id) ); QToolButton* toolButton = dynamic_cast<QToolButton*>( m_ToolButtonGroup->buttons().at(id) ); if (toolButton) { if ( (m_ButtonIDForToolID.find( m_ToolManager->GetActiveToolID() ) != m_ButtonIDForToolID.end()) // if we have this tool in our box && (m_ButtonIDForToolID[ m_ToolManager->GetActiveToolID() ] == id) ) // the tool corresponding to this button is already active { // disable this button, disable all tools // mmueller toolButton->setChecked(false); m_ToolManager->ActivateTool(-1); // disable everything } else { // enable the corresponding tool m_SelfCall = true; m_ToolManager->ActivateTool( m_ToolIDForButtonID[id] ); m_SelfCall = false; } } }
void QmitkToolSelectionBox::ToolSelected | ( | int | id ) | [signal] |
Whenever a tool is activated. id is the index of the active tool. Counting starts at 0, -1 indicates "no tool selected" This signal is also emitted, when the whole QmitkToolSelectionBox get disabled. Then it will claim ToolSelected(-1) When it is enabled again, there will be another ToolSelected event with the tool that is currently selected
Referenced by SetGUIEnabledAccordingToToolManagerState(), and SetOrUnsetButtonForActiveTool().
std::map<int,int> QmitkToolSelectionBox::m_ButtonIDForToolID [protected] |
stores relationship between button IDs of the Qt widget and tool IDs of ToolManager
Definition at line 127 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), SetOrUnsetButtonForActiveTool(), and toolButtonClicked().
QGridLayout* QmitkToolSelectionBox::m_ButtonLayout [protected] |
Definition at line 140 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons().
std::string QmitkToolSelectionBox::m_DisplayedGroups [protected] |
Definition at line 124 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), and SetDisplayedToolGroups().
EnabledMode QmitkToolSelectionBox::m_EnabledMode [protected] |
Definition at line 142 of file QmitkToolSelectionBox.h.
Referenced by SetEnabledMode(), and SetGUIEnabledAccordingToToolManagerState().
bool QmitkToolSelectionBox::m_GenerateAccelerators [protected] |
Definition at line 133 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), and SetGenerateAccelerators().
QmitkToolGUI* QmitkToolSelectionBox::m_LastToolGUI [protected] |
Definition at line 136 of file QmitkToolSelectionBox.h.
Referenced by SetOrUnsetButtonForActiveTool().
int QmitkToolSelectionBox::m_LayoutColumns [protected] |
Definition at line 131 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), and SetLayoutColumns().
bool QmitkToolSelectionBox::m_SelfCall [protected] |
Definition at line 122 of file QmitkToolSelectionBox.h.
Referenced by OnToolManagerReferenceDataModified(), OnToolManagerWorkingDataModified(), and toolButtonClicked().
bool QmitkToolSelectionBox::m_ShowNames [protected] |
Definition at line 132 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), and SetShowNames().
QButtonGroup* QmitkToolSelectionBox::m_ToolButtonGroup [protected] |
Definition at line 139 of file QmitkToolSelectionBox.h.
Referenced by QmitkToolSelectionBox(), RecreateButtons(), SetOrUnsetButtonForActiveTool(), and toolButtonClicked().
QWidget* QmitkToolSelectionBox::m_ToolGUIWidget [protected] |
Definition at line 135 of file QmitkToolSelectionBox.h.
Referenced by SetOrUnsetButtonForActiveTool(), and SetToolGUIArea().
std::map<int,int> QmitkToolSelectionBox::m_ToolIDForButtonID [protected] |
stores relationship between button IDs of the Qt widget and tool IDs of ToolManager
Definition at line 129 of file QmitkToolSelectionBox.h.
Referenced by RecreateButtons(), and toolButtonClicked().
Definition at line 120 of file QmitkToolSelectionBox.h.
Referenced by GetToolManager(), QmitkToolSelectionBox(), RecreateButtons(), SetGUIEnabledAccordingToToolManagerState(), SetOrUnsetButtonForActiveTool(), SetToolManager(), toolButtonClicked(), and ~QmitkToolSelectionBox().