00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision: 17194 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkMouseMovePointSetInteractor.h" 00020 #include "mitkPositionEvent.h" 00021 #include "mitkStateEvent.h" 00022 #include "mitkBaseRenderer.h" 00023 00024 mitk::MouseMovePointSetInteractor 00025 ::MouseMovePointSetInteractor(const char * type, DataNode* dataNode, int n) 00026 :PointSetInteractor(type, dataNode, n) 00027 { 00028 } 00029 00030 mitk::MouseMovePointSetInteractor::~MouseMovePointSetInteractor() 00031 { 00032 } 00033 00034 //##Documentation 00035 //## overwritten cause this class can handle mouse move events! 00036 float mitk::MouseMovePointSetInteractor::CanHandleEvent(StateEvent const* stateEvent) const 00037 { 00038 float returnValue = 0.0; 00039 //if it is a key event that can be handled in the current state, then return 0.5 00040 mitk::DisplayPositionEvent const *disPosEvent = 00041 dynamic_cast <const mitk::DisplayPositionEvent *> (stateEvent->GetEvent()); 00042 00043 //Key event handling: 00044 if (disPosEvent == NULL) 00045 { 00046 //check, if the current state has a transition waiting for that key event. 00047 if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) 00048 { 00049 return 0.5; 00050 } 00051 else 00052 { 00053 return 0; 00054 } 00055 } 00056 00057 //get the time of the sender to look for the right transition. 00058 mitk::BaseRenderer* sender = stateEvent->GetEvent()->GetSender(); 00059 if (sender != NULL) 00060 { 00061 unsigned int timeStep = sender->GetTimeStep(m_DataNode->GetData()); 00062 //if the event can be understood and if there is a transition waiting for that event 00063 mitk::State const* state = this->GetCurrentState(timeStep); 00064 if (state!= NULL) 00065 if (state->GetTransition(stateEvent->GetId())!=NULL) 00066 returnValue = 0.5;//it can be understood 00067 } 00068 return returnValue; 00069 } 00070 00071