Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkMouseModeSwitcher.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 "mitkMouseModeSwitcher.h"
14 // us
15 #include "usGetModuleContext.h"
16 #include "usModuleContext.h"
17 
19 
21  : m_ActiveInteractionScheme(MITK), m_ActiveMouseMode(MousePointer), m_CurrentObserver(nullptr)
22 {
23  this->InitializeListeners();
24  this->SetInteractionScheme(m_ActiveInteractionScheme);
25 }
26 
28 {
29  m_ServiceRegistration.Unregister();
30 }
31 
32 void mitk::MouseModeSwitcher::InitializeListeners()
33 {
34  if (m_CurrentObserver.IsNull())
35  {
36  m_CurrentObserver = mitk::DisplayInteractor::New();
37  m_CurrentObserver->LoadStateMachine("DisplayInteraction.xml");
38  m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml");
39  // Register as listener via micro services
41  props["name"] = std::string("DisplayInteractor");
42  m_ServiceRegistration =
43  us::GetModuleContext()->RegisterService<InteractionEventObserver>(m_CurrentObserver.GetPointer(), props);
44  }
45 }
46 
48 {
49  switch (scheme)
50  {
51  case MITK:
52  {
53  m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml");
54  }
55  break;
56  case PACS:
57  {
58  m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml");
59  }
60  break;
61 
62  case ROTATION:
63  {
64  m_CurrentObserver->SetEventConfig("DisplayConfigMITKRotationUnCoupled.xml");
65  }
66  break;
67 
68  case ROTATIONLINKED:
69  {
70  m_CurrentObserver->SetEventConfig("DisplayConfigMITKRotation.xml");
71  }
72  break;
73 
74  case SWIVEL:
75  {
76  m_CurrentObserver->SetEventConfig("DisplayConfigMITKSwivel.xml");
77  }
78  break;
79  }
80  m_ActiveInteractionScheme = scheme;
81  this->InvokeEvent(MouseModeChangedEvent());
82 }
83 
85 {
86  if (m_ActiveInteractionScheme != PACS)
87  return;
88 
89  switch (mode)
90  {
91  case MousePointer:
92  {
93  m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml");
94  break;
95  } // case 0
96  case Scroll:
97  {
98  m_CurrentObserver->AddEventConfig("DisplayConfigPACSScroll.xml");
99 
100  break;
101  }
102  case LevelWindow:
103  {
104  m_CurrentObserver->AddEventConfig("DisplayConfigPACSLevelWindow.xml");
105  break;
106  }
107  case Zoom:
108  {
109  m_CurrentObserver->AddEventConfig("DisplayConfigPACSZoom.xml");
110  break;
111  }
112  case Pan:
113  {
114  m_CurrentObserver->AddEventConfig("DisplayConfigPACSPan.xml");
115  break;
116  }
117  } // end switch (mode)
118  m_ActiveMouseMode = mode;
119  this->InvokeEvent(MouseModeChangedEvent());
120 }
121 
123 {
124  return m_ActiveMouseMode;
125 }
Base class to implement InteractionEventObservers.
ServiceRegistrationU RegisterService(const InterfaceMap &service, const ServiceProperties &properties=ServiceProperties())
void SetInteractionScheme(InteractionScheme)
Setter for interaction scheme.
static Pointer New()
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
MouseMode GetCurrentMouseMode() const
Returns the current mouse mode.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void SelectMouseMode(MouseMode mode)
Setter for mouse mode.