Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkVtkEventAdapter.h"
00019 #include <mitkInteractionConst.h>
00020 #include <mitkWheelEvent.h>
00021
00022 #include "vtkCommand.h"
00023
00024 mitk::MouseEvent
00025
00026 mitk::VtkEventAdapter::AdaptMouseEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId,vtkRenderWindowInteractor* rwi)
00027 {
00028
00029 mitk::Point2D p;
00030 p[0] = rwi->GetEventPosition()[0];
00031 p[1] = rwi->GetEventPosition()[1];
00032
00033
00034 int button = 0;
00035 int type = 0;
00036 int state = 0;
00037 switch(vtkCommandEventId)
00038 {
00039 case vtkCommand::MouseMoveEvent:
00040 type = 5;
00041 button = 0x00000000;
00042 break;
00043 case vtkCommand::LeftButtonReleaseEvent:
00044 type = 3;
00045 button = 0x00000001;
00046 break;
00047 case vtkCommand::MiddleButtonReleaseEvent:
00048 type = 3;
00049 button = 0x00000004;
00050 break;
00051 case vtkCommand::RightButtonReleaseEvent:
00052 type = 3;
00053 button = 0x00000002;
00054 break;
00055 case vtkCommand::LeftButtonPressEvent:
00056 type = 2;
00057 button = 0x00000001;
00058 break;
00059 case vtkCommand::MiddleButtonPressEvent:
00060 type = 2;
00061 button = 0x00000004;
00062 break;
00063 case vtkCommand::RightButtonPressEvent:
00064 type = 2;
00065 button = 0x00000002;
00066 break;
00067
00068 }
00069
00070 int modifiers = 0;
00071 if(rwi->GetShiftKey())
00072 {
00073 modifiers |= 0x02000000;
00074 state |= mitk::BS_ShiftButton;
00075 }
00076 if(rwi->GetControlKey())
00077 {
00078 modifiers |= 0x04000000;
00079 state |= mitk::BS_ControlButton;
00080 }
00081 if(rwi->GetAltKey())
00082 {
00083 modifiers |= 0x08000000;
00084 state |= mitk::BS_AltButton;
00085 }
00086
00087 mitk::MouseEvent mitkEvent(sender, type, button, state, mitk::Key_none, p);
00088
00089 return mitkEvent;
00090 }
00091
00092 mitk::WheelEvent
00093
00094 mitk::VtkEventAdapter::AdaptWheelEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId,vtkRenderWindowInteractor* rwi)
00095 {
00096 mitk::Point2D p;
00097 p[0] = rwi->GetEventPosition()[0];
00098 p[1] = rwi->GetEventPosition()[1];
00099
00100
00101 int button = 0;
00102 int type = 0;
00103 int state = 0;
00104 int delta = 0;
00105 switch(vtkCommandEventId)
00106 {
00107 case vtkCommand::MouseWheelForwardEvent:
00108 type = 31;
00109 button = 0x00000000;
00110 delta = +120;
00111 break;
00112 case vtkCommand::MouseWheelBackwardEvent:
00113 type = 31;
00114 button = 0x00000000;
00115 delta = -120;
00116 break;
00117 }
00118
00119 int modifiers = 0;
00120 if(rwi->GetShiftKey())
00121 modifiers |= 0x02000000;
00122 state |= mitk::BS_ShiftButton;
00123 if(rwi->GetControlKey())
00124 modifiers |= 0x04000000;
00125 state |= mitk::BS_ControlButton;
00126 if(rwi->GetAltKey())
00127 modifiers |= 0x08000000;
00128 state |= mitk::BS_AltButton;
00129
00130 mitk::WheelEvent mitkEvent(sender, type, button,state, mitk::Key_none, p, delta);
00131
00132 return mitkEvent;
00133 }
00134
00135
00136 mitk::KeyEvent
00137
00138 mitk::VtkEventAdapter::AdaptKeyEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId,vtkRenderWindowInteractor* rwi)
00139 {
00140
00141 int key = (int)rwi->GetKeyCode();
00142
00143
00144 if (key >= 0x01000000 && key <= 0x01000060)
00145 key -= (0x01000000 - 0x1000);
00146 else if(key >= 0x01001120 && key <= 0x01001262)
00147 key -= 0x01000000;
00148
00149 mitk::Point2D p;
00150 p[0] = rwi->GetEventPosition()[0];
00151 p[1] = rwi->GetEventPosition()[1];
00152
00153 int type = 0;
00154 if(vtkCommandEventId == vtkCommand::KeyPressEvent)
00155 type = 6;
00156
00157 int state = 0;
00158 int modifiers = 0;
00159 if(rwi->GetShiftKey())
00160 modifiers |= 0x02000000;
00161 state |= mitk::BS_ShiftButton;
00162 if(rwi->GetControlKey())
00163 modifiers |= 0x04000000;
00164 state |= mitk::BS_ControlButton;
00165 if(rwi->GetAltKey())
00166 modifiers |= 0x08000000;
00167 state |= mitk::BS_AltButton;
00168
00169 mitk::KeyEvent mke(sender, type, mitk::BS_NoButton, state, key, std::string(rwi->GetKeySym()), p);
00170
00171 return mke;
00172 }