Hi Ingmar,

 thank you for your help. I turned set INTERDEBUG and found that events (520, 
530, ...) are properly generated, but not forwarded to my interactor.

 After a lot of headache I found that I have to 'select' the interactor so that 
it gets 'mouse move' events. I dont know if this is a bug(*) or a feature (to 
increase performance by forwarding these high-volume-events only to interactors 
that really handle them) and if it is mentioned somewhere in the documentation. 
If not it should.

 The solution is to create an AcModeSelect (1101) action when the mouse is 
clicked and an AcModeDeselect (1100) action if the mouse button is released, eg:


 <state NAME="WaitForMouseClick" ID="1" START_STATE="TRUE">
 <transition NAME="click" NEXT_STATE_ID="2" EVENT_ID="1">
 <action ID="1101" /> <------------------ This here!
 <action ID="10000" />
 </transition>
 </state>


 Both actions must not be cought in the switch/case statement of the 
interactor, because default implementations are provided in mitkInteractor.cpp 
from which each interactor derives:

 // handle these actions in those Methods
 CONNECT_ACTION( AcMODEDESELECT, OnModeDeselect );
 CONNECT_ACTION( AcMODESELECT, OnModeSelect );




 (*)
 It could also be a bug, because you did not mention my workaround above and in 
mitkGlobalInteraction.cpp in ExecuteAction the following can be found:


 switch (action->GetActionId())
 {
 case AcDONOTHING:
 ok = true;
 break;
 case AcINFORMLISTENERS:
 InformListeners(stateEvent);
 ok = true;
 break;
 case AcASKINTERACTORS:
 if (! AskSelected(stateEvent))//no interactor selected anymore
 {
 //fill the jurisdictionMap to ask them bit by bit.
 //currentInteractor is set here to the beginning
 FillJurisdictionMap(stateEvent, 0);

 //ask the Interactors to handle that event
 AskCurrentInteractor(stateEvent);
 }
 ok = true;
 break;
 default:
 ok = true;
 }

 AskSelected returns true if at least one interactor handled the event. In this 
case other interactors are not asked anymore.

 In my case the statemachine "navigation" was active (dont know why), which 
handled the move event before my interactor had the chance. Or with other 
words: If the statemachine "navigation" would not have been active, my 
statemachine/interactor would work as expected. This is kind of unpredictive 
behaviour :)

 Maybe the code snippet above should be changed to first ask selected 
interactors and then ask others:

 case AcASKINTERACTORS:
 AskSelected(stateEvent))//no interactor selected anymore 
 //fill the jurisdictionMap to ask them bit by bit.
 //currentInteractor is set here to the beginning
 FillJurisdictionMap(stateEvent, 0);
 //ask the Interactors to handle that event
 AskCurrentInteractor(stateEvent);
 ok = true;
 break;
 This way selected interactors have a higher priority then unselected ones, but 
unselected ones still get a chance to handle an event.

 What do you think?



 One more question:
 All selected interactors can handle an event, but only the first unselected 
one as can be seen in AskCurrentInteractor:


 while ( m_CurrentInteractorIter != m_JurisdictionMap.end()&& !handled)
 {
 handled = (*m_CurrentInteractorIter).second->HandleEvent(stateEvent);

 if (!handled) 
 m_CurrentInteractorIter++;
 }

 ...

 return handled;

 If one interactor returns true then the while loop is left. Should not all 
interactors be asked here?


 Best wishes,
 Klaus


----- Ursprüngliche Nachricht -----
Von: Wegner Ingmar
Gesendet: 27.01.11 11:04 Uhr
An: 'Klaus Drechsler', [email protected]
Betreff: AW: [mitk-users] Interactor doesn´t get mouse move events

Hi Klaus,
I did not directly see a reason why MouseMoveEvents are not processed. 
To debug Interaction, you can set a brakepoint into mitkBaseRenderer line 611 
(MITK 0.12.2) in method MouseMoveEvent(..). Here the events are sent to 
EventMapper and should be matched to a mitk event ID and passed to your state 
machine via Globalinteraction. 
In general to debug interaction is tricky as debugging will interfere with 
interaction. For this I have added debug outputs via mbi log (cmake-flag 
mbilog_enable_debug_messages) that show the behavior of state machines. But for 
this changes you would have to update. 
Taking a look into 0.12 I just saw a flag (INTERDEBUG), that you could activate 
to log interaction: See mitkEventMapper.cpp line 505.
Hope this helps,
Ingmar

Von: Klaus Drechsler [mailto: [email protected] ]
 *Gesendet:* Donnerstag, 27. Januar 2011 10:11
 *An:* [email protected] 
 *Betreff:* [mitk-users] Interactor doesn´t get mouse move events
Hi,

 I have problems capturing mouse move events. They do not seem to get through 
to my interactor.

 I defined the following statemachine:

 <stateMachine NAME="MyInteractions">

 <state NAME="WaitForMouseClick" ID="1" START_STATE="TRUE">

 <transition NAME="click" NEXT_STATE_ID="2" EVENT_ID="1">

 <action ID="10000" />

 </transition>

 </state>

 <state NAME="MouseMoveOrRelease" ID="2">

 <transition NAME="move" NEXT_STATE_ID="2" EVENT_ID="530">

 <action ID="10002" />

 </transition>

 <transition NAME="release" NEXT_STATE_ID="1" EVENT_ID="505">

 <action ID="10001" />

 </transition>

 </state>

 </stateMachine> 



 ExecuteAction is implemented as follows:

switch (action->GetActionId())

{

case 10000: //mouse clicked

{

 std::cout << "mouse clicked " << event->GetWorldPosition() << std::endl;

 ok=true;

 break;

}

case 10001: //mouse released

{

 std::cout << "mouse released " << event->GetWorldPosition() << std::endl;

 ok=true;

 break;

}

case 10002: //mouse move

{

 std::cout << "mouse moved " << event->GetWorldPosition() << std::endl;

 ok=true;

 break;

}

default:

 ok = Superclass::ExecuteAction(action, stateEvent);

}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();

return ok;



In my functionality I attach the interactor to a surface:
 m_DeformSurfaceInteractor = SurfaceDeformInteractor::New("MyInteractions", 
m_SurfaceNode);


 I expect to get the following events:

 1. Left mouse button clicked
 2. Mouse is moved with left mouse button clicked
 3. Left mouse button is released


 But in the DOS bos I only see "mouse released" and "mouse clicked". No move 
events.


 At the beginning of ExecuteAction I print out the received ActionIDs:
 std::cout << action->GetActionId() << std::endl;

 However, my interactor only receives 10000 and 10001. Not 10002.


 Can someone enlight me what I have overseen? What do I have to do to capture 
mouse move events?


 I am still using MITK 0.12 together with "mainapp" (and cannot upgrade 
currently), but it should also work with this version as AffineInteractor for 
example does something similar (e.g. translate object with left button+move), 
but I do not see what I am missing. The documentation could not help me either 
(or I am too blind to find it :)).


 I am thankful for any help!

 Best wishes,
 Klaus
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to