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
00030 #include "mitkEventMapper.h"
00031 #include "mitkInteractionConst.h"
00032 #include "mitkStateEvent.h"
00033 #include "mitkOperationEvent.h"
00034 #include "mitkGlobalInteraction.h"
00035
00036 #include "mitkStandardFileLocations.h"
00037
00038
00039 #include "mitkConfig.h"
00040 #include "mitkCoreObjectFactory.h"
00041
00042 #include <itkOutputWindow.h>
00043 #include <itkMacro.h>
00044
00045 #include <vtkObjectFactory.h>
00046
00047 #include <vector>
00048
00049 namespace mitk
00050 {
00051 vtkStandardNewMacro(EventMapper);
00052 }
00053
00054 #ifdef MBI_INTERNAL_CONFERENCE
00055 #include <mitkGeometry3D.h>
00056 #include <mitkDisplayPositionEvent.h>
00057
00058 #include <mitkConferenceKit.h>
00059 #include <mitkConferenceToken.h>
00060 #include <mitkBaseRenderer.h>
00061 #endif //MBI_INTERNAL_CONFERENCE
00062
00063
00064 const std::string mitk::EventMapper::STYLE = "STYLE";
00065 const std::string mitk::EventMapper::NAME = "NAME";
00066 const std::string mitk::EventMapper::ID = "ID";
00067 const std::string mitk::EventMapper::TYPE = "TYPE";
00068 const std::string mitk::EventMapper::BUTTON = "BUTTON";
00069 const std::string mitk::EventMapper::BUTTONSTATE = "BUTTONSTATE";
00070 const std::string mitk::EventMapper::KEY = "KEY";
00071
00072 const std::string mitk::EventMapper::EVENTS = "events";
00073
00074 const std::string mitk::EventMapper::EVENT = "event";
00075
00076 mitk::EventMapper::EventDescriptionVec mitk::EventMapper::m_EventDescriptions;
00077
00078 mitk::StateEvent mitk::EventMapper::m_StateEvent;
00079
00080 std::string mitk::EventMapper::m_StyleName;
00081
00082
00083
00084 struct ltstr
00085 {
00086 bool operator()(const char* s1, const char* s2) const
00087 {
00088 return strcmp(s1, s2) < 0;
00089 }
00090 };
00091
00092 mitk::EventMapper::EventMapper()
00093 {
00094
00095
00096 m_EventConstMap["Type_None"] = mitk::Type_None;
00097 m_EventConstMap["Type_Timer"] = mitk::Type_Timer;
00098 m_EventConstMap["Type_MouseButtonPress"] = mitk::Type_MouseButtonPress;
00099 m_EventConstMap["Type_MouseButtonRelease"] = mitk::Type_MouseButtonRelease;
00100 m_EventConstMap["Type_MouseButtonDblClick"] = mitk::Type_MouseButtonDblClick;
00101 m_EventConstMap["Type_MouseMove"] = mitk::Type_MouseMove;
00102 m_EventConstMap["Type_KeyPress"] = mitk::Type_KeyPress;
00103 m_EventConstMap["Type_KeyRelease"] = mitk::Type_KeyRelease;
00104 m_EventConstMap["Type_FocusIn"] = 8;
00105 m_EventConstMap["Type_FocusOut"] = 9;
00106 m_EventConstMap["Type_Enter"] = 10;
00107 m_EventConstMap["Type_Leave"] = 11;
00108 m_EventConstMap["Type_Paint"] = 12;
00109 m_EventConstMap["Type_Move"] = 13;
00110 m_EventConstMap["Type_Resize"] = 14;
00111 m_EventConstMap["Type_Create"] = 15;
00112 m_EventConstMap["Type_Destroy"] = 16;
00113 m_EventConstMap["Type_Show"] = 17;
00114 m_EventConstMap["Type_Hide"] = 18;
00115 m_EventConstMap["Type_Close"] = 19;
00116 m_EventConstMap["Type_Quit"] = 20;
00117 m_EventConstMap["Type_Reparent"] = 21;
00118 m_EventConstMap["Type_ShowMinimized"] = 22;
00119 m_EventConstMap["Type_ShowNormal"] = 23;
00120 m_EventConstMap["Type_WindowActivate"] = 24;
00121 m_EventConstMap["Type_WindowDeactivate"] = 25;
00122 m_EventConstMap["Type_ShowToParent"] = 26;
00123 m_EventConstMap["Type_HideToParent"] = 27;
00124 m_EventConstMap["Type_ShowMaximized"] = 28;
00125 m_EventConstMap["Type_ShowFullScreen"] = 29;
00126 m_EventConstMap["Type_Accel"] = 30;
00127 m_EventConstMap["Type_Wheel"] = 31;
00128 m_EventConstMap["Type_AccelAvailable"] = 32;
00129 m_EventConstMap["Type_CaptionChange"] = 33;
00130 m_EventConstMap["Type_IconChange"] = 34;
00131 m_EventConstMap["Type_ParentFontChange"] = 35;
00132 m_EventConstMap["Type_ApplicationFontChange"] = 36;
00133 m_EventConstMap["Type_ParentPaletteChange"] = 37;
00134 m_EventConstMap["Type_ApplicationPaletteChange"] = 38;
00135 m_EventConstMap["Type_PaletteChange"] = 39;
00136 m_EventConstMap["Type_Clipboard"] = 40;
00137 m_EventConstMap["Type_Speech"] = 42;
00138 m_EventConstMap["Type_SockAct"] = 50;
00139 m_EventConstMap["Type_AccelOverride"] = 51;
00140 m_EventConstMap["Type_DeferredDelete"] = 52;
00141 m_EventConstMap["Type_DragEnter"] = 60;
00142 m_EventConstMap["Type_DragMove"] = 61;
00143 m_EventConstMap["Type_DragLeave"] = 62;
00144 m_EventConstMap["Type_Drop"] = 63;
00145 m_EventConstMap["Type_DragResponse"] = 64;
00146 m_EventConstMap["Type_ChildInserted"] = 70;
00147 m_EventConstMap["Type_ChildRemoved"] = 71;
00148 m_EventConstMap["Type_LayoutHint"] = 72;
00149 m_EventConstMap["Type_ShowWindowRequest"] = 73;
00150 m_EventConstMap["Type_ActivateControl"] = 80;
00151 m_EventConstMap["Type_DeactivateControl"] = 81;
00152 m_EventConstMap["Type_ContextMenu"] = 82;
00153 m_EventConstMap["Type_IMStart"] = 83;
00154 m_EventConstMap["Type_IMCompose"] = 84;
00155 m_EventConstMap["Type_IMEnd"] = 85;
00156 m_EventConstMap["Type_Accessibility"] = 86;
00157 m_EventConstMap["Type_TabletMove"] = 87;
00158 m_EventConstMap["Type_LocaleChange"] = 88;
00159 m_EventConstMap["Type_LanguageChange"] = 89;
00160 m_EventConstMap["Type_LayoutDirectionChange"] = 90;
00161 m_EventConstMap["Type_Style"] = 91;
00162 m_EventConstMap["Type_TabletPress"] = 92;
00163 m_EventConstMap["Type_TabletRelease"] = 93;
00164
00165
00166 m_EventConstMap["Type_User"] = 1000;
00167 m_EventConstMap["Type_MaxUser"] = 65535;
00168
00169
00170 m_EventConstMap["BS_NoButton"] = mitk::BS_NoButton;
00171 m_EventConstMap["BS_LeftButton"] = mitk::BS_LeftButton;
00172 m_EventConstMap["BS_RightButton"] = mitk::BS_RightButton;
00173 m_EventConstMap["BS_MidButton"] = mitk::BS_MidButton;
00174 m_EventConstMap["BS_MouseButtonMask"] = mitk::BS_MouseButtonMask;
00175 m_EventConstMap["BS_ShiftButton"] = mitk::BS_ShiftButton;
00176 m_EventConstMap["BS_ControlButton"] = mitk::BS_ControlButton;
00177 m_EventConstMap["BS_AltButton"] = mitk::BS_AltButton;
00178 m_EventConstMap["BS_KeyButtonMask"] = mitk::BS_KeyButtonMask;
00179 m_EventConstMap["BS_Keypad"] = mitk::BS_Keypad;
00180
00181
00182 m_EventConstMap["Mod_SHIFT"] = 0x00200000;
00183 m_EventConstMap["Mod_CTRL"] = 0x00400000;
00184 m_EventConstMap["Mod_ALT"] = 0x00800000;
00185 m_EventConstMap["Mod_MODIFIER_MASK"] = 0x00e00000;
00186 m_EventConstMap["Mod_UNICODE_ACCEL"] = 0x10000000;
00187 m_EventConstMap["Mod_ASCII_ACCEL"] = 0x10000000;
00188
00189
00190 m_EventConstMap["Key_Escape"] = 0x1000;
00191 m_EventConstMap["Key_Tab"] = 0x1001;
00192 m_EventConstMap["Key_Backtab"] = 0x1002;
00193 m_EventConstMap["Key_BackTab"] = 0x1002;
00194 m_EventConstMap["Key_Backspace"] = 0x1003;
00195 m_EventConstMap["Key_BackSpace"] = 0x1003;
00196 m_EventConstMap["Key_Return"] = 0x1004;
00197 m_EventConstMap["Key_Enter"] = 0x1005;
00198 m_EventConstMap["Key_Insert"] = 0x1006;
00199 m_EventConstMap["Key_Delete"] = 0x1007;
00200 m_EventConstMap["Key_Pause"] = 0x1008;
00201 m_EventConstMap["Key_Print"] = 0x1009;
00202 m_EventConstMap["Key_SysReq"] = 0x100a;
00203 m_EventConstMap["Key_Home"] = 0x1010;
00204 m_EventConstMap["Key_End"] = 0x1011;
00205 m_EventConstMap["Key_Left"] = 0x1012;
00206 m_EventConstMap["Key_Up"] = 0x1013;
00207 m_EventConstMap["Key_Right"] = 0x1014;
00208 m_EventConstMap["Key_Down"] = 0x1015;
00209 m_EventConstMap["Key_Prior"] = 0x1016;
00210 m_EventConstMap["Key_PageUp"] = 0x1016;
00211 m_EventConstMap["Key_Next"] = 0x1017;
00212 m_EventConstMap["Key_PageDown"] = 0x1017;
00213 m_EventConstMap["Key_Shift"] = 0x1020;
00214 m_EventConstMap["Key_Control"] = 0x1021;
00215 m_EventConstMap["Key_Meta"] = 0x1022;
00216 m_EventConstMap["Key_Alt"] = 0x1023;
00217 m_EventConstMap["Key_CapsLock"] = 0x1024;
00218 m_EventConstMap["Key_NumLock"] = 0x1025;
00219 m_EventConstMap["Key_ScrollLock"] = 0x1026;
00220 m_EventConstMap["Key_F1"] = 0x1030;
00221 m_EventConstMap["Key_F2"] = 0x1031;
00222 m_EventConstMap["Key_F3"] = 0x1032;
00223 m_EventConstMap["Key_F4"] = 0x1033;
00224 m_EventConstMap["Key_F5"] = 0x1034;
00225 m_EventConstMap["Key_F6"] = 0x1035;
00226 m_EventConstMap["Key_F7"] = 0x1036;
00227 m_EventConstMap["Key_F8"] = 0x1037;
00228 m_EventConstMap["Key_F9"] = 0x1038;
00229 m_EventConstMap["Key_F10"] = 0x1039;
00230 m_EventConstMap["Key_F11"] = 0x103a;
00231 m_EventConstMap["Key_F12"] = 0x103b;
00232 m_EventConstMap["Key_F13"] = 0x103c;
00233 m_EventConstMap["Key_F14"] = 0x103d;
00234 m_EventConstMap["Key_F15"] = 0x103e;
00235 m_EventConstMap["Key_F16"] = 0x103f;
00236 m_EventConstMap["Key_F17"] = 0x1040;
00237 m_EventConstMap["Key_F18"] = 0x1041;
00238 m_EventConstMap["Key_F19"] = 0x1042;
00239 m_EventConstMap["Key_F20"] = 0x1043;
00240 m_EventConstMap["Key_F21"] = 0x1044;
00241 m_EventConstMap["Key_F22"] = 0x1045;
00242 m_EventConstMap["Key_F23"] = 0x1046;
00243 m_EventConstMap["Key_F24"] = 0x1047;
00244 m_EventConstMap["Key_F25"] = 0x1048;
00245 m_EventConstMap["Key_F26"] = 0x1049;
00246 m_EventConstMap["Key_F27"] = 0x104a;
00247 m_EventConstMap["Key_F28"] = 0x104b;
00248 m_EventConstMap["Key_F29"] = 0x104c;
00249 m_EventConstMap["Key_F30"] = 0x104d;
00250 m_EventConstMap["Key_F31"] = 0x104e;
00251 m_EventConstMap["Key_F32"] = 0x104f;
00252 m_EventConstMap["Key_F33"] = 0x1050;
00253 m_EventConstMap["Key_F34"] = 0x1051;
00254 m_EventConstMap["Key_F35"] = 0x1052;
00255 m_EventConstMap["Key_Super_L"] = 0x1053;
00256 m_EventConstMap["Key_Super_R"] = 0x1054;
00257 m_EventConstMap["Key_Menu"] = 0x1055;
00258 m_EventConstMap["Key_Hyper_L"] = 0x1056;
00259 m_EventConstMap["Key_Hyper_R"] = 0x1057;
00260 m_EventConstMap["Key_Help"] = 0x1058;
00261 m_EventConstMap["Key_Muhenkan"] = 0x1122;
00262 m_EventConstMap["Key_Henkan"] = 0x1123;
00263 m_EventConstMap["Key_Hiragana_Katakana"] = 0x1127;
00264 m_EventConstMap["Key_Zenkaku_Hankaku"] = 0x112A;
00265 m_EventConstMap["Key_Space"] = 0x20;
00266 m_EventConstMap["Key_Any"] = 0x20;
00267 m_EventConstMap["Key_Exclam"] = 0x21;
00268 m_EventConstMap["Key_QuoteDbl"] = 0x22;
00269 m_EventConstMap["Key_NumberSign"] = 0x23;
00270 m_EventConstMap["Key_Dollar"] = 0x24;
00271 m_EventConstMap["Key_Percent"] = 0x25;
00272 m_EventConstMap["Key_Ampersand"] = 0x26;
00273 m_EventConstMap["Key_Apostrophe"] = 0x27;
00274 m_EventConstMap["Key_ParenLeft"] = 0x28;
00275 m_EventConstMap["Key_ParenRight"] = 0x29;
00276 m_EventConstMap["Key_Asterisk"] = 0x2a;
00277 m_EventConstMap["Key_Plus"] = 0x2b;
00278 m_EventConstMap["Key_Comma"] = 0x2c;
00279 m_EventConstMap["Key_Minus"] = 0x2d;
00280 m_EventConstMap["Key_Period"] = 0x2e;
00281 m_EventConstMap["Key_Slash"] = 0x2f;
00282 m_EventConstMap["Key_0"] = 0x30;
00283 m_EventConstMap["Key_1"] = 0x31;
00284 m_EventConstMap["Key_2"] = 0x32;
00285 m_EventConstMap["Key_3"] = 0x33;
00286 m_EventConstMap["Key_4"] = 0x34;
00287 m_EventConstMap["Key_5"] = 0x35;
00288 m_EventConstMap["Key_6"] = 0x36;
00289 m_EventConstMap["Key_7"] = 0x37;
00290 m_EventConstMap["Key_8"] = 0x38;
00291 m_EventConstMap["Key_9"] = 0x39;
00292 m_EventConstMap["Key_Colon"] = 0x3a;
00293 m_EventConstMap["Key_Semicolon"] = 0x3b;
00294 m_EventConstMap["Key_Less"] = 0x3c;
00295 m_EventConstMap["Key_Equal"] = 0x3d;
00296 m_EventConstMap["Key_Greater"] = 0x3e;
00297 m_EventConstMap["Key_Question"] = 0x3f;
00298 m_EventConstMap["Key_At"] = 0x40;
00299 m_EventConstMap["Key_A"] = 0x41;
00300 m_EventConstMap["Key_B"] = 0x42;
00301 m_EventConstMap["Key_C"] = 0x43;
00302 m_EventConstMap["Key_D"] = 0x44;
00303 m_EventConstMap["Key_E"] = 0x45;
00304 m_EventConstMap["Key_F"] = 0x46;
00305 m_EventConstMap["Key_G"] = 0x47;
00306 m_EventConstMap["Key_H"] = 0x48;
00307 m_EventConstMap["Key_I"] = 0x49;
00308 m_EventConstMap["Key_J"] = 0x4a;
00309 m_EventConstMap["Key_K"] = 0x4b;
00310 m_EventConstMap["Key_L"] = 0x4c;
00311 m_EventConstMap["Key_M"] = 0x4d;
00312 m_EventConstMap["Key_N"] = 0x4e;
00313 m_EventConstMap["Key_O"] = 0x4f;
00314 m_EventConstMap["Key_P"] = 0x50;
00315 m_EventConstMap["Key_Q"] = 0x51;
00316 m_EventConstMap["Key_R"] = 0x52;
00317 m_EventConstMap["Key_S"] = 0x53;
00318 m_EventConstMap["Key_T"] = 0x54;
00319 m_EventConstMap["Key_U"] = 0x55;
00320 m_EventConstMap["Key_V"] = 0x56;
00321 m_EventConstMap["Key_W"] = 0x57;
00322 m_EventConstMap["Key_X"] = 0x58;
00323 m_EventConstMap["Key_Y"] = 0x59;
00324 m_EventConstMap["Key_Z"] = 0x5a;
00325 m_EventConstMap["Key_BracketLeft"] = 0x5b;
00326 m_EventConstMap["Key_Backslash"] = 0x5c;
00327 m_EventConstMap["Key_BracketRight"] = 0x5d;
00328 m_EventConstMap["Key_AsciiCircum"] = 0x5e;
00329 m_EventConstMap["Key_Underscore"] = 0x5f;
00330 m_EventConstMap["Key_QuoteLeft"] = 0x60;
00331 m_EventConstMap["Key_BraceLeft"] = 0x7b;
00332 m_EventConstMap["Key_Bar"] = 0x7c;
00333 m_EventConstMap["Key_BraceRight"] = 0x7d;
00334 m_EventConstMap["Key_AsciiTilde"] = 0x7e;
00335 m_EventConstMap["Key_nobreakspace"] = 0x0a0;
00336 m_EventConstMap["Key_exclamdown"] = 0x0a1;
00337 m_EventConstMap["Key_cent"] = 0x0a2;
00338 m_EventConstMap["Key_sterling"] = 0x0a3;
00339 m_EventConstMap["Key_currency"] = 0x0a4;
00340 m_EventConstMap["Key_yen"] = 0x0a5;
00341 m_EventConstMap["Key_brokenbar"] = 0x0a6;
00342 m_EventConstMap["Key_section"] = 0x0a7;
00343 m_EventConstMap["Key_diaeresis"] = 0x0a8;
00344 m_EventConstMap["Key_copyright"] = 0x0a9;
00345 m_EventConstMap["Key_ordfeminine"] = 0x0aa;
00346 m_EventConstMap["Key_guillemotleft"] = 0x0ab;
00347 m_EventConstMap["Key_notsign"] = 0x0ac;
00348 m_EventConstMap["Key_hyphen"] = 0x0ad;
00349 m_EventConstMap["Key_registered"] = 0x0ae;
00350 m_EventConstMap["Key_macron"] = 0x0af;
00351 m_EventConstMap["Key_degree"] = 0x0b0;
00352 m_EventConstMap["Key_plusminus"] = 0x0b1;
00353 m_EventConstMap["Key_twosuperior"] = 0x0b2;
00354 m_EventConstMap["Key_threesuperior"] = 0x0b3;
00355 m_EventConstMap["Key_acute"] = 0x0b4;
00356 m_EventConstMap["Key_mu"] = 0x0b5;
00357 m_EventConstMap["Key_paragraph"] = 0x0b6;
00358 m_EventConstMap["Key_periodcentered"] = 0x0b7;
00359 m_EventConstMap["Key_cedilla"] = 0x0b8;
00360 m_EventConstMap["Key_onesuperior"] = 0x0b9;
00361 m_EventConstMap["Key_masculine"] = 0x0ba;
00362 m_EventConstMap["Key_guillemotright"] = 0x0bb;
00363 m_EventConstMap["Key_onequarter"] = 0x0bc;
00364 m_EventConstMap["Key_onehalf"] = 0x0bd;
00365 m_EventConstMap["Key_threequarters"] = 0x0be;
00366 m_EventConstMap["Key_questiondown"] = 0x0bf;
00367 m_EventConstMap["Key_Agrave"] = 0x0c0;
00368 m_EventConstMap["Key_Aacute"] = 0x0c1;
00369 m_EventConstMap["Key_Acircumflex"] = 0x0c2;
00370 m_EventConstMap["Key_Atilde"] = 0x0c3;
00371 m_EventConstMap["Key_Adiaeresis"] = 0x0c4;
00372 m_EventConstMap["Key_Aring"] = 0x0c5;
00373 m_EventConstMap["Key_AE"] = 0x0c6;
00374 m_EventConstMap["Key_Ccedilla"] = 0x0c7;
00375 m_EventConstMap["Key_Egrave"] = 0x0c8;
00376 m_EventConstMap["Key_Eacute"] = 0x0c9;
00377 m_EventConstMap["Key_Ecircumflex"] = 0x0ca;
00378 m_EventConstMap["Key_Ediaeresis"] = 0x0cb;
00379 m_EventConstMap["Key_Igrave"] = 0x0cc;
00380 m_EventConstMap["Key_Iacute"] = 0x0cd;
00381 m_EventConstMap["Key_Icircumflex"] = 0x0ce;
00382 m_EventConstMap["Key_Idiaeresis"] = 0x0cf;
00383 m_EventConstMap["Key_ETH"] = 0x0d0;
00384 m_EventConstMap["Key_Ntilde"] = 0x0d1;
00385 m_EventConstMap["Key_Ograve"] = 0x0d2;
00386 m_EventConstMap["Key_Oacute"] = 0x0d3;
00387 m_EventConstMap["Key_Ocircumflex"] = 0x0d4;
00388 m_EventConstMap["Key_Otilde"] = 0x0d5;
00389 m_EventConstMap["Key_Odiaeresis"] = 0x0d6;
00390 m_EventConstMap["Key_multiply"] = 0x0d7;
00391 m_EventConstMap["Key_Ooblique"] = 0x0d8;
00392 m_EventConstMap["Key_Ugrave"] = 0x0d9;
00393 m_EventConstMap["Key_Uacute"] = 0x0da;
00394 m_EventConstMap["Key_Ucircumflex"] = 0x0db;
00395 m_EventConstMap["Key_Udiaeresis"] = 0x0dc;
00396 m_EventConstMap["Key_Yacute"] = 0x0dd;
00397 m_EventConstMap["Key_THORN"] = 0x0de;
00398 m_EventConstMap["Key_ssharp"] = 0x0df;
00399 m_EventConstMap["Key_agrave"] = 0x0e0;
00400 m_EventConstMap["Key_aacute"] = 0x0e1;
00401 m_EventConstMap["Key_acircumflex"] = 0x0e2;
00402 m_EventConstMap["Key_atilde"] = 0x0e3;
00403 m_EventConstMap["Key_adiaeresis"] = 0x0e4;
00404 m_EventConstMap["Key_aring"] = 0x0e5;
00405 m_EventConstMap["Key_ae"] = 0x0e6;
00406 m_EventConstMap["Key_ccedilla"] = 0x0e7;
00407 m_EventConstMap["Key_egrave"] = 0x0e8;
00408 m_EventConstMap["Key_eacute"] = 0x0e9;
00409 m_EventConstMap["Key_ecircumflex"] = 0x0ea;
00410 m_EventConstMap["Key_ediaeresis"] = 0x0eb;
00411 m_EventConstMap["Key_igrave"] = 0x0ec;
00412 m_EventConstMap["Key_iacute"] = 0x0ed;
00413 m_EventConstMap["Key_icircumflex"] = 0x0ee;
00414 m_EventConstMap["Key_idiaeresis"] = 0x0ef;
00415 m_EventConstMap["Key_eth"] = 0x0f0;
00416 m_EventConstMap["Key_ntilde"] = 0x0f1;
00417 m_EventConstMap["Key_ograve"] = 0x0f2;
00418 m_EventConstMap["Key_oacute"] = 0x0f3;
00419 m_EventConstMap["Key_ocircumflex"] = 0x0f4;
00420 m_EventConstMap["Key_otilde"] = 0x0f5;
00421 m_EventConstMap["Key_odiaeresis"] = 0x0f6;
00422 m_EventConstMap["Key_division"] = 0x0f7;
00423 m_EventConstMap["Key_oslash"] = 0x0f8;
00424 m_EventConstMap["Key_ugrave"] = 0x0f9;
00425 m_EventConstMap["Key_uacute"] = 0x0fa;
00426 m_EventConstMap["Key_ucircumflex"] = 0x0fb;
00427 m_EventConstMap["Key_udiaeresis"] = 0x0fc;
00428 m_EventConstMap["Key_yacute"] = 0x0fd;
00429 m_EventConstMap["Key_thorn"] = 0x0fe;
00430 m_EventConstMap["Key_ydiaeresis"] = 0x0ff;
00431 m_EventConstMap["Key_unknown"] = 0xffff;
00432 m_EventConstMap["Key_none"] = 0xffff;
00433
00434 }
00435
00436 mitk::EventMapper::~EventMapper()
00437 {
00438
00439 }
00440
00441
00442
00443
00444 bool mitk::EventMapper::MapEvent(Event* event, GlobalInteraction* globalInteraction, int mitkPostedEventID )
00445 {
00446 int eventID = mitkPostedEventID;
00447
00448 if( mitkPostedEventID == 0 )
00449 {
00450
00451 EventDescriptionVecIter iter;
00452 for (iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end();iter++)
00453 {
00454 if (*iter == *event)
00455 break;
00456 }
00457
00458 if (iter == m_EventDescriptions.end())
00459 return false;
00460 eventID = (*iter).GetId();
00461 }
00462
00463
00464 m_StateEvent.Set( eventID, event );
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 switch (event->GetType())
00478 {
00479 case mitk::Type_MouseButtonPress:
00480 mitk::OperationEvent::IncCurrObjectEventId();
00481 break;
00482 case mitk::Type_MouseMove:
00483 break;
00484 case mitk::Type_MouseButtonRelease:
00485 break;
00486 case mitk::Type_User:
00487 break;
00488 case mitk::Type_KeyPress:
00489 mitk::OperationEvent::IncCurrObjectEventId();
00490 break;
00491 default:
00492 mitk::OperationEvent::IncCurrObjectEventId();
00493 }
00494
00495 #ifdef MBI_INTERNAL_CONFERENCE
00496
00497 if ( mitkPostedEventID == 0 )
00498 {
00499 mitk::CoreObjectFactory::GetInstance()->MapEvent(event,eventID);
00500 }
00501 #endif //MBI_INTERNAL_CONFERENCE
00502
00503 mitk::OperationEvent::ExecuteIncrement();
00504
00505 if ( globalInteraction != NULL )
00506 {
00507 return globalInteraction->HandleEvent( &m_StateEvent );
00508 }
00509 else
00510 {
00511 return mitk::GlobalInteraction::GetInstance()->HandleEvent(&m_StateEvent);
00512 }
00513 }
00514
00515
00516
00517
00518 bool mitk::EventMapper::LoadBehavior(std::string fileName)
00519 {
00520 if ( fileName.empty() )
00521 return false;
00522
00523 this->SetFileName( fileName.c_str() );
00524
00525 return ( this->Parse() );
00526 }
00527
00528
00529
00530
00531 bool mitk::EventMapper::LoadBehaviorString(std::string xmlString)
00532 {
00533 if ( xmlString.empty() )
00534 return false;
00535
00536 return ( this->Parse(xmlString.c_str(), xmlString.length()) );
00537 }
00538
00539 bool mitk::EventMapper::LoadStandardBehavior()
00540 {
00541
00542
00543 std::string xmlFileName = mitk::StandardFileLocations::GetInstance()->FindFile("StateMachine.xml", "Core/Code/Interactions");
00544 if(xmlFileName != "")
00545 return LoadBehavior(xmlFileName);
00546
00547 return false;
00548 }
00549
00550
00551
00552
00553 inline int mitk::EventMapper::convertConstString2ConstInt(std::string input)
00554 {
00555 ConstMapIter tempIt = m_EventConstMap.find(input.c_str());
00556 if (tempIt != m_EventConstMap.end())
00557 {
00558 return (tempIt)->second;
00559 }
00560
00561
00562 return -1;
00563 }
00564
00565 void mitk::EventMapper::StartElement (const char *elementName, const char **atts)
00566 {
00567
00568 if ( elementName == EVENT )
00569 {
00570
00571
00572 EventDescription eventDescr( convertConstString2ConstInt( ReadXMLStringAttribut( TYPE, atts )),
00573 convertConstString2ConstInt( ReadXMLStringAttribut( BUTTON, atts )),
00574 ReadXMLIntegerAttribut( BUTTONSTATE, atts ),
00575 convertConstString2ConstInt( ReadXMLStringAttribut( KEY, atts )),
00576 ReadXMLStringAttribut( NAME, atts ),
00577 ReadXMLIntegerAttribut( ID, atts ));
00578
00579
00580 if (eventDescr.GetType()!= mitk::Type_User)
00581 {
00582 for (EventDescriptionVecIter iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end(); iter++)
00583 {
00584 if (*iter == eventDescr)
00585 {
00586 STATEMACHINE_WARN<<"Event description " << eventDescr.GetName() << " already present! Skipping event description";
00587 return;
00588 }
00589 }
00590 }
00591
00592 m_EventDescriptions.push_back(eventDescr);
00593 }
00594 else if ( elementName == EVENTS )
00595 m_StyleName = ReadXMLStringAttribut( STYLE, atts );
00596
00597 }
00598
00599 std::string mitk::EventMapper::GetStyleName() const
00600 {
00601 return m_StyleName;
00602 }
00603
00604
00605 std::string mitk::EventMapper::ReadXMLStringAttribut( std::string name, const char** atts )
00606 {
00607 if(atts)
00608 {
00609 const char** attsIter = atts;
00610
00611 while(*attsIter)
00612 {
00613 if ( name == *attsIter )
00614 {
00615 attsIter++;
00616 return *attsIter;
00617 }
00618 attsIter++;
00619 attsIter++;
00620 }
00621 }
00622
00623 return std::string();
00624 }
00625
00626
00627 int mitk::EventMapper::ReadXMLIntegerAttribut( std::string name, const char** atts )
00628 {
00629 std::string s = ReadXMLStringAttribut( name, atts );
00630 static const std::string hex = "0x";
00631 int result;
00632
00633 if ( s[0] == hex[0] && s[1] == hex[1] )
00634 result = strtol( s.c_str(), NULL, 16 );
00635 else
00636 result = atoi( s.c_str() );
00637
00638 return result;
00639 }
00640
00641 void mitk::EventMapper::SetStateEvent(mitk::Event* event)
00642 {
00643 m_StateEvent.Set( m_StateEvent.GetId(), event );
00644 }
00645
00646 bool mitk::EventMapper::RefreshStateEvent(mitk::StateEvent* stateEvent)
00647 {
00648
00649 EventDescriptionVecIter iter;
00650 for (iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end(); iter++)
00651 {
00652 if (*iter == *(stateEvent->GetEvent()))
00653 break;
00654 }
00655
00656 if (iter != m_EventDescriptions.end())
00657 {
00658 stateEvent->Set((*iter).GetId(), stateEvent->GetEvent());
00659 return true;
00660 }
00661 else
00662 return false;
00663
00664 return false;
00665 }
00666
00667 void mitk::EventMapper::AddEventMapperAddOn(mitk::EventMapperAddOn* newAddOn)
00668 {
00669 bool addOnAlreadyAdded = false;
00670
00671 for(AddOnVectorType::const_iterator it = this->m_AddOnVector.begin();it != m_AddOnVector.end();it++)
00672 {
00673 if(*it == newAddOn)
00674 {
00675 addOnAlreadyAdded = true;
00676 break;
00677 }
00678 }
00679
00680 if(!addOnAlreadyAdded)
00681 {
00682 m_AddOnVector.push_back(newAddOn);
00683 MITK_INFO << "AddOn Count: " << m_AddOnVector.size();
00684 }
00685 }
00686
00687 void mitk::EventMapper::RemoveEventMapperAddOn(mitk::EventMapperAddOn* unusedAddOn)
00688 {
00689 for(AddOnVectorType::iterator it = this->m_AddOnVector.begin();it != m_AddOnVector.end();it++)
00690 {
00691 if(*it == unusedAddOn)
00692 {
00693 m_AddOnVector.erase(it);
00694 break;
00695 }
00696 }
00697
00698 }