Open3D (C++ API)  0.18.0+252c867
PickPointsInteractor.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 <queue>
11 
14 
15 namespace open3d {
16 
17 namespace geometry {
18 class Geometry3D;
19 class Image;
20 } // namespace geometry
21 
22 namespace visualization {
23 
24 namespace rendering {
25 class Camera;
26 struct MaterialRecord;
27 class MatrixInteractorLogic;
28 class Open3DScene;
29 } // namespace rendering
30 
31 namespace gui {
32 
33 class SelectionIndexLookup;
34 
35 // This is an internal class used by SceneWidget
37 public:
39  rendering::Camera* camera);
40  virtual ~PickPointsInteractor();
41 
42  void SetPointSize(int px);
43 
47  const std::vector<SceneWidget::PickableGeometry>& geometry);
48 
51  void SetNeedsRedraw();
52 
55  void SetOnPointsPicked(
56  std::function<void(
57  const std::map<
58  std::string,
59  std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
60  int)> f);
61 
65  void SetOnUIChanged(
66  std::function<void(const std::vector<Eigen::Vector2i>&)>);
67 
69  void SetOnStartedPolygonPicking(std::function<void()> on_poly_pick);
70 
71  void DoPick();
72  void ClearPick();
73 
75  void Mouse(const MouseEvent& e) override;
76  void Key(const KeyEvent& e) override;
77 
78 protected:
79  void OnPickImageDone(std::shared_ptr<geometry::Image> img);
80 
82 
83 private:
84  rendering::Open3DScene* scene_;
85  rendering::Camera* camera_;
86 
87  std::function<void(
88  const std::map<std::string,
89  std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
90  int)>
91  on_picked_;
92  std::function<void(const std::vector<Eigen::Vector2i>&)> on_ui_changed_;
93  std::function<void()> on_started_poly_pick_;
94  int point_size_ = 3;
96  std::shared_ptr<rendering::Open3DScene> picking_scene_;
97  std::vector<Eigen::Vector3d> points_;
98  // This is a pointer rather than unique_ptr so that we don't have
99  // to define this (internal) class in the header file.
100  SelectionIndexLookup* lookup_ = nullptr;
101  std::shared_ptr<geometry::Image> pick_image_;
102  bool dirty_ = true;
103  struct PickInfo {
104  std::vector<gui::Point> polygon; // or point, if only one item
105  int keymods;
106  };
107  std::queue<PickInfo> pending_;
108 };
109 
110 } // namespace gui
111 } // namespace visualization
112 } // namespace open3d
Definition: PickPointsInteractor.h:36
void ClearPick()
Definition: PickPointsInteractor.cpp:342
void Key(const KeyEvent &e) override
Definition: PickPointsInteractor.cpp:311
void SetPointSize(int px)
Definition: PickPointsInteractor.cpp:137
void SetOnUIChanged(std::function< void(const std::vector< Eigen::Vector2i > &)>)
Definition: PickPointsInteractor.cpp:264
void SetOnPointsPicked(std::function< void(const std::map< std::string, std::vector< std::pair< size_t, Eigen::Vector3d >>> &, int)> f)
Definition: PickPointsInteractor.cpp:255
virtual ~PickPointsInteractor()
Definition: PickPointsInteractor.cpp:135
PickPointsInteractor(rendering::Open3DScene *scene, rendering::Camera *camera)
Definition: PickPointsInteractor.cpp:122
void OnPickImageDone(std::shared_ptr< geometry::Image > img)
Definition: PickPointsInteractor.cpp:362
rendering::MaterialRecord MakeMaterial()
Definition: PickPointsInteractor.cpp:352
void SetOnStartedPolygonPicking(std::function< void()> on_poly_pick)
Calls the provided function when polygon picking is initiated.
Definition: PickPointsInteractor.cpp:269
void Mouse(const MouseEvent &e) override
Definition: PickPointsInteractor.cpp:274
void DoPick()
Definition: PickPointsInteractor.cpp:319
void SetNeedsRedraw()
Definition: PickPointsInteractor.cpp:249
void SetPickableGeometry(const std::vector< SceneWidget::PickableGeometry > &geometry)
Definition: PickPointsInteractor.cpp:146
rendering::MatrixInteractorLogic & GetMatrixInteractor() override
Definition: PickPointsInteractor.cpp:251
Definition: PickPointsInteractor.cpp:71
Definition: MatrixInteractorLogic.h:20
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:250
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Events.h:203