diff --git a/Modules/QtWidgets/include/QmitkInteractionSchemeToolBar.h b/Modules/QtWidgets/include/QmitkInteractionSchemeToolBar.h index d230c84a77..cda66228aa 100644 --- a/Modules/QtWidgets/include/QmitkInteractionSchemeToolBar.h +++ b/Modules/QtWidgets/include/QmitkInteractionSchemeToolBar.h @@ -1,56 +1,55 @@ /*============================================================================ 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. ============================================================================*/ #ifndef QMITKINTERACTIONSCHEMETOOLBAR_H #define QMITKINTERACTIONSCHEMETOOLBAR_H #include "MitkQtWidgetsExports.h" // mitk core #include "mitkInteractionSchemeSwitcher.h" #include #include /** * @brief * * */ class MITKQTWIDGETS_EXPORT QmitkInteractionSchemeToolBar : public QToolBar { Q_OBJECT public: using InteractionScheme = mitk::InteractionSchemeSwitcher::InteractionScheme; QmitkInteractionSchemeToolBar(QWidget* parent = nullptr); ~QmitkInteractionSchemeToolBar() override; void SetInteractionEventHandler(mitk::InteractionEventHandler::Pointer interactionEventHandler); protected Q_SLOTS: void AddButton(InteractionScheme id, const QString& toolName, const QIcon& icon, bool on = false); void OnInteractionSchemeChanged(); private: QActionGroup* m_ActionGroup; - mitk::InteractionSchemeSwitcher::Pointer m_InteractionSchemeSwitcher; mitk::InteractionEventHandler::Pointer m_InteractionEventHandler; }; #endif // QMITKINTERACTIONSCHEMETOOLBAR_H diff --git a/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp b/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp index 4dd306314c..adb126da5e 100644 --- a/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp +++ b/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp @@ -1,95 +1,90 @@ /*============================================================================ 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; } 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) + auto interactionSchemeSwitcher = mitk::InteractionSchemeSwitcher::New(); + try { - try - { - m_InteractionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, interactionScheme); - } - catch (const mitk::Exception&) - { - return; - } + interactionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, interactionScheme); + } + catch (const mitk::Exception &) + { + return; } } }