Index: Core/Code/DataManagement/mitkApplicationCursor.cpp =================================================================== --- Core/Code/DataManagement/mitkApplicationCursor.cpp (revision 20980) +++ Core/Code/DataManagement/mitkApplicationCursor.cpp (working copy) @@ -66,6 +66,33 @@ LOG_ERROR << "in mitk::ApplicationCursor::PopCursor(): no implementation registered." << std::endl; } } + +const Point2I ApplicationCursor::GetCursorPosition() +{ + if (m_Implementation) + { + return m_Implementation->GetCursorPosition(); + } + else + { + LOG_ERROR << "in mitk::ApplicationCursor::GetCursorPosition(): no implementation registered." << std::endl; + Point2I p; + p[0] = -1; p[1] = -1; + return p; + } +} + +void ApplicationCursor::SetCursorPosition(const Point2I& p) +{ + if (m_Implementation) + { + m_Implementation->SetCursorPosition(p); + } + else + { + LOG_ERROR << "in mitk::ApplicationCursor::SetCursorPosition(): no implementation registered." << std::endl; + } +} } // namespace Index: Core/Code/DataManagement/mitkApplicationCursor.h =================================================================== --- Core/Code/DataManagement/mitkApplicationCursor.h (revision 20980) +++ Core/Code/DataManagement/mitkApplicationCursor.h (working copy) @@ -17,7 +17,9 @@ #ifndef MITK_APPLICATION_CURSOR_H_DEFINED_AND_ALL_IS_GOOD #define MITK_APPLICATION_CURSOR_H_DEFINED_AND_ALL_IS_GOOD + #include "mitkCommon.h" +#include "mitkVector.h" namespace mitk { @@ -39,6 +41,12 @@ /// Restore the previous cursor virtual void PopCursor() = 0; + /// Get absolute mouse position on screen + virtual const Point2I GetCursorPosition() = 0; + + /// Set absolute mouse position on screen + virtual void SetCursorPosition(const Point2I&) = 0; + virtual ~ApplicationCursorImplementation() {}; protected: @@ -70,7 +78,15 @@ /// Restore the previous cursor void PopCursor(); + + /// Get absolute mouse position on screen + /// \return (-1, -1) if querying mouse position is not possible + const Point2I GetCursorPosition(); + /// Set absolute mouse position on screen + void SetCursorPosition(const Point2I&); + + protected: /// Purposely hidden - singleton Index: CoreUI/Qmitk/QmitkApplicationCursor.cpp =================================================================== --- CoreUI/Qmitk/QmitkApplicationCursor.cpp (revision 20980) +++ CoreUI/Qmitk/QmitkApplicationCursor.cpp (working copy) @@ -39,4 +39,19 @@ { QApplication::restoreOverrideCursor(); } + +const mitk::Point2I QmitkApplicationCursor::GetCursorPosition() +{ + mitk::Point2I mp; + QPoint qp = QCursor::pos(); + mp[0] = qp.x(); + mp[1] = qp.y(); + return mp; +} +void QmitkApplicationCursor::SetCursorPosition(const mitk::Point2I& p) +{ + QCursor::setPos( p[0], p[1] ); +} + + Index: CoreUI/Qmitk/QmitkApplicationCursor.h =================================================================== --- CoreUI/Qmitk/QmitkApplicationCursor.h (revision 20980) +++ CoreUI/Qmitk/QmitkApplicationCursor.h (working copy) @@ -35,7 +35,10 @@ virtual void PushCursor(const char* XPM[], int hotspotX, int hotspotY); virtual void PopCursor(); + virtual const mitk::Point2I GetCursorPosition(); + virtual void SetCursorPosition(const mitk::Point2I&); + protected: private: };