Open3D (C++ API)  0.18.0+252c867
Events.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <cstdint>
11 #include <sstream>
12 #include <string>
13 
15 
17 namespace Json {
18 class Value;
19 } // namespace Json
21 
22 namespace open3d {
23 namespace visualization {
24 namespace gui {
25 
26 enum class MouseButton {
27  NONE = 0,
28  LEFT = (1 << 0),
29  MIDDLE = (1 << 1),
30  RIGHT = (1 << 2),
31  BUTTON4 = (1 << 3),
32  BUTTON5 = (1 << 4)
33 };
34 
35 // The key modifiers are labeled by functionality; for instance,
36 // Ctrl on Windows and Command on macOS have roughly the same functionality.
37 enum class KeyModifier {
38  NONE = 0,
39  SHIFT = (1 << 0),
40  CTRL = (1 << 1), // win/linux: ctrl, macOS: command
41  ALT = (1 << 2), // win/linux: alt, macOS: ctrl
42  META = (1 << 3), // win/linux: windows key, macOS: option
43 };
44 
45 struct MouseEvent {
47 
48  static MouseEvent MakeMoveEvent(const Type type,
49  const int x,
50  const int y,
51  const int modifiers,
52  const int buttons);
53 
54  static MouseEvent MakeButtonEvent(const Type type,
55  const int x,
56  const int y,
57  const int modifiers,
58  const MouseButton button,
59  const int count);
60 
61  static MouseEvent MakeWheelEvent(const Type type,
62  const int x,
63  const int y,
64  const int modifiers,
65  const float dx,
66  const float dy,
67  const bool isTrackpad);
68 
70  int x;
71  int y;
72  int modifiers; // KeyModifiers ORed together
73  union {
74  struct {
75  int buttons; // MouseButtons ORed together
76  } move; // includes drag
77  struct {
79  int count;
80  } button;
81  struct {
82  float dx; // macOS gives fractional values, and is required
83  float dy; // for the buttery-smooth trackpad scrolling on macOS
84  bool isTrackpad;
85  } wheel;
86  };
87 
88  bool FromJson(const Json::Value &value);
89  std::string ToString() const;
90 };
91 
92 struct TickEvent {
93  double dt;
94 };
95 
96 enum KeyName {
97  KEY_NONE = 0,
99  KEY_TAB = 9,
100  KEY_ENTER = 10,
102  KEY_SPACE = 32,
105  KEY_HASH = 35,
113  KEY_PLUS = 43,
114  KEY_COMMA = 44,
115  KEY_MINUS = 45,
117  KEY_SLASH = 47,
118  KEY_0 = 48,
128  KEY_COLON = 58,
134  KEY_AT = 64,
138  KEY_CARET = 94,
141  KEY_A = 97,
168  KEY_PIPE = 124,
170  KEY_TILDE = 126,
171  KEY_DELETE = 127,
172  KEY_LSHIFT = 256,
188  KEY_F1 = 290,
200  KEY_UNKNOWN = 1000
201 };
202 
203 struct KeyEvent {
204  enum Type { DOWN, UP };
206  // This is the actual key that was pressed, not the character that
207  // was generated (use TextInputEvent for that). Values correspond
208  // to ASCII values where applicable.
210  bool isRepeat;
211 };
212 
214  const char *utf8;
215 };
216 
217 } // namespace gui
218 } // namespace visualization
219 } // namespace open3d
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle uint32_t
Definition: K4aPlugin.cpp:548
KeyName
Definition: Events.h:96
@ KEY_L
Definition: Events.h:152
@ KEY_EXCLAMATION
Definition: Events.h:103
@ KEY_F
Definition: Events.h:146
@ KEY_P
Definition: Events.h:156
@ KEY_J
Definition: Events.h:150
@ KEY_META
Definition: Events.h:177
@ KEY_SINGLE_QUOTE
Definition: Events.h:109
@ KEY_F11
Definition: Events.h:198
@ KEY_RSHIFT
Definition: Events.h:173
@ KEY_PLUS
Definition: Events.h:113
@ KEY_H
Definition: Events.h:148
@ KEY_Y
Definition: Events.h:165
@ KEY_B
Definition: Events.h:142
@ KEY_RIGHT_PAREN
Definition: Events.h:111
@ KEY_T
Definition: Events.h:160
@ KEY_AMPERSAND
Definition: Events.h:108
@ KEY_F5
Definition: Events.h:192
@ KEY_I
Definition: Events.h:149
@ KEY_ASTERISK
Definition: Events.h:112
@ KEY_F3
Definition: Events.h:190
@ KEY_ENTER
Definition: Events.h:100
@ KEY_PIPE
Definition: Events.h:168
@ KEY_R
Definition: Events.h:158
@ KEY_Q
Definition: Events.h:157
@ KEY_V
Definition: Events.h:162
@ KEY_7
Definition: Events.h:125
@ KEY_SEMICOLON
Definition: Events.h:129
@ KEY_UNDERSCORE
Definition: Events.h:139
@ KEY_LSHIFT
Definition: Events.h:172
@ KEY_F6
Definition: Events.h:193
@ KEY_S
Definition: Events.h:159
@ KEY_DOWN
Definition: Events.h:182
@ KEY_2
Definition: Events.h:120
@ KEY_8
Definition: Events.h:126
@ KEY_ALT
Definition: Events.h:176
@ KEY_LESS_THAN
Definition: Events.h:130
@ KEY_3
Definition: Events.h:121
@ KEY_LEFT_PAREN
Definition: Events.h:110
@ KEY_UNKNOWN
Definition: Events.h:200
@ KEY_UP
Definition: Events.h:181
@ KEY_F2
Definition: Events.h:189
@ KEY_LEFT_BRACKET
Definition: Events.h:135
@ KEY_F9
Definition: Events.h:196
@ KEY_F7
Definition: Events.h:194
@ KEY_ESCAPE
Definition: Events.h:101
@ KEY_CARET
Definition: Events.h:138
@ KEY_F1
Definition: Events.h:188
@ KEY_F8
Definition: Events.h:195
@ KEY_E
Definition: Events.h:145
@ KEY_4
Definition: Events.h:122
@ KEY_G
Definition: Events.h:147
@ KEY_PAGEUP
Definition: Events.h:186
@ KEY_W
Definition: Events.h:163
@ KEY_O
Definition: Events.h:155
@ KEY_TILDE
Definition: Events.h:170
@ KEY_EQUALS
Definition: Events.h:131
@ KEY_HASH
Definition: Events.h:105
@ KEY_U
Definition: Events.h:161
@ KEY_X
Definition: Events.h:164
@ KEY_PAGEDOWN
Definition: Events.h:187
@ KEY_INSERT
Definition: Events.h:183
@ KEY_0
Definition: Events.h:118
@ KEY_BACKSLASH
Definition: Events.h:136
@ KEY_END
Definition: Events.h:185
@ KEY_SLASH
Definition: Events.h:117
@ KEY_LEFT_BRACE
Definition: Events.h:167
@ KEY_MINUS
Definition: Events.h:115
@ KEY_COLON
Definition: Events.h:128
@ KEY_BACKTICK
Definition: Events.h:140
@ KEY_TAB
Definition: Events.h:99
@ KEY_PERIOD
Definition: Events.h:116
@ KEY_RIGHT_BRACKET
Definition: Events.h:137
@ KEY_NONE
Definition: Events.h:97
@ KEY_RCTRL
Definition: Events.h:175
@ KEY_SPACE
Definition: Events.h:102
@ KEY_QUESTION_MARK
Definition: Events.h:133
@ KEY_A
Definition: Events.h:141
@ KEY_F10
Definition: Events.h:197
@ KEY_5
Definition: Events.h:123
@ KEY_RIGHT_BRACE
Definition: Events.h:169
@ KEY_COMMA
Definition: Events.h:114
@ KEY_BACKSPACE
Definition: Events.h:98
@ KEY_HOME
Definition: Events.h:184
@ KEY_PERCENT
Definition: Events.h:107
@ KEY_LCTRL
Definition: Events.h:174
@ KEY_1
Definition: Events.h:119
@ KEY_RIGHT
Definition: Events.h:180
@ KEY_DOUBLE_QUOTE
Definition: Events.h:104
@ KEY_6
Definition: Events.h:124
@ KEY_M
Definition: Events.h:153
@ KEY_Z
Definition: Events.h:166
@ KEY_D
Definition: Events.h:144
@ KEY_AT
Definition: Events.h:134
@ KEY_GREATER_THAN
Definition: Events.h:132
@ KEY_CAPSLOCK
Definition: Events.h:178
@ KEY_F12
Definition: Events.h:199
@ KEY_C
Definition: Events.h:143
@ KEY_LEFT
Definition: Events.h:179
@ KEY_K
Definition: Events.h:151
@ KEY_9
Definition: Events.h:127
@ KEY_F4
Definition: Events.h:191
@ KEY_DELETE
Definition: Events.h:171
@ KEY_N
Definition: Events.h:154
@ KEY_DOLLAR_SIGN
Definition: Events.h:106
MouseButton
Definition: Events.h:26
KeyModifier
Definition: Events.h:37
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Events.h:203
Type type
Definition: Events.h:205
uint32_t key
Definition: Events.h:209
Type
Definition: Events.h:204
@ UP
Definition: Events.h:204
@ DOWN
Definition: Events.h:204
bool isRepeat
Definition: Events.h:210
bool FromJson(const Json::Value &value)
Definition: Events.cpp:71
struct open3d::visualization::gui::MouseEvent::@1::@3 move
@ BUTTON_DOWN
Definition: Events.h:46
@ WHEEL
Definition: Events.h:46
@ BUTTON_UP
Definition: Events.h:46
float dy
Definition: Events.h:83
int buttons
Definition: Events.h:75
float dx
Definition: Events.h:82
int modifiers
Definition: Events.h:72
std::string ToString() const
Definition: Events.cpp:22
struct open3d::visualization::gui::MouseEvent::@1::@5 wheel
bool isTrackpad
Definition: Events.h:84
static MouseEvent MakeWheelEvent(const Type type, const int x, const int y, const int modifiers, const float dx, const float dy, const bool isTrackpad)
Definition: Events.cpp:170
static MouseEvent MakeButtonEvent(const Type type, const int x, const int y, const int modifiers, const MouseButton button, const int count)
Definition: Events.cpp:154
int count
Definition: Events.h:79
Type type
Definition: Events.h:69
MouseButton button
Definition: Events.h:78
int y
Definition: Events.h:71
static MouseEvent MakeMoveEvent(const Type type, const int x, const int y, const int modifiers, const int buttons)
Definition: Events.cpp:140
int x
Definition: Events.h:70
const char * utf8
Definition: Events.h:214
double dt
Definition: Events.h:93