Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
Medical Imaging Interaction Toolkit
mitkInteractionEventHandler.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 
14 #include "mitkInteractionEvent.h"
15 
17 {
18 }
19 
21 {
22 }
23 
24 bool mitk::InteractionEventHandler::SetEventConfig(const std::string &filename, const us::Module *module)
25 {
26  EventConfig newConfig(filename, module);
27  if (newConfig.IsValid())
28  {
29  m_EventConfig = newConfig;
30  // notify sub-classes that new config is set
32  return true;
33  }
34  MITK_ERROR << "InteractionEventHandler: Failed to load EventConfiguration";
35  return false;
36 }
37 
39 {
40  if (config.IsValid())
41  {
42  m_EventConfig = config;
43  // notify sub-classes that new config is set
45  return true;
46  }
47  return false;
48 }
49 
51 {
52  return m_EventConfig;
53 }
54 
55 bool mitk::InteractionEventHandler::AddEventConfig(const std::string &filename, const us::Module *module)
56 {
57  if (!m_EventConfig.IsValid())
58  {
59  MITK_ERROR << "SetEventConfig has to be called before AddEventConfig can be used.";
60  return false;
61  }
62  // notify sub-classes that new config is set
63  bool success = m_EventConfig.AddConfig(filename, module);
64  if (success)
65  {
67  }
68  return success;
69 }
70 
72 {
73  if (!m_EventConfig.IsValid())
74  {
75  MITK_ERROR << "SetEventConfig has to be called before AddEventConfig can be used.";
76  return false;
77  }
78  // notify sub-classes that new config is set
79  bool success = m_EventConfig.AddConfig(config);
80  if (success)
81  {
83  }
84  return success;
85 }
86 
88 {
89  if (m_EventConfig.IsValid())
90  {
91  return m_EventConfig.GetAttributes();
92  }
93  else
94  {
95  MITK_ERROR << "InteractionEventHandler::GetAttributes() requested, but not configuration loaded.";
96  return nullptr;
97  }
98 }
99 
101 {
102  if (m_EventConfig.IsValid())
103  {
104  return m_EventConfig.GetMappedEvent(interactionEvent);
105  }
106  else
107  {
108  return "";
109  }
110 }
111 
113 {
114 }
#define MITK_ERROR
Definition: mitkLogMacros.h:20
std::string GetMappedEvent(const EventType &interactionEvent) const
bool AddConfig(const std::string &filename, const us::Module *module=nullptr)
This method extends this configuration.
bool IsValid() const
Checks wether this EventConfig object is valid.
EventConfig GetEventConfig() const
Returns the current configuration.
Configuration Object for Statemachines.
PropertyList::Pointer GetAttributes() const
bool AddEventConfig(const std::string &filename, const us::Module *module=nullptr)
This method extends the configuration.
PropertyList::Pointer GetAttributes() const
std::string MapToEventVariant(InteractionEvent *interactionEvent)
bool SetEventConfig(const std::string &filename, const us::Module *module=nullptr)
Loads a configuration from an XML resource.