| 95 | } |
| 96 | |
| 97 | bool mitk::EventStateMachine::HandleEvent(InteractionEvent *event, DataNode *dataNode) |
| 98 | { |
| 99 | if (!m_IsActive) |
| 100 | return false; |
| 101 | |
| 102 | if (!FilterEvents(event, dataNode)) |
| 103 | { |
| 104 | return false; |
| 105 | } |
| 106 | |
| 107 | // Get the transition that can be executed |
| 108 | mitk::StateMachineTransition::Pointer transition = GetExecutableTransition(event); |
| 109 | |
| 110 | // check if the current state holds a transition that works with the given event. |
| 111 | if (transition.IsNotNull()) |
| 112 | { |
| 113 | // all conditions are fulfilled so we can continue with the actions |
| 114 | m_CurrentState = transition->GetNextState(); |
| 115 | |
| 116 | // iterate over all actions in this transition and execute them |
| 117 | const ActionVectorType actions = transition->GetActions(); |
| 118 | for (auto it = actions.cbegin(); it != actions.cend(); ++it) |
| 119 | { |
| 120 | try |
| 121 | { |
| 122 | ExecuteAction(*it, event); |
| 123 | } |
| 124 | catch (const std::exception &e) |
| 125 | { |
| 126 | MITK_ERROR << "Unhandled exception caught in ExecuteAction(): " << e.what(); |
| 127 | return false; |
| 128 | } |
| 129 | catch (...) |
| 130 | { |
| 131 | MITK_ERROR << "Unhandled exception caught in ExecuteAction()"; |
| 132 | return false; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return true; |
| 137 | } |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | void mitk::EventStateMachine::ConnectActionsAndFunctions() |
| 142 | { |
no test coverage detected