Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::EventConfig Class Reference

Configuration Object for Statemachines. More...

#include <mitkEventConfig.h>

Public Types

typedef itk::SmartPointer< InteractionEvent > EventType
 

Public Member Functions

 EventConfig ()
 Constructs an invalid EventConfig object. More...
 
 EventConfig (const EventConfig &other)
 Copy constructor. More...
 
 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...
 
EventConfig & operator= (const EventConfig &other)
 Copy assignment operator. More...
 
 ~EventConfig ()
 Destructor. More...
 
bool IsValid () const
 Checks whether 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. More...
 
void ClearConfig ()
 Reset this EventConfig object, rendering it invalid. More...
 
PropertyList::Pointer GetAttributes () const
 Returns the attributes defined in the configuration file. More...
 
std::string GetMappedEvent (const EventType &interactionEvent) const
 Get the mapped event variant name for a given interaction event. More...
 

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 .

See also
InteractionEvent
EventFactory

Definition at line 46 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)

Copy constructor.

Parameters
otherThe EventConfig object to copy from.

◆ 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.
moduleThe module containing the resource. Defaults to the Mitk module.

◆ EventConfig() [4/5]

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

Construct an EventConfig object based on a XML configuration file.

Uses the specified istream referring 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
mitk::PropertyList::Pointer propertyList1 = mitk::PropertyList::New();
// 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
mitk::PropertyList::Pointer propertyList2 = mitk::PropertyList::New();
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);
Configuration Object for Statemachines.
static Pointer New()
static const std::string xmlParameterEventVariant()
static const std::string xmlParameterEventClass()

◆ ~EventConfig()

mitk::EventConfig::~EventConfig ( )

Destructor.

Member Function Documentation

◆ AddConfig() [1/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.

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

◆ AddConfig() [2/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.

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.
See also
AddConfig(const EventConfig&)
InteractionEventHandler::AddEventConfig(const std::string&, const Module*)

◆ ClearConfig()

void mitk::EventConfig::ClearConfig ( )

Reset this EventConfig object, rendering it invalid.

◆ GetAttributes()

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

Returns the attributes defined in the configuration file.

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

Returns
A PropertyList containing the configuration attributes.

◆ GetMappedEvent()

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

Get the mapped event variant name for a given interaction event.

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 returned as 'StdA'.
Parameters
interactionEventThe interaction event to look up.
Returns
The mapped event variant name, or an empty string if no mapping exists.

◆ IsValid()

bool mitk::EventConfig::IsValid ( ) const

Checks whether this EventConfig object is valid.

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

◆ operator=()

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

Copy assignment operator.


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