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