Medical Imaging Interaction Toolkit
2024.06.99-e4ca64e0
Medical Imaging Interaction Toolkit
|
Previously the statemachine pattern along with the event description has been stored in a single file (StateMachine.xml). Now the pattern and the events are separated from each other. The statemachine pattern describes the workflow and the configuration file describes which specific event triggers an action in the workflow. Every pattern is now put into a single file (for inclusion refer to Register statemachine patterns and configuration w/o the build system ).
The pattern description has to be completely rewritten, but is pretty straight forward based on the old one, how to do this is explained here HowTo Write a State Machine . Here an example is shown for a simple state containing a transition and a parameter.
Example snippet (old)
Example snippet (new)
Changes:
Event_class describes the class of the event (see Event Class ) - the event_variant provides a name that is used in the configuration file to give an explicit description of the event (or the globalConfig.xml is loaded as configuration file and standard values are used).
Configuration files for state machines are described here: How to create a Config-File .
Actions are now directly connected to functions in the DataInteractors, so the classic switch statement becomes obsolete:
changes to
where each action is implemented as a function. See Implementation of a new mitk::DataInteractor .
Formerly there where so called guard states, which cause a transition only if certain conditions are met. These states have been removed, as a replacement serve the InternalEvents which can be triggered from within a data interactor. An example showing how to use them is given in Example Interactor using InternalEvent .
In most cases, guard states can be eliminated by using transition conditions.
There are different ways to load a statemachine pattern or configuration objects from files. If you are working in a module you can use the resources to easily load patterns and configurations. To use this place your XML file in the 'Resources/Interactions' folder of the respective module, and add the file path to the corresponding files.cmake in the resource section like this:
Loading the statemachine pattern can then be done by simply calling
here module is optional, if none is provided the core module is assumed.
The third possibility is to build up a configuration by vector of mitk::PropertyLists, where each item describes an event configuration.
In the following example a configuration is build which defines two event variants using basic properties, for a full list of usable properties see mitkInteractionEventConst.h