ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
O3DVisualizerSelections.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <map>
12 #include <set>
13 #include <string>
14 #include <vector>
15 
17 
18 namespace cloudViewer {
19 
20 namespace t {
21 namespace geometry {
22 class Geometry;
23 } // namespace geometry
24 } // namespace t
25 
26 namespace visualization {
27 namespace visualizer {
28 
32 public:
33  struct SelectedIndex {
34  size_t index;
35  size_t order;
37  Eigen::Vector3d point;
38 
39  bool operator!=(const SelectedIndex& rhs) const {
40  return index != rhs.index;
41  }
42  bool operator<(const SelectedIndex& rhs) const {
43  return index < rhs.index;
44  }
45  };
46  using SelectionSet = std::map<std::string, // name of object
47  std::set<SelectedIndex>>;
48 
49 public:
52 
53  void NewSet();
54  void RemoveSet(int index);
55  void SelectSet(int index);
56  size_t GetNumberOfSets() const;
57 
58  void SelectIndices(
59  const std::map<std::string,
60  std::vector<std::pair<size_t, Eigen::Vector3d>>>&
61  indices);
62  void UnselectIndices(
63  const std::map<std::string,
64  std::vector<std::pair<size_t, Eigen::Vector3d>>>&
65  indices);
66  std::vector<SelectionSet> GetSets();
67 
68  // Since the points are spheres, the radius is in world coordinates
69  void SetPointSize(double radius_world);
70 
71  void MakeActive();
72  void MakeInactive();
73  bool IsActive() const;
74 
76  const std::vector<gui::SceneWidget::PickableGeometry>& geometry);
77 
78 private:
79  void UpdatePointSize();
80  void UpdateSelectionGeometry();
81 
82 private:
83  gui::SceneWidget& widget3d_;
84  int next_id_ = 1;
85 
86  struct SelectedPoints {
87  std::string name;
88  SelectionSet indices;
89  };
90 
91  double point_size_ = 3.0;
92  bool is_active_ = false;
93  size_t pick_order_ = 0;
94  std::vector<SelectedPoints> sets_;
95  int current_set_index_ = -1;
96 
97  bool point_size_changed_ = false;
98 };
99 
100 } // namespace visualizer
101 } // namespace visualization
102 } // namespace cloudViewer
std::string name
void SelectIndices(const std::map< std::string, std::vector< std::pair< size_t, Eigen::Vector3d >>> &indices)
void SetSelectableGeometry(const std::vector< gui::SceneWidget::PickableGeometry > &geometry)
std::map< std::string, std::set< SelectedIndex > > SelectionSet
void UnselectIndices(const std::map< std::string, std::vector< std::pair< size_t, Eigen::Vector3d >>> &indices)
::ccHObject Geometry
Definition: Geometry.h:18
Generic file read and write utility for python interface.
bool operator!=(const SelectedIndex &rhs) const
the point in R^3 (for convenience)