Open3D (C++ API)  0.16.1
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-2021 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
34namespace open3d {
35
36namespace geometry {
37class Geometry3D;
38class Image;
39} // namespace geometry
40
41namespace visualization {
42
43namespace rendering {
44class Camera;
45struct MaterialRecord;
46class MatrixInteractorLogic;
47class Open3DScene;
48} // namespace rendering
49
50namespace gui {
51
52class SelectionIndexLookup;
53
54// This is an internal class used by SceneWidget
56public:
58 rendering::Camera* camera);
59 virtual ~PickPointsInteractor();
60
61 void SetPointSize(int px);
62
66 const std::vector<SceneWidget::PickableGeometry>& geometry);
67
70 void SetNeedsRedraw();
71
75 std::function<void(
76 const std::map<
77 std::string,
78 std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
79 int)> f);
80
84 void SetOnUIChanged(
85 std::function<void(const std::vector<Eigen::Vector2i>&)>);
86
88 void SetOnStartedPolygonPicking(std::function<void()> on_poly_pick);
89
90 void DoPick();
91 void ClearPick();
92
94 void Mouse(const MouseEvent& e) override;
95 void Key(const KeyEvent& e) override;
96
97protected:
98 void OnPickImageDone(std::shared_ptr<geometry::Image> img);
99
101
102private:
104 rendering::Camera* camera_;
105
106 std::function<void(
107 const std::map<std::string,
108 std::vector<std::pair<size_t, Eigen::Vector3d>>>&,
109 int)>
110 on_picked_;
111 std::function<void(const std::vector<Eigen::Vector2i>&)> on_ui_changed_;
112 std::function<void()> on_started_poly_pick_;
113 int point_size_ = 3;
115 std::shared_ptr<rendering::Open3DScene> picking_scene_;
116 std::vector<Eigen::Vector3d> points_;
117 // This is a pointer rather than unique_ptr so that we don't have
118 // to define this (internal) class in the header file.
119 SelectionIndexLookup* lookup_ = nullptr;
120 std::shared_ptr<geometry::Image> pick_image_;
121 bool dirty_ = true;
122 struct PickInfo {
123 std::vector<gui::Point> polygon; // or point, if only one item
124 int keymods;
125 };
126 std::queue<PickInfo> pending_;
127};
128
129} // namespace gui
130} // namespace visualization
131} // namespace open3d
Definition: PickPointsInteractor.h:55
void ClearPick()
Definition: PickPointsInteractor.cpp:339
void Key(const KeyEvent &e) override
Definition: PickPointsInteractor.cpp:308
void SetPointSize(int px)
Definition: PickPointsInteractor.cpp:154
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:152
PickPointsInteractor(rendering::Open3DScene *scene, rendering::Camera *camera)
Definition: PickPointsInteractor.cpp:139
void OnPickImageDone(std::shared_ptr< geometry::Image > img)
Definition: PickPointsInteractor.cpp:359
rendering::MaterialRecord MakeMaterial()
Definition: PickPointsInteractor.cpp:349
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:316
void SetNeedsRedraw()
Definition: PickPointsInteractor.cpp:249
void SetPickableGeometry(const std::vector< SceneWidget::PickableGeometry > &geometry)
Definition: PickPointsInteractor.cpp:163
rendering::MatrixInteractorLogic & GetMatrixInteractor() override
Definition: PickPointsInteractor.cpp:251
Definition: PickPointsInteractor.cpp:88
Definition: MatrixInteractorLogic.h:39
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:269
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Events.h:222