Open3D (C++ API)  0.15.1
O3DVisualizerSelections.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 <Eigen/Core>
30#include <map>
31#include <set>
32#include <string>
33#include <vector>
34
36
37namespace open3d {
38
39namespace geometry {
40class Geometry3D;
41} // namespace geometry
42
43namespace t {
44namespace geometry {
45class Geometry;
46} // namespace geometry
47} // namespace t
48
49namespace visualization {
50namespace visualizer {
51
55public:
57 size_t index;
58 size_t order;
60 Eigen::Vector3d point;
61
62 bool operator!=(const SelectedIndex& rhs) const {
63 return index != rhs.index;
64 }
65 bool operator<(const SelectedIndex& rhs) const {
66 return index < rhs.index;
67 }
68 };
69 using SelectionSet = std::map<std::string, // name of object
70 std::set<SelectedIndex>>;
71
72public:
75
76 void NewSet();
77 void RemoveSet(int index);
78 void SelectSet(int index);
79 size_t GetNumberOfSets() const;
80
81 void SelectIndices(
82 const std::map<std::string,
83 std::vector<std::pair<size_t, Eigen::Vector3d>>>&
84 indices);
85 void UnselectIndices(
86 const std::map<std::string,
87 std::vector<std::pair<size_t, Eigen::Vector3d>>>&
88 indices);
89 std::vector<SelectionSet> GetSets();
90
91 // Since the points are spheres, the radius is in world coordinates
92 void SetPointSize(double radius_world);
93
94 void MakeActive();
95 void MakeInactive();
96 bool IsActive() const;
97
99 const std::vector<gui::SceneWidget::PickableGeometry>& geometry);
100
101private:
102 void UpdatePointSize();
103 void UpdateSelectionGeometry();
104
105private:
106 gui::SceneWidget& widget3d_;
107 int next_id_ = 1;
108
109 struct SelectedPoints {
110 std::string name;
111 SelectionSet indices;
112 };
113
114 double point_size_ = 3.0;
115 bool is_active_ = false;
116 size_t pick_order_ = 0;
117 std::vector<SelectedPoints> sets_;
118 int current_set_index_ = -1;
119
120 bool point_size_changed_ = false;
121};
122
123} // namespace visualizer
124} // namespace visualization
125} // namespace open3d
Definition: SceneWidget.h:68
Definition: O3DVisualizerSelections.h:54
void RemoveSet(int index)
Definition: O3DVisualizerSelections.cpp:65
void NewSet()
Definition: O3DVisualizerSelections.cpp:57
void MakeActive()
Definition: O3DVisualizerSelections.cpp:180
void SelectSet(int index)
Definition: O3DVisualizerSelections.cpp:78
void MakeInactive()
Definition: O3DVisualizerSelections.cpp:202
std::map< std::string, std::set< SelectedIndex > > SelectionSet
Definition: O3DVisualizerSelections.h:70
~O3DVisualizerSelections()
Definition: O3DVisualizerSelections.cpp:55
void SetSelectableGeometry(const std::vector< gui::SceneWidget::PickableGeometry > &geometry)
Definition: O3DVisualizerSelections.cpp:213
size_t GetNumberOfSets() const
Definition: O3DVisualizerSelections.cpp:91
std::vector< SelectionSet > GetSets()
Definition: O3DVisualizerSelections.cpp:162
void SelectIndices(const std::map< std::string, std::vector< std::pair< size_t, Eigen::Vector3d > > > &indices)
Definition: O3DVisualizerSelections.cpp:93
void UnselectIndices(const std::map< std::string, std::vector< std::pair< size_t, Eigen::Vector3d > > > &indices)
Definition: O3DVisualizerSelections.cpp:113
O3DVisualizerSelections(gui::SceneWidget &widget3d)
Definition: O3DVisualizerSelections.cpp:52
bool IsActive() const
Definition: O3DVisualizerSelections.cpp:200
void SetPointSize(double radius_world)
Definition: O3DVisualizerSelections.cpp:171
std::string name
Definition: FilePCD.cpp:58
Definition: PinholeCameraIntrinsic.cpp:35
size_t order
the index of the point within the object
Definition: O3DVisualizerSelections.h:58
bool operator!=(const SelectedIndex &rhs) const
the point in R^3 (for convenience)
Definition: O3DVisualizerSelections.h:62
Eigen::Vector3d point
Definition: O3DVisualizerSelections.h:60
bool operator<(const SelectedIndex &rhs) const
Definition: O3DVisualizerSelections.h:65