diff --git a/Modules/Core/include/mitkInteractionSchemeSwitcher.h b/Modules/Core/include/mitkInteractionSchemeSwitcher.h index 1d1fe45713..139d6f0738 100644 --- a/Modules/Core/include/mitkInteractionSchemeSwitcher.h +++ b/Modules/Core/include/mitkInteractionSchemeSwitcher.h @@ -1,125 +1,116 @@ /*============================================================================ 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 MITKINTERACTIONSCHEMESWITCHER_H #define MITKINTERACTIONSCHEMESWITCHER_H #include "MitkCoreExports.h" #include "mitkInteractionEventHandler.h" #include namespace mitk { /*********************************************************************** * * \brief Class that offers a convenient way to switch between different * interaction schemes. * * This class offers the possibility to switch between the different * interaction schemes that are available: * * - MITKStandard : The original MITK interaction scheme * - MITKRotationUncoupled : A modified MITK interaction scheme with rotation * - MITKRotationCoupled : A modified MTIK interaction scheme with coupled rotation * - MITKSwivel : A modified MITK interaction scheme with plane swiveling * * - PACS : An alternative interaction scheme that behaves more like a * PACS workstation * - left mouse button : behavior depends on current PACS scheme * Always enabled: * - middle mouse button : fast scrolling * - right mouse button : level-window * - ctrl + right button : zooming * - shift+ right button : panning * * There are 6 different PACS schemes. * Each scheme defines the interaction that is performed on a left * mouse button click: * - PACSBase : No interaction on a left mouse button click - This scheme serves as a base for other PACS schemes and defines the right and middle mouse button clicks, which are available in every PACS scheme. * - PACSStandard : Sets the cross position for the MPR * - PACSLevelWindow : Sets the level window * - PACSPan : Moves the slice * - PACSScroll : Scrolls through the slices stepwise * - PACSZoom : Zooms into / out of the slice * * When the interaction scheme is changed, this class sets the corresponding * interaction .xml-files for a given interaction event handler. * ***********************************************************************/ + class MITKCORE_EXPORT InteractionSchemeSwitcher : public itk::Object { public: #pragma GCC visibility push(default) /** \brief Can be observed by GUI class to update button states when type is changed programmatically. */ itkEventMacro(InteractionSchemeChangedEvent, itk::AnyEvent); #pragma GCC visibility pop mitkClassMacroItkParent(InteractionSchemeSwitcher, itk::Object); itkFactorylessNewMacro(Self); - itkCloneMacro(Self); // enum of the different interaction schemes that are available enum InteractionScheme { MITKStandard = 0, MITKRotationUncoupled, MITKRotationCoupled, MITKSwivel, PACSBase, PACSStandard, PACSLevelWindow, PACSPan, PACSScroll, PACSZoom }; /** * @brief Set the current interaction scheme of the given interaction event handler * * The interaction event handler is able to accept xml-configuration files that will define the interaction scheme. * Based on the given interaction scheme different configuration files are loaded into the interaction event handler. * The interaction scheme can be a variant of the MITK-scheme or the PACS-scheme (see 'enum InteractionScheme'). * The default is 'MITKStandard'. * If the interaction scheme has been changed, an 'InteractionSchemeChangedEvent' will be invoked. * * @pre The interaction event handler has to be valid (!nullptr). * @throw mitk::Exception, if the interaction event handler is invalid (==nullptr). * * @param interactionEventHandler The interaction event handler that defines the interaction scheme via configuration files * @param interactionScheme The interaction scheme that should be used for the currently active interaction event handler. */ void SetInteractionScheme(mitk::InteractionEventHandler* interactionEventHandler, InteractionScheme interactionScheme); - /** - * @brief Return the current interaction scheme - * - * @return The currently set InteractionScheme - */ - InteractionScheme GetInteractionScheme() const { return m_InteractionScheme; }; protected: InteractionSchemeSwitcher(); ~InteractionSchemeSwitcher() override; - private: - - InteractionScheme m_InteractionScheme; }; } // namespace mitk #endif // MITKINTERACTIONSCHEMESWITCHER_H diff --git a/Modules/Core/src/Interactions/mitkInteractionSchemeSwitcher.cpp b/Modules/Core/src/Interactions/mitkInteractionSchemeSwitcher.cpp index 5de7de8a5f..0b104903dc 100644 --- a/Modules/Core/src/Interactions/mitkInteractionSchemeSwitcher.cpp +++ b/Modules/Core/src/Interactions/mitkInteractionSchemeSwitcher.cpp @@ -1,108 +1,102 @@ /*============================================================================ 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 "mitkInteractionSchemeSwitcher.h" -// us -#include -#include - // mitk core #include #include mitk::InteractionSchemeSwitcher::InteractionSchemeSwitcher() - : m_InteractionScheme(MITKStandard) { // nothing here } mitk::InteractionSchemeSwitcher::~InteractionSchemeSwitcher() { // nothing here } -void mitk::InteractionSchemeSwitcher::SetInteractionScheme(mitk::InteractionEventHandler* interactionEventHandler, InteractionScheme interactionScheme) +void mitk::InteractionSchemeSwitcher::SetInteractionScheme(InteractionEventHandler* interactionEventHandler, InteractionScheme interactionScheme) { if (nullptr == interactionEventHandler) { mitkThrow() << "Not a valid interaction event handler to set the interaction scheme."; } switch (interactionScheme) { // MITK MODE case MITKStandard: { interactionEventHandler->SetEventConfig("DisplayConfigMITK.xml"); break; } case MITKRotationUncoupled: { interactionEventHandler->SetEventConfig("DisplayConfigMITKRotationUnCoupled.xml"); break; } case MITKRotationCoupled: { interactionEventHandler->SetEventConfig("DisplayConfigMITKRotation.xml"); break; } case MITKSwivel: { interactionEventHandler->SetEventConfig("DisplayConfigMITKSwivel.xml"); break; } // PACS MODE case PACSBase: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); break; } case PACSStandard: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); interactionEventHandler->AddEventConfig("DisplayConfigPACSCrosshair.xml"); break; } case PACSLevelWindow: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); interactionEventHandler->AddEventConfig("DisplayConfigPACSLevelWindow.xml"); break; } case PACSPan: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); interactionEventHandler->AddEventConfig("DisplayConfigPACSPan.xml"); break; } case PACSScroll: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); interactionEventHandler->AddEventConfig("DisplayConfigPACSScroll.xml"); break; } case PACSZoom: { interactionEventHandler->SetEventConfig("DisplayConfigPACS.xml"); interactionEventHandler->AddEventConfig("DisplayConfigPACSZoom.xml"); break; } default: { interactionEventHandler->SetEventConfig("DisplayConfigMITK.xml"); } } - m_InteractionScheme = interactionScheme; InvokeEvent(InteractionSchemeChangedEvent()); } 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 383e3cdfcc..adb126da5e 100644 --- a/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp +++ b/Modules/QtWidgets/src/QmitkInteractionSchemeToolBar.cpp @@ -1,106 +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; - 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) + 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; } } } diff --git a/Plugins/org.mitk.gui.qt.mxnmultiwidgeteditor/src/QmitkMxNMultiWidgetEditor.cpp b/Plugins/org.mitk.gui.qt.mxnmultiwidgeteditor/src/QmitkMxNMultiWidgetEditor.cpp index e77de09d48..aa05008ddd 100644 --- a/Plugins/org.mitk.gui.qt.mxnmultiwidgeteditor/src/QmitkMxNMultiWidgetEditor.cpp +++ b/Plugins/org.mitk.gui.qt.mxnmultiwidgeteditor/src/QmitkMxNMultiWidgetEditor.cpp @@ -1,178 +1,174 @@ /*============================================================================ 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 "QmitkMxNMultiWidgetEditor.h" #include #include #include #include #include // mxn multi widget editor plugin #include "QmitkMultiWidgetDecorationManager.h" // mitk qt widgets module #include #include #include // qt #include const QString QmitkMxNMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.mxnmultiwidget"; struct QmitkMxNMultiWidgetEditor::Impl final { Impl(); ~Impl() = default; QmitkInteractionSchemeToolBar* m_InteractionSchemeToolBar; QmitkMultiWidgetConfigurationToolBar* m_ConfigurationToolBar; }; QmitkMxNMultiWidgetEditor::Impl::Impl() : m_InteractionSchemeToolBar(nullptr) , m_ConfigurationToolBar(nullptr) { // nothing here } ////////////////////////////////////////////////////////////////////////// // QmitkMxNMultiWidgetEditor ////////////////////////////////////////////////////////////////////////// QmitkMxNMultiWidgetEditor::QmitkMxNMultiWidgetEditor() : QmitkAbstractMultiWidgetEditor() , m_Impl(std::make_unique()) { // nothing here } QmitkMxNMultiWidgetEditor::~QmitkMxNMultiWidgetEditor() { GetSite()->GetPage()->RemovePartListener(this); } void QmitkMxNMultiWidgetEditor::OnLayoutSet(int row, int column) { const auto &multiWidget = dynamic_cast(GetMultiWidget()); if (nullptr != multiWidget) { multiWidget->SetCrosshairVisibility(true); QmitkAbstractMultiWidgetEditor::OnLayoutSet(row, column); } } void QmitkMxNMultiWidgetEditor::OnInteractionSchemeChanged(mitk::InteractionSchemeSwitcher::InteractionScheme scheme) { const auto &multiWidget = GetMultiWidget(); if (nullptr == multiWidget) { return; } if (mitk::InteractionSchemeSwitcher::PACSStandard == scheme) { m_Impl->m_InteractionSchemeToolBar->setVisible(true); } else { m_Impl->m_InteractionSchemeToolBar->setVisible(false); } QmitkAbstractMultiWidgetEditor::OnInteractionSchemeChanged(scheme); } ////////////////////////////////////////////////////////////////////////// // PRIVATE ////////////////////////////////////////////////////////////////////////// void QmitkMxNMultiWidgetEditor::SetFocus() { const auto& multiWidget = GetMultiWidget(); if (nullptr != multiWidget) { multiWidget->setFocus(); } } void QmitkMxNMultiWidgetEditor::CreateQtPartControl(QWidget* parent) { QHBoxLayout *layout = new QHBoxLayout(parent); layout->setContentsMargins(0, 0, 0, 0); berry::IBerryPreferences *preferences = dynamic_cast(GetPreferences().GetPointer()); auto multiWidget = GetMultiWidget(); if (nullptr == multiWidget) { multiWidget = new QmitkMxNMultiWidget(parent, 0, nullptr); // create left toolbar: interaction scheme toolbar to switch how the render window navigation behaves in PACS mode if (nullptr == m_Impl->m_InteractionSchemeToolBar) { m_Impl->m_InteractionSchemeToolBar = new QmitkInteractionSchemeToolBar(parent); layout->addWidget(m_Impl->m_InteractionSchemeToolBar); } m_Impl->m_InteractionSchemeToolBar->SetInteractionEventHandler(multiWidget->GetInteractionEventHandler()); - // show / hide PACS mouse mode interaction scheme toolbar - bool PACSInteractionScheme = preferences->GetBool("PACS like mouse interaction", false); - m_Impl->m_InteractionSchemeToolBar->setVisible(PACSInteractionScheme); - multiWidget->SetDataStorage(GetDataStorage()); multiWidget->InitializeMultiWidget(); SetMultiWidget(multiWidget); } layout->addWidget(multiWidget); // create right toolbar: configuration toolbar to change the render window widget layout if (nullptr == m_Impl->m_ConfigurationToolBar) { m_Impl->m_ConfigurationToolBar = new QmitkMultiWidgetConfigurationToolBar(multiWidget); layout->addWidget(m_Impl->m_ConfigurationToolBar); } connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::LayoutSet, this, &QmitkMxNMultiWidgetEditor::OnLayoutSet); connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::Synchronized, this, &QmitkMxNMultiWidgetEditor::OnSynchronize); connect(m_Impl->m_ConfigurationToolBar, &QmitkMultiWidgetConfigurationToolBar::InteractionSchemeChanged, this, &QmitkMxNMultiWidgetEditor::OnInteractionSchemeChanged); GetSite()->GetPage()->AddPartListener(this); OnPreferencesChanged(preferences); } void QmitkMxNMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* preferences) { const auto& multiWidget = GetMultiWidget(); if (nullptr == multiWidget) { return; } // update decoration preferences //m_Impl->m_MultiWidgetDecorationManager->DecorationPreferencesChanged(preferences); // zooming and panning preferences bool constrainedZooming = preferences->GetBool("Use constrained zooming and panning", true); mitk::RenderingManager::GetInstance()->SetConstrainedPanningZooming(constrainedZooming); bool PACSInteractionScheme = preferences->GetBool("PACS like mouse interaction", false); OnInteractionSchemeChanged(PACSInteractionScheme ? mitk::InteractionSchemeSwitcher::PACSStandard : mitk::InteractionSchemeSwitcher::MITKStandard); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); }