Open3D (C++ API)  0.12.0
PickPointsInteractor.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 <queue>
30 
33 
34 namespace open3d {
35 
36 namespace geometry {
37 class Geometry3D;
38 class Image;
39 } // namespace geometry
40 
41 namespace visualization {
42 
43 namespace rendering {
44 class Camera;
45 struct Material;
46 class MatrixInteractorLogic;
47 class Open3DScene;
48 } // namespace rendering
49 
50 namespace gui {
51 
52 class SelectionIndexLookup;
53 
54 // This is an internal class used by SceneWidget
56 public:
58  rendering::Camera* camera);
59  virtual ~PickPointsInteractor();
60 
61  void SetPointSize(int px);
62 
65  void SetPickableGeometry(
66  const std::vector<SceneWidget::PickableGeometry>& geometry);
67 
70  void SetNeedsRedraw();
71 
74  void SetOnPointsPicked(
75  std::function<void(
76  const std::map<
77  std::string,
78  std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
79  int)> f);
80 
81  rendering::MatrixInteractorLogic& GetMatrixInteractor() override;
82  void Mouse(const MouseEvent& e) override;
83  void Key(const KeyEvent& e) override;
84 
85 protected:
86  void OnPickImageDone(std::shared_ptr<geometry::Image> img);
87 
88  rendering::Material MakeMaterial();
89 
90 private:
91  rendering::Open3DScene* scene_;
92  rendering::Camera* camera_;
93 
94  std::function<void(
95  const std::map<std::string,
96  std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
97  int)>
98  on_picked_;
99  int point_size_ = 3;
100  rendering::MatrixInteractorLogic matrix_logic_;
101  std::shared_ptr<rendering::Open3DScene> picking_scene_;
102  std::vector<Eigen::Vector3d> points_;
103  // This is a pointer rather than unique_ptr so that we don't have
104  // to define this (internal) class in the header file.
105  SelectionIndexLookup* lookup_ = nullptr;
106  std::shared_ptr<geometry::Image> pick_image_;
107  bool dirty_ = true;
108  struct PickInfo {
109  gui::Rect rect;
110  int keymods;
111  };
112  std::queue<PickInfo> pending_;
113 };
114 
115 } // namespace gui
116 } // namespace visualization
117 } // namespace open3d
Definition: PickPointsInteractor.cpp:87
Definition: PickPointsInteractor.h:55
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:259
Definition: MatrixInteractorLogic.h:39
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Events.h:172