ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::visualization::Visualizer Class Reference

The main Visualizer class. More...

#include <Visualizer.h>

Inheritance diagram for cloudViewer::visualization::Visualizer:
[legend]
Collaboration diagram for cloudViewer::visualization::Visualizer:
[legend]

Classes

struct  MouseControl
 

Public Member Functions

 Visualizer ()
 
virtual ~Visualizer ()
 
 Visualizer (Visualizer &&)=delete
 
 Visualizer (const Visualizer &)=delete
 
Visualizer & operator= (const Visualizer &)=delete
 
bool CreateVisualizerWindow (const std::string &window_name="CloudViewer", 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 ccHObject > 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 ccHObject > 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 ccHObject > 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 SetFullScreen (bool fullscreen)
 Functions to change between fullscreen and windowed modes. More...
 
virtual void ToggleFullScreen ()
 
virtual bool IsFullScreen ()
 
virtual void PrintVisualizerHelp ()
 
virtual void UpdateWindowTitle ()
 
virtual void BuildUtilities ()
 
ViewControl & GetViewControl ()
 Function to retrieve the associated ViewControl. More...
 
RenderOption & GetRenderOption ()
 Function to retrieve the associated RenderOption. More...
 
std::shared_ptr< geometry::Image > CaptureScreenFloatBuffer (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::Image > CaptureDepthFloatBuffer (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 (bool render_screen=false)
 
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_ = nullptr
 
std::string window_name_ = "CloudViewer"
 
std::shared_ptr< GLFWContext > glfw_context_ = nullptr
 Shared GLFW context. More...
 
Eigen::Vector2i saved_window_size_ = Eigen::Vector2i::Zero()
 
Eigen::Vector2i saved_window_pos_ = Eigen::Vector2i::Zero()
 
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_ = 0
 
GLuint render_fbo_ = 0
 
GLuint render_rgb_tex_ = 0
 
GLuint render_depth_stencil_rbo_ = 0
 
std::unique_ptr< ViewControl > view_control_ptr_
 
std::unique_ptr< RenderOption > render_option_ptr_
 
std::unordered_set< std::shared_ptr< const ccHObject > > geometry_ptrs_
 
std::unordered_set< std::shared_ptr< glsl::GeometryRenderer > > geometry_renderer_ptrs_
 
std::vector< std::shared_ptr< const ccHObject > > utility_ptrs_
 
std::vector< std::shared_ptr< glsl::GeometryRenderer > > utility_renderer_ptrs_
 
std::unordered_map< std::shared_ptr< glsl::GeometryRenderer >, RenderOption > utility_renderer_opts_
 
std::shared_ptr< ccMesh > coordinate_frame_mesh_ptr_
 
std::shared_ptr< glsl::CoordinateFrameRenderer > coordinate_frame_mesh_renderer_ptr_
 

Detailed Description

The main Visualizer class.

Constructor & Destructor Documentation

◆ Visualizer() [1/3]

cloudViewer::visualization::Visualizer::Visualizer ( )

◆ ~Visualizer()

cloudViewer::visualization::Visualizer::~Visualizer ( )
virtual

◆ Visualizer() [2/3]

cloudViewer::visualization::Visualizer::Visualizer ( Visualizer &&  )
delete

◆ Visualizer() [3/3]

cloudViewer::visualization::Visualizer::Visualizer ( const Visualizer &  )
delete

Member Function Documentation

◆ AddGeometry()

bool cloudViewer::visualization::Visualizer::AddGeometry ( std::shared_ptr< const ccHObject >  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 cloudViewer::visualization::VisualizerWithEditing, and cloudViewer::visualization::VisualizerWithVertexSelection.

References CV_TYPES::BBOX, CV_TYPES::CUSTOM_H_OBJECT, CV_TYPES::FACET, geometry_ptrs_, geometry_renderer_ptrs_, CV_TYPES::HALF_EDGE_MESH, CV_TYPES::IMAGE2, is_initialized_, CV_TYPES::LINESET, LogDebug, LogWarning, CV_TYPES::MESH, CV_TYPES::ORIENTED_BBOX, CV_TYPES::POINT_CLOUD, CV_TYPES::POINT_OCTREE2, CV_TYPES::POLY_LINE, ResetViewPoint(), CV_TYPES::RGBD_IMAGE, CV_TYPES::TETRA_MESH, UpdateGeometry(), view_control_ptr_, CV_TYPES::VOXEL_GRID, and window_.

Referenced by cloudViewer::VisualizerForAlignment::AddSourceAndTarget(), cloudViewer::visualization::DrawGeometries(), cloudViewer::visualization::DrawGeometriesWithAnimationCallback(), cloudViewer::visualization::DrawGeometriesWithCustomAnimation(), cloudViewer::visualization::DrawGeometriesWithKeyCallbacks(), and main().

◆ BuildUtilities()

◆ CaptureDepthFloatBuffer()

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

◆ CaptureDepthImage()

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

◆ CaptureDepthPointCloud()

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

◆ CaptureRenderOption()

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

◆ CaptureScreenFloatBuffer()

std::shared_ptr< geometry::Image > cloudViewer::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.

References cloudViewer::geometry::Image::BytesPerLine(), cloudViewer::geometry::Image::data_, cloudViewer::geometry::Image::height_, is_redraw_required_, cloudViewer::geometry::Image::Prepare(), Render(), view_control_ptr_, and window_.

◆ CaptureScreenImage()

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

◆ ClearGeometries()

bool cloudViewer::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.

References geometry_ptrs_, geometry_renderer_ptrs_, is_initialized_, UpdateGeometry(), and window_.

◆ Close()

void cloudViewer::visualization::Visualizer::Close ( )

Function to to notify the window to be closed.

References LogDebug, and window_.

Referenced by KeyPressCallback(), and cloudViewer::visualization::VisualizerWithCustomAnimation::Play().

◆ CopyViewStatusFromClipboard()

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

◆ CopyViewStatusToClipboard()

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

◆ CreateVisualizerWindow()

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

◆ DestroyVisualizerWindow()

◆ GetRenderOption()

◆ GetViewControl()

◆ GetWindowName()

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

References window_name_.

◆ HasGeometry()

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

References geometry_ptrs_.

Referenced by main().

◆ InitOpenGL()

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

Function to initialize OpenGL.

References LogWarning, render_fbo_, and vao_id_.

Referenced by CreateVisualizerWindow().

◆ InitRenderOption()

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

◆ InitViewControl()

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

◆ IsFullScreen()

bool cloudViewer::visualization::Visualizer::IsFullScreen ( )
virtual

References window_.

Referenced by KeyPressCallback(), and ToggleFullScreen().

◆ KeyPressCallback()

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

Reimplemented in cloudViewer::visualization::VisualizerWithKeyCallback, cloudViewer::visualization::VisualizerWithVertexSelection, cloudViewer::visualization::VisualizerWithEditing, cloudViewer::visualization::VisualizerWithCustomAnimation, and cloudViewer::VisualizerForAlignment.

References CaptureDepthImage(), CaptureRenderOption(), CaptureScreenImage(), Close(), cloudViewer::visualization::RenderOption::Color, CopyViewStatusFromClipboard(), CopyViewStatusToClipboard(), cloudViewer::visualization::RenderOption::Default, cloudViewer::visualization::RenderOption::FlatShade, cloudViewer::visualization::ColorMap::Gray, cloudViewer::visualization::ColorMap::Hot, is_redraw_required_, IsFullScreen(), cloudViewer::visualization::ColorMap::Jet, LogDebug, cloudViewer::visualization::RenderOption::Normal, PrintVisualizerHelp(), render_option_ptr_, ResetViewPoint(), SetFullScreen(), cloudViewer::visualization::SetGlobalColorMap(), cloudViewer::visualization::ColorMap::Summer, UpdateGeometry(), view_control_ptr_, cloudViewer::visualization::ColorMap::Winter, cloudViewer::visualization::RenderOption::XCoordinate, cloudViewer::visualization::RenderOption::YCoordinate, and cloudViewer::visualization::RenderOption::ZCoordinate.

Referenced by CreateVisualizerWindow(), cloudViewer::visualization::VisualizerWithCustomAnimation::KeyPressCallback(), cloudViewer::VisualizerForAlignment::KeyPressCallback(), cloudViewer::visualization::VisualizerWithEditing::KeyPressCallback(), cloudViewer::visualization::VisualizerWithVertexSelection::KeyPressCallback(), and cloudViewer::visualization::VisualizerWithKeyCallback::KeyPressCallback().

◆ MouseButtonCallback()

◆ MouseMoveCallback()

◆ MouseScrollCallback()

◆ operator=()

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

◆ PollEvents()

bool cloudViewer::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.

References animation_callback_func_, animation_callback_func_in_loop_, is_initialized_, is_redraw_required_, window_, and WindowRefreshCallback().

Referenced by main(), and Run().

◆ PrintVisualizerHelp()

◆ RegisterAnimationCallback()

void cloudViewer::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.

References animation_callback_func_.

Referenced by cloudViewer::visualization::DrawGeometriesWithAnimationCallback(), and cloudViewer::visualization::VisualizerWithCustomAnimation::Play().

◆ RemoveGeometry()

bool cloudViewer::visualization::Visualizer::RemoveGeometry ( std::shared_ptr< const ccHObject >  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.

References geometry_ptrs_, geometry_renderer_ptrs_, is_initialized_, LogDebug, ResetViewPoint(), UpdateGeometry(), view_control_ptr_, and window_.

◆ Render()

void cloudViewer::visualization::Visualizer::Render ( bool  render_screen = false)
protectedvirtual

◆ ResetViewPoint()

◆ Run()

◆ SetFullScreen()

void cloudViewer::visualization::Visualizer::SetFullScreen ( bool  fullscreen)
virtual

Functions to change between fullscreen and windowed modes.

References LogError, NULL, saved_window_pos_, saved_window_size_, and window_.

Referenced by KeyPressCallback(), and ToggleFullScreen().

◆ ToggleFullScreen()

void cloudViewer::visualization::Visualizer::ToggleFullScreen ( )
virtual

References IsFullScreen(), and SetFullScreen().

◆ UpdateGeometry()

◆ UpdateRender()

◆ UpdateWindowTitle()

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

◆ WaitEvents()

bool cloudViewer::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.

References animation_callback_func_, animation_callback_func_in_loop_, is_initialized_, is_redraw_required_, window_, and WindowRefreshCallback().

Referenced by Run().

◆ WindowCloseCallback()

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

Function to notify the window to be closed.

Referenced by CreateVisualizerWindow().

◆ WindowRefreshCallback()

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

◆ WindowResizeCallback()

Member Data Documentation

◆ animation_callback_func_

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

◆ animation_callback_func_in_loop_

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

Referenced by PollEvents(), Run(), and WaitEvents().

◆ coordinate_frame_mesh_ptr_

std::shared_ptr<ccMesh> cloudViewer::visualization::Visualizer::coordinate_frame_mesh_ptr_
protected

Referenced by BuildUtilities(), and ResetViewPoint().

◆ coordinate_frame_mesh_renderer_ptr_

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

Referenced by BuildUtilities(), and ResetViewPoint().

◆ geometry_ptrs_

◆ geometry_renderer_ptrs_

◆ glfw_context_

std::shared_ptr<GLFWContext> cloudViewer::visualization::Visualizer::glfw_context_ = nullptr
protected

Shared GLFW context.

Referenced by CreateVisualizerWindow(), and DestroyVisualizerWindow().

◆ is_initialized_

◆ is_redraw_required_

◆ mouse_control_

MouseControl cloudViewer::visualization::Visualizer::mouse_control_
protected

◆ render_depth_stencil_rbo_

GLuint cloudViewer::visualization::Visualizer::render_depth_stencil_rbo_ = 0
protected

Referenced by Render().

◆ render_fbo_

GLuint cloudViewer::visualization::Visualizer::render_fbo_ = 0
protected

Referenced by InitOpenGL(), and Render().

◆ render_option_ptr_

◆ render_rgb_tex_

GLuint cloudViewer::visualization::Visualizer::render_rgb_tex_ = 0
protected

Referenced by Render().

◆ saved_window_pos_

Eigen::Vector2i cloudViewer::visualization::Visualizer::saved_window_pos_ = Eigen::Vector2i::Zero()
protected

Referenced by SetFullScreen().

◆ saved_window_size_

Eigen::Vector2i cloudViewer::visualization::Visualizer::saved_window_size_ = Eigen::Vector2i::Zero()
protected

Referenced by SetFullScreen().

◆ utility_ptrs_

std::vector<std::shared_ptr<const ccHObject> > cloudViewer::visualization::Visualizer::utility_ptrs_
protected

◆ utility_renderer_opts_

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

◆ utility_renderer_ptrs_

◆ vao_id_

GLuint cloudViewer::visualization::Visualizer::vao_id_ = 0
protected

◆ view_control_ptr_

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

Referenced by cloudViewer::visualization::VisualizerWithVertexSelection::AddGeometry(), cloudViewer::visualization::VisualizerWithEditing::AddGeometry(), AddGeometry(), cloudViewer::visualization::VisualizerWithVertexSelection::CalcDragDelta(), CaptureDepthFloatBuffer(), CaptureDepthImage(), CaptureDepthPointCloud(), CaptureScreenFloatBuffer(), CaptureScreenImage(), CopyViewStatusFromClipboard(), CopyViewStatusToClipboard(), cloudViewer::visualization::VisualizerWithVertexSelection::GetDepth(), GetViewControl(), cloudViewer::visualization::VisualizerWithCustomAnimation::InitViewControl(), cloudViewer::visualization::VisualizerWithEditing::InitViewControl(), cloudViewer::visualization::VisualizerWithVertexSelection::InitViewControl(), InitViewControl(), cloudViewer::visualization::VisualizerWithCustomAnimation::KeyPressCallback(), cloudViewer::visualization::VisualizerWithEditing::KeyPressCallback(), cloudViewer::visualization::VisualizerWithVertexSelection::KeyPressCallback(), KeyPressCallback(), cloudViewer::visualization::VisualizerWithCustomAnimation::MouseButtonCallback(), cloudViewer::visualization::VisualizerWithEditing::MouseButtonCallback(), cloudViewer::visualization::VisualizerWithVertexSelection::MouseButtonCallback(), MouseButtonCallback(), cloudViewer::visualization::VisualizerWithCustomAnimation::MouseMoveCallback(), cloudViewer::visualization::VisualizerWithEditing::MouseMoveCallback(), cloudViewer::visualization::VisualizerWithVertexSelection::MouseMoveCallback(), MouseMoveCallback(), cloudViewer::visualization::VisualizerWithCustomAnimation::MouseScrollCallback(), cloudViewer::visualization::VisualizerWithEditing::MouseScrollCallback(), MouseScrollCallback(), cloudViewer::visualization::VisualizerWithEditing::PickPoint(), cloudViewer::visualization::VisualizerWithVertexSelection::PickPoints(), cloudViewer::visualization::VisualizerWithCustomAnimation::Play(), RemoveGeometry(), Render(), ResetViewPoint(), cloudViewer::visualization::VisualizerWithCustomAnimation::UpdateWindowTitle(), cloudViewer::visualization::VisualizerWithVertexSelection::UpdateWindowTitle(), cloudViewer::visualization::VisualizerWithEditing::UpdateWindowTitle(), and WindowResizeCallback().

◆ window_

◆ window_name_


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