Medical Imaging Interaction Toolkit  2018.4.99-6aa36ba9
Medical Imaging Interaction Toolkit
mitk::EventConfig Class Reference

Configuration Object for Statemachines. More...

#include <mitkEventConfig.h>

Public Types

typedef itk::SmartPointer< InteractionEventEventType
 

Public Member Functions

 EventConfig ()
 Constructs an invalid EventConfig object. More...
 
 EventConfig (const EventConfig &other)
 
 EventConfig (const std::string &filename, const us::Module *module=nullptr)
 Construct an EventConfig object based on a XML configuration file. More...
 
 EventConfig (std::istream &inputStream)
 Construct an EventConfig object based on a XML configuration file. More...
 
 EventConfig (const std::vector< PropertyList::Pointer > &configDescription)
 Construct an EventConfig object based on a vector of mitk::PropertyLists. More...
 
EventConfigoperator= (const EventConfig &other)
 
 ~EventConfig ()
 
bool IsValid () const
 Checks wether this EventConfig object is valid. More...
 
bool AddConfig (const std::string &filename, const us::Module *module=nullptr)
 This method extends this configuration. More...
 
bool AddConfig (const EventConfig &config)
 This method extends this configuration. The configuration from the EventConfig object is loaded and only the ones conflicting are replaced by the new one. This way several configurations can be combined. More...
 
void ClearConfig ()
 Reset this EventConfig object, rendering it invalid. More...
 
PropertyList::Pointer GetAttributes () const
 
std::string GetMappedEvent (const EventType &interactionEvent) const
 

Detailed Description

Configuration Object for Statemachines.

Reads given config file, which translates specific user inputs (InteractionEvents) into EventVariants that can be processed by the StateMachine. Refer to How to create a Config-File .

Definition at line 44 of file mitkEventConfig.h.

Member Typedef Documentation

◆ EventType

Constructor & Destructor Documentation

◆ EventConfig() [1/5]

mitk::EventConfig::EventConfig ( )

Constructs an invalid EventConfig object.

Call LoadConfig to create a valid configuration object.

Definition at line 233 of file mitkEventConfig.cpp.

◆ EventConfig() [2/5]

mitk::EventConfig::EventConfig ( const EventConfig other)

Definition at line 237 of file mitkEventConfig.cpp.

◆ EventConfig() [3/5]

mitk::EventConfig::EventConfig ( const std::string &  filename,
const us::Module module = nullptr 
)

Construct an EventConfig object based on a XML configuration file.

Uses the specified resource file containing an XML event configuration to construct an EventConfig object. If the resource is invalid, the created EventConfig object will also be invalid.

Parameters
filenameThe resource name relative to the Interactions resource folder.
module

Definition at line 241 of file mitkEventConfig.cpp.

References ModuleContext::GetModule(), us::GetModuleContext(), us::Module::GetName(), us::Module::GetResource(), us::ModuleResource::IsValid(), and MITK_ERROR.

◆ EventConfig() [4/5]

mitk::EventConfig::EventConfig ( std::istream &  inputStream)

Construct an EventConfig object based on a XML configuration file.

Uses the specified istream refering to a file containing an XML event configuration to construct an EventConfig object. If the resource is invalid, the created EventConfig object will also be invalid.

Parameters
inputStreamstd::ifstream to XML configuration file

Definition at line 265 of file mitkEventConfig.cpp.

◆ EventConfig() [5/5]

mitk::EventConfig::EventConfig ( const std::vector< PropertyList::Pointer > &  configDescription)

Construct an EventConfig object based on a vector of mitk::PropertyLists.

Constructs the EventObject based on a description provided by vector of property values, where each mitk::PropertyList describes one Event. Example

#include "mitkEventConfig.h"
#include "mitkPropertyList.h"
// First event
// Setting the EventClass property to 'MousePressEvent'
propertyList1->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventClass.c_str(), "MousePressEvent");
// Setting the Event variant value to 'MousePressEventVariantÄ
propertyList1->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventVariant.c_str(),
"MousePressEventVariant");
// set control and alt buttons as modifiers
propertyList1->SetStringProperty("Modifiers","CTRL,ALT");
// Second event
propertyList2->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventClass.c_str(),
"MouseReleaseEvent");
propertyList2->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventVariant.c_str(),
"MouseReleaseEventVariant");
propertyList2->SetStringProperty("Modifiers","SHIFT");
// putting both descriptions in a vector
std::vector<mitk::PropertyList::Pointer>* configDescription = new std::vector<mitk::PropertyList::Pointer>();
configDescription->push_back(propertyList1);
configDescription->push_back(propertyList2);
// create the config object
mitk::EventConfig newConfig(configDescription);

Definition at line 276 of file mitkEventConfig.cpp.

References mitk::EventFactory::CreateEvent(), MITK_WARN, mitk::InteractionEventConst::xmlParameterName(), mitk::InteractionEventConst::xmlParameterValue(), mitk::InteractionEventConst::xmlTagEventVariant(), and mitk::InteractionEventConst::xmlTagParam().

◆ ~EventConfig()

mitk::EventConfig::~EventConfig ( )

Definition at line 319 of file mitkEventConfig.cpp.

Member Function Documentation

◆ AddConfig() [1/2]

bool mitk::EventConfig::AddConfig ( const std::string &  filename,
const us::Module module = nullptr 
)

This method extends this configuration.

The configuration from the resource provided is loaded and only the ones conflicting are replaced by the new one. This way several configuration files can be combined.

See also
AddConfig(const EventConfig&)
InteractionEventHandler::AddEventConfig(const std::string&, const Module*)
Parameters
filenameThe resource name relative to the Interactions resource folder.
moduleThe module containing the resource. Defaults to the Mitk module.
Returns
true if the configuration was successfully added, false otherwise.

Definition at line 328 of file mitkEventConfig.cpp.

References ModuleContext::GetModule(), us::GetModuleContext(), us::Module::GetName(), us::Module::GetResource(), us::ModuleResource::IsValid(), and MITK_ERROR.

Referenced by mitk::InteractionEventHandler::AddEventConfig().

◆ AddConfig() [2/2]

bool mitk::EventConfig::AddConfig ( const EventConfig config)

This method extends this configuration. The configuration from the EventConfig object is loaded and only the ones conflicting are replaced by the new one. This way several configurations can be combined.

See also
AddConfig(const std::string&, const Module*)
InteractionEventHandler::AddEventConfig(const EventConfig&)
Parameters
configThe EventConfig object whose configuration should be added.
Returns
true if the configuration was successfully added, false otherwise.

Definition at line 353 of file mitkEventConfig.cpp.

References us::SharedDataPointer< T >::Clone(), and IsValid().

◆ ClearConfig()

void mitk::EventConfig::ClearConfig ( )

Reset this EventConfig object, rendering it invalid.

Definition at line 398 of file mitkEventConfig.cpp.

◆ GetAttributes()

mitk::PropertyList::Pointer mitk::EventConfig::GetAttributes ( ) const

Returns a PropertyList that contains the properties set in the configuration file. All properties are stored as strings.

Definition at line 366 of file mitkEventConfig.cpp.

Referenced by mitk::InteractionEventHandler::GetAttributes(), and mitkEventConfigTest().

◆ GetMappedEvent()

std::string mitk::EventConfig::GetMappedEvent ( const EventType interactionEvent) const

Checks if the config object has a definition for the given event. If it has, the corresponding variant name is returned, else an empty string is returned.

Note
mitk::InternalEvent is handled differently. Their signal name is returned as event variant. So there is no need to configure them in a config file.
mitk::InteractionKeyEvent may have a defined event variant, if this is the case, this function returns it. If no such definition is found key events are mapped to Std + Key , so an 'A' will be return as 'StdA' .

Definition at line 371 of file mitkEventConfig.cpp.

References mitk::InternalEvent::GetSignalName().

Referenced by mitk::InteractionEventHandler::MapToEventVariant(), and mitkEventConfigTest().

◆ IsValid()

bool mitk::EventConfig::IsValid ( ) const

Checks wether this EventConfig object is valid.

Returns
Returns true if a configuration was successfully loaded, false otherwise.

Definition at line 323 of file mitkEventConfig.cpp.

Referenced by AddConfig(), mitk::InteractionEventHandler::AddEventConfig(), mitk::InteractionEventHandler::GetAttributes(), mitk::InteractionEventHandler::MapToEventVariant(), mitkEventConfigTest(), and mitk::InteractionEventHandler::SetEventConfig().

◆ operator=()

mitk::EventConfig & mitk::EventConfig::operator= ( const EventConfig other)

Definition at line 313 of file mitkEventConfig.cpp.


The documentation for this class was generated from the following files: