Page MenuHomePhabricator

WiiMoteIGTTracking.patch

Authored By
iud
Nov 5 2010, 2:06 PM
Size
42 KB
Referenced Files
None
Subscribers
None

WiiMoteIGTTracking.patch

Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/CMakeLists.txt
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/CMakeLists.txt (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/CMakeLists.txt (revision 0)
@@ -0,0 +1 @@
+MACRO_CREATE_MITK_PLUGIN(QmitkExt mitkWiiMoteIGT MitkIGTUI)
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/documentation/doxygen/modules.dox
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/documentation/doxygen/modules.dox (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/documentation/doxygen/modules.dox (revision 0)
@@ -0,0 +1,16 @@
+/**
+ \defgroup org_mitk_gui_qt_igtwiimotetracking org.mitk.gui.qt.igtwiimotetracking Plugin
+ \ingroup MITKPlugins
+
+ \brief Describe your plugin here.
+
+*/
+
+/**
+ \defgroup org_mitk_gui_qt_igtwiimotetracking_internal Internal
+ \ingroup org_mitk_gui_qt_igtwiimotetracking
+
+ \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igtwiimotetracking plugin. Other
+ plugins must not rely on these classes. They contain implementation details and their interface
+ may change at any time. We mean it.
+*/
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\documentation\doxygen\modules.dox
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/files.cmake
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/files.cmake (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/files.cmake (revision 0)
@@ -0,0 +1,35 @@
+SET(SRC_CPP_FILES
+
+)
+
+SET(INTERNAL_CPP_FILES
+ QmitkWiimoteTrackingView.cpp
+
+)
+
+SET(UI_FILES
+ src/internal/QmitkWiimoteTrackingViewControls.ui
+)
+
+SET(MOC_H_FILES
+ src/internal/QmitkWiimoteTrackingView.h
+)
+
+SET(RESOURCE_FILES
+ resources/icon.xpm
+)
+
+SET(RES_FILES
+ resources/QmitkWiimoteTrackingView.qrc
+)
+
+SET(CPP_FILES manifest.cpp)
+
+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})
+
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\files.cmake
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/manifest.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/manifest.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/manifest.cpp (revision 0)
@@ -0,0 +1,26 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include <Poco/ClassLibrary.h>
+
+
+
+#include "src/internal/QmitkWiimoteTrackingView.h"
+
+POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart)
+ POCO_EXPORT_CLASS(::QmitkWiimoteTrackingView)
+POCO_END_MANIFEST
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\manifest.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/META-INF/MANIFEST.MF
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/META-INF/MANIFEST.MF (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/META-INF/MANIFEST.MF (revision 0)
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-Name: Wiimote Tracking
+Bundle-SymbolicName: org.mitk.gui.qt.igtwiimotetracking
+Bundle-Version: 0.1
+Bundle-Vendor: DKFZ, Medical and Biological Informatics
+Require-Bundle: org.mitk.gui.qt.common
+Bundle-Activator:
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/plugin.xml
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/plugin.xml (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/plugin.xml (revision 0)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?BlueBerry version="0.1"?>
+<plugin>
+
+ <extension point="org.blueberry.ui.views">
+ <view id="org.mitk.views.wiimotetracking"
+ name="Wiimote Tracking"
+ class="::QmitkWiimoteTrackingView"
+ icon="resources/icon.xpm" />
+ </extension>
+
+</plugin>
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/icon.xpm
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/icon.xpm (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/icon.xpm (revision 0)
@@ -0,0 +1,21 @@
+/* XPM */
+static const char * icon_xpm[] = {
+"16 16 2 1",
+" c #FF0000",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\resources\icon.xpm
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/QmitkWiimoteTrackingView.qrc
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/QmitkWiimoteTrackingView.qrc (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/resources/QmitkWiimoteTrackingView.qrc (revision 0)
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/QmitkWiimoteTrackingView">
+ <file>icon.xpm</file>
+ </qresource>
+ </RCC>
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/IgtwiimotetrackingDll.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/IgtwiimotetrackingDll.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/IgtwiimotetrackingDll.h (revision 0)
@@ -0,0 +1,43 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef _IGTWIIMOTETRACKING_EXPORT_DLL_H_
+#define _IGTWIIMOTETRACKING_EXPORT_DLL_H_
+
+
+//
+// The following block is the standard way of creating macros which make exporting
+// from a DLL simpler. All files within this DLL are compiled with the org_mitk_gui_qt_igtwiimotetracking_EXPORTS
+// symbol defined on the command line. this symbol should not be defined on any project
+// that uses this DLL. This way any other project whose source files include this file see
+// org_mitk_gui_qt_igtwiimotetracking_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols
+// defined with this macro as being exported.
+//
+#if defined(_WIN32) && !defined(MITK_STATIC)
+ #if defined(org_mitk_gui_qt_igtwiimotetracking_EXPORTS)
+ #define IGTWIIMOTETRACKING_EXPORT __declspec(dllexport)
+ #else
+ #define IGTWIIMOTETRACKING_EXPORT __declspec(dllimport)
+ #endif
+#endif
+
+
+#if !defined(IGTWIIMOTETRACKING_EXPORT)
+ #define IGTWIIMOTETRACKING_EXPORT
+#endif
+
+#endif /*_IGTWIIMOTETRACKING_EXPORT_DLL_H_*/
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\src\IgtwiimotetrackingDll.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.cpp (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.cpp (revision 0)
@@ -0,0 +1,241 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+// Blueberry
+#include <berryISelectionService.h>
+#include <berryIWorkbenchWindow.h>
+
+// Qmitk
+#include "QmitkWiimoteTrackingView.h"
+#include "QmitkStdMultiWidget.h"
+
+// Qt
+#include <QMessageBox>
+
+const std::string QmitkWiimoteTrackingView::VIEW_ID = "org.mitk.views.wiimotetracking";
+const QString WIIMOTE_CONNECTED = "online";
+const QString WIIMOTE_DISCONNECTED = "offline";
+const QString WIIMOTE_TRACKING = "tracking";
+const QString WIIMOTE_CALIBRATING = "calibrating";
+
+QmitkWiimoteTrackingView::QmitkWiimoteTrackingView()
+: QmitkFunctionality()
+, m_Controls( 0 )
+, m_MultiWidget( NULL )
+, m_WiiMoteTrackingDevice(mitk::WiiMoteTrackingDevice::New())
+, m_TrackingDeviceSource(mitk::TrackingDeviceSource::New())
+, m_DialogDataSave(NULL)
+, m_ParentWindow(NULL)
+{
+}
+
+QmitkWiimoteTrackingView::~QmitkWiimoteTrackingView()
+{
+}
+
+
+void QmitkWiimoteTrackingView::CreateQtPartControl( QWidget *parent )
+{
+ // build up qt view, unless already done
+ if ( !m_Controls )
+ {
+ // create GUI widgets from the Qt Designer's .ui file
+ m_Controls = new Ui::QmitkWiimoteTrackingViewControls;
+ m_Controls->setupUi( parent );
+
+ m_ParentWindow = parent;
+
+ connect( m_Controls->pushButtonConnectWiimotes, SIGNAL(clicked()), this, SLOT(OnOpenConnection()) );
+ connect( m_Controls->pushButtonDisconnectWiimotes, SIGNAL(clicked()), this, SLOT(OnCloseConnection()) );
+ connect( m_Controls->pushButtonStartTracking, SIGNAL(clicked()), this, SLOT(OnStartTracking()) );
+ connect( m_Controls->pushButtonStopTracking, SIGNAL(clicked()), this, SLOT(OnStopTracking()) );
+ connect( m_Controls->pushButtonStartCalibration, SIGNAL(clicked()), this, SLOT(OnStartCalibration()) );
+ connect( m_Controls->pushButtonStopCalibration, SIGNAL(clicked()), this, SLOT(OnStopCalibration()) );
+ connect( m_Controls->pushButtonSaveData, SIGNAL(clicked()), this, SLOT(OnSaveData()) );
+
+ m_Controls->pushButtonDisconnectWiimotes->setEnabled(false);
+ m_Controls->pushButtonStartTracking->setEnabled(false);
+ m_Controls->pushButtonStopTracking->setEnabled(false);
+ m_Controls->pushButtonStartCalibration->setEnabled(false);
+ m_Controls->pushButtonStopCalibration->setEnabled(false);
+ m_Controls->pushButtonSaveData->setEnabled(false);
+
+ }
+}
+
+
+void QmitkWiimoteTrackingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
+{
+ m_MultiWidget = &stdMultiWidget;
+}
+
+
+void QmitkWiimoteTrackingView::StdMultiWidgetNotAvailable()
+{
+ m_MultiWidget = NULL;
+}
+
+
+void QmitkWiimoteTrackingView::OnSelectionChanged( std::vector<mitk::DataNode*> nodes )
+{
+ // iterate all selected objects, adjust warning visibility
+ for( std::vector<mitk::DataNode*>::iterator it = nodes.begin();
+ it != nodes.end();
+ ++it )
+ {
+ mitk::DataNode::Pointer node = *it;
+
+ if( node.IsNotNull() && dynamic_cast<mitk::Image*>(node->GetData()) )
+ {
+ //m_Controls->lblWarning->setVisible( false );
+ return;
+ }
+ }
+
+ //m_Controls->lblWarning->setVisible( true );
+}
+
+void QmitkWiimoteTrackingView::OnOpenConnection()
+{
+ try
+ {
+ m_TrackingDeviceSource->SetTrackingDevice(this->m_WiiMoteTrackingDevice);
+ m_TrackingDeviceSource->Connect();
+
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_CONNECTED,2);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_CONNECTED,2);
+
+ m_Controls->pushButtonDisconnectWiimotes->setEnabled(true);
+ m_Controls->pushButtonStartTracking->setEnabled(true);
+ m_Controls->pushButtonStopTracking->setEnabled(true);
+ m_Controls->pushButtonStartCalibration->setEnabled(true);
+ m_Controls->pushButtonStopCalibration->setEnabled(true);
+ m_Controls->pushButtonSaveData->setEnabled(true);
+ }
+ catch(...)
+ {
+
+ }
+}
+
+void QmitkWiimoteTrackingView::OnCloseConnection()
+{
+ m_TrackingDeviceSource->Disconnect();
+
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_DISCONNECTED,1);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_DISCONNECTED,1);
+}
+
+void QmitkWiimoteTrackingView::OnStartTracking()
+{
+ m_TrackingDeviceSource->StartTracking();
+
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_TRACKING,3);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_TRACKING,3);
+}
+
+void QmitkWiimoteTrackingView::OnStopTracking()
+{
+ m_TrackingDeviceSource->StopTracking();
+
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_CONNECTED,2);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_CONNECTED,2);
+}
+
+void QmitkWiimoteTrackingView::OnStartCalibration()
+{
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_CALIBRATING,3);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_CALIBRATING,3);
+}
+
+void QmitkWiimoteTrackingView::OnStopCalibration()
+{
+ this->ChangeColorAndText(m_Controls->labelWiiMote1StatusInput, WIIMOTE_CONNECTED,2);
+ this->ChangeColorAndText(m_Controls->labelWiiMote2StatusInput, WIIMOTE_CONNECTED,2);
+}
+
+void QmitkWiimoteTrackingView::OnSaveData()
+{
+
+ this->m_DialogDataSave = new QDialog(this->m_ParentWindow,Qt::WindowTitleHint);
+ m_DialogDataSave->show();
+
+}
+
+void QmitkWiimoteTrackingView::ChangeColorAndText(QLabel* labelToChange, QString newText, int color)
+{
+ labelToChange->setText(newText);
+
+ switch(color)
+ {
+ case 1:
+ labelToChange->setStyleSheet("background-color: red");
+ break;
+ case 2:
+ labelToChange->setStyleSheet("background-color: green");
+ break;
+ case 3:
+ labelToChange->setStyleSheet("background-color: orange");
+ break;
+ }
+
+ // required for the colors to show
+ labelToChange->setAutoFillBackground(true);
+}
+
+void QmitkWiimoteTrackingView::DoImageProcessing()
+{
+ std::vector<mitk::DataNode*> 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<mitk::Image*>( 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();
+
+ // TODO actually do something here...
+ }
+ }
+}
+
+
+
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\src\internal\QmitkWiimoteTrackingView.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.h
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.h (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingView.h (revision 0)
@@ -0,0 +1,98 @@
+/*=========================================================================
+
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef QmitkWiimoteTrackingView_h
+#define QmitkWiimoteTrackingView_h
+
+// BlueBerry
+#include <berryISelectionListener.h>
+
+// Qmitk
+#include <QmitkFunctionality.h>
+#include <QDialog>
+
+#include "ui_QmitkWiimoteTrackingViewControls.h"
+
+// mitk
+#include <mitkWiiMoteTrackingDevice.h>
+#include <mitkTrackingDeviceSource.h>
+
+
+
+/*!
+ \brief QmitkWiimoteTrackingView
+
+ \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation.
+
+ \sa QmitkFunctionality
+ \ingroup Functionalities
+*/
+class QmitkWiimoteTrackingView : public QObject, public QmitkFunctionality
+{
+ // 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;
+
+ QmitkWiimoteTrackingView();
+ virtual ~QmitkWiimoteTrackingView();
+
+ virtual void CreateQtPartControl(QWidget *parent);
+
+ virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget);
+ virtual void StdMultiWidgetNotAvailable();
+
+ protected slots:
+
+ /// \brief Called when the user clicks the GUI button
+ void DoImageProcessing();
+ void OnOpenConnection();
+ void OnCloseConnection();
+ void OnStartTracking();
+ void OnStopTracking();
+ void OnStartCalibration();
+ void OnStopCalibration();
+ void OnSaveData();
+
+ protected:
+
+ /// \brief called by QmitkFunctionality when DataManager's selection has changed
+ virtual void OnSelectionChanged( std::vector<mitk::DataNode*> nodes );
+
+ Ui::QmitkWiimoteTrackingViewControls* m_Controls;
+
+ QmitkStdMultiWidget* m_MultiWidget;
+
+ private:
+
+ // pipeline
+ mitk::WiiMoteTrackingDevice::Pointer m_WiiMoteTrackingDevice;
+ mitk::TrackingDeviceSource::Pointer m_TrackingDeviceSource;
+
+ void ChangeColorAndText(QLabel* labelToChange, QString newText, int color);
+
+ QDialog* m_DialogDataSave;
+ QWidget* m_ParentWindow;
+};
+
+
+
+#endif // _QMITKWIIMOTETRACKINGVIEW_H_INCLUDED
+
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\src\internal\QmitkWiimoteTrackingView.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingViewControls.ui
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingViewControls.ui (revision 0)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.igtwiimotetracking/src/internal/QmitkWiimoteTrackingViewControls.ui (revision 0)
@@ -0,0 +1,281 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QmitkWiimoteTrackingViewControls</class>
+ <widget class="QWidget" name="QmitkWiimoteTrackingViewControls">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>823</width>
+ <height>887</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>QmitkTemplate</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBoxWiiMote1">
+ <property name="title">
+ <string>Wiimote 1</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayoutWiiMote1">
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelWiiMote1SensorInput">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>offline</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelWiiMote1SensorName">
+ <property name="text">
+ <string>Sensor 1 Data:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelWiiMote1StatusInput">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>offline</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelWiiMote1Status">
+ <property name="text">
+ <string>Status:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBoxWiiMote2">
+ <property name="title">
+ <string>Wiimote 2</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayoutWiiMote2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelWiiMote2Status">
+ <property name="text">
+ <string>Status:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelWiiMote2StatusInput">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>offline</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelWiiMote2SensorName">
+ <property name="text">
+ <string>Sensor 1 Data:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelWiiMote2SensorInput">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>offline</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBoxTrackingData">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Tracking Data</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayoutTrackingData">
+ <item>
+ <widget class="QLabel" name="label3DCoordinate">
+ <property name="text">
+ <string>3D Coordinate:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label3DCoordinateInput">
+ <property name="styleSheet">
+ <string notr="true">background-color: red;</string>
+ </property>
+ <property name="text">
+ <string>offline</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBoxControlPanel">
+ <property name="title">
+ <string>Control Panel</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_9">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayoutControlPanel">
+ <item row="3" column="0">
+ <widget class="QPushButton" name="pushButtonConnectWiimotes">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Do image processing</string>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string>Connect Wiimotes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="pushButtonDisconnectWiimotes">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Disconnect Wiimotes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QPushButton" name="pushButtonStartTracking">
+ <property name="text">
+ <string>Start Tracking</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QPushButton" name="pushButtonStopTracking">
+ <property name="text">
+ <string>Stop Tracking</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="pushButtonStartCalibration">
+ <property name="text">
+ <string>Start Calibration</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QPushButton" name="pushButtonStopCalibration">
+ <property name="text">
+ <string>Stop Calibration</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QPushButton" name="pushButtonSaveData">
+ <property name="text">
+ <string>Save Data</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
Property changes on: mitk\Modules\Bundles\org.mitk.gui.qt.igtwiimotetracking\src\internal\QmitkWiimoteTrackingViewControls.ui
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/InputDevices/WiiMoteIGT/CMakeLists.txt
===================================================================
--- mitk/Modules/InputDevices/WiiMoteIGT/CMakeLists.txt (revision 0)
+++ mitk/Modules/InputDevices/WiiMoteIGT/CMakeLists.txt (revision 0)
@@ -0,0 +1,10 @@
+IF(WIN32)
+
+IF(MITK_USE_WIIMOTE)
+MITK_CREATE_MODULE(mitkWiiMoteIGT
+ DEPENDS Mitk mitkWiiMote MitkIGT
+)
+ENDIF(MITK_USE_WIIMOTE)
+
+ENDIF(WIN32)
+
Property changes on: mitk\Modules\InputDevices\WiiMoteIGT\CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Index: mitk/Modules/InputDevices/WiiMoteIGT/files.cmake
===================================================================
--- mitk/Modules/InputDevices/WiiMoteIGT/files.cmake (revision 0)
+++ mitk/Modules/InputDevices/WiiMoteIGT/files.cmake (revision 0)
@@ -0,0 +1,4 @@
+SET(CPP_FILES
+ mitkWiiMoteTrackingDevice.cpp
+ )
+
Property changes on: mitk\Modules\InputDevices\WiiMoteIGT\files.cmake
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.cpp
===================================================================
--- mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.cpp (revision 0)
+++ mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.cpp (revision 0)
@@ -0,0 +1,298 @@
+#include "mitkWiiMoteTrackingDevice.h"
+
+// mitk
+#include "mitkInteractionConst.h"
+
+mitk::WiiMoteTrackingDevice::WiiMoteTrackingDevice()
+: TrackingDevice()
+, m_ThreadID(-1)
+, m_MultiThreader(itk::MultiThreader::New())
+, m_WiiMoteTrackingFinished(itk::FastMutexLock::New())
+, m_StopWiiMoteTracking(false)
+, m_InCalibrationMode(false)
+, m_NumberDetectedWiiMotes(0)
+{
+
+}
+
+mitk::WiiMoteTrackingDevice::~WiiMoteTrackingDevice()
+{
+
+}
+
+// ------------------------------------ interface TrackingDevice ------------------------------------
+bool mitk::WiiMoteTrackingDevice::OpenConnection()
+{
+ bool wiiMotesConnected = false;
+
+ while(CONNECTED && !m_StopWiiMoteTracking)
+ {
+ m_WiiMoteTrackingFinished->Lock();
+ if(this->DetectWiiMotes())
+ {
+ wiiMotesConnected = true;
+ this->SetState(Ready);
+ break;
+ }
+ else
+ {
+ MITK_ERROR << "Could not connect two Wiimotes successfully - please check the devices again!";
+ break;
+ }
+ m_WiiMoteTrackingFinished->Unlock();
+ }
+
+ return wiiMotesConnected;
+}
+
+bool mitk::WiiMoteTrackingDevice::CloseConnection()
+{
+ bool connectionClosed = false;
+
+ if(this->DisconnectWiiMotes())
+ {
+ connectionClosed = true;
+ if(this->GetState() != Setup)
+ {
+ this->SetState(Setup);
+ }
+ }
+
+ return connectionClosed;
+}
+
+bool mitk::WiiMoteTrackingDevice::StartTracking()
+{
+ bool trackingStarted = false;
+
+ if(this->GetState() == Ready)
+ {
+ m_ThreadID = this->m_MultiThreader->SpawnThread(this->StartWiiMoteThread, this);
+
+ if(m_ThreadID != -1)
+ {
+ trackingStarted = true;
+ }
+ }
+
+return trackingStarted;
+}
+
+bool mitk::WiiMoteTrackingDevice::StopTracking()
+{
+ if (this->GetState() == Tracking)
+ {
+ // transfers the execution rights to the WiiMote thread
+ m_WiiMoteTrackingFinished->Lock();
+
+ // is needed in case the Wiimote was deactivated
+ // while the application is running
+ this->m_StopWiiMoteTracking = true;
+
+ // transfers the execution rights back to the main thread
+ m_WiiMoteTrackingFinished->Unlock();
+
+ this->SetState(Ready);
+ }
+
+ return true;
+}
+
+mitk::TrackingTool* mitk::WiiMoteTrackingDevice::GetTool(unsigned int toolNumber) const
+{
+ return NULL;
+}
+
+unsigned int mitk::WiiMoteTrackingDevice::GetToolCount() const
+{
+ return this->m_NumberDetectedWiiMotes;
+}
+
+// ------------------------------------ threading ------------------------------------
+ITK_THREAD_RETURN_TYPE mitk::WiiMoteTrackingDevice::StartWiiMoteThread(void* pInfoStruct)
+{
+ // extract this pointer from Thread Info structure
+ struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
+ if (pInfo == NULL)
+ return ITK_THREAD_RETURN_VALUE;
+
+ if (pInfo->UserData == NULL)
+ return ITK_THREAD_RETURN_VALUE;
+
+ mitk::WiiMoteTrackingDevice* wiiMoteTrackingDevice = static_cast<mitk::WiiMoteTrackingDevice*>(pInfo->UserData);
+
+ if (wiiMoteTrackingDevice != NULL)
+ wiiMoteTrackingDevice->TrackTools();
+
+ return ITK_THREAD_RETURN_VALUE;
+}
+
+void mitk::WiiMoteTrackingDevice::TrackTools()
+{
+ // transfers the execution rights to the WiiMote thread
+ m_WiiMoteTrackingFinished->Lock();
+
+ // is needed in case the Wiimote was deactivated
+ // while the application is running
+ this->m_StopWiiMoteTracking = false;
+
+ // transfers the execution rights back to the main thread
+ m_WiiMoteTrackingFinished->Unlock();
+
+ // update loop
+ this->MultiWiiMoteUpdate();
+
+ // clean up
+ this->DisconnectWiiMotes();
+
+ return;
+}
+
+bool mitk::WiiMoteTrackingDevice::DetectWiiMotes()
+{
+ bool result = false;
+ unsigned detected = 0;
+ unsigned connectionTrys = 0;
+
+ while(detected < 5)
+ {
+ connectionTrys++;
+
+ if(!m_WiiMotes[detected].Connect(wiimote::FIRST_AVAILABLE))
+ {
+ if(connectionTrys > 5)
+ {
+ break;
+ }
+ }
+ else
+ {
+ MITK_INFO << "WiiMote detected :: Assigned ID: " << detected;
+
+ switch(detected)
+ {
+ // 0x00 none
+ // 0x0f all leds
+ // 0x01 first led
+ // 0x02 second led
+ // 0x03 third led
+ // 0x04 fourth led
+ case 0:
+ m_WiiMotes[detected].SetLEDs(0x01);
+ break;
+
+ case 1:
+ m_WiiMotes[detected].SetLEDs(0x02);
+
+ break;
+ }
+
+ // use a non-extension report mode (this gives us back the IR dot sizes)
+ m_WiiMotes[detected].SetReportType(wiimote::IN_BUTTONS_ACCEL_IR);
+ result = true;
+
+ detected++;
+ connectionTrys = 0;
+
+ } // end else
+ } // end while
+
+ m_NumberDetectedWiiMotes = detected;
+ return result;
+}
+
+bool mitk::WiiMoteTrackingDevice::DisconnectWiiMotes()
+{
+ bool wiiMotesDisconnected = false;
+
+ try
+ {
+ for(int i = 0; i < m_NumberDetectedWiiMotes;i++)
+ {
+ this->m_WiiMotes[i].Disconnect();
+ }
+
+ wiiMotesDisconnected = true;
+ MITK_INFO << "Wiimotes disconnected";
+ }
+ catch(...)
+ {
+
+ MITK_ERROR << "Disconnect of Wiimotes failed!";
+ }
+
+ return wiiMotesDisconnected;
+}
+
+void mitk::WiiMoteTrackingDevice::MultiWiiMoteUpdate()
+{
+ // update and settings process
+ while(!m_WiiMotes[0].Button.Minus() && !m_StopWiiMoteTracking)
+ {
+ m_WiiMoteTrackingFinished->Lock();
+ // refreshes the state of the wiimotes
+ // do not remove
+ while(m_WiiMotes[0].RefreshState() == NO_CHANGE
+ && m_WiiMotes[1].RefreshState() == NO_CHANGE)
+ {
+ itksys::SystemTools::Delay(1);
+ }
+ m_WiiMoteTrackingFinished->Unlock();
+
+ m_WiiMoteTrackingFinished->Lock();
+ if(!m_InCalibrationMode)
+ {
+ this->MultiWiiMoteIRInput();
+ }
+ else
+ {
+ // stereo calibration
+ }
+ m_WiiMoteTrackingFinished->Unlock();
+
+ } // end while
+}
+
+void mitk::WiiMoteTrackingDevice::MultiWiiMoteIRInput()
+{
+ // testing multiple wiimotes
+ if(IR_CHANGED && m_WiiMotes[0].IR.Dot[0].bVisible && m_WiiMotes[1].IR.Dot[0].bVisible)
+ {
+ float inputCoordinates[2] = {m_WiiMotes[0].IR.Dot[0].RawX, m_WiiMotes[0].IR.Dot[0].RawY};
+ mitk::Point2D tempPoint(inputCoordinates);
+
+ float inputCoordinates2[2] = {m_WiiMotes[1].IR.Dot[0].RawX, m_WiiMotes[1].IR.Dot[0].RawY};
+ mitk::Point2D tempPoint2(inputCoordinates2);
+
+ mitk::Vector2D result = (tempPoint2 - tempPoint);
+ MITK_INFO << "IR1 :: X: " << tempPoint[0];
+ MITK_INFO << "IR1 :: Y: " << tempPoint[1];
+
+ MITK_INFO << "IR2 :: X: " << tempPoint2[0];
+ MITK_INFO << "IR2 :: Y: " << tempPoint2[1];
+ }
+}
+
+void mitk::WiiMoteTrackingDevice::StartCalibration()
+{
+ // own calibration state would be better
+ if(this->GetState() == Ready)
+ {
+ this->m_InCalibrationMode = true;
+ }
+ else
+ {
+ MITK_ERROR << "Wiimotes not in Ready state!";
+ }
+}
+
+void mitk::WiiMoteTrackingDevice::StopCalibration()
+{
+ if(this->m_InCalibrationMode == true)
+ {
+ this->m_InCalibrationMode = false;
+ }
+
+ //itksys::SystemTools::Delay(3000);
+}
+
Property changes on: mitk\Modules\InputDevices\WiiMoteIGT\mitkWiiMoteTrackingDevice.cpp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Index: mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.h
===================================================================
--- mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.h (revision 0)
+++ mitk/Modules/InputDevices/WiiMoteIGT/mitkWiiMoteTrackingDevice.h (revision 0)
@@ -0,0 +1,95 @@
+#ifndef MITK_WIIMOTETRACKINGDEVICE_H
+#define MITK_WIIMOTETRACKINGDEVICE_H
+
+// export
+#include "mitkWiiMoteIGTExports.h"
+
+// mitk
+#include <mitkTrackingDevice.h>
+#include <mitkTrackingTool.h>
+
+// itk
+#include "itkMultiThreader.h"
+#include "itkFastMutexLock.h"
+#include "itksys/SystemTools.hxx"
+
+// other
+#include <wiimote.h>
+
+namespace mitk
+{
+ class mitkWiiMoteIGT_EXPORT WiiMoteTrackingDevice : public TrackingDevice
+ {
+ public:
+
+ // Smartpointer macros
+ mitkClassMacro(WiiMoteTrackingDevice, TrackingDevice);
+ itkNewMacro(Self);
+
+ WiiMoteTrackingDevice();
+ ~WiiMoteTrackingDevice();
+
+ /**
+ * @see mitk::TrackinDevice::OpenConnection()
+ */
+ bool OpenConnection();
+
+ /**
+ * @see mitk::TrackinDevice::CloseConnection()
+ */
+ bool CloseConnection();
+
+ /**
+ * @see mitk::TrackinDevice::StartTracking()
+ */
+ bool StartTracking();
+
+ /**
+ * @see mitk::TrackinDevice::StopTracking()
+ */
+ bool StopTracking();
+
+ /**
+ * @see mitk::TrackinDevice::GetTool(unsigned int toolNumber) const
+ */
+ TrackingTool* GetTool(unsigned int toolNumber) const;
+
+ /**
+ * @see mitk::TrackinDevice::GetToolCount() const
+ */
+ unsigned int GetToolCount() const;
+
+ protected:
+
+ /**
+ * Helper function, because the itk::MultiThreader can only <br>
+ * start a new thread with a static member function.
+ */
+ static ITK_THREAD_RETURN_TYPE StartWiiMoteThread(void* data);
+
+ void TrackTools();
+ bool DetectWiiMotes();
+ bool DisconnectWiiMotes();
+ void MultiWiiMoteUpdate();
+ void MultiWiiMoteIRInput();
+ void StartCalibration();
+ void StopCalibration();
+
+ private:
+
+ int m_ThreadID;
+ itk::MultiThreader::Pointer m_MultiThreader;
+
+ itk::FastMutexLock::Pointer m_WiiMoteTrackingFinished;
+ bool m_StopWiiMoteTracking;
+
+ bool m_InCalibrationMode;
+
+ // two would have been enough
+ // this is just the generic approach
+ unsigned int m_NumberDetectedWiiMotes;
+ wiimote m_WiiMotes[2];
+
+ }; // end class
+} // end namespace
+#endif // MITK_WIIMOTETRACKINGDEVICE_H
\ No newline at end of file
Property changes on: mitk\Modules\InputDevices\WiiMoteIGT\mitkWiiMoteTrackingDevice.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native

File Metadata

Mime Type
application/octet-stream
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
606
Default Alt Text
WiiMoteIGTTracking.patch (42 KB)

Event Timeline