Open3D (C++ API)  0.11.0
VisualizerWithKeyCallback.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <map>
30 
32 
33 namespace open3d {
34 namespace visualization {
35 
40 public:
41  typedef std::pair<int, std::function<bool(Visualizer *)>> KeyCallbackPair;
42 
43 public:
46  ~VisualizerWithKeyCallback() override;
49  delete;
50 
51 public:
52  void PrintVisualizerHelp() override;
53  void RegisterKeyCallback(int key,
54  std::function<bool(Visualizer *)> callback);
68  int key, std::function<bool(Visualizer *, int, int)> callback);
69 
70 protected:
71  void KeyPressCallback(GLFWwindow *window,
72  int key,
73  int scancode,
74  int action,
75  int mods) override;
76  std::string PrintKeyToString(int key);
77 
78 protected:
79  std::map<int, std::function<bool(Visualizer *)>> key_to_callback_;
80  std::map<int, std::function<bool(Visualizer *, int, int)>>
82 };
83 
84 } // namespace visualization
85 } // namespace open3d
VisualizerWithKeyCallback()
Default Constructor.
Definition: VisualizerWithKeyCallback.cpp:33
void PrintVisualizerHelp() override
Definition: VisualizerWithKeyCallback.cpp:37
std::string PrintKeyToString(int key)
Definition: VisualizerWithKeyCallback.cpp:85
void RegisterKeyCallback(int key, std::function< bool(Visualizer *)> callback)
Definition: VisualizerWithKeyCallback.cpp:50
void KeyPressCallback(GLFWwindow *window, int key, int scancode, int action, int mods) override
Definition: VisualizerWithKeyCallback.cpp:60
std::pair< int, std::function< bool(Visualizer *)> > KeyCallbackPair
Definition: VisualizerWithKeyCallback.h:41
Visualizer with custom key callack capabilities.
Definition: VisualizerWithKeyCallback.h:39
std::map< int, std::function< bool(Visualizer *, int, int)> > key_action_to_callback_
Definition: VisualizerWithKeyCallback.h:81
std::map< int, std::function< bool(Visualizer *)> > key_to_callback_
Definition: VisualizerWithKeyCallback.h:79
VisualizerWithKeyCallback & operator=(const VisualizerWithKeyCallback &)=delete
~VisualizerWithKeyCallback() override
Definition: VisualizerWithKeyCallback.cpp:35
Definition: PinholeCameraIntrinsic.cpp:35
The main Visualizer class.
Definition: Visualizer.h:61
void RegisterKeyActionCallback(int key, std::function< bool(Visualizer *, int, int)> callback)
Definition: VisualizerWithKeyCallback.cpp:55