diff --git a/Core/Code/Interactions/mitkEventRecorder.cpp b/Core/Code/Interactions/mitkEventRecorder.cpp index 82a43c7191..d9294b2a7c 100644 --- a/Core/Code/Interactions/mitkEventRecorder.cpp +++ b/Core/Code/Interactions/mitkEventRecorder.cpp @@ -1,30 +1,77 @@ /*=================================================================== 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 "mitkEventRecorder.h" #include "mitkEventFactory.h" #include "mitkInteractionEvent.h" +mitk::EventRecorder::EventRecorder() + : m_Active(false) +{ +} + +mitk::EventRecorder::~EventRecorder() +{ + if (m_FileStream.is_open()) + { + m_FileStream.flush(); + m_FileStream.close(); + } +} + void mitk::EventRecorder::Notify(mitk::InteractionEvent *interactionEvent, bool /*isHandled*/) { std::cout << EventFactory::EventToXML(interactionEvent) << "\n"; + if (m_FileStream.is_open()) + m_FileStream << EventFactory::EventToXML(interactionEvent) << "\n"; } void mitk::EventRecorder::SetEventIgnoreList(std::vector list) { - m_IgnoreList = list; + m_IgnoreList = list; +} + +void mitk::EventRecorder::StartRecording() +{ + if (m_FileName == "") + { + MITK_ERROR << "EventRecorder::StartRecording - Filename needs to be set first."; + return; + } + if (m_FileStream.is_open()) + { + MITK_ERROR << "EventRecorder::StartRecording - Still recording. Stop recording before starting it again."; + return; + } + + m_FileStream.open(m_FileName.c_str(), std::ofstream::out ); + if ( !m_FileStream.good() ) + { + MITK_ERROR << "File " << m_FileName << " could not be opened!"; + m_FileStream.close(); + return ; + } +} + +void mitk::EventRecorder::StopRecording() +{ + if (m_FileStream.is_open()) + { + m_FileStream.flush(); + m_FileStream.close(); + } } diff --git a/Core/Code/Interactions/mitkEventRecorder.h b/Core/Code/Interactions/mitkEventRecorder.h index a53746fa85..7013d4a5c9 100644 --- a/Core/Code/Interactions/mitkEventRecorder.h +++ b/Core/Code/Interactions/mitkEventRecorder.h @@ -1,53 +1,74 @@ /*=================================================================== 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 mitkEventRecorder_h #define mitkEventRecorder_h #include #include "mitkInteractionEventObserver.h" +#include "iostream" namespace mitk { - /** +/** *\class EventRecorder *@brief Observer that enables recoding of all user interaction with the render windows and storing it in an XML file. * * @ingroup Interaction **/ - class MITK_CORE_EXPORT EventRecorder: public InteractionEventObserver - { - public: - EventRecorder(){} - ~EventRecorder(){} +class MITK_CORE_EXPORT EventRecorder: public InteractionEventObserver +{ +public: + EventRecorder(); + ~EventRecorder(); - /** + /** * By this function the Observer gets notified about new events. */ - virtual void Notify(InteractionEvent* interactionEvent, bool); + virtual void Notify(InteractionEvent* interactionEvent, bool); - /** + /** * @brief SetEventIgnoreList Optional. Provide a list of strings that describe which events are to be ignored */ - void SetEventIgnoreList(std::vector list); + void SetEventIgnoreList(std::vector list); + + void StartRecording(); + void StopRecording(); + + void SetOutputFile(std::string filename) + { + m_FileName = filename; + } + +private: + + /** + * @brief m_IgnoreList lists the names of events that are dropped + */ + std::vector m_IgnoreList; + + /** + * @brief m_Active determindes if events are caught and written to file + */ + bool m_Active; + std::string m_FileName; - private: + std::ofstream m_FileStream; - std::vector m_IgnoreList; - }; +}; } #endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index be564e382b..778c013e6d 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,56 +1,57 @@ # Plug-ins must be ordered according to their dependencies if (MITK_USE_Qt4) set(MITK_EXT_PLUGINS org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dtiatlasapp:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.meshdecimation:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF + org.mitk.gui.qt.eventrecorder:OFF ) else() set(MITK_EXT_PLUGINS # empty so far ) endif() diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt b/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt new file mode 100644 index 0000000000..975204ac07 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt @@ -0,0 +1,7 @@ +project(org_mitk_gui_gt_eventrecorder) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE EVENTRECORDER_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES QmitkExt +) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox new file mode 100644 index 0000000000..905b3c790f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox @@ -0,0 +1,18 @@ +/** +\page org_mitk_gui_gt_eventrecorder Eventrecorder + +\image html icon.xpm "Icon of Eventrecorder" + +Available sections: + - \ref org_mitk_gui_gt_eventrecorderOverview + +\section org_mitk_gui_gt_eventrecorderOverview +Describe the features of your awesome plugin here +
    +
  • Increases productivity +
  • Creates beautiful images +
  • Generates PhD thesis +
  • Brings world peace +
+ +*/ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm new file mode 100644 index 0000000000..9057c20bc6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..a690d5a53b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_gt_eventrecorder org.mitk.gui.gt.eventrecorder + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_gt_eventrecorder_internal Internal + \ingroup org_mitk_gui_gt_eventrecorder + + \brief This subcategory includes the internal classes of the org.mitk.gui.gt.eventrecorder plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake b/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake new file mode 100644 index 0000000000..6fec7729e3 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake @@ -0,0 +1,42 @@ +set(SRC_CPP_FILES + +) + +set(INTERNAL_CPP_FILES + org_mitk_gui_gt_eventrecorder_Activator.cpp + InteractionEventRecorder.cpp +) + +set(UI_FILES + src/internal/InteractionEventRecorderControls.ui +) + +set(MOC_H_FILES + src/internal/org_mitk_gui_gt_eventrecorder_Activator.h + src/internal/InteractionEventRecorder.h +) + +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench +set(CACHED_RESOURCE_FILES + resources/icon.xpm + plugin.xml +) + +# list of Qt .qrc files which contain additional resources +# specific to this plugin +set(QRC_FILES + +) + +set(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake new file mode 100644 index 0000000000..f3074cf0d1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Eventrecorder") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml b/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml new file mode 100644 index 0000000000..9c575e254c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.xpm b/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.xpm new file mode 100644 index 0000000000..9057c20bc6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp new file mode 100644 index 0000000000..3edf081ce6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp @@ -0,0 +1,101 @@ +/*=================================================================== + +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 + + +const std::string InteractionEventRecorder::VIEW_ID = "org.mitk.views.interactioneventrecorder"; + +void InteractionEventRecorder::SetFocus() +{ + m_Controls.buttonPerformImageProcessing->setFocus(); +} + +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()) ); +} + +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 ); +} + + +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... + + } + } +} diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h new file mode 100644 index 0000000000..bab24d9f97 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h @@ -0,0 +1,65 @@ +/*=================================================================== + +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" + + +/** + \brief InteractionEventRecorder + + \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. + + \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(); + + 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; + +}; + +#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 new file mode 100644 index 0000000000..ba853e35f9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui @@ -0,0 +1,64 @@ + + + InteractionEventRecorderControls + + + + 0 + 0 + 222 + 161 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + QLabel { color: rgb(255, 0, 0) } + + + Please select an image! + + + + + + + Do image processing + + + Do Something + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 220 + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp new file mode 100644 index 0000000000..0631ac9380 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp @@ -0,0 +1,38 @@ +/*=================================================================== + +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 "org_mitk_gui_gt_eventrecorder_Activator.h" + +#include + +#include "InteractionEventRecorder.h" + +namespace mitk { + +void org_mitk_gui_gt_eventrecorder_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(InteractionEventRecorder, context) +} + +void org_mitk_gui_gt_eventrecorder_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_gt_eventrecorder, mitk::org_mitk_gui_gt_eventrecorder_Activator) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h new file mode 100644 index 0000000000..ccb98449c8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h @@ -0,0 +1,40 @@ +/*=================================================================== + +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 org_mitk_gui_gt_eventrecorder_Activator_h +#define org_mitk_gui_gt_eventrecorder_Activator_h + +#include + +namespace mitk { + +class org_mitk_gui_gt_eventrecorder_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +}; // org_mitk_gui_gt_eventrecorder_Activator + +} + +#endif // org_mitk_gui_gt_eventrecorder_Activator_h