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