Medical Imaging Interaction Toolkit  2018.4.99-ef453c4b
Medical Imaging Interaction Toolkit
mitkApplicationCursor.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkApplicationCursor.h"
14 #include <mitkLogMacros.h>
15 
16 #include <iostream>
17 
18 mitk::ApplicationCursorImplementation *mitk::ApplicationCursor::m_Implementation = nullptr;
19 
20 namespace mitk
21 {
24  {
25  static ApplicationCursor *m_Instance = nullptr;
26  if (!m_Instance)
27  {
28  m_Instance = new ApplicationCursor();
29  }
30 
31  return m_Instance;
32  }
33 
35  {
36  m_Implementation = implementation;
37  }
38 
39  void ApplicationCursor::PushCursor(std::istream &cursor, int hotspotX, int hotspotY)
40  {
41  if (m_Implementation)
42  {
43  m_Implementation->PushCursor(cursor, hotspotX, hotspotY);
44  }
45  else
46  {
47  MITK_ERROR << "in mitk::ApplicationCursor::PushCursor(): no implementation registered." << std::endl;
48  throw std::logic_error("No implementation registered for mitk::ApplicationCursor.");
49  }
50  }
51 
52  void ApplicationCursor::PushCursor(const char *XPM[], int hotspotX, int hotspotY)
53  {
54  if (m_Implementation)
55  {
56  m_Implementation->PushCursor(XPM, hotspotX, hotspotY);
57  }
58  else
59  {
60  MITK_ERROR << "in mitk::ApplicationCursor::PushCursor(): no implementation registered." << std::endl;
61  throw std::logic_error("No implementation registered for mitk::ApplicationCursor.");
62  }
63  }
64 
66  {
67  if (m_Implementation)
68  {
69  m_Implementation->PopCursor();
70  }
71  else
72  {
73  MITK_ERROR << "in mitk::ApplicationCursor::PopCursor(): no implementation registered." << std::endl;
74  throw std::logic_error("No implementation registered for mitk::ApplicationCursor.");
75  }
76  }
77 
79  {
80  if (m_Implementation)
81  {
82  return m_Implementation->GetCursorPosition();
83  }
84  else
85  {
86  MITK_ERROR << "in mitk::ApplicationCursor::GetCursorPosition(): no implementation registered." << std::endl;
87  throw std::logic_error("No implementation registered for mitk::ApplicationCursor.");
88  }
89  }
90 
92  {
93  if (m_Implementation)
94  {
95  m_Implementation->SetCursorPosition(p);
96  }
97  else
98  {
99  MITK_ERROR << "in mitk::ApplicationCursor::SetCursorPosition(): no implementation registered." << std::endl;
100  throw std::logic_error("No implementation registered for mitk::ApplicationCursor.");
101  }
102  }
103 
104 } // namespace
void SetCursorPosition(const Point2I &)
Set absolute mouse position on screen.
Allows to override the application&#39;s cursor.
virtual void SetCursorPosition(const Point2I &)=0
Set absolute mouse position on screen.
#define MITK_ERROR
Definition: mitkLogMacros.h:20
DataCollection - Class to facilitate loading/accessing structured data.
static void RegisterImplementation(ApplicationCursorImplementation *implementation)
To be called by a toolkit specific ApplicationCursorImplementation.
Toolkit specific implementation of mitk::ApplicationCursor.
void PopCursor()
Restore the previous cursor.
static ApplicationCursor * GetInstance()
This class is a singleton.
void PushCursor(const char *XPM[], int hotspotX=-1, int hotspotY=-1)
Change the current application cursor.
ApplicationCursor()
Purposely hidden - singleton.
virtual void PushCursor(const char *XPM[], int hotspotX, int hotspotY)=0
Change the current application cursor.
virtual const Point2I GetCursorPosition()=0
Get absolute mouse position on screen.
virtual void PopCursor()=0
Restore the previous cursor.