<commit_before>/*=========================================================================

  Program:   Medical Imaging & Interaction Toolkit
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/ for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

/**
*   EventMapping:
*       This class mapps the Events, usually given by the OS or here by QT, to a MITK internal EventId.
*       It loads all information from the xml-file (possible, understandable Events with the mitkEventID).
*       If an event appears, the method MapEvent is called with the event params.
*       This Method looks up the event params, and tries to find an mitkEventId to it.
*       If yes, then sends the event and the found ID to the globalStateMachine, which handles all
*       further operations of that event.
*
*/

#include "mitkPositionEvent.h"
#include "mitkEventMapper.h"
#include <itkOutputWindow.h>
#include <itkMacro.h>
#include "mitkStatusBar.h"
#include "mitkInteractionConst.h"

//XML Event
//##ModelId=3E788FC000E5
const std::string mitk::EventMapper::STYLE = "STYLE";
//##ModelId=3E788FC0025C
const std::string mitk::EventMapper::NAME = "NAME";
//##ModelId=3E788FC002AA
const std::string mitk::EventMapper::ID = "ID";
//##ModelId=3E77572901E9
const std::string mitk::EventMapper::TYPE = "TYPE";
//##ModelId=3E7757290256
const std::string mitk::EventMapper::BUTTON = "BUTTON";
//##ModelId=3E8B08FA01AA
const std::string mitk::EventMapper::BUTTONSTATE = "BUTTONSTATE";
//##ModelId=3E77572902C4
const std::string mitk::EventMapper::KEY = "KEY";

const std::string mitk::EventMapper::EVENTS = "events";

const std::string mitk::EventMapper::EVENT = "event";

mitk::StateMachine *mitk::EventMapper::m_GlobalStateMachine;

mitk::EventMapper::EventDescriptionVec mitk::EventMapper::m_EventDescriptions;

mitk::StateEvent mitk::EventMapper::m_StateEvent;

std::string mitk::EventMapper::m_StyleName;



struct ltstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) < 0;
  }
};

//##ModelId=3F02F896006D
mitk::EventMapper::EventMapper()
{

//map with string to key for mapping string from xml-file to int
	m_EventConstMap["Type_None"] = 0;		// invalid event //@TODO:replace with mitk::Type_None
	m_EventConstMap["Type_Timer"] = 1;		// timer event
	m_EventConstMap["Type_MouseButtonPress"] = 2;		// mouse button pressed
	m_EventConstMap["Type_MouseButtonRelease"] = 3;		// mouse button released
	m_EventConstMap["Type_MouseButtonDblClick"] =	4;		// mouse button double click
	m_EventConstMap["Type_MouseMove"] = 5;		// mouse move
	m_EventConstMap["Type_KeyPress"] = 6;		// key pressed
	m_EventConstMap["Type_KeyRelease"] = 7;		// key released
	m_EventConstMap["Type_FocusIn"] = 				8;		// keyboard focus received
	m_EventConstMap["Type_FocusOut"] = 				9;		// keyboard focus lost
	m_EventConstMap["Type_Enter"] = 					10;	// mouse enters widget
	m_EventConstMap["Type_Leave"] = 					11;	// mouse leaves widget
	m_EventConstMap["Type_Paint"] = 					12;	// paint widget
	m_EventConstMap["Type_Move"] = 					13;	// move widget
	m_EventConstMap["Type_Resize"] = 				14;	// resize widget
	m_EventConstMap["Type_Create"] = 				15;	// after object creation
	m_EventConstMap["Type_Destroy"] = 				16;	// during object destruction
	m_EventConstMap["Type_Show"] = 					17;	// widget is shown
	m_EventConstMap["Type_Hide"] = 					18;	// widget is hidden
	m_EventConstMap["Type_Close"] = 					19;	// request to close widget
	m_EventConstMap["Type_Quit"] = 					20;	// request to quit application
	m_EventConstMap["Type_Reparent"] = 				21;	// widget has been reparented
	m_EventConstMap["Type_ShowMinimized"] = 			22;	// widget is shown minimized
	m_EventConstMap["Type_ShowNormal"] = 			23;	// widget is shown normal
	m_EventConstMap["Type_WindowActivate"] = 		24;	// window was activated
	m_EventConstMap["Type_WindowDeactivate"] = 		25;	// window was deactivated
	m_EventConstMap["Type_ShowToParent"] = 			26;	// widget is shown to parent
	m_EventConstMap["Type_HideToParent"] = 			27;	// widget is hidden to parent
	m_EventConstMap["Type_ShowMaximized"] = 			28;	// widget is shown maximized
	m_EventConstMap["Type_ShowFullScreen"] = 		29;	// widget is shown full-screen
	m_EventConstMap["Type_Accel"] = 					30;	// accelerator event
	m_EventConstMap["Type_Wheel"] = 					31;	// wheel event
	m_EventConstMap["Type_AccelAvailable"] = 		32;	// accelerator available event
	m_EventConstMap["Type_CaptionChange"] = 			33;	// caption changed
	m_EventConstMap["Type_IconChange"] = 			34;	// icon changed
	m_EventConstMap["Type_ParentFontChange"] = 		35;	// parent font changed
	m_EventConstMap["Type_ApplicationFontChange"] = 	36;// application font changed
	m_EventConstMap["Type_ParentPaletteChange"] = 	37;	// parent palette changed
	m_EventConstMap["Type_ApplicationPaletteChange"] =  38;// application palette changed
	m_EventConstMap["Type_PaletteChange"] = 			39;	// widget palette changed
	m_EventConstMap["Type_Clipboard"] = 				40;	// internal clipboard event
	m_EventConstMap["Type_Speech"] = 				42;	// reserved for speech input
	m_EventConstMap["Type_SockAct"] = 				50;	// socket activation
	m_EventConstMap["Type_AccelOverride"] = 			51;	// accelerator override event
	m_EventConstMap["Type_DeferredDelete"] = 		52;	// deferred delete event
	m_EventConstMap["Type_DragEnter"] = 				60;	// drag moves into widget
	m_EventConstMap["Type_DragMove"] = 				61;	// drag moves in widget
	m_EventConstMap["Type_DragLeave"] = 				62;	// drag leaves or is cancelled
	m_EventConstMap["Type_Drop"] = 					63;	// actual drop
	m_EventConstMap["Type_DragResponse"] = 			64;	// drag accepted/rejected
	m_EventConstMap["Type_ChildInserted"] = 			70;	// new child widget
	m_EventConstMap["Type_ChildRemoved"] = 			71;	// deleted child widget
	m_EventConstMap["Type_LayoutHint"] = 			72;	// child min/max size changed
	m_EventConstMap["Type_ShowWindowRequest"] = 		73;	// widget's window should be mapped
	m_EventConstMap["Type_ActivateControl"] = 		80;	// ActiveX activation
	m_EventConstMap["Type_DeactivateControl"] = 		81;	// ActiveX deactivation
	m_EventConstMap["Type_ContextMenu"] = 			82;	// context popup menu
	m_EventConstMap["Type_IMStart"] = 				83;	// input method composition start
	m_EventConstMap["Type_IMCompose"] = 				84;	// input method composition
	m_EventConstMap["Type_IMEnd"] = 					85;	// input method composition end
	m_EventConstMap["Type_Accessibility"] = 			86;	// accessibility information is requested
	m_EventConstMap["Type_TabletMove"] = 			87;	// Wacom tablet event
	m_EventConstMap["Type_LocaleChange"] = 			88;	// the system locale changed
	m_EventConstMap["Type_LanguageChange"] = 		89;	// the application language changed
	m_EventConstMap["Type_LayoutDirectionChange"] = 	90;	// the layout direction changed
	m_EventConstMap["Type_Style"] = 					91;	// internal style event
	m_EventConstMap["Type_TabletPress"] = 			92;	// tablet press
	m_EventConstMap["Type_TabletRelease"] = 			93;	// tablet release
	m_EventConstMap["Type_User"] = 					1000;	// first user event id
	m_EventConstMap["Type_MaxUser"] = 				65535;	// last user event id

//ButtonState
    m_EventConstMap["BS_NoButton"] =  0x0000;
    m_EventConstMap["BS_LeftButton"] =  0x0001;
    m_EventConstMap["BS_RightButton"] =  0x0002;
    m_EventConstMap["BS_MidButton"] =  0x0004;
    m_EventConstMap["BS_MouseButtonMask"] =  0x0007;
    m_EventConstMap["BS_ShiftButton"] =  0x0008;
    m_EventConstMap["BS_ControlButton"] =  0x0010;
    m_EventConstMap["BS_AltButton"] =  0x0020;
    m_EventConstMap["BS_KeyButtonMask"] =  0x0038;
    m_EventConstMap["BS_Keypad"] =  0x4000;

//Modifier
    m_EventConstMap["Mod_SHIFT"] =  0x00200000;<commit_msg>replaced most important vars from numbers to mitk-constants<commit_after>/*=========================================================================

  Program:   Medical Imaging & Interaction Toolkit
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/ for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

/**
*   EventMapping:
*       This class mapps the Events, usually given by the OS or here by QT, to a MITK internal EventId.
*       It loads all information from the xml-file (possible, understandable Events with the mitkEventID).
*       If an event appears, the method MapEvent is called with the event params.
*       This Method looks up the event params, and tries to find an mitkEventId to it.
*       If yes, then sends the event and the found ID to the globalStateMachine, which handles all
*       further operations of that event.
*
*/

#include "mitkPositionEvent.h"
#include "mitkEventMapper.h"
#include <itkOutputWindow.h>
#include <itkMacro.h>
#include "mitkStatusBar.h"
#include "mitkInteractionConst.h"

//XML Event
//##ModelId=3E788FC000E5
const std::string mitk::EventMapper::STYLE = "STYLE";
//##ModelId=3E788FC0025C
const std::string mitk::EventMapper::NAME = "NAME";
//##ModelId=3E788FC002AA
const std::string mitk::EventMapper::ID = "ID";
//##ModelId=3E77572901E9
const std::string mitk::EventMapper::TYPE = "TYPE";
//##ModelId=3E7757290256
const std::string mitk::EventMapper::BUTTON = "BUTTON";
//##ModelId=3E8B08FA01AA
const std::string mitk::EventMapper::BUTTONSTATE = "BUTTONSTATE";
//##ModelId=3E77572902C4
const std::string mitk::EventMapper::KEY = "KEY";

const std::string mitk::EventMapper::EVENTS = "events";

const std::string mitk::EventMapper::EVENT = "event";

mitk::StateMachine *mitk::EventMapper::m_GlobalStateMachine;

mitk::EventMapper::EventDescriptionVec mitk::EventMapper::m_EventDescriptions;

mitk::StateEvent mitk::EventMapper::m_StateEvent;

std::string mitk::EventMapper::m_StyleName;



struct ltstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) < 0;
  }
};

//##ModelId=3F02F896006D
mitk::EventMapper::EventMapper()
{

//map with string to key for mapping string from xml-file to int
  m_EventConstMap["Type_None"] = mitk::Type_None;		// invalid event 
  m_EventConstMap["Type_Timer"] = mitk::Type_Timer;		// timer event
  m_EventConstMap["Type_MouseButtonPress"] = mitk::Type_MouseButtonPress;		// mouse button pressed
  m_EventConstMap["Type_MouseButtonRelease"] = mitk::Type_MouseButtonRelease;		// mouse button released
  m_EventConstMap["Type_MouseButtonDblClick"] =	mitk::Type_MouseButtonDblClick;		// mouse button double click
  m_EventConstMap["Type_MouseMove"] = mitk::Type_MouseMove;		// mouse move
  m_EventConstMap["Type_KeyPress"] = mitk::Type_KeyPress;		// key pressed
  m_EventConstMap["Type_KeyRelease"] = mitk::Type_KeyRelease;		// key released
	m_EventConstMap["Type_FocusIn"] = 				8;		// keyboard focus received
	m_EventConstMap["Type_FocusOut"] = 				9;		// keyboard focus lost
	m_EventConstMap["Type_Enter"] = 					10;	// mouse enters widget
	m_EventConstMap["Type_Leave"] = 					11;	// mouse leaves widget
	m_EventConstMap["Type_Paint"] = 					12;	// paint widget
	m_EventConstMap["Type_Move"] = 					13;	// move widget
	m_EventConstMap["Type_Resize"] = 				14;	// resize widget
	m_EventConstMap["Type_Create"] = 				15;	// after object creation
	m_EventConstMap["Type_Destroy"] = 				16;	// during object destruction
	m_EventConstMap["Type_Show"] = 					17;	// widget is shown
	m_EventConstMap["Type_Hide"] = 					18;	// widget is hidden
	m_EventConstMap["Type_Close"] = 					19;	// request to close widget
	m_EventConstMap["Type_Quit"] = 					20;	// request to quit application
	m_EventConstMap["Type_Reparent"] = 				21;	// widget has been reparented
	m_EventConstMap["Type_ShowMinimized"] = 			22;	// widget is shown minimized
	m_EventConstMap["Type_ShowNormal"] = 			23;	// widget is shown normal
	m_EventConstMap["Type_WindowActivate"] = 		24;	// window was activated
	m_EventConstMap["Type_WindowDeactivate"] = 		25;	// window was deactivated
	m_EventConstMap["Type_ShowToParent"] = 			26;	// widget is shown to parent
	m_EventConstMap["Type_HideToParent"] = 			27;	// widget is hidden to parent
	m_EventConstMap["Type_ShowMaximized"] = 			28;	// widget is shown maximized
	m_EventConstMap["Type_ShowFullScreen"] = 		29;	// widget is shown full-screen
	m_EventConstMap["Type_Accel"] = 					30;	// accelerator event
	m_EventConstMap["Type_Wheel"] = 					31;	// wheel event
	m_EventConstMap["Type_AccelAvailable"] = 		32;	// accelerator available event
	m_EventConstMap["Type_CaptionChange"] = 			33;	// caption changed
	m_EventConstMap["Type_IconChange"] = 			34;	// icon changed
	m_EventConstMap["Type_ParentFontChange"] = 		35;	// parent font changed
	m_EventConstMap["Type_ApplicationFontChange"] = 	36;// application font changed
	m_EventConstMap["Type_ParentPaletteChange"] = 	37;	// parent palette changed
	m_EventConstMap["Type_ApplicationPaletteChange"] =  38;// application palette changed
	m_EventConstMap["Type_PaletteChange"] = 			39;	// widget palette changed
	m_EventConstMap["Type_Clipboard"] = 				40;	// internal clipboard event
	m_EventConstMap["Type_Speech"] = 				42;	// reserved for speech input
	m_EventConstMap["Type_SockAct"] = 				50;	// socket activation
	m_EventConstMap["Type_AccelOverride"] = 			51;	// accelerator override event
	m_EventConstMap["Type_DeferredDelete"] = 		52;	// deferred delete event
	m_EventConstMap["Type_DragEnter"] = 				60;	// drag moves into widget
	m_EventConstMap["Type_DragMove"] = 				61;	// drag moves in widget
	m_EventConstMap["Type_DragLeave"] = 				62;	// drag leaves or is cancelled
	m_EventConstMap["Type_Drop"] = 					63;	// actual drop
	m_EventConstMap["Type_DragResponse"] = 			64;	// drag accepted/rejected
	m_EventConstMap["Type_ChildInserted"] = 			70;	// new child widget
	m_EventConstMap["Type_ChildRemoved"] = 			71;	// deleted child widget
	m_EventConstMap["Type_LayoutHint"] = 			72;	// child min/max size changed
	m_EventConstMap["Type_ShowWindowRequest"] = 		73;	// widget's window should be mapped
	m_EventConstMap["Type_ActivateControl"] = 		80;	// ActiveX activation
	m_EventConstMap["Type_DeactivateControl"] = 		81;	// ActiveX deactivation
	m_EventConstMap["Type_ContextMenu"] = 			82;	// context popup menu
	m_EventConstMap["Type_IMStart"] = 				83;	// input method composition start
	m_EventConstMap["Type_IMCompose"] = 				84;	// input method composition
	m_EventConstMap["Type_IMEnd"] = 					85;	// input method composition end
	m_EventConstMap["Type_Accessibility"] = 			86;	// accessibility information is requested
	m_EventConstMap["Type_TabletMove"] = 			87;	// Wacom tablet event
	m_EventConstMap["Type_LocaleChange"] = 			88;	// the system locale changed
	m_EventConstMap["Type_LanguageChange"] = 		89;	// the application language changed
	m_EventConstMap["Type_LayoutDirectionChange"] = 	90;	// the layout direction changed
	m_EventConstMap["Type_Style"] = 					91;	// internal style event
	m_EventConstMap["Type_TabletPress"] = 			92;	// tablet press
	m_EventConstMap["Type_TabletRelease"] = 			93;	// tablet release
	m_EventConstMap["Type_User"] = 					1000;	// first user event id
	m_EventConstMap["Type_MaxUser"] = 				65535;	// last user event id

//ButtonState
  m_EventConstMap["BS_NoButton"] =  mitk::BS_NoButton;//0x0000
    m_EventConstMap["BS_LeftButton"] =  mitk::BS_LeftButton;//0x0001
    m_EventConstMap["BS_RightButton"] =  mitk::BS_RightButton;//0x0002
    m_EventConstMap["BS_MidButton"] =  mitk::BS_MidButton;//0x0004
    m_EventConstMap["BS_MouseButtonMask"] =  mitk::BS_MouseButtonMask;//0x0007
    m_EventConstMap["BS_ShiftButton"] =  mitk::BS_ShiftButton;//0x0008
    m_EventConstMap["BS_ControlButton"] =  mitk::BS_ControlButton;//0x0010
    m_EventConstMap["BS_AltButton"] =  mitk::BS_AltButton;//0x0020
    m_EventConstMap["BS_KeyButtonMask"] =  mitk::BS_KeyButtonMask;//0x0038
    m_EventConstMap["BS_Keypad"] =  mitk::BS_Keypad;//0x4000

//Modifier
    m_EventConstMap["Mod_SHIFT"] =  0x00200000;
{'fraction_non_alphanumeric': 0.13163289917993246, 'fraction_numerical': 0.03183791606367583, 'mean_word_length': 4.662342096278594, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1770195', 'n_tokens_mistral': 6085, 'n_tokens_neox': 5549, 'n_words': 1251}