Hi Miklos,
you’re right – transitions is the way to go here, they are replacing the guard
states.
We only very recently added a small paragraph about Conditions in the Step10 of
the tutorial,
but I forgot about the mention in the migration guide. I’ll fix that! Thanks
for pointing out!
Best,
Christian
From: Miklos Espak [mailto:[email protected]]
Sent: Samstag, 21. Juni 2014 09:47
To: mitk-users
Subject: [mitk-users] Interaction framework migration, guard states -> internal
events or conditions?
Hi,
I want to migrate a state machine from the old style to the new one. It has
guard states. The documentation says that guard states have been removed and
you should use internal events, like this:
<state name="start" startstate="true" >
<transition event_class="MousePressEvent" event_variant="AddPointClick"
target="start">
<action name="addPoint"/>
</transition>
<transition event_class="InternalEvent" event_variant="enoughPointsAdded"
target="final">
<action name="enoughPoints"/>
</transition>
</state>
and check the condition inside the 'addPoint' action and if it fulfils, raise
the internal event programmatically, like this:
InteractionPositionEvent* positionEvent =
dynamic_cast<InteractionPositionEvent*>(interactionEvent);
if (positionEvent != NULL)
{
...
if (...)
{
// create internal event that signal that the maximal number of points is
reached
InternalEvent::Pointer event = InternalEvent::New(NULL,this,
"enoughPointsAdded");
// add the internal event to the event queue of the Dispatcher
positionEvent->GetSender()->GetDispatcher()->QueueEvent(event.GetPointer());
}
However, in a recent version of MITK I see 'conditions', like this:
<state name="selected">
<transition event_class="MouseMoveEvent" event_variant="CheckSelected"
target="start">
<condition name="isoverpoint" inverted="true"/>
<action name="update"/>
<action name="unselectAll"/>
</transition>
which are connected like this:
// Condition which is evaluated before transition is taken
// following actions in the statemachine are only executed if it returns TRUE
CONNECT_CONDITION("isoverpoint", CheckSelection);
CONNECT_FUNCTION("addpoint", AddPoint);
...
But I have not found anything in the documentation about this. This solution
seems much simpler, though.
Are the conditions to replace the guard states? I do not need to bother with
internal events, right?
Cheers,
Miklos
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users