Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
Super-class that provides the functionality of a StateMachine to DataInteractors. More...
#include <mitkEventStateMachine.h>
Public Types | |
typedef EventStateMachine | Self |
typedef InteractionEventHandler | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
typedef std::map< std::string, TActionFunctor * > | ActionFunctionsMapType |
typedef itk::SmartPointer< StateMachineState > | StateMachineStateType |
Public Types inherited from mitk::InteractionEventHandler | |
typedef InteractionEventHandler | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
Public Member Functions | |
virtual std::vector< std::string > | GetClassHierarchy () const override |
virtual const char * | GetClassName () const |
bool | LoadStateMachine (const std::string &filename, const us::Module *module=nullptr) |
Loads XML resource. More... | |
bool | HandleEvent (InteractionEvent *event, DataNode *dataNode) |
void | EnableUndo (bool enable) |
Enables or disabled Undo. More... | |
void | EnableInteraction (bool enable) |
Enables/disables the state machine. In un-enabled state it won't react to any events. More... | |
Public Member Functions inherited from mitk::InteractionEventHandler | |
bool | SetEventConfig (const std::string &filename, const us::Module *module=nullptr) |
Loads a configuration from an XML resource. More... | |
bool | SetEventConfig (const EventConfig &config) |
Loads a configuration from an EventConfig object. More... | |
EventConfig | GetEventConfig () const |
Returns the current configuration. More... | |
bool | AddEventConfig (const std::string &filename, const us::Module *module=nullptr) |
This method extends the configuration. More... | |
bool | AddEventConfig (const EventConfig &config) |
This method extends the 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... | |
Static Public Member Functions | |
static const char * | GetStaticNameOfClass () |
Static Public Member Functions inherited from mitk::InteractionEventHandler | |
static const char * | GetStaticNameOfClass () |
Protected Types | |
typedef MessageAbstractDelegate2< StateMachineAction *, InteractionEvent *, void > | ActionFunctionDelegate |
typedef MessageAbstractDelegate1< const InteractionEvent *, bool > | ConditionFunctionDelegate |
Protected Member Functions | |
EventStateMachine () | |
virtual | ~EventStateMachine () |
void | AddActionFunction (const std::string &action, TActionFunctor *functor) |
void | AddActionFunction (const std::string &action, const ActionFunctionDelegate &delegate) |
void | AddConditionFunction (const std::string &condition, const ConditionFunctionDelegate &delegate) |
StateMachineState * | GetCurrentState () const |
void | ResetToStartState () |
ResetToStartState Reset state machine to it initial starting state. More... | |
virtual void | ConnectActionsAndFunctions () |
virtual bool | CheckCondition (const StateMachineCondition &condition, const InteractionEvent *interactionEvent) |
virtual void | ExecuteAction (StateMachineAction *action, InteractionEvent *interactionEvent) |
virtual bool | FilterEvents (InteractionEvent *interactionEvent, DataNode *dataNode) |
void | SetMouseCursor (const char *xpm[], int hotspotX, int hotspotY) |
Sets the specified mouse cursor. More... | |
void | ResetMouseCursor () |
Resets the mouse cursor (if modified by the SlicesCoordinator) to its original state. More... | |
StateMachineTransition * | GetExecutableTransition (InteractionEvent *event) |
Returns the executable transition for the given event. More... | |
Protected Member Functions inherited from mitk::InteractionEventHandler | |
InteractionEventHandler () | |
virtual | ~InteractionEventHandler () |
PropertyList::Pointer | GetAttributes () const |
std::string | MapToEventVariant (InteractionEvent *interactionEvent) |
virtual void | ConfigurationChanged () |
Protected Attributes | |
bool | m_IsActive |
UndoController * | m_UndoController |
bool | m_UndoEnabled |
Super-class that provides the functionality of a StateMachine to DataInteractors.
A state machine is created by loading a state machine pattern. It consists of states, transitions and action. The state represent the current status of the interaction, transitions are means to switch between states. Each transition is triggered by an event and it is associated with actions that are to be executed when the state change is performed.
Definition at line 115 of file mitkEventStateMachine.h.
|
protected |
Definition at line 160 of file mitkEventStateMachine.h.
typedef std::map<std::string, TActionFunctor *> mitk::EventStateMachine::ActionFunctionsMapType |
Definition at line 120 of file mitkEventStateMachine.h.
|
protected |
Definition at line 161 of file mitkEventStateMachine.h.
typedef itk::SmartPointer<const Self> mitk::EventStateMachine::ConstPointer |
Definition at line 118 of file mitkEventStateMachine.h.
Definition at line 118 of file mitkEventStateMachine.h.
Definition at line 118 of file mitkEventStateMachine.h.
Definition at line 122 of file mitkEventStateMachine.h.
Definition at line 118 of file mitkEventStateMachine.h.
|
protected |
here the Undo mechanism is enabled / disabled for all interactors.
Definition at line 27 of file mitkEventStateMachine.cpp.
References m_UndoController, m_UndoEnabled, and mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO.
|
protectedvirtual |
Definition at line 88 of file mitkEventStateMachine.cpp.
|
protected |
Connects action from StateMachine (String in XML file) with a function that is called when this action is to be executed.
Definition at line 96 of file mitkEventStateMachine.cpp.
|
protected |
Definition at line 111 of file mitkEventStateMachine.cpp.
References mitk::MessageAbstractDelegate2< T, U, A >::Clone().
|
protected |
Definition at line 124 of file mitkEventStateMachine.cpp.
References mitk::MessageAbstractDelegate1< T, A >::Clone().
|
protectedvirtual |
Definition at line 180 of file mitkEventStateMachine.cpp.
References mitk::StateMachineCondition::GetConditionName(), and MITK_WARN.
|
protectedvirtual |
Is called after loading a statemachine. Overwrite this function in specific interactor implementations. Connect actions and functions using the CONNECT_FUNCTION macro within this function.
Reimplemented in mitk::Tool, mitk::FastMarchingTool, mitk::PointSetDataInteractor, mitk::TubeGraphDataInteractor, mitk::DataInteractor, mitk::PlanarFigureInteractor, mitk::RegionGrowingTool, mitk::CorrectorTool2D, mitk::LiveWireTool2D, mitk::ContourTool, mitk::PaintbrushTool, mitk::DisplayInteractor, mitk::AffineBaseDataInteractor3D, mitk::SetRegionTool, mitk::ContourModelLiveWireInteractor, mitk::ContourModelInteractor, mitk::SegmentationInteractor, mitk::AffineImageCropperInteractor, mitk::ClippingPlaneInteractor3D, mitk::SurfaceDeformationDataInteractor3D, mitk::SimulationInteractor, and mitk::ExampleInteractor.
Definition at line 174 of file mitkEventStateMachine.cpp.
References MITK_WARN.
Referenced by mitk::SegmentationInteractor::ConnectActionsAndFunctions().
|
inline |
Enables/disables the state machine. In un-enabled state it won't react to any events.
Definition at line 155 of file mitkEventStateMachine.h.
|
inline |
Enables or disabled Undo.
Definition at line 151 of file mitkEventStateMachine.h.
|
protectedvirtual |
Looks up function that is associated with action and executes it. To implement your own execution scheme overwrite this in your DataInteractor.
Definition at line 196 of file mitkEventStateMachine.cpp.
References mitk::StateMachineAction::GetActionName(), and MITK_WARN.
|
protectedvirtual |
Implements filter scheme for events. Standard implementation accepts events from 2d and 3d windows, and rejects events if DataNode is not visible.
Overwrite this function to adapt for your own needs, for example to filter out events from 3d windows like this:
or to enforce that the interactor only reacts when the corresponding DataNode is selected in the DataManager view..
Reimplemented in mitk::Tool, mitk::PlanarFigureInteractor, mitk::SegTool2D, and mitk::DisplayInteractor.
Definition at line 230 of file mitkEventStateMachine.cpp.
References mitk::DataNode::GetBoolProperty(), mitk::InteractionEvent::GetSender(), and MITK_WARN.
|
inlineoverridevirtual |
Reimplemented from mitk::InteractionEventHandler.
Reimplemented in mitk::PointSetDataInteractor, mitk::DataInteractor, mitk::SinglePointDataInteractor, and mitk::DisplayInteractor.
Definition at line 118 of file mitkEventStateMachine.h.
|
virtual |
Reimplemented from mitk::InteractionEventHandler.
Reimplemented in mitk::PointSetDataInteractor, mitk::DataInteractor, mitk::SinglePointDataInteractor, and mitk::DisplayInteractor.
|
protected |
Definition at line 225 of file mitkEventStateMachine.cpp.
|
protected |
Returns the executable transition for the given event.
This method takes a list of transitions that correspond to the given event from the current state.
This method iterates through all transitions and checks all corresponding conditions. The results of each condition in stored in map, as other transitions may need the same condition again.
As soon as a transition is found for which all conditions are fulfilled, this instance is returned.
If a transition has no condition, it is automatically returned. If no executable transition is found, NULL is returned.
Definition at line 245 of file mitkEventStateMachine.cpp.
References MITK_ERROR.
|
inlinestatic |
Definition at line 118 of file mitkEventStateMachine.h.
bool mitk::EventStateMachine::HandleEvent | ( | InteractionEvent * | event, |
DataNode * | dataNode | ||
) |
Receives Event from Dispatcher. Event is mapped using the EventConfig Object to a variant, then it is checked if the StateMachine is listening for such an Event. If this is the case, the transition to the next state it performed and all actions associated with the transition executed, and true is returned to the caller. If the StateMachine can't handle this event false is returned. Attention: If a transition is associated with multiple actions - "true" is returned if one action returns true, and the event is treated as HANDLED even though some actions might not have been executed! So be sure that all actions that occur within one transitions have the same conditions.
Definition at line 130 of file mitkEventStateMachine.cpp.
References MITK_ERROR.
Referenced by mitk::DisplayInteractor::Notify().
bool mitk::EventStateMachine::LoadStateMachine | ( | const std::string & | filename, |
const us::Module * | module = nullptr |
||
) |
Loads XML resource.
Loads a XML resource file from the given module. Default is the Mitk module (core). The files have to be placed in the Resources/Interaction folder of their respective module.
Definition at line 45 of file mitkEventStateMachine.cpp.
References mitk::ConnectActionsAndFunctions(), filename, MITK_WARN, and mitk::StateMachineContainer::New().
|
protected |
Resets the mouse cursor (if modified by the SlicesCoordinator) to its original state.
Should be used by subclasses and from external application instead of using QmitkApplicationCursor directly to avoid conflicts.
Definition at line 342 of file mitkEventStateMachine.cpp.
References mitk::ApplicationCursor::GetInstance(), and mitk::ApplicationCursor::PopCursor().
|
protected |
ResetToStartState Reset state machine to it initial starting state.
Definition at line 325 of file mitkEventStateMachine.cpp.
|
protected |
Sets the specified mouse cursor.
Use this in subclasses instead of using QmitkApplicationCursor directly.
Definition at line 330 of file mitkEventStateMachine.cpp.
References mitk::ApplicationCursor::GetInstance(), mitk::ApplicationCursor::PopCursor(), and mitk::ApplicationCursor::PushCursor().
|
protected |
Definition at line 248 of file mitkEventStateMachine.h.
|
protected |
Definition at line 250 of file mitkEventStateMachine.h.
Referenced by EventStateMachine().
|
protected |
Definition at line 251 of file mitkEventStateMachine.h.
Referenced by EventStateMachine().