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
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef PCL_VISUALIZATION_KEYBOARD_EVENT_H_
00040 #define PCL_VISUALIZATION_KEYBOARD_EVENT_H_
00041
00042 #include <string>
00043
00044 namespace pcl
00045 {
00046 namespace visualization
00047 {
00049 class KeyboardEvent
00050 {
00051 public:
00053 static const unsigned int Alt = 1;
00055 static const unsigned int Ctrl = 2;
00057 static const unsigned int Shift = 4;
00058
00067 inline KeyboardEvent (bool action, const std::string& key_sym, unsigned char key,
00068 bool alt, bool ctrl, bool shift);
00069
00073 inline bool
00074 isAltPressed () const;
00075
00079 inline bool
00080 isCtrlPressed () const;
00081
00085 inline bool
00086 isShiftPressed () const;
00087
00091 inline unsigned char
00092 getKeyCode () const;
00093
00097 inline const std::string&
00098 getKeySym () const;
00099
00103 inline bool
00104 keyDown () const;
00105
00109 inline bool
00110 keyUp () const;
00111
00112 protected:
00113
00114 bool action_;
00115 unsigned int modifiers_;
00116 unsigned char key_code_;
00117 std::string key_sym_;
00118 };
00119
00120 KeyboardEvent::KeyboardEvent (bool action, const std::string& key_sym, unsigned char key,
00121 bool alt, bool ctrl, bool shift)
00122 : action_ (action)
00123 , modifiers_ (0)
00124 , key_code_(key)
00125 , key_sym_ (key_sym)
00126 {
00127 if (alt)
00128 modifiers_ = Alt;
00129
00130 if (ctrl)
00131 modifiers_ |= Ctrl;
00132
00133 if (shift)
00134 modifiers_ |= Shift;
00135 }
00136
00137 bool
00138 KeyboardEvent::isAltPressed () const
00139 {
00140 return (modifiers_ & Alt) != 0;
00141 }
00142
00143 bool
00144 KeyboardEvent::isCtrlPressed () const
00145 {
00146 return (modifiers_ & Ctrl) != 0;
00147 }
00148
00149 bool
00150 KeyboardEvent::isShiftPressed () const
00151 {
00152 return (modifiers_ & Shift) != 0;
00153 }
00154
00155 unsigned char
00156 KeyboardEvent::getKeyCode () const
00157 {
00158 return (key_code_);
00159 }
00160
00161 const std::string&
00162 KeyboardEvent::getKeySym () const
00163 {
00164 return (key_sym_);
00165 }
00166
00167 bool
00168 KeyboardEvent::keyDown () const
00169 {
00170 return (action_);
00171 }
00172
00173 bool
00174 KeyboardEvent::keyUp () const
00175 {
00176 return (!action_);
00177 }
00178 }
00179 }
00180
00181 #endif
00182