Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
17 #include "mitkMouseModeSwitcher.h"
18 // us
19 #include "usGetModuleContext.h"
20 #include "usModuleContext.h"
21 
23 
25  : m_ActiveInteractionScheme(MITK), m_ActiveMouseMode(MousePointer), m_CurrentObserver(NULL)
26 {
27  this->InitializeListeners();
28  this->SetInteractionScheme(m_ActiveInteractionScheme);
29 }
30 
32 {
33  m_ServiceRegistration.Unregister();
34 }
35 
36 void mitk::MouseModeSwitcher::InitializeListeners()
37 {
38  if (m_CurrentObserver.IsNull())
39  {
40  m_CurrentObserver = mitk::DisplayInteractor::New();
41  m_CurrentObserver->LoadStateMachine("DisplayInteraction.xml");
42  m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml");
43  // Register as listener via micro services
45  props["name"] = std::string("DisplayInteractor");
46  m_ServiceRegistration =
47  us::GetModuleContext()->RegisterService<InteractionEventObserver>(m_CurrentObserver.GetPointer(), props);
48  }
49 }
50 
52 {
53  switch (scheme)
54  {
55  case MITK:
56  {
57  m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml");
58  }
59  break;
60  case PACS:
61  {
62  m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml");
63  }
64  break;
65 
66  case ROTATION:
67  {
68  m_CurrentObserver->SetEventConfig("DisplayConfigMITKRotationUnCoupled.xml");
69  }
70  break;
71 
72  case ROTATIONLINKED:
73  {
74  m_CurrentObserver->SetEventConfig("DisplayConfigMITKRotation.xml");
75  }
76  break;
77 
78  case SWIVEL:
79  {
80  m_CurrentObserver->SetEventConfig("DisplayConfigMITKSwivel.xml");
81  }
82  break;
83  }
84  m_ActiveInteractionScheme = scheme;
85  this->InvokeEvent(MouseModeChangedEvent());
86 }
87 
89 {
90  if (m_ActiveInteractionScheme != PACS)
91  return;
92 
93  switch (mode)
94  {
95  case MousePointer:
96  {
97  m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml");
98  break;
99  } // case 0
100  case Scroll:
101  {
102  m_CurrentObserver->AddEventConfig("DisplayConfigPACSScroll.xml");
103 
104  break;
105  }
106  case LevelWindow:
107  {
108  m_CurrentObserver->AddEventConfig("DisplayConfigPACSLevelWindow.xml");
109  break;
110  }
111  case Zoom:
112  {
113  m_CurrentObserver->AddEventConfig("DisplayConfigPACSZoom.xml");
114  break;
115  }
116  case Pan:
117  {
118  m_CurrentObserver->AddEventConfig("DisplayConfigPACSPan.xml");
119  break;
120  }
121  } // end switch (mode)
122  m_ActiveMouseMode = mode;
123  this->InvokeEvent(MouseModeChangedEvent());
124 }
125 
127 {
128  return m_ActiveMouseMode;
129 }
Base class to implement InteractionEventObservers.
ServiceRegistrationU RegisterService(const InterfaceMap &service, const ServiceProperties &properties=ServiceProperties())
void SetInteractionScheme(InteractionScheme)
Setter for interaction scheme.
static Pointer New()
The LevelWindow class Class to store level/window values.
MouseMode GetCurrentMouseMode() const
Returns the current mouse mode.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void SelectMouseMode(MouseMode mode)
Setter for mouse mode.