Open3D (C++ API)  0.17.0
VisualizerWithEditing.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 
11 
12 namespace open3d {
13 
14 namespace visualization {
15 class SelectionPolygon;
16 class PointCloudPicker;
17 
22 public:
23  enum class SelectionMode {
24  None = 0,
25  Rectangle = 1,
26  Polygon = 2,
27  };
28 
29 public:
30  VisualizerWithEditing(double voxel_size = -1.0,
31  bool use_dialog = true,
32  const std::string &directory = "")
33  : voxel_size_(voxel_size),
34  use_dialog_(use_dialog),
35  default_directory_(directory) {}
36  ~VisualizerWithEditing() override {}
39 
40 public:
44  bool AddGeometry(std::shared_ptr<const geometry::Geometry> geometry_ptr,
45  bool reset_bounding_box = true) override;
46  void PrintVisualizerHelp() override;
47  void UpdateWindowTitle() override;
48  void BuildUtilities() override;
49  int PickPoint(double x, double y);
50  std::vector<size_t> &GetPickedPoints();
51  std::shared_ptr<geometry::Geometry> GetCroppedGeometry() const;
52 
53 protected:
54  bool InitViewControl() override;
55  bool InitRenderOption() override;
56  void WindowResizeCallback(GLFWwindow *window, int w, int h) override;
57  void MouseMoveCallback(GLFWwindow *window, double x, double y) override;
58  void MouseScrollCallback(GLFWwindow *window, double x, double y) override;
59  void MouseButtonCallback(GLFWwindow *window,
60  int button,
61  int action,
62  int mods) override;
63  void KeyPressCallback(GLFWwindow *window,
64  int key,
65  int scancode,
66  int action,
67  int mods) override;
69  void InvalidatePicking();
70  void SaveCroppingResult(const std::string &filename = "");
71 
72 protected:
73  std::shared_ptr<SelectionPolygon> selection_polygon_ptr_;
74  std::shared_ptr<glsl::SelectionPolygonRenderer>
77 
78  std::shared_ptr<PointCloudPicker> pointcloud_picker_ptr_;
79  std::shared_ptr<glsl::PointCloudPickerRenderer>
81 
82  std::shared_ptr<const geometry::Geometry> original_geometry_ptr_;
83  std::shared_ptr<geometry::Geometry> editing_geometry_ptr_;
84  std::shared_ptr<glsl::GeometryRenderer> editing_geometry_renderer_ptr_;
85 
86  double voxel_size_ = -1.0;
87  bool use_dialog_ = true;
88  std::string default_directory_;
89  unsigned int crop_action_count_ = 0;
90 };
91 
92 } // namespace visualization
93 } // namespace open3d
The main Visualizer class.
Definition: Visualizer.h:43
Visualizer with editing capabilities.
Definition: VisualizerWithEditing.h:21
SelectionMode selection_mode_
Definition: VisualizerWithEditing.h:76
double voxel_size_
Definition: VisualizerWithEditing.h:86
void SaveCroppingResult(const std::string &filename="")
Definition: VisualizerWithEditing.cpp:670
std::shared_ptr< SelectionPolygon > selection_polygon_ptr_
Definition: VisualizerWithEditing.h:73
void KeyPressCallback(GLFWwindow *window, int key, int scancode, int action, int mods) override
Definition: VisualizerWithEditing.cpp:274
std::shared_ptr< geometry::Geometry > editing_geometry_ptr_
Definition: VisualizerWithEditing.h:83
void UpdateWindowTitle() override
Definition: VisualizerWithEditing.cpp:133
~VisualizerWithEditing() override
Definition: VisualizerWithEditing.h:36
std::shared_ptr< const geometry::Geometry > original_geometry_ptr_
Definition: VisualizerWithEditing.h:82
bool InitViewControl() override
Function to initialize ViewControl.
Definition: VisualizerWithEditing.cpp:261
bool InitRenderOption() override
Function to initialize RenderOption.
Definition: VisualizerWithEditing.cpp:268
VisualizerWithEditing & operator=(const VisualizerWithEditing &)=delete
std::shared_ptr< geometry::Geometry > GetCroppedGeometry() const
Definition: VisualizerWithEditing.cpp:247
void InvalidatePicking()
Definition: VisualizerWithEditing.cpp:663
std::shared_ptr< PointCloudPicker > pointcloud_picker_ptr_
Definition: VisualizerWithEditing.h:78
void WindowResizeCallback(GLFWwindow *window, int w, int h) override
Definition: VisualizerWithEditing.cpp:494
std::string default_directory_
Definition: VisualizerWithEditing.h:88
void InvalidateSelectionPolygon()
Definition: VisualizerWithEditing.cpp:655
std::shared_ptr< glsl::SelectionPolygonRenderer > selection_polygon_renderer_ptr_
Definition: VisualizerWithEditing.h:75
int PickPoint(double x, double y)
Definition: VisualizerWithEditing.cpp:177
SelectionMode
Definition: VisualizerWithEditing.h:23
void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) override
Definition: VisualizerWithEditing.cpp:539
std::vector< size_t > & GetPickedPoints()
Definition: VisualizerWithEditing.cpp:243
bool use_dialog_
Definition: VisualizerWithEditing.h:87
std::shared_ptr< glsl::GeometryRenderer > editing_geometry_renderer_ptr_
Definition: VisualizerWithEditing.h:84
void MouseMoveCallback(GLFWwindow *window, double x, double y) override
Definition: VisualizerWithEditing.cpp:501
void PrintVisualizerHelp() override
Definition: VisualizerWithEditing.cpp:107
bool AddGeometry(std::shared_ptr< const geometry::Geometry > geometry_ptr, bool reset_bounding_box=true) override
Definition: VisualizerWithEditing.cpp:30
VisualizerWithEditing(const VisualizerWithEditing &)=delete
unsigned int crop_action_count_
Definition: VisualizerWithEditing.h:89
void MouseScrollCallback(GLFWwindow *window, double x, double y) override
Definition: VisualizerWithEditing.cpp:529
void BuildUtilities() override
Definition: VisualizerWithEditing.cpp:142
std::shared_ptr< glsl::PointCloudPickerRenderer > pointcloud_picker_renderer_ptr_
Definition: VisualizerWithEditing.h:80
VisualizerWithEditing(double voxel_size=-1.0, bool use_dialog=true, const std::string &directory="")
Definition: VisualizerWithEditing.h:30
Definition: PinholeCameraIntrinsic.cpp:16