Medical Imaging Interaction Toolkit  2018.4.99-701c8286
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.

◆ EventConfig() [2/5]

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

◆ 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

◆ 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

◆ 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);

◆ ~EventConfig()

mitk::EventConfig::~EventConfig ( )

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.

◆ 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.

◆ ClearConfig()

void mitk::EventConfig::ClearConfig ( )

Reset this EventConfig object, rendering it invalid.

◆ GetAttributes()

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

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

◆ 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' .

◆ IsValid()

bool mitk::EventConfig::IsValid ( ) const

Checks wether this EventConfig object is valid.

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

◆ operator=()

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

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