diff --git a/Core/Code/Interactions/mitkMouseModeSwitcher.cpp b/Core/Code/Interactions/mitkMouseModeSwitcher.cpp index 7638492319..1048a6359b 100644 --- a/Core/Code/Interactions/mitkMouseModeSwitcher.cpp +++ b/Core/Code/Interactions/mitkMouseModeSwitcher.cpp @@ -1,121 +1,112 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkMouseModeSwitcher.h" // us #include "usGetModuleContext.h" #include "usModuleContext.h" #include "mitkInteractionEventObserver.h" mitk::MouseModeSwitcher::MouseModeSwitcher() : m_ActiveInteractionScheme(MITK), m_ActiveMouseMode(MousePointer), m_CurrentObserver(NULL) { this->InitializeListeners(); this->SetInteractionScheme(m_ActiveInteractionScheme); } mitk::MouseModeSwitcher::~MouseModeSwitcher() { m_ServiceRegistration.Unregister(); - - delete m_CurrentObserverDEBUG; - m_ServiceRegistrationDEBUG.Unregister(); } void mitk::MouseModeSwitcher::InitializeListeners() { if (m_CurrentObserver.IsNull()) { m_CurrentObserver = mitk::DisplayInteractor::New(); - m_CurrentObserverDEBUG = new EventRecorder(); m_CurrentObserver->LoadStateMachine("DisplayInteraction.xml"); m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml"); // Register as listener via micro services us::ServiceProperties props; props["name"] = std::string("DisplayInteractor"); m_ServiceRegistration = us::GetModuleContext()->RegisterService( m_CurrentObserver.GetPointer(),props); - - props["name"] = std::string("EventRecorder"); - m_ServiceRegistrationDEBUG = us::GetModuleContext()->RegisterService( - m_CurrentObserverDEBUG,props); - } } void mitk::MouseModeSwitcher::SetInteractionScheme(InteractionScheme scheme) { switch (scheme) { case MITK: { m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml"); } break; case PACS: { m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml"); } break; } m_ActiveInteractionScheme = scheme; this->InvokeEvent(MouseModeChangedEvent()); } void mitk::MouseModeSwitcher::SelectMouseMode(MouseMode mode) { if (m_ActiveInteractionScheme != PACS) return; switch (mode) { case MousePointer: { m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml"); break; } // case 0 case Scroll: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSScroll.xml"); break; } case LevelWindow: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSLevelWindow.xml"); break; } case Zoom: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSZoom.xml"); break; } case Pan: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSPan.xml"); break; } } // end switch (mode) m_ActiveMouseMode = mode; this->InvokeEvent(MouseModeChangedEvent()); } mitk::MouseModeSwitcher::MouseMode mitk::MouseModeSwitcher::GetCurrentMouseMode() const { return m_ActiveMouseMode; } diff --git a/Core/Code/Interactions/mitkMouseModeSwitcher.h b/Core/Code/Interactions/mitkMouseModeSwitcher.h index 9d26de7096..4fc102844f 100644 --- a/Core/Code/Interactions/mitkMouseModeSwitcher.h +++ b/Core/Code/Interactions/mitkMouseModeSwitcher.h @@ -1,135 +1,132 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB #define MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB #include "MitkExports.h" #include #include "mitkDisplayInteractor.h" #include "mitkEventRecorder.h" namespace mitk { /*********************************************************************** * * \brief Class that offers a convenient way to switch between different * interaction schemes * * This class offers the possibility to switch between the two different * interaction schemes that are available: * - MITK : The original interaction scheme * - left mouse button : setting the cross position in the MPR view * - middle mouse button : panning * - right mouse button : zooming * * * - PACS : an alternative interaction scheme that behaves more like a * PACS workstation * - left mouse button : behavior depends on current MouseMode * - middle mouse button : fast scrolling * - right mouse button : level-window * - ctrl + right button : zooming * - shift+ right button : panning * * There are 5 different MouseModes that are available in the PACS scheme. * Each MouseMode defines the interaction that is performed on a left * mouse button click: * - Pointer : sets the cross position for the MPR * - Scroll * - Level-Window * - Zoom * - Pan * * When the interaction scheme or the MouseMode is changed, this class * manages the adding and removing of the relevant listeners offering * a convenient way to modify the interaction behavior. * ***********************************************************************/ class MITK_CORE_EXPORT MouseModeSwitcher : public itk::Object { public: #pragma GCC visibility push(default) /** \brief Can be observed by GUI class to update button states when mode is changed programatically. */ itkEventMacro( MouseModeChangedEvent, itk::AnyEvent ); #pragma GCC visibility pop mitkClassMacro( MouseModeSwitcher, itk::Object ); itkNewMacro(Self); // enum of the different interaction schemes that are available enum InteractionScheme { PACS = 0, MITK = 1 }; // enum of available mouse modes for PACS interaction scheme enum MouseMode { MousePointer = 0, Scroll, LevelWindow, Zoom, Pan }; /** * \brief Setter for interaction scheme */ void SetInteractionScheme( InteractionScheme ); /** * \brief Setter for mouse mode */ void SelectMouseMode( MouseMode mode ); /** * \brief Returns the current mouse mode */ MouseMode GetCurrentMouseMode() const; protected: MouseModeSwitcher(); virtual ~MouseModeSwitcher(); private: /** * \brief Initializes the listener with the MITK default behavior. */ void InitializeListeners(); InteractionScheme m_ActiveInteractionScheme; MouseMode m_ActiveMouseMode; DisplayInteractor::Pointer m_CurrentObserver; - EventRecorder* m_CurrentObserverDEBUG; /** * Reference to the service registration of the observer, * it is needed to unregister the observer on unload. */ us::ServiceRegistration m_ServiceRegistration; - - us::ServiceRegistration m_ServiceRegistrationDEBUG; }; } // namespace mitk #endif /* MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp index 3edf081ce6..44989e2bd3 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp @@ -1,101 +1,71 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include "InteractionEventRecorder.h" // Qt #include +// us +#include "usGetModuleContext.h" +#include "usModuleContext.h" + +#include + +US_INITIALIZE_MODULE("InteractionEventRecorder","liborg_mitk_gui_qt_eventrecorder") const std::string InteractionEventRecorder::VIEW_ID = "org.mitk.views.interactioneventrecorder"; void InteractionEventRecorder::SetFocus() { - m_Controls.buttonPerformImageProcessing->setFocus(); + m_Controls.textFileName->setFocus(); +} + +void InteractionEventRecorder::StartRecording() +{ + MITK_INFO << "Start Recording"; + m_CurrentObserver->SetOutputFile(m_Controls.textFileName->text().toStdString()); + m_CurrentObserver->StartRecording(); } void InteractionEventRecorder::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); - connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); -} + connect( m_Controls.btnStartRecording, SIGNAL(clicked()), this, SLOT(StartRecording()) ); -void InteractionEventRecorder::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, - const QList& nodes ) -{ - // iterate all selected objects, adjust warning visibility - foreach( mitk::DataNode::Pointer node, nodes ) - { - if( node.IsNotNull() && dynamic_cast(node->GetData()) ) - { - m_Controls.labelWarning->setVisible( false ); - m_Controls.buttonPerformImageProcessing->setEnabled( true ); - return; - } - } - - m_Controls.labelWarning->setVisible( true ); - m_Controls.buttonPerformImageProcessing->setEnabled( false ); -} + m_CurrentObserver = new mitk::EventRecorder(); + // Register as listener via micro services + us::ServiceProperties props; + props["name"] = std::string("EventRecorder"); + m_ServiceRegistration = us::GetModuleContext()->RegisterService(m_CurrentObserver,props); -void InteractionEventRecorder::DoImageProcessing() -{ - QList nodes = this->GetDataManagerSelection(); - if (nodes.empty()) return; - - mitk::DataNode* node = nodes.front(); - - if (!node) - { - // Nothing selected. Inform the user and return - QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing."); - return; - } - - // here we have a valid mitk::DataNode - - // a node itself is not very useful, we need its data item (the image) - mitk::BaseData* data = node->GetData(); - if (data) - { - // test if this data item is an image or not (could also be a surface or something totally different) - mitk::Image* image = dynamic_cast( data ); - if (image) - { - std::stringstream message; - std::string name; - message << "Performing image processing for image "; - if (node->GetName(name)) - { - // a property called "name" was found for this DataNode - message << "'" << name << "'"; - } - message << "."; - MITK_INFO << message.str(); - - // actually do something here... - - } - } + + /* + +delete m_CurrentObserverDEBUG; + m_ServiceRegistrationDEBUG.Unregister(); + */ } + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h index bab24d9f97..c0ff230cb5 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h @@ -1,65 +1,73 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef InteractionEventRecorder_h #define InteractionEventRecorder_h #include #include #include "ui_InteractionEventRecorderControls.h" +#include "mitkInteractionEventObserver.h" +#include "mitkEventRecorder.h" /** \brief InteractionEventRecorder - \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. + Demontrates the use of InteractionOversers. + + Allows to record all mouse interaction in the renderwindows save it as XML file. And also replay the interaction. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class InteractionEventRecorder : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; protected slots: /// \brief Called when the user clicks the GUI button - void DoImageProcessing(); + + void StartRecording(); protected: virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus(); - /// \brief called by QmitkFunctionality when DataManager's selection has changed - virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, - const QList& nodes ); + Ui::InteractionEventRecorderControls m_Controls; + private: + mitk::EventRecorder* m_CurrentObserver; + + us::ServiceRegistration m_ServiceRegistration; + }; #endif // InteractionEventRecorder_h diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui index ba853e35f9..0aa3b76d55 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui @@ -1,64 +1,64 @@ InteractionEventRecorderControls 0 0 222 161 0 0 QmitkTemplate - - - QLabel { color: rgb(255, 0, 0) } - + - Please select an image! + Filename to store interaction - + + + + Do image processing - Do Something + Start Recording Qt::Vertical QSizePolicy::Expanding 20 220