Hi,

First of all thank you to Wegner Ingmar and Sascha Zelzer for your valuable
help on my previous question on mitkEventMapper.cpp.

Now i have a different problem. I did modify the EventMapper class and was
able to log the event data to a file in the following order.

eventID , base renderer* c_Sender, c_Type, c_Button, c_ButtonState, c_Key,
c_WorldPosition[0], c_WorldPosition[1],
c_WorldPosition[2], c_DisplayPosition[0], c_DisplayPosition[1]

in mitkbaserenderer.cpp i added a new function called remoteclientevent() so
that the function reads the file with above
 order and then call the mapevent function of conferenceeventmapper class.
the function i wrote is as follows.

{
 ifstream OpenFile("eventua.txt");
std::string line;

    int id;
std::string sndr;
int type;
int button;
 int bstate;
int key;
float threed1;
 float threed2;
float threed3;
float twod1;
 float twod2;

// code for assigning values goes here

mitk::ConferenceEventMapper::MapEvent(id,sender,type,button,bstate,key,threed1,threed2,threed3,twod1,twod2);

}

i cannot get the result as i expected and i think i need to do something
more on qmitkrenderwindow class and etc.

I would be very grateful if you could give me some guidance to this.

As i mentioned earlier what i need to do is capture all events and
synchronously do them on a remote machine.

Thank you,



On Tue, May 25, 2010 at 8:17 PM, Sascha Zelzer
<[email protected]>wrote:

>  Hi,
>
> if you are using Qt, another approach could be to use the native Qt event
> filtering. Just install a global event filter and either record or directly
> stream the event data (using for example QTcpSocket) to the other machine.
> The "client" then creates QEvent instances and uses
> QCoreApplication::postEvent(...).
>
> - Sascha
>
>
> On 05/22/2010 07:47 AM, Sajith Rabel wrote:
>
> Hello,
>
>  I'm pretty new to MITK and and for a project i'm involved i need to
> capture the mouse events and key events perfomed in gui. For this purpose i
> modified the mapEvent function of mitkEventMapper.cpp as following.
>
>   bool mitk::EventMapper::MapEvent(Event* event, int mitkPostedEventID )
>>
>> {
>>
>>   int eventID = mitkPostedEventID;
>>
>>
>>>    if( mitkPostedEventID == 0 )
>>
>>   {
>>
>>     //search the event in the list of event descriptions, if found, then
>>> take the number and produce a stateevent
>>
>>     EventDescriptionVecIter iter;
>>
>>     for (iter = m_EventDescriptions.begin();
>>> iter!=m_EventDescriptions.end();iter++)
>>
>>     {
>>
>>       if (*iter == *event)
>>
>>         break;
>>
>>     }
>>
>>
>>>      if (iter == m_EventDescriptions.end())//not found
>>
>>       return false;
>>
>>     eventID = (*iter).GetId();
>>
>>   }
>>
>>
>>>  //***************************************** the edited code
>>> ************************************
>>
>>
>
>>          mitk::BaseRenderer * c_Sender = event->GetSender();
>>
>>  int c_Type = event->GetType();
>>
>>  int c_Button = event->GetButton();
>>
>>  int c_ButtonState = event->GetButtonState();
>>
>>  int c_Key = event->GetKey();
>>
>>
>>>  mitk::Point2D c_DisplayPosition = dynamic_cast<const
>>> mitk::PositionEvent*>(event) ->GetDisplayPosition() ;
>>
>>  mitk::Point3D c_WorldPosition = dynamic_cast<const
>>> mitk::PositionEvent*>(event) ->GetWorldPosition() ;
>>
>>
>>>      std::ofstream eventfile;
>>
>>     eventfile.open("eventua.txt");
>>
>>   eventfile << eventID;
>>
>>     eventfile.close();
>>
>>
>>> //*****************************************************************************
>>
>>
>>>    //set the Menger_Var m_StateEvent and send to StateMachine, which
>>> does everything further!
>>
>>   m_StateEvent.Set( eventID, event );
>>
>>   /*
>>
>>   Group and Object EventId:
>>
>>   then EventMapper has the power to decide which operations hang together;
>>
>>   each event causes n (n e N) operations (e.g. StateChanges,
>>> data-operations...).
>>
>>   Undo must recall all these coherent operations, so all of the same
>>> objectId.
>>
>>   But Undo has also the power to recall more operationsets, for example a
>>> set for building up a new object,
>>
>>   so that a newly build up object is deleted after a Undo and not only the
>>> latest set point.
>>
>>   The StateMachines::ExecuteAction have the power to descide weather a new
>>> GroupID has to be calculated
>>
>>   (by example after the editing of a new object)
>>
>>
>>>    A user interaction with the mouse is started by a mousePressEvent,
>>> continues with a MouseMove and finishes with a MouseReleaseEvent
>>
>>    */
>>
>>   switch (event->GetType())
>>
>>   {
>>
>>   case mitk::Type_MouseButtonPress://Increase
>>
>>     mitk::OperationEvent::IncCurrObjectEventId();
>>
>>     break;
>>
>>   case mitk::Type_MouseMove://same
>>
>>     break;
>>
>>   case mitk::Type_MouseButtonRelease://same
>>
>>     break;
>>
>>   case mitk::Type_User://same
>>
>>     break;
>>
>>   case mitk::Type_KeyPress://Increase
>>
>>     mitk::OperationEvent::IncCurrObjectEventId();
>>
>>     break;
>>
>>   default://increase
>>
>>     mitk::OperationEvent::IncCurrObjectEventId();
>>
>>   }
>>
>>
>>>  #ifdef MBI_INTERNAL_CONFERENCE
>>
>>   //Conference - pass local events through
>>
>>   if ( mitkPostedEventID == 0 )
>>
>>   {
>>
>>     mitk::CoreObjectFactory::GetInstance()->MapEvent(event,eventID);
>>
>>   }
>>
>> #endif //MBI_INTERNAL_CONFERENCE
>>
>>
>>>    mitk::OperationEvent::ExecuteIncrement();
>>
>>
>>
>>   return
>>> mitk::GlobalInteraction::GetInstance()->HandleEvent(&m_StateEvent);
>>
>> }
>>
>>
>
>  when i add the lines the project builds without errors.
>
>> mitk::Point2D c_DisplayPosition = dynamic_cast<const
>> mitk::PositionEvent*>(event) ->GetDisplayPosition() ;
>
> mitk::Point3D c_WorldPosition = dynamic_cast<const
>> mitk::PositionEvent*>(event) ->GetWorldPosition() ;
>
>
>  i get a runtime error when running step5. (step5.exe crashes.)
>
>  what i need to do in my project is capture mouse events from one machine
> and make them happen in a remote computer. (using a log of captured events)
>  I'm hoping to use mitkconferenceeventmapper.cpp to achieve this.
>
>  I would be very grateful if anyone could tell me wats wrong with the
> above lines.
>
>  Any alternatives to get my task done would be very helpful.
>
>  Thanks in advance.
>
>  Best Regards,
>
>  --
> Sajith Rabel
>
>
>
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> mitk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mitk-users
>
>


-- 
Sajith Rabel
------------------------------------------------------------------------------

_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to