Open3D (C++ API)  0.18.0+fcf98ee
VisualizerWithKeyCallback.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 <map>
11 
13 
14 namespace open3d {
15 namespace visualization {
16 
21 public:
22  typedef std::pair<int, std::function<bool(Visualizer *)>> KeyCallbackPair;
23 
24 public:
27  ~VisualizerWithKeyCallback() override;
30  delete;
31 
32 public:
33  void PrintVisualizerHelp() override;
34  void RegisterKeyCallback(int key,
35  std::function<bool(Visualizer *)> callback);
36 
50  int key, std::function<bool(Visualizer *, int, int)> callback);
51 
61  std::function<bool(Visualizer *, double, double)> callback);
62 
72  std::function<bool(Visualizer *, double, double)> callback);
73 
84  std::function<bool(Visualizer *, int, int, int)> callback);
85 
86 protected:
87  void KeyPressCallback(GLFWwindow *window,
88  int key,
89  int scancode,
90  int action,
91  int mods) override;
92  void MouseMoveCallback(GLFWwindow *window, double x, double y) override;
93  void MouseScrollCallback(GLFWwindow *window, double x, double y) override;
94  void MouseButtonCallback(GLFWwindow *window,
95  int button,
96  int action,
97  int mods) override;
98  std::string PrintKeyToString(int key);
99 
100 protected:
101  std::map<int, std::function<bool(Visualizer *)>> key_to_callback_;
102  std::map<int, std::function<bool(Visualizer *, int, int)>>
104  std::function<bool(Visualizer *, double, double)> mouse_move_callback_;
105  std::function<bool(Visualizer *, double, double)> mouse_scroll_callback_;
106  std::function<bool(Visualizer *, int, int, int)> mouse_button_callback_;
107 };
108 
109 } // namespace visualization
110 } // namespace open3d
std::function< void(std::shared_ptr< core::Tensor >)> callback
Definition: FilamentRenderer.cpp:182
The main Visualizer class.
Definition: Visualizer.h:45
Visualizer with custom key callback capabilities.
Definition: VisualizerWithKeyCallback.h:20
void RegisterMouseMoveCallback(std::function< bool(Visualizer *, double, double)> callback)
Definition: VisualizerWithKeyCallback.cpp:48
std::map< int, std::function< bool(Visualizer *)> > key_to_callback_
Definition: VisualizerWithKeyCallback.h:101
void RegisterKeyActionCallback(int key, std::function< bool(Visualizer *, int, int)> callback)
Definition: VisualizerWithKeyCallback.cpp:43
std::function< bool(Visualizer *, int, int, int)> mouse_button_callback_
Definition: VisualizerWithKeyCallback.h:106
std::function< bool(Visualizer *, double, double)> mouse_scroll_callback_
Definition: VisualizerWithKeyCallback.h:105
VisualizerWithKeyCallback(const VisualizerWithKeyCallback &)=delete
void KeyPressCallback(GLFWwindow *window, int key, int scancode, int action, int mods) override
Definition: VisualizerWithKeyCallback.cpp:63
void MouseMoveCallback(GLFWwindow *window, double x, double y) override
Definition: VisualizerWithKeyCallback.cpp:88
void MouseScrollCallback(GLFWwindow *window, double x, double y) override
Definition: VisualizerWithKeyCallback.cpp:101
std::pair< int, std::function< bool(Visualizer *)> > KeyCallbackPair
Definition: VisualizerWithKeyCallback.h:22
VisualizerWithKeyCallback & operator=(const VisualizerWithKeyCallback &)=delete
void RegisterMouseButtonCallback(std::function< bool(Visualizer *, int, int, int)> callback)
Definition: VisualizerWithKeyCallback.cpp:58
std::string PrintKeyToString(int key)
Definition: VisualizerWithKeyCallback.cpp:128
void RegisterKeyCallback(int key, std::function< bool(Visualizer *)> callback)
Definition: VisualizerWithKeyCallback.cpp:38
~VisualizerWithKeyCallback() override
Definition: VisualizerWithKeyCallback.cpp:16
void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) override
Definition: VisualizerWithKeyCallback.cpp:114
void PrintVisualizerHelp() override
Definition: VisualizerWithKeyCallback.cpp:18
std::map< int, std::function< bool(Visualizer *, int, int)> > key_action_to_callback_
Definition: VisualizerWithKeyCallback.h:103
std::function< bool(Visualizer *, double, double)> mouse_move_callback_
Definition: VisualizerWithKeyCallback.h:104
VisualizerWithKeyCallback()
Default Constructor.
Definition: VisualizerWithKeyCallback.cpp:14
void RegisterMouseScrollCallback(std::function< bool(Visualizer *, double, double)> callback)
Definition: VisualizerWithKeyCallback.cpp:53
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 int
Definition: K4aPlugin.cpp:474
Definition: PinholeCameraIntrinsic.cpp:16