diff --git a/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp b/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp index 383e3cdfcc..4dd306314c 100644 --- a/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp +++ b/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp @@ -1,106 +1,95 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkInteractionSchemeToolBar.h" #include QmitkInteractionSchemeToolBar::QmitkInteractionSchemeToolBar(QWidget* parent/* = nullptr*/) : QToolBar(parent) , m_ActionGroup(new QActionGroup(this)) , m_InteractionSchemeSwitcher(nullptr) , m_InteractionEventHandler(nullptr) { QToolBar::setOrientation(Qt::Vertical); QToolBar::setIconSize(QSize(17, 17)); QToolBar::setFixedWidth(33); m_ActionGroup->setExclusive(false); // allow having no action selected AddButton(InteractionScheme::PACSStandard, tr("Pointer"), QIcon(":/Qmitk/mm_pointer.png"), true); AddButton(InteractionScheme::PACSLevelWindow, tr("Level/Window"), QIcon(":/Qmitk/mm_contrast.png")); AddButton(InteractionScheme::PACSPan, tr("Pan"), QIcon(":/Qmitk/mm_pan.png")); AddButton(InteractionScheme::PACSScroll, tr("Scroll"), QIcon(":/Qmitk/mm_scroll.png")); AddButton(InteractionScheme::PACSZoom, tr("Zoom"), QIcon(":/Qmitk/mm_zoom.png")); m_InteractionSchemeSwitcher = mitk::InteractionSchemeSwitcher::New(); } QmitkInteractionSchemeToolBar::~QmitkInteractionSchemeToolBar() { // nothing here } void QmitkInteractionSchemeToolBar::SetInteractionEventHandler(mitk::InteractionEventHandler::Pointer interactionEventHandler) { if (interactionEventHandler == m_InteractionEventHandler) { return; } m_InteractionEventHandler = interactionEventHandler; - if (nullptr != m_InteractionSchemeSwitcher) - { - try - { - m_InteractionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, InteractionScheme::PACSStandard); - } - catch (const mitk::Exception&) - { - return; - } - } } void QmitkInteractionSchemeToolBar::AddButton(InteractionScheme interactionScheme, const QString& toolName, const QIcon& icon, bool on) { QAction* action = new QAction(icon, toolName, this); action->setCheckable(true); action->setActionGroup(m_ActionGroup); action->setChecked(on); action->setData(interactionScheme); connect(action, &QAction::triggered, this, &QmitkInteractionSchemeToolBar::OnInteractionSchemeChanged); QToolBar::addAction(action); } void QmitkInteractionSchemeToolBar::OnInteractionSchemeChanged() { QAction* action = dynamic_cast(sender()); if (nullptr != action) { for (auto actionIter : m_ActionGroup->actions()) { if (actionIter != action) { actionIter->setChecked(false); } } InteractionScheme interactionScheme = static_cast(action->data().toInt()); // If the selected option is unchecked, use the base interaction with no primary tool if (!action->isChecked()) { interactionScheme = InteractionScheme::PACSBase; } if (nullptr != m_InteractionSchemeSwitcher) { try { m_InteractionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, interactionScheme); } catch (const mitk::Exception&) { return; } } } }