Open3D (C++ API)  0.12.0
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) 2020 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 
37 namespace open3d {
38 
39 namespace geometry {
40 class Geometry3D;
41 } // namespace geometry
42 
43 namespace t {
44 namespace geometry {
45 class Geometry;
46 } // namespace geometry
47 } // namespace t
48 
49 namespace visualization {
50 namespace visualizer {
51 
55 public:
56  struct SelectedIndex {
57  size_t index;
58  size_t order;
59  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 
72 public:
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 
98  void SetSelectableGeometry(
99  const std::vector<gui::SceneWidget::PickableGeometry>& geometry);
100 
101 private:
102  void UpdatePointSize();
103  void UpdateSelectionGeometry();
104 
105 private:
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
size_t order
the index of the point within the object
Definition: O3DVisualizerSelections.h:58
Definition: PinholeCameraIntrinsic.cpp:35
Definition: O3DVisualizerSelections.h:54
bool operator!=(const SelectedIndex &rhs) const
the point in R^3 (for convenience)
Definition: O3DVisualizerSelections.h:62
std::map< std::string, std::set< SelectedIndex > > SelectionSet
Definition: O3DVisualizerSelections.h:70
std::string name
Definition: FilePCD.cpp:58
bool operator<(const SelectedIndex &rhs) const
Definition: O3DVisualizerSelections.h:65
Definition: SceneWidget.h:64