Hi Piotr,
the operating system takes care of event handling in the first place. Secondly 
QT (if you use the ExtApp as application) takes care and MITK grabs these 
events and sends them to different statemachines called interactors. An 
Interactor consists of a state machine pattern, definition in XML (see 
Statemachine.xml, beware, currently there are two files, will be solved in the 
near furure), and a class where all actions are implemented.

So you need to adapt an existing or define a new state machine pattern, that 
takes care of your Z-Mouse-move zoom feature. One state within this pattern 
will fire an action AcMYACTION and the code that shall be executed needs to be 
declared in your interaction class. Both components are connected via the 
instantiation:
MyInteraction::Pointer myInteraction = MyInteraction::New("MyPattern"); 
//parameters depending on your interactor

I am currently not sure if QT sends a key release event once a key is released 
(please check in debug mode).
Modifyer keys are different. You can also set a break point in debug mode and 
check which event is sent after pressing a key. Then you can use this 
information to define your pattern.

Depending on the mode of compilation, you do not have to recompile the 
application after you changed the pattern. See mitkStateMachineFactory and 
check which instance is parsed (statemachine.xml file or qt stream). I  think, 
ExtApp reads the pattern as stream and not the xml file. Once you changed 
mitkInteractionConst.h or an interactor you need to recompile.

Besides this, your way to define the pattern sounds good.
Go to state z-button-pressed and wait for mouse move
On mouse move do zoom
On z-button release leave state waiting for mouse move

A lot of questions and only some answers to start with...
Best regards,
Ingmar



Von: Piotr Bialecki [mailto:[email protected]]
Gesendet: Donnerstag, 1. Dezember 2011 14:37
An: [email protected]
Betreff: [mitk-users] StateMachine with modified keys (Key_Z+MouseMove)

Hi,

I am writing on my own StateMachine and would like to implement a transition
like "Press Z + MouseMove" to zoom in and out.
Because the system does not send the mentioned event, I tried to implement a 
transition
which is fired once "Key_Z" is pressed.
Then the state machine is waiting for a mouse movement and zooms.
After releasing the Z key the state machine returns to "neutral" state.

To use the Z key anyway, I had to implement it in this way:
StateMachine.xml:
...
<!-- Z -->
<event NAME="Z" ID="15000" TYPE="Type_KeyPress" BUTTON="BS_NoButton" 
BUTTONSTATE="0x0000" KEY="Key_Z" />
...

This event works fine!
Unfortunately the release event does not work at all:
<event NAME="Zrelease" ID="15001" TYPE="Type_KeyRelease" BUTTON="BS_NoButton" 
BUTTONSTATE="0x0000" KEY="Key_Z" />

Is there an error in the release line? (e.g. Type oder BUTTON)

The next issue is that no actions are fired when the transition is made by a 
key press event.
First I thought this issue occures because I implemented the z key by myself 
but even if I use a predefined key like "Key_N"
no action is fired.
In that case my AcINITZOOM action is not executed and the zoom does not work 
although I switched the state
(checked via this->GetCurrentState()->GetName() in CanHandleEvent()) and the 
mouse movement is caught.

How do I fire an action in a "key transition" and why isn't it fired anyway?
All transitions work fine with other events like leftMouseButton,...

Is there a possibility to use the Z key as a "modifier"? In that case the z key 
would not fire key press events all the time.
This could cause some problems too.

Also I tried to create an own "Z+MouseMove" event by changing the Type and 
BUTTONSTATE.
Unfortunately without success.
What is the BUTTONSTATE "BS_KeyButtonMask" for? I thought maybe exactly for 
this case?

Besides that how do I add new events without recompiling mitk?
Is there a possibility to add new events to mitkInteractionConst.h via 
mitkEventMapperAddOn?

Regards,
Piotr
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to