iridescence
Loading...
Searching...
No Matches
guik::LightViewerContext Class Reference

Viewer context. More...

#include <light_viewer_context.hpp>

Inheritance diagram for guik::LightViewerContext:
Collaboration diagram for guik::LightViewerContext:

Public Member Functions

 LightViewerContext (const std::string &context_name)
virtual ~LightViewerContext ()
void draw_ui ()
void draw_gl ()
bool init_canvas (const Eigen::Vector2i &size)
void set_size (const Eigen::Vector2i &size)
void set_clear_color (const Eigen::Vector4f &color)
void set_pos (const Eigen::Vector2i &pos, ImGuiCond cond=ImGuiCond_FirstUseEver, ImGuiWindowFlags=0)
void show ()
void hide ()
virtual void clear ()
 Clear everything in the viewer (callbacks, filters, drawables, texts).
virtual void clear_text ()
 Clear texts.
virtual void append_text (const std::string &text)
 Append debug text to the viewer. This method is thread-safe.
virtual void register_ui_callback (const std::string &name, const std::function< void()> &callback=0)
 Register a UI callback function.
void remove_ui_callback (const std::string &name)
 Remove a UI callback function.
guik::ShaderSetting & shader_setting ()
 Global shader setting.
const guik::ShaderSetting & shader_setting () const
 Global shader setting.
void disable_xy_grid ()
 Disable XY grid drawing.
void enable_xy_grid ()
 Enable XY grid drawing.
void set_draw_xy_grid (bool draw_xy_grid)
 Set enable/disable XY grid drawing.
void set_colormap (glk::COLORMAP colormap)
 Set colormap used for RAINBOW and VERTEX_COLORMAP modes.
void set_screen_effect (const std::shared_ptr< glk::ScreenEffect > &effect)
 Set screen effect.
const std::shared_ptr< glk::ScreenEffect > & get_screen_effect () const
 Get screen effect.
void set_bg_texture (const std::shared_ptr< glk::Texture > &bg_texture)
 Set background texture.
void set_rainbow_range (const Eigen::Vector2f &minmax_z)
 Set range of color mapping for RAINBOW mode.
void set_rainbow_axis (const Eigen::Vector3f &axis)
 Set axis of color mapping for RAINBOW mode.
void set_colormap_range (const Eigen::Vector2f &minmax)
 Set range of color mapping for VERTEX_COLORMAP mode.
void set_point_shape (float point_size=1.0f, bool metric=true, bool circle=true)
 Set point shape properties.
void enable_normal_buffer ()
 Enable normal buffer.
void enable_info_buffer ()
 Enable info buffer.
void enable_decimal_rendering ()
 Enable partial rendering (This method will be deprecated).
void enable_partial_rendering (double clear_thresh=1e-6)
 Enable partial rendering.
void disable_partial_rendering ()
 Disable partial rendering.
void enable_backface_culling ()
 Enable backface culling. Fragments with back-facing normals will not be rendered.
void disable_backface_culling ()
 Disable backface culling.
void set_backface_culling_range (const Eigen::Vector2f &range)
 Set the range of normal.z for backface culling. Fragments with normal.z outside the range will be culled when backface culling is enabled.
bool normal_buffer_enabled () const
 Whether normal buffer is enabled.
bool info_buffer_enabled () const
 Whether info buffer is enabled.
bool partial_rendering_enabled () const
 Whether partial rendering is enabled.
bool backface_culling_enabled () const
 Whether backface culling is enabled.
const glk::Texture & color_buffer () const
 Color buffer.
const glk::Texture & depth_buffer () const
 Depth buffer.
const glk::Texture & normal_buffer () const
 Normal buffer.
const glk::Texture & info_buffer () const
 Info buffer.
const glk::Texture & dynamic_flag_buffer () const
 Dynamic flag buffer.
void clear_drawables ()
 Clear all drawables.
void clear_drawables (const std::function< bool(const std::string &)> &fn)
 Clear drawables that satisfy the given condition.
std::unordered_map< std::string, std::pair< ShaderSetting::Ptr, glk::Drawable::ConstPtr > > & get_drawables ()
 Get all drawables.
std::pair< ShaderSetting::Ptr, glk::Drawable::ConstPtr > find_drawable (const std::string &name)
 Find a drawable by name.
void remove_drawable (const std::string &name)
 Remove a drawable by name.
void remove_drawable (const std::regex &regex)
 Remove all drawables that match the given regex.
void update_drawable (const std::string &name, const glk::Drawable::ConstPtr &drawable, const ShaderSetting &shader_setting=ShaderSetting())
 Update a drawable.
void clear_drawable_filters ()
 Clear all drawable filters.
void register_drawable_filter (const std::string &filter_name, const std::function< bool(const std::string &)> &filter=0)
 Register a drawable filter.
void remove_drawable_filter (const std::string &filter_name)
 Remove a drawable filter.
void clear_partial_rendering ()
 Clear partial rendering buffer.
const std::shared_ptr< CameraControl > & get_camera_control () const
 Get camera control (model matrix control).
const std::shared_ptr< ProjectionControl > & get_projection_control () const
 Get projection control (projection matrix control).
void set_camera_control (const std::shared_ptr< CameraControl > &camera_control)
 Set camera control (model matrix control).
void set_projection_control (const std::shared_ptr< ProjectionControl > &projection_control)
 Set projection control (projection matrix control).
bool save_camera_settings (const std::string &path) const
 Save camera settings to a file.
bool load_camera_settings (const std::string &path)
 Load camera settings from a file.
void reset_center ()
 Reset camera center to the center of the screen.
void lookat (const Eigen::Vector3f &pt)
 Make the camera look at a point.
void lookat (const Eigen::Isometry3f &T_world_sensor)
 Make the camera look at a transform.
void lookat (const Eigen::Isometry3d &T_world_sensor)
 Make the camera look at a transform.
template<typename Vector>
void lookat (const Vector &pt)
 Make the camera look at a point.
std::shared_ptr< OrbitCameraControlXY > use_orbit_camera_control (double distance=80.0, double theta=0.0, double phi=-60.0f *M_PI/180.0f)
 Use orbit camera control (XY plane) useful for systems in which XYZ = front-left-up like LiDAR odometry.
std::shared_ptr< OrbitCameraControlXZ > use_orbit_camera_control_xz (double distance=80.0, double theta=0.0, double phi=0.0)
 Use orbit camera control (XZ plane) useful for systems in which XYZ = right-down-forward like visual odometry.
std::shared_ptr< TopDownCameraControl > use_topdown_camera_control (double distance=80.0, double theta=0.0)
 Use top-down camera control useful for 2D SLAM.
std::shared_ptr< ArcBallCameraControl > use_arcball_camera_control (double distance=80.0, double theta=0.0, double phi=-60.0f *M_PI/180.0f)
 Use arcball camera control.
std::shared_ptr< FPSCameraControl > use_fps_camera_control (double fovy_deg=60.0)
 Use FPS game-like camera control.
std::shared_ptr< SensorViewCameraControl > use_sensor_view_camera_control (const Eigen::Isometry3f &T_sensor_camera=Eigen::Translation3f(-5.0f, 0.0f, 0.1f) *Eigen::Isometry3f::Identity(), double smoothing_factor_trans=0.75, double smoothing_factor_rot=0.9)
 Use sensor-view camera control that follows a given sensor pose.
std::shared_ptr< BasicProjectionControl > use_perspective_projection_control (float fovy_deg=30.0f, float near_=1.0f, float far_=1000.0f)
 Use perspective projection control.
std::shared_ptr< BasicProjectionControl > use_orthographic_projection_control (float width=10.0f, float near_=1.0f, float far_=1000.0f)
 Use orthographic projection control.
guik::GLCanvas & get_canvas ()
 Get underlying GLCanvas.
Eigen::Vector2i canvas_tl () const
Eigen::Vector2i canvas_br () const
 Get bottom right corner of the canvas rectangle.
Eigen::Vector2i canvas_size () const
 Get canvas size.
Eigen::Matrix4f view_matrix () const
 Get view matrix.
Eigen::Matrix4f projection_matrix () const
 Get projection matrix.
Eigen::Vector4i pick_info (const Eigen::Vector2i &p, int window=2) const
 Pick info from the info buffer.
float pick_depth (const Eigen::Vector2i &p, int window=2) const
 Pick depth from the depth buffer.
Eigen::Vector3f unproject (const Eigen::Vector2i &p, float depth) const
 Unproject a pixel to a 3D point.
std::optional< Eigen::Vector3f > pick_point (int button=0, int window=2, Eigen::Vector4i *info=nullptr) const
 Pick a 3D point from the depth buffer.
std::vector< unsigned char > read_color_buffer () const
 Read color buffer values.
std::vector< float > read_depth_buffer (bool real_scale=true)
 Read depth buffer values.
bool save_color_buffer (const std::string &filename)
 Save color buffer to an image file (PNG).
bool save_depth_buffer (const std::string &filename, bool real_scale=true)
 Save depth buffer to a file (PNG).
AsyncLightViewerContext async ()
 Get an asynchronous light viewer context.
std::shared_ptr< glk::PointCloudBuffer > update_points (const std::string &name, const float *data, int stride, int num_points, const ShaderSetting &shader_setting)
 Register or update a point cloud buffer.
template<typename Scalar, int Dim>
std::shared_ptr< glk::PointCloudBuffer > update_points (const std::string &name, const Eigen::Matrix< Scalar, Dim, 1 > *points, int num_points, const ShaderSetting &shader_setting)
 Register or update a point cloud buffer.
template<typename Scalar, int Dim, typename Allocator>
std::shared_ptr< glk::PointCloudBuffer > update_points (const std::string &name, const std::vector< Eigen::Matrix< Scalar, Dim, 1 >, Allocator > &points, const ShaderSetting &shader_setting)
 Register or update a point cloud buffer.
template<typename Scalar, int Dim>
void update_normal_dists (const std::string &name, const Eigen::Matrix< Scalar, Dim, 1 > *points, const Eigen::Matrix< Scalar, Dim, Dim > *covs, int num_points, float sigma, const ShaderSetting &shader_setting)
 Register or update a normal distribution set.
template<typename Scalar, int Dim, typename Alloc1, typename Alloc2>
void update_normal_dists (const std::string &name, const std::vector< Eigen::Matrix< Scalar, Dim, 1 >, Alloc1 > &points, const std::vector< Eigen::Matrix< Scalar, Dim, Dim >, Alloc2 > &covs, float sigma, const ShaderSetting &shader_setting)
 Register or update a normal distribution set.
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const float *vertices, const float *colors, int num_vertices, const unsigned int *indices, int num_indices, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const float *vertices, const float *colors, int num_vertices, const unsigned int *indices, int num_indices, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Scalar, int Dim>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< Scalar, Dim, 1 > *points, int num_points, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< ScalarV, DimV, 1 > *points, const Eigen::Matrix< ScalarC, DimC, 1 > *colors, int num_points, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< ScalarV, DimV, 1 > *points, const Eigen::Matrix< ScalarC, DimC, 1 > *colors, int num_points, const unsigned int *indices, int num_indices, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, Alloc > &points, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, Alloc > &points, const std::vector< unsigned int > &indices, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, AllocP > &points, const std::vector< Color, AllocC > &colors, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, AllocP > &points, const std::vector< Color, AllocC > &colors, const std::vector< unsigned int > &indices, bool line_strip, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Scalar, int Dim>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< Scalar, Dim, 1 > *points, int num_points, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< ScalarV, DimV, 1 > *points, const Eigen::Matrix< ScalarC, DimC, 1 > *colors, int num_points, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const Eigen::Matrix< ScalarV, DimV, 1 > *points, const Eigen::Matrix< ScalarC, DimC, 1 > *colors, int num_points, const unsigned int *indices, int num_indices, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, Alloc > &points, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, Alloc > &points, const std::vector< unsigned int > &indices, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, AllocP > &points, const std::vector< Color, AllocC > &colors, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > update_thin_lines (const std::string &name, const std::vector< Point, AllocP > &points, const std::vector< Color, AllocC > &colors, const std::vector< unsigned int > &indices, bool line_strip, float line_width, const ShaderSetting &shader_setting)
 Register or update a thin lines drawable.
void update_icosahedron (const std::string &name, const ShaderSetting &shader_setting)
 Register or update an icosahedron primitive.
void update_sphere (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a sphere primitive.
void update_cube (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a cube primitive.
void update_cone (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a cone primitive.
void update_frustum (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a frustum primitive.
void update_coord (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a coordinate axes primitive.
void update_wire_icosahedron (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a wireframe icosahedron primitive.
void update_wire_sphere (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a wireframe sphere primitive.
void update_wire_cube (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a wireframe cube primitive.
void update_wire_cone (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a wireframe cone primitive.
void update_wire_frustum (const std::string &name, const ShaderSetting &shader_setting)
 Register or update a wireframe frustum primitive.

Protected Attributes

std::string context_name
 Viewer context name.
Eigen::Vector2i canvas_rect_min
 Top-left corner of the canvas rectangle.
Eigen::Vector2i canvas_rect_max
 Bottom-right corner of the canvas rectangle.
std::unique_ptr< guik::GLCanvas > canvas
 GL canvas.
guik::ShaderSetting global_shader_setting
 Global shader setting.
bool show_window
bool draw_xy_grid
bool decimal_rendering
Eigen::Matrix4f last_projection_view_matrix
std::unordered_map< std::string, std::function< bool(const std::string &)> > drawable_filters
std::unordered_map< std::string, std::pair< ShaderSetting::Ptr, glk::Drawable::ConstPtr > > drawables
std::mutex sub_texts_mutex
std::deque< std::string > sub_texts
std::vector< std::pair< std::string, std::function< void()> > > sub_ui_callbacks

Detailed Description

Viewer context.

Constructor & Destructor Documentation

◆ LightViewerContext()

guik::LightViewerContext::LightViewerContext ( const std::string & context_name)

◆ ~LightViewerContext()

virtual guik::LightViewerContext::~LightViewerContext ( )
virtual

Member Function Documentation

◆ append_text()

virtual void guik::LightViewerContext::append_text ( const std::string & text)
virtual

Append debug text to the viewer. This method is thread-safe.

Reimplemented in guik::LightViewer.

◆ async()

AsyncLightViewerContext guik::LightViewerContext::async ( )

Get an asynchronous light viewer context.

◆ backface_culling_enabled()

bool guik::LightViewerContext::backface_culling_enabled ( ) const

Whether backface culling is enabled.

◆ canvas_br()

Eigen::Vector2i guik::LightViewerContext::canvas_br ( ) const
inline

Get bottom right corner of the canvas rectangle.

◆ canvas_size()

Eigen::Vector2i guik::LightViewerContext::canvas_size ( ) const
inline

Get canvas size.

◆ canvas_tl()

Eigen::Vector2i guik::LightViewerContext::canvas_tl ( ) const
inline

◆ clear()

virtual void guik::LightViewerContext::clear ( )
virtual

Clear everything in the viewer (callbacks, filters, drawables, texts).

Reimplemented in guik::LightViewer.

◆ clear_drawable_filters()

void guik::LightViewerContext::clear_drawable_filters ( )

Clear all drawable filters.

◆ clear_drawables() [1/2]

void guik::LightViewerContext::clear_drawables ( )

Clear all drawables.

◆ clear_drawables() [2/2]

void guik::LightViewerContext::clear_drawables ( const std::function< bool(const std::string &)> & fn)

Clear drawables that satisfy the given condition.

Parameters
fnCondition function

◆ clear_partial_rendering()

void guik::LightViewerContext::clear_partial_rendering ( )

Clear partial rendering buffer.

◆ clear_text()

virtual void guik::LightViewerContext::clear_text ( )
virtual

Clear texts.

Reimplemented in guik::LightViewer.

◆ color_buffer()

const glk::Texture & guik::LightViewerContext::color_buffer ( ) const

Color buffer.

◆ depth_buffer()

const glk::Texture & guik::LightViewerContext::depth_buffer ( ) const

Depth buffer.

◆ disable_backface_culling()

void guik::LightViewerContext::disable_backface_culling ( )

Disable backface culling.

◆ disable_partial_rendering()

void guik::LightViewerContext::disable_partial_rendering ( )

Disable partial rendering.

◆ disable_xy_grid()

void guik::LightViewerContext::disable_xy_grid ( )
inline

Disable XY grid drawing.

◆ draw_gl()

void guik::LightViewerContext::draw_gl ( )

◆ draw_ui()

void guik::LightViewerContext::draw_ui ( )

◆ dynamic_flag_buffer()

const glk::Texture & guik::LightViewerContext::dynamic_flag_buffer ( ) const

Dynamic flag buffer.

◆ enable_backface_culling()

void guik::LightViewerContext::enable_backface_culling ( )

Enable backface culling. Fragments with back-facing normals will not be rendered.

◆ enable_decimal_rendering()

void guik::LightViewerContext::enable_decimal_rendering ( )

Enable partial rendering (This method will be deprecated).

◆ enable_info_buffer()

void guik::LightViewerContext::enable_info_buffer ( )

Enable info buffer.

◆ enable_normal_buffer()

void guik::LightViewerContext::enable_normal_buffer ( )

Enable normal buffer.

◆ enable_partial_rendering()

void guik::LightViewerContext::enable_partial_rendering ( double clear_thresh = 1e-6)

Enable partial rendering.

Parameters
clear_threshThreshold for clearing the partial rendering buffer.

◆ enable_xy_grid()

void guik::LightViewerContext::enable_xy_grid ( )
inline

Enable XY grid drawing.

◆ find_drawable()

std::pair< ShaderSetting::Ptr, glk::Drawable::ConstPtr > guik::LightViewerContext::find_drawable ( const std::string & name)

Find a drawable by name.

Parameters
nameDrawable name
Returns
Drawable and its shader setting pair if found, otherwise an empty pair

◆ get_camera_control()

const std::shared_ptr< CameraControl > & guik::LightViewerContext::get_camera_control ( ) const

Get camera control (model matrix control).

◆ get_canvas()

guik::GLCanvas & guik::LightViewerContext::get_canvas ( )

Get underlying GLCanvas.

◆ get_drawables()

std::unordered_map< std::string, std::pair< ShaderSetting::Ptr, glk::Drawable::ConstPtr > > & guik::LightViewerContext::get_drawables ( )

Get all drawables.

Note
This method may be removed in the future.

◆ get_projection_control()

const std::shared_ptr< ProjectionControl > & guik::LightViewerContext::get_projection_control ( ) const

Get projection control (projection matrix control).

◆ get_screen_effect()

const std::shared_ptr< glk::ScreenEffect > & guik::LightViewerContext::get_screen_effect ( ) const

Get screen effect.

◆ hide()

void guik::LightViewerContext::hide ( )

◆ info_buffer()

const glk::Texture & guik::LightViewerContext::info_buffer ( ) const

Info buffer.

◆ info_buffer_enabled()

bool guik::LightViewerContext::info_buffer_enabled ( ) const

Whether info buffer is enabled.

◆ init_canvas()

bool guik::LightViewerContext::init_canvas ( const Eigen::Vector2i & size)

◆ load_camera_settings()

bool guik::LightViewerContext::load_camera_settings ( const std::string & path)

Load camera settings from a file.

◆ lookat() [1/4]

void guik::LightViewerContext::lookat ( const Eigen::Isometry3d & T_world_sensor)

Make the camera look at a transform.

◆ lookat() [2/4]

void guik::LightViewerContext::lookat ( const Eigen::Isometry3f & T_world_sensor)

Make the camera look at a transform.

◆ lookat() [3/4]

void guik::LightViewerContext::lookat ( const Eigen::Vector3f & pt)

Make the camera look at a point.

◆ lookat() [4/4]

template<typename Vector>
void guik::LightViewerContext::lookat ( const Vector & pt)
inline

Make the camera look at a point.

◆ normal_buffer()

const glk::Texture & guik::LightViewerContext::normal_buffer ( ) const

Normal buffer.

◆ normal_buffer_enabled()

bool guik::LightViewerContext::normal_buffer_enabled ( ) const

Whether normal buffer is enabled.

◆ partial_rendering_enabled()

bool guik::LightViewerContext::partial_rendering_enabled ( ) const

Whether partial rendering is enabled.

◆ pick_depth()

float guik::LightViewerContext::pick_depth ( const Eigen::Vector2i & p,
int window = 2 ) const

Pick depth from the depth buffer.

Parameters
pPixel coordinates
windowWindow size for finding a valid pixel neighboring p
Returns
Depth value. Depth > 1.0f indicates background.

◆ pick_info()

Eigen::Vector4i guik::LightViewerContext::pick_info ( const Eigen::Vector2i & p,
int window = 2 ) const

Pick info from the info buffer.

Parameters
pPixel coordinates
windowWindow size for finding a valid pixel neighboring p
Returns
Info vector

◆ pick_point()

std::optional< Eigen::Vector3f > guik::LightViewerContext::pick_point ( int button = 0,
int window = 2,
Eigen::Vector4i * info = nullptr ) const

Pick a 3D point from the depth buffer.

Parameters
pPixel coordinates
windowWindow size for finding a valid pixel neighboring p
infoIf not null, the info vector is stored here.
Returns
3D point in the world coordinate. If no valid depth is found, std::nullopt is returned.

◆ projection_matrix()

Eigen::Matrix4f guik::LightViewerContext::projection_matrix ( ) const
inline

Get projection matrix.

◆ read_color_buffer()

std::vector< unsigned char > guik::LightViewerContext::read_color_buffer ( ) const

Read color buffer values.

Returns
Color buffer values in RGBA format.

◆ read_depth_buffer()

std::vector< float > guik::LightViewerContext::read_depth_buffer ( bool real_scale = true)

Read depth buffer values.

Parameters
real_scaleIf true, depth values are scaled to real-world values. Otherwise, raw depth buffer values are returned.
Returns
Depth buffer values.

◆ register_drawable_filter()

void guik::LightViewerContext::register_drawable_filter ( const std::string & filter_name,
const std::function< bool(const std::string &)> & filter = 0 )

Register a drawable filter.

Parameters
filter_nameFilter name
filterFilter function. If null, the filter with the given name is removed.

◆ register_ui_callback()

virtual void guik::LightViewerContext::register_ui_callback ( const std::string & name,
const std::function< void()> & callback = 0 )
virtual

Register a UI callback function.

Parameters
nameCallback name
callbackCallback function. If null, the callback with the given name is removed.

Reimplemented in guik::LightViewer.

◆ remove_drawable() [1/2]

void guik::LightViewerContext::remove_drawable ( const std::regex & regex)

Remove all drawables that match the given regex.

◆ remove_drawable() [2/2]

void guik::LightViewerContext::remove_drawable ( const std::string & name)

Remove a drawable by name.

◆ remove_drawable_filter()

void guik::LightViewerContext::remove_drawable_filter ( const std::string & filter_name)

Remove a drawable filter.

◆ remove_ui_callback()

void guik::LightViewerContext::remove_ui_callback ( const std::string & name)

Remove a UI callback function.

Parameters
nameCallback name

◆ reset_center()

void guik::LightViewerContext::reset_center ( )

Reset camera center to the center of the screen.

◆ save_camera_settings()

bool guik::LightViewerContext::save_camera_settings ( const std::string & path) const

Save camera settings to a file.

◆ save_color_buffer()

bool guik::LightViewerContext::save_color_buffer ( const std::string & filename)

Save color buffer to an image file (PNG).

◆ save_depth_buffer()

bool guik::LightViewerContext::save_depth_buffer ( const std::string & filename,
bool real_scale = true )

Save depth buffer to a file (PNG).

◆ set_backface_culling_range()

void guik::LightViewerContext::set_backface_culling_range ( const Eigen::Vector2f & range)

Set the range of normal.z for backface culling. Fragments with normal.z outside the range will be culled when backface culling is enabled.

Parameters
range[min, max] range of normal.z for backface culling

◆ set_bg_texture()

void guik::LightViewerContext::set_bg_texture ( const std::shared_ptr< glk::Texture > & bg_texture)

Set background texture.

◆ set_camera_control()

void guik::LightViewerContext::set_camera_control ( const std::shared_ptr< CameraControl > & camera_control)

Set camera control (model matrix control).

◆ set_clear_color()

void guik::LightViewerContext::set_clear_color ( const Eigen::Vector4f & color)

◆ set_colormap()

void guik::LightViewerContext::set_colormap ( glk::COLORMAP colormap)

Set colormap used for RAINBOW and VERTEX_COLORMAP modes.

◆ set_colormap_range()

void guik::LightViewerContext::set_colormap_range ( const Eigen::Vector2f & minmax)

Set range of color mapping for VERTEX_COLORMAP mode.

◆ set_draw_xy_grid()

void guik::LightViewerContext::set_draw_xy_grid ( bool draw_xy_grid)

Set enable/disable XY grid drawing.

◆ set_point_shape()

void guik::LightViewerContext::set_point_shape ( float point_size = 1.0f,
bool metric = true,
bool circle = true )

Set point shape properties.

Parameters
point_sizePoint size
metricIf true, point size is in the metric unit [m], otherwise in pixel unit.
circleIf true, points are rendered as circles, otherwise as squares.

◆ set_pos()

void guik::LightViewerContext::set_pos ( const Eigen::Vector2i & pos,
ImGuiCond cond = ImGuiCond_FirstUseEver,
ImGuiWindowFlags = 0 )

◆ set_projection_control()

void guik::LightViewerContext::set_projection_control ( const std::shared_ptr< ProjectionControl > & projection_control)

Set projection control (projection matrix control).

◆ set_rainbow_axis()

void guik::LightViewerContext::set_rainbow_axis ( const Eigen::Vector3f & axis)

Set axis of color mapping for RAINBOW mode.

◆ set_rainbow_range()

void guik::LightViewerContext::set_rainbow_range ( const Eigen::Vector2f & minmax_z)

Set range of color mapping for RAINBOW mode.

◆ set_screen_effect()

void guik::LightViewerContext::set_screen_effect ( const std::shared_ptr< glk::ScreenEffect > & effect)

Set screen effect.

◆ set_size()

void guik::LightViewerContext::set_size ( const Eigen::Vector2i & size)

◆ shader_setting() [1/2]

guik::ShaderSetting & guik::LightViewerContext::shader_setting ( )
inline

Global shader setting.

◆ shader_setting() [2/2]

const guik::ShaderSetting & guik::LightViewerContext::shader_setting ( ) const
inline

Global shader setting.

◆ show()

void guik::LightViewerContext::show ( )

◆ unproject()

Eigen::Vector3f guik::LightViewerContext::unproject ( const Eigen::Vector2i & p,
float depth ) const

Unproject a pixel to a 3D point.

Parameters
pPixel coordinates
depthDepth value
Returns
3D point in the world coordinate

◆ update_cone()

void guik::LightViewerContext::update_cone ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a cone primitive.

◆ update_coord()

void guik::LightViewerContext::update_coord ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a coordinate axes primitive.

◆ update_cube()

void guik::LightViewerContext::update_cube ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a cube primitive.

◆ update_drawable()

void guik::LightViewerContext::update_drawable ( const std::string & name,
const glk::Drawable::ConstPtr & drawable,
const ShaderSetting & shader_setting = ShaderSetting() )

Update a drawable.

Parameters
nameDrawable name
drawableDrawable
shader_settingShader setting

◆ update_frustum()

void guik::LightViewerContext::update_frustum ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a frustum primitive.

◆ update_icosahedron()

void guik::LightViewerContext::update_icosahedron ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update an icosahedron primitive.

◆ update_normal_dists() [1/2]

template<typename Scalar, int Dim>
void guik::LightViewerContext::update_normal_dists ( const std::string & name,
const Eigen::Matrix< Scalar, Dim, 1 > * points,
const Eigen::Matrix< Scalar, Dim, Dim > * covs,
int num_points,
float sigma,
const ShaderSetting & shader_setting )

Register or update a normal distribution set.

Parameters
nameDrawable name
pointsPoint mean array
covsPoint covariance array
num_pointsNumber of points
sigmaSize of the ellipsoids in standard deviations (e.g., 3.0 renders 3-sigma ellipsoids)
shader_settingShader setting

◆ update_normal_dists() [2/2]

template<typename Scalar, int Dim, typename Alloc1, typename Alloc2>
void guik::LightViewerContext::update_normal_dists ( const std::string & name,
const std::vector< Eigen::Matrix< Scalar, Dim, 1 >, Alloc1 > & points,
const std::vector< Eigen::Matrix< Scalar, Dim, Dim >, Alloc2 > & covs,
float sigma,
const ShaderSetting & shader_setting )

Register or update a normal distribution set.

◆ update_points() [1/3]

template<typename Scalar, int Dim>
std::shared_ptr< glk::PointCloudBuffer > guik::LightViewerContext::update_points ( const std::string & name,
const Eigen::Matrix< Scalar, Dim, 1 > * points,
int num_points,
const ShaderSetting & shader_setting )

Register or update a point cloud buffer.

◆ update_points() [2/3]

std::shared_ptr< glk::PointCloudBuffer > guik::LightViewerContext::update_points ( const std::string & name,
const float * data,
int stride,
int num_points,
const ShaderSetting & shader_setting )

Register or update a point cloud buffer.

Parameters
nameDrawable name
dataPointer to point data (float array)
strideStride (in bytes) between points
num_pointsNumber of points
shader_settingShader setting
Returns
Created PointCloudBuffer

◆ update_points() [3/3]

template<typename Scalar, int Dim, typename Allocator>
std::shared_ptr< glk::PointCloudBuffer > guik::LightViewerContext::update_points ( const std::string & name,
const std::vector< Eigen::Matrix< Scalar, Dim, 1 >, Allocator > & points,
const ShaderSetting & shader_setting )

Register or update a point cloud buffer.

◆ update_sphere()

void guik::LightViewerContext::update_sphere ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a sphere primitive.

◆ update_thin_lines() [1/16]

template<typename Scalar, int Dim>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< Scalar, Dim, 1 > * points,
int num_points,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [2/16]

template<typename Scalar, int Dim>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< Scalar, Dim, 1 > * points,
int num_points,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [3/16]

template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< ScalarV, DimV, 1 > * points,
const Eigen::Matrix< ScalarC, DimC, 1 > * colors,
int num_points,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [4/16]

template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< ScalarV, DimV, 1 > * points,
const Eigen::Matrix< ScalarC, DimC, 1 > * colors,
int num_points,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [5/16]

template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< ScalarV, DimV, 1 > * points,
const Eigen::Matrix< ScalarC, DimC, 1 > * colors,
int num_points,
const unsigned int * indices,
int num_indices,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [6/16]

template<typename ScalarV, int DimV, typename ScalarC, int DimC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const Eigen::Matrix< ScalarV, DimV, 1 > * points,
const Eigen::Matrix< ScalarC, DimC, 1 > * colors,
int num_points,
const unsigned int * indices,
int num_indices,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [7/16]

std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const float * vertices,
const float * colors,
int num_vertices,
const unsigned int * indices,
int num_indices,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [8/16]

std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const float * vertices,
const float * colors,
int num_vertices,
const unsigned int * indices,
int num_indices,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

Parameters
nameDrawable name
verticesPointer to vertex data (array of float3)
colorsPointer to color data (array of float4). If null, no vertex colors are assigned..
num_verticesNumber of vertices
indicesPointer to index data (array of unsigned int). If null, non-indexed drawing is used.
num_indicesNumber of indices
line_stripIf true, line strip mode is used. Otherwise, line list mode is used.
line_widthWidth of the lines in pixels.
shader_settingShader setting

◆ update_thin_lines() [9/16]

template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, Alloc > & points,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [10/16]

template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, Alloc > & points,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [11/16]

template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, Alloc > & points,
const std::vector< unsigned int > & indices,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [12/16]

template<typename Point, typename Alloc>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, Alloc > & points,
const std::vector< unsigned int > & indices,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [13/16]

template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, AllocP > & points,
const std::vector< Color, AllocC > & colors,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [14/16]

template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, AllocP > & points,
const std::vector< Color, AllocC > & colors,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [15/16]

template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, AllocP > & points,
const std::vector< Color, AllocC > & colors,
const std::vector< unsigned int > & indices,
bool line_strip,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_thin_lines() [16/16]

template<typename Point, typename AllocP, typename Color, typename AllocC>
std::shared_ptr< glk::ThinLines > guik::LightViewerContext::update_thin_lines ( const std::string & name,
const std::vector< Point, AllocP > & points,
const std::vector< Color, AllocC > & colors,
const std::vector< unsigned int > & indices,
bool line_strip,
float line_width,
const ShaderSetting & shader_setting )

Register or update a thin lines drawable.

◆ update_wire_cone()

void guik::LightViewerContext::update_wire_cone ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a wireframe cone primitive.

◆ update_wire_cube()

void guik::LightViewerContext::update_wire_cube ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a wireframe cube primitive.

◆ update_wire_frustum()

void guik::LightViewerContext::update_wire_frustum ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a wireframe frustum primitive.

◆ update_wire_icosahedron()

void guik::LightViewerContext::update_wire_icosahedron ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a wireframe icosahedron primitive.

◆ update_wire_sphere()

void guik::LightViewerContext::update_wire_sphere ( const std::string & name,
const ShaderSetting & shader_setting )

Register or update a wireframe sphere primitive.

◆ use_arcball_camera_control()

std::shared_ptr< ArcBallCameraControl > guik::LightViewerContext::use_arcball_camera_control ( double distance = 80.0,
double theta = 0.0,
double phi = -60.0f *M_PI/180.0f )

Use arcball camera control.

◆ use_fps_camera_control()

std::shared_ptr< FPSCameraControl > guik::LightViewerContext::use_fps_camera_control ( double fovy_deg = 60.0)

Use FPS game-like camera control.

◆ use_orbit_camera_control()

std::shared_ptr< OrbitCameraControlXY > guik::LightViewerContext::use_orbit_camera_control ( double distance = 80.0,
double theta = 0.0,
double phi = -60.0f *M_PI/180.0f )

Use orbit camera control (XY plane) useful for systems in which XYZ = front-left-up like LiDAR odometry.

◆ use_orbit_camera_control_xz()

std::shared_ptr< OrbitCameraControlXZ > guik::LightViewerContext::use_orbit_camera_control_xz ( double distance = 80.0,
double theta = 0.0,
double phi = 0.0 )

Use orbit camera control (XZ plane) useful for systems in which XYZ = right-down-forward like visual odometry.

◆ use_orthographic_projection_control()

std::shared_ptr< BasicProjectionControl > guik::LightViewerContext::use_orthographic_projection_control ( float width = 10.0f,
float near_ = 1.0f,
float far_ = 1000.0f )

Use orthographic projection control.

◆ use_perspective_projection_control()

std::shared_ptr< BasicProjectionControl > guik::LightViewerContext::use_perspective_projection_control ( float fovy_deg = 30.0f,
float near_ = 1.0f,
float far_ = 1000.0f )

Use perspective projection control.

◆ use_sensor_view_camera_control()

std::shared_ptr< SensorViewCameraControl > guik::LightViewerContext::use_sensor_view_camera_control ( const Eigen::Isometry3f & T_sensor_camera = Eigen::Translation3f(-5.0f, 0.0f, 0.1f) *Eigen::Isometry3f::Identity(),
double smoothing_factor_trans = 0.75,
double smoothing_factor_rot = 0.9 )

Use sensor-view camera control that follows a given sensor pose.

◆ use_topdown_camera_control()

std::shared_ptr< TopDownCameraControl > guik::LightViewerContext::use_topdown_camera_control ( double distance = 80.0,
double theta = 0.0 )

Use top-down camera control useful for 2D SLAM.

◆ view_matrix()

Eigen::Matrix4f guik::LightViewerContext::view_matrix ( ) const
inline

Get view matrix.

Member Data Documentation

◆ canvas

std::unique_ptr<guik::GLCanvas> guik::LightViewerContext::canvas
protected

GL canvas.

◆ canvas_rect_max

Eigen::Vector2i guik::LightViewerContext::canvas_rect_max
protected

Bottom-right corner of the canvas rectangle.

◆ canvas_rect_min

Eigen::Vector2i guik::LightViewerContext::canvas_rect_min
protected

Top-left corner of the canvas rectangle.

◆ context_name

std::string guik::LightViewerContext::context_name
protected

Viewer context name.

◆ decimal_rendering

bool guik::LightViewerContext::decimal_rendering
protected

◆ draw_xy_grid

bool guik::LightViewerContext::draw_xy_grid
protected

◆ drawable_filters

std::unordered_map<std::string, std::function<bool(const std::string&)> > guik::LightViewerContext::drawable_filters
protected

◆ drawables

std::unordered_map<std::string, std::pair<ShaderSetting::Ptr, glk::Drawable::ConstPtr> > guik::LightViewerContext::drawables
protected

◆ global_shader_setting

guik::ShaderSetting guik::LightViewerContext::global_shader_setting
protected

Global shader setting.

◆ last_projection_view_matrix

Eigen::Matrix4f guik::LightViewerContext::last_projection_view_matrix
protected

◆ show_window

bool guik::LightViewerContext::show_window
protected

◆ sub_texts

std::deque<std::string> guik::LightViewerContext::sub_texts
protected

◆ sub_texts_mutex

std::mutex guik::LightViewerContext::sub_texts_mutex
protected

◆ sub_ui_callbacks

std::vector<std::pair<std::string, std::function<void()> > > guik::LightViewerContext::sub_ui_callbacks
protected

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