Open3D (C++ API)
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes
open3d::visualization::Visualizer Class Reference

The main Visualizer class. More...

#include <Visualizer.h>

Inheritance diagram for open3d::visualization::Visualizer:
open3d::visualization::VisualizerWithCustomAnimation open3d::visualization::VisualizerWithEditing open3d::visualization::VisualizerWithKeyCallback open3d::visualization::VisualizerWithVertexSelection

Data Structures

struct  MouseControl
 

Public Member Functions

 Visualizer ()
 
virtual ~Visualizer ()
 
 Visualizer (Visualizer &&)=delete
 
 Visualizer (const Visualizer &)=delete
 
Visualizeroperator= (const Visualizer &)=delete
 
bool CreateVisualizerWindow (const std::string &window_name="Open3D", const int width=640, const int height=480, const int left=50, const int top=50, const bool visible=true)
 Function to create a window and initialize GLFW. More...
 
void DestroyVisualizerWindow ()
 Function to destroy a window. More...
 
void RegisterAnimationCallback (std::function< bool(Visualizer *)> callback_func)
 Function to register a callback function for animation. More...
 
void Run ()
 Function to activate the window. More...
 
void Close ()
 Function to to notify the window to be closed. More...
 
bool WaitEvents ()
 Function to process the event queue and return if the window is closed. More...
 
bool PollEvents ()
 
virtual bool AddGeometry (std::shared_ptr< const geometry::Geometry > geometry_ptr, bool reset_bounding_box=true)
 Function to add geometry to the scene and create corresponding shaders. More...
 
virtual bool RemoveGeometry (std::shared_ptr< const geometry::Geometry > geometry_ptr, bool reset_bounding_box=true)
 Function to remove geometry from the scene. More...
 
virtual bool ClearGeometries ()
 
virtual bool UpdateGeometry (std::shared_ptr< const geometry::Geometry > geometry_ptr=nullptr)
 Function to update geometry. More...
 
virtual bool HasGeometry () const
 
virtual void UpdateRender ()
 Function to inform render needed to be updated. More...
 
virtual void PrintVisualizerHelp ()
 
virtual void UpdateWindowTitle ()
 
virtual void BuildUtilities ()
 
ViewControlGetViewControl ()
 Function to retrieve the associated ViewControl. More...
 
RenderOptionGetRenderOption ()
 Function to retrieve the associated RenderOption. More...
 
std::shared_ptr< geometry::ImageCaptureScreenFloatBuffer (bool do_render=true)
 Function to capture screen and store RGB in a float buffer. More...
 
void CaptureScreenImage (const std::string &filename="", bool do_render=true)
 Function to capture and save a screen image. More...
 
std::shared_ptr< geometry::ImageCaptureDepthFloatBuffer (bool do_render=true)
 
void CaptureDepthImage (const std::string &filename="", bool do_render=true, double depth_scale=1000.0)
 
void CaptureDepthPointCloud (const std::string &filename="", bool do_render=true, bool convert_to_world_coordinate=false)
 Function to capture and save local point cloud. More...
 
void CaptureRenderOption (const std::string &filename="")
 
void ResetViewPoint (bool reset_bounding_box=false)
 Function to reset view point. More...
 
const std::string & GetWindowName () const
 

Protected Member Functions

virtual bool InitOpenGL ()
 Function to initialize OpenGL. More...
 
virtual bool InitViewControl ()
 Function to initialize ViewControl. More...
 
virtual bool InitRenderOption ()
 Function to initialize RenderOption. More...
 
virtual void Render ()
 
void CopyViewStatusToClipboard ()
 
void CopyViewStatusFromClipboard ()
 
virtual void WindowRefreshCallback (GLFWwindow *window)
 
virtual void WindowResizeCallback (GLFWwindow *window, int w, int h)
 
virtual void MouseMoveCallback (GLFWwindow *window, double x, double y)
 
virtual void MouseScrollCallback (GLFWwindow *window, double x, double y)
 
virtual void MouseButtonCallback (GLFWwindow *window, int button, int action, int mods)
 
virtual void KeyPressCallback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
virtual void WindowCloseCallback (GLFWwindow *window)
 Function to notify the window to be closed. More...
 

Protected Attributes

GLFWwindow * window_ = NULL
 
std::string window_name_ = "Open3D"
 
std::function< bool(Visualizer *)> animation_callback_func_ = nullptr
 
std::function< bool(Visualizer *)> animation_callback_func_in_loop_
 
MouseControl mouse_control_
 
bool is_redraw_required_ = true
 
bool is_initialized_ = false
 
GLuint vao_id_
 
std::unique_ptr< ViewControlview_control_ptr_
 
std::unique_ptr< RenderOptionrender_option_ptr_
 
std::unordered_set< std::shared_ptr< const geometry::Geometry > > geometry_ptrs_
 
std::unordered_set< std::shared_ptr< glsl::GeometryRenderer > > geometry_renderer_ptrs_
 
std::vector< std::shared_ptr< const geometry::Geometry > > utility_ptrs_
 
std::vector< std::shared_ptr< glsl::GeometryRenderer > > utility_renderer_ptrs_
 
std::unordered_map< std::shared_ptr< glsl::GeometryRenderer >, RenderOptionutility_renderer_opts_
 
std::shared_ptr< geometry::TriangleMeshcoordinate_frame_mesh_ptr_
 
std::shared_ptr< glsl::CoordinateFrameRenderercoordinate_frame_mesh_renderer_ptr_
 

Detailed Description

The main Visualizer class.

Constructor & Destructor Documentation

◆ Visualizer() [1/3]

open3d::visualization::Visualizer::Visualizer ( )

◆ ~Visualizer()

open3d::visualization::Visualizer::~Visualizer ( )
virtual

◆ Visualizer() [2/3]

open3d::visualization::Visualizer::Visualizer ( Visualizer &&  )
delete

◆ Visualizer() [3/3]

open3d::visualization::Visualizer::Visualizer ( const Visualizer )
delete

Member Function Documentation

◆ AddGeometry()

bool open3d::visualization::Visualizer::AddGeometry ( std::shared_ptr< const geometry::Geometry geometry_ptr,
bool  reset_bounding_box = true 
)
virtual

Function to add geometry to the scene and create corresponding shaders.

  1. After calling this function, the Visualizer owns the geometry object.
  2. This function MUST be called after CreateVisualizerWindow().
  3. This function returns FALSE when the geometry is of an unsupported type.
  4. If an added geometry is changed, the behavior of Visualizer is undefined. Programmers are responsible for calling Geometry() to notify the Visualizer that the geometry has been changed and the Visualizer should be updated accordingly.
Parameters
geometry_ptrThe Geometry object.

Reimplemented in open3d::visualization::VisualizerWithEditing, and open3d::visualization::VisualizerWithVertexSelection.

◆ BuildUtilities()

void open3d::visualization::Visualizer::BuildUtilities ( )
virtual

◆ CaptureDepthFloatBuffer()

std::shared_ptr< geometry::Image > open3d::visualization::Visualizer::CaptureDepthFloatBuffer ( bool  do_render = true)

Function to capture depth in a float buffer.

Parameters
do_renderSet to true to do render.

◆ CaptureDepthImage()

void open3d::visualization::Visualizer::CaptureDepthImage ( const std::string &  filename = "",
bool  do_render = true,
double  depth_scale = 1000.0 
)

Function to capture and save a depth image.

Parameters
filenamePath to file.
do_renderSet to true to do render.
depth_scaleScale depth value when capturing the depth image.

◆ CaptureDepthPointCloud()

void open3d::visualization::Visualizer::CaptureDepthPointCloud ( const std::string &  filename = "",
bool  do_render = true,
bool  convert_to_world_coordinate = false 
)

Function to capture and save local point cloud.

Parameters
filenamePath to file.
do_renderSet to true to do render.
convert_to_world_coordinateSet to true to convert to world coordinates.

◆ CaptureRenderOption()

void open3d::visualization::Visualizer::CaptureRenderOption ( const std::string &  filename = "")

◆ CaptureScreenFloatBuffer()

std::shared_ptr< geometry::Image > open3d::visualization::Visualizer::CaptureScreenFloatBuffer ( bool  do_render = true)

Function to capture screen and store RGB in a float buffer.

Parameters
do_renderSet to true to do render.

◆ CaptureScreenImage()

void open3d::visualization::Visualizer::CaptureScreenImage ( const std::string &  filename = "",
bool  do_render = true 
)

Function to capture and save a screen image.

Parameters
filenamePath to file.
do_renderSet to true to do render.

◆ ClearGeometries()

bool open3d::visualization::Visualizer::ClearGeometries ( )
virtual

Function to remove all geometries from the scene. After calling this function, the Visualizer releases the pointer of all geometry objects.

◆ Close()

void open3d::visualization::Visualizer::Close ( )

Function to to notify the window to be closed.

◆ CopyViewStatusFromClipboard()

void open3d::visualization::Visualizer::CopyViewStatusFromClipboard ( )
protected

◆ CopyViewStatusToClipboard()

void open3d::visualization::Visualizer::CopyViewStatusToClipboard ( )
protected

◆ CreateVisualizerWindow()

bool open3d::visualization::Visualizer::CreateVisualizerWindow ( const std::string &  window_name = "Open3D",
const int  width = 640,
const int  height = 480,
const int  left = 50,
const int  top = 50,
const bool  visible = true 
)

Function to create a window and initialize GLFW.

This function MUST be called from the main thread.

Parameters
window_nameWindow title name.
widthWidth of the window.
heightHeight of window.
leftLeft margin of the window to the screen.
topTop margin of the window to the screen.
visibleWhether the window is visible.

◆ DestroyVisualizerWindow()

void open3d::visualization::Visualizer::DestroyVisualizerWindow ( )

Function to destroy a window.

This function MUST be called from the main thread.

◆ GetRenderOption()

RenderOption& open3d::visualization::Visualizer::GetRenderOption ( )
inline

Function to retrieve the associated RenderOption.

◆ GetViewControl()

ViewControl& open3d::visualization::Visualizer::GetViewControl ( )
inline

Function to retrieve the associated ViewControl.

◆ GetWindowName()

const std::string& open3d::visualization::Visualizer::GetWindowName ( ) const
inline

◆ HasGeometry()

bool open3d::visualization::Visualizer::HasGeometry ( ) const
virtual

◆ InitOpenGL()

bool open3d::visualization::Visualizer::InitOpenGL ( )
protectedvirtual

Function to initialize OpenGL.

◆ InitRenderOption()

bool open3d::visualization::Visualizer::InitRenderOption ( )
protectedvirtual

◆ InitViewControl()

bool open3d::visualization::Visualizer::InitViewControl ( )
protectedvirtual

◆ KeyPressCallback()

void open3d::visualization::Visualizer::KeyPressCallback ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
protectedvirtual

◆ MouseButtonCallback()

void open3d::visualization::Visualizer::MouseButtonCallback ( GLFWwindow *  window,
int  button,
int  action,
int  mods 
)
protectedvirtual

◆ MouseMoveCallback()

void open3d::visualization::Visualizer::MouseMoveCallback ( GLFWwindow *  window,
double  x,
double  y 
)
protectedvirtual

◆ MouseScrollCallback()

void open3d::visualization::Visualizer::MouseScrollCallback ( GLFWwindow *  window,
double  x,
double  y 
)
protectedvirtual

◆ operator=()

Visualizer& open3d::visualization::Visualizer::operator= ( const Visualizer )
delete

◆ PollEvents()

bool open3d::visualization::Visualizer::PollEvents ( )

Function to process the event queue and return if the window is closed.

Use this function if you want to manage the while loop yourself. This function will NOT block the thread. Thus it is suitable for computation heavy task behind the scene.

◆ PrintVisualizerHelp()

void open3d::visualization::Visualizer::PrintVisualizerHelp ( )
virtual

◆ RegisterAnimationCallback()

void open3d::visualization::Visualizer::RegisterAnimationCallback ( std::function< bool(Visualizer *)>  callback_func)

Function to register a callback function for animation.

The callback function returns if UpdateGeometry() needs to be run.

Parameters
callback_funcThe call back function.

◆ RemoveGeometry()

bool open3d::visualization::Visualizer::RemoveGeometry ( std::shared_ptr< const geometry::Geometry geometry_ptr,
bool  reset_bounding_box = true 
)
virtual

Function to remove geometry from the scene.

  1. After calling this function, the Visualizer releases the pointer of the geometry object.
  2. This function MUST be called after CreateVisualizerWindow().
  3. This function returns FALSE if the geometry to be removed is not added by AddGeometry
Parameters
geometry_ptrThe Geometry object.

◆ Render()

void open3d::visualization::Visualizer::Render ( )
protectedvirtual

Function to do the main rendering The function first sets view point, then draw geometry (pointclouds and meshes individually).

◆ ResetViewPoint()

void open3d::visualization::Visualizer::ResetViewPoint ( bool  reset_bounding_box = false)

Function to reset view point.

◆ Run()

void open3d::visualization::Visualizer::Run ( )

Function to activate the window.

This function will block the current thread until the window is closed.

◆ UpdateGeometry()

bool open3d::visualization::Visualizer::UpdateGeometry ( std::shared_ptr< const geometry::Geometry geometry_ptr = nullptr)
virtual

Function to update geometry.

This function must be called when geometry has been changed. Otherwise the behavior of Visualizer is undefined. If called without an argument, updates all geometries, otherwise only updates the geometry specified.

Reimplemented in open3d::visualization::VisualizerWithVertexSelection.

◆ UpdateRender()

void open3d::visualization::Visualizer::UpdateRender ( )
virtual

Function to inform render needed to be updated.

◆ UpdateWindowTitle()

void open3d::visualization::Visualizer::UpdateWindowTitle ( )
virtual

◆ WaitEvents()

bool open3d::visualization::Visualizer::WaitEvents ( )

Function to process the event queue and return if the window is closed.

Use this function if you want to manage the while loop yourself. This function will block the thread.

◆ WindowCloseCallback()

void open3d::visualization::Visualizer::WindowCloseCallback ( GLFWwindow *  window)
protectedvirtual

Function to notify the window to be closed.

◆ WindowRefreshCallback()

void open3d::visualization::Visualizer::WindowRefreshCallback ( GLFWwindow *  window)
protectedvirtual

◆ WindowResizeCallback()

void open3d::visualization::Visualizer::WindowResizeCallback ( GLFWwindow *  window,
int  w,
int  h 
)
protectedvirtual

Field Documentation

◆ animation_callback_func_

std::function<bool(Visualizer *)> open3d::visualization::Visualizer::animation_callback_func_ = nullptr
protected

◆ animation_callback_func_in_loop_

std::function<bool(Visualizer *)> open3d::visualization::Visualizer::animation_callback_func_in_loop_
protected
Initial value:
=
nullptr

◆ coordinate_frame_mesh_ptr_

std::shared_ptr<geometry::TriangleMesh> open3d::visualization::Visualizer::coordinate_frame_mesh_ptr_
protected

◆ coordinate_frame_mesh_renderer_ptr_

std::shared_ptr<glsl::CoordinateFrameRenderer> open3d::visualization::Visualizer::coordinate_frame_mesh_renderer_ptr_
protected

◆ geometry_ptrs_

std::unordered_set<std::shared_ptr<const geometry::Geometry> > open3d::visualization::Visualizer::geometry_ptrs_
protected

◆ geometry_renderer_ptrs_

std::unordered_set<std::shared_ptr<glsl::GeometryRenderer> > open3d::visualization::Visualizer::geometry_renderer_ptrs_
protected

◆ is_initialized_

bool open3d::visualization::Visualizer::is_initialized_ = false
protected

◆ is_redraw_required_

bool open3d::visualization::Visualizer::is_redraw_required_ = true
protected

◆ mouse_control_

MouseControl open3d::visualization::Visualizer::mouse_control_
protected

◆ render_option_ptr_

std::unique_ptr<RenderOption> open3d::visualization::Visualizer::render_option_ptr_
protected

◆ utility_ptrs_

std::vector<std::shared_ptr<const geometry::Geometry> > open3d::visualization::Visualizer::utility_ptrs_
protected

◆ utility_renderer_opts_

std::unordered_map<std::shared_ptr<glsl::GeometryRenderer>, RenderOption> open3d::visualization::Visualizer::utility_renderer_opts_
protected

◆ utility_renderer_ptrs_

std::vector<std::shared_ptr<glsl::GeometryRenderer> > open3d::visualization::Visualizer::utility_renderer_ptrs_
protected

◆ vao_id_

GLuint open3d::visualization::Visualizer::vao_id_
protected

◆ view_control_ptr_

std::unique_ptr<ViewControl> open3d::visualization::Visualizer::view_control_ptr_
protected

◆ window_

GLFWwindow* open3d::visualization::Visualizer::window_ = NULL
protected

◆ window_name_

std::string open3d::visualization::Visualizer::window_name_ = "Open3D"
protected

The documentation for this class was generated from the following files: