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 a34e1f3d2c..60d067ac27 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp @@ -1,90 +1,110 @@ /*=================================================================== 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 +#include // us #include "usGetModuleContext.h" #include "usModuleContext.h" #include #include #include #include "QmitkRenderWindow.h" US_INITIALIZE_MODULE("InteractionEventRecorder","liborg_mitk_gui_qt_eventrecorder") const std::string InteractionEventRecorder::VIEW_ID = "org.mitk.views.interactioneventrecorder"; void InteractionEventRecorder::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::StopRecording() +{ + MITK_INFO << "Stop Recording"; + m_CurrentObserver->StopRecording(); +} + void InteractionEventRecorder::Play() { std::ifstream xmlStream(m_Controls.textFileName->text().toStdString().c_str()); mitk::XML2EventParser parser(xmlStream); mitk::XML2EventParser::EventContainerType events = parser.GetInteractions(); MITK_INFO << "parsed events"; for (int i=0; i < events.size(); ++i) - this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetRenderer()->GetDispatcher()->ProcessEvent(events.at(i)); + { + events.at(i)->SetSender(this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderer()); + this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderer()->GetDispatcher()->ProcessEvent(events.at(i)); + } MITK_INFO << "DONE"; } +void InteractionEventRecorder::OpenFile() +{ + QString fn = QFileDialog::getOpenFileName(NULL, "Open File...", + QString(), "All Files (*)"); + if (!fn.isEmpty()) + this->m_Controls.textFileName->setText(fn); +} + void InteractionEventRecorder::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); + connect( m_Controls.btnStopRecording, SIGNAL(clicked()), this, SLOT(StopRecording()) ); connect( m_Controls.btnStartRecording, SIGNAL(clicked()), this, SLOT(StartRecording()) ); connect( m_Controls.btnPlay, SIGNAL(clicked()), this, SLOT(Play()) ); + connect( m_Controls.btnOpenFile, SIGNAL(clicked()), this, SLOT(OpenFile()) ); 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); /* 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 26151819b8..c360c4c394 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h @@ -1,74 +1,76 @@ /*=================================================================== 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 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 StartRecording(); + void StopRecording(); + void OpenFile(); void Play(); protected: virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus(); 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 bcacecedfd..a1727d764e 100644 --- a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui @@ -1,71 +1,111 @@ InteractionEventRecorderControls 0 0 - 222 - 161 + 253 + 214 0 0 QmitkTemplate Filename to store interaction - + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + 30 + 20 + + + + ... + + + + Do image processing Start Recording + + + + Stop Recording + + + Play Recording Qt::Vertical QSizePolicy::Expanding 20 220