1#ifndef GUIK_ASYNC_LIGHT_VIEWER_CONTEXT_HPP
2#define GUIK_ASYNC_LIGHT_VIEWER_CONTEXT_HPP
58 void set_point_shape(
float point_size = 1.0f,
bool metric =
true,
bool circle =
true);
82 void lookat(
const Eigen::Vector3f& pt);
84 template <
typename Vector>
86 const auto ptf = pt.eval().template cast<float>();
91 void lookat(
const Eigen::Isometry3f& T_world_sensor);
93 void lookat(
const Eigen::Isometry3d& T_world_sensor);
110 const Eigen::Isometry3f& T_sensor_camera = Eigen::Translation3f(-5.0f, 0.0f, 0.1f) * Eigen::Isometry3f::Identity(),
111 double smoothing_factor_trans = 0.75,
112 double smoothing_factor_rot = 0.9);
132 template <
typename Scalar,
int Dim>
133 void update_points(
const std::string& name,
const Eigen::Matrix<Scalar, Dim, 1>* points,
int num_points,
const ShaderSetting& shader_setting);
135 template <
typename Scalar,
int Dim,
typename Allocator>
136 void update_points(
const std::string& name,
const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Allocator>& points,
const ShaderSetting& shader_setting);
139 void update_points(
const std::string& name,
const float* vertices,
int vertex_stride,
const float* colors,
int color_stride,
int num_points,
const ShaderSetting& shader_setting);
141 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
143 const std::string& name,
144 const Eigen::Matrix<ScalarV, DimV, 1>* points,
145 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
149 template <
typename ScalarV,
int DimV,
typename AllocatorV,
typename ScalarC,
int DimC,
typename AllocatorC>
151 const std::string& name,
152 const std::vector<Eigen::Matrix<ScalarV, DimV, 1>, AllocatorV>& points,
153 const std::vector<Eigen::Matrix<ScalarC, DimC, 1>, AllocatorC>& colors,
164 template <
typename Scalar,
int Dim>
166 const std::string& name,
167 const Eigen::Matrix<Scalar, Dim, 1>* points,
168 const Eigen::Matrix<Scalar, Dim, Dim>* covs,
174 template <
typename Scalar,
int Dim,
typename Alloc1,
typename Alloc2>
176 const std::string& name,
177 const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Alloc1>& points,
178 const std::vector<Eigen::Matrix<Scalar, Dim, Dim>, Alloc2>& covs,
194 const std::string& name,
195 const float* vertices,
198 const unsigned int* indices,
205 const std::string& name,
206 const float* vertices,
209 const unsigned int* indices,
215 template <
typename Scalar,
int Dim>
216 void update_thin_lines(
const std::string& name,
const Eigen::Matrix<Scalar, Dim, 1>* points,
int num_points,
bool line_strip,
const ShaderSetting& shader_setting);
219 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
221 const std::string& name,
222 const Eigen::Matrix<ScalarV, DimV, 1>* points,
223 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
229 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
231 const std::string& name,
232 const Eigen::Matrix<ScalarV, DimV, 1>* points,
233 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
235 const unsigned int* indices,
241 template <
typename Po
int,
typename Alloc>
245 template <
typename Po
int,
typename Alloc>
247 const std::string& name,
248 const std::vector<Point, Alloc>& points,
249 const std::vector<unsigned int>& indices,
254 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
256 const std::string& name,
257 const std::vector<Point, AllocP>& points,
258 const std::vector<Color, AllocC>& colors,
263 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
265 const std::string& name,
266 const std::vector<Point, AllocP>& points,
267 const std::vector<Color, AllocC>& colors,
268 const std::vector<unsigned int>& indices,
273 template <
typename Scalar,
int Dim>
275 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);
278 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
280 const std::string& name,
281 const Eigen::Matrix<ScalarV, DimV, 1>* points,
282 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
289 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
291 const std::string& name,
292 const Eigen::Matrix<ScalarV, DimV, 1>* points,
293 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
295 const unsigned int* indices,
302 template <
typename Po
int,
typename Alloc>
303 void update_thin_lines(
const std::string& name,
const std::vector<Point, Alloc>& points,
bool line_strip,
float line_width,
const ShaderSetting& shader_setting);
306 template <
typename Po
int,
typename Alloc>
308 const std::string& name,
309 const std::vector<Point, Alloc>& points,
310 const std::vector<unsigned int>& indices,
316 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
318 const std::string& name,
319 const std::vector<Point, AllocP>& points,
320 const std::vector<Color, AllocC>& colors,
326 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
328 const std::string& name,
329 const std::vector<Point, AllocP>& points,
330 const std::vector<Color, AllocC>& colors,
331 const std::vector<unsigned int>& indices,
367template <
typename Scalar,
int Dim>
369 if constexpr (std::is_same<Scalar, float>::value) {
370 return update_points(name,
reinterpret_cast<const float*
>(points),
sizeof(
float) * Dim, num_points, shader_setting);
373 return update_points(name, points_3f.data(), num_points, shader_setting);
377template <
typename Scalar,
int Dim,
typename Allocator>
379 return update_points(name, points.data(), points.size(), shader_setting);
382template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
384 const std::string& name,
385 const Eigen::Matrix<ScalarV, DimV, 1>* points,
386 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
389 if constexpr (std::is_same<ScalarV, float>::value && std::is_same<ScalarC, float>::value) {
392 reinterpret_cast<const float*
>(points),
393 sizeof(
float) * DimV,
394 reinterpret_cast<const float*
>(colors),
395 sizeof(
float) * DimC,
401 return update_points(name, points_3f.data(), colors_4f.data(), num_points, shader_setting);
405template <
typename ScalarV,
int DimV,
typename AllocatorV,
typename ScalarC,
int DimC,
typename AllocatorC>
407 const std::string& name,
408 const std::vector<Eigen::Matrix<ScalarV, DimV, 1>, AllocatorV>& points,
409 const std::vector<Eigen::Matrix<ScalarC, DimC, 1>, AllocatorC>& colors,
411 return update_points(name, points.data(), colors.data(), points.size(), shader_setting);
415template <
typename Scalar,
int Dim,
typename Alloc1,
typename Alloc2>
417 const std::string& name,
418 const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Alloc1>& points,
419 const std::vector<Eigen::Matrix<Scalar, Dim, Dim>, Alloc2>& covs,
422 update_normal_dists(name, points.data(), covs.data(), points.size(), sigma, shader_setting);
426template <
typename Scalar,
int Dim>
428 const std::string& name,
429 const Eigen::Matrix<Scalar, Dim, 1>* points,
433 if constexpr (std::is_same<Scalar, float>::value && Dim == 3) {
434 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
nullptr, num_points,
nullptr, 0, line_strip, shader_setting);
437 return update_thin_lines(name, points_3f.data(), num_points, line_strip, shader_setting);
441template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
443 const std::string& name,
444 const Eigen::Matrix<ScalarV, DimV, 1>* points,
445 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
449 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
450 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
reinterpret_cast<const float*
>(colors), num_points,
nullptr, 0, line_strip, shader_setting);
454 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, line_strip, shader_setting);
458template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
460 const std::string& name,
461 const Eigen::Matrix<ScalarV, DimV, 1>* points,
462 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
464 const unsigned int* indices,
468 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
469 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
reinterpret_cast<const float*
>(colors), num_points, indices, num_indices, line_strip, shader_setting);
473 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, indices, num_indices, line_strip, shader_setting);
477template <
typename Po
int,
typename Alloc>
479 return update_thin_lines(name, points.data(), points.size(), line_strip, shader_setting);
482template <
typename Po
int,
typename Alloc>
484 const std::string& name,
485 const std::vector<Point, Alloc>& points,
486 const std::vector<unsigned int>& indices,
489 return update_thin_lines(name, points.data(),
static_cast<const Eigen::Vector4f*
>(
nullptr), points.size(), indices.data(), indices.size(), line_strip, shader_setting);
492template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
494 const std::string& name,
495 const std::vector<Point, AllocP>& points,
496 const std::vector<Color, AllocC>& colors,
499 return update_thin_lines(name, points.data(), colors.data(), points.size(), line_strip, shader_setting);
502template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
504 const std::string& name,
505 const std::vector<Point, AllocP>& points,
506 const std::vector<Color, AllocC>& colors,
507 const std::vector<unsigned int>& indices,
510 return update_thin_lines(name, points.data(), colors.data(), points.size(), indices.data(), indices.size(), line_strip, shader_setting);
514template <
typename Scalar,
int Dim>
516 const std::string& name,
517 const Eigen::Matrix<Scalar, Dim, 1>* points,
522 if constexpr (std::is_same<Scalar, float>::value && Dim == 3) {
523 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
nullptr, num_points,
nullptr, 0, line_strip, line_width, shader_setting);
526 return update_thin_lines(name, points_3f.data(), num_points, line_strip, line_width, shader_setting);
530template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
532 const std::string& name,
533 const Eigen::Matrix<ScalarV, DimV, 1>* points,
534 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
539 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
540 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
reinterpret_cast<const float*
>(colors), num_points,
nullptr, 0, line_strip, line_width, shader_setting);
544 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, line_strip, line_width, shader_setting);
548template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
550 const std::string& name,
551 const Eigen::Matrix<ScalarV, DimV, 1>* points,
552 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
554 const unsigned int* indices,
559 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
562 reinterpret_cast<const float*
>(points),
563 reinterpret_cast<const float*
>(colors),
573 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, indices, num_indices, line_strip, line_width, shader_setting);
577template <
typename Po
int,
typename Alloc>
579 const std::string& name,
580 const std::vector<Point, Alloc>& points,
584 return update_thin_lines(name, points.data(), points.size(), line_strip, line_width, shader_setting);
587template <
typename Po
int,
typename Alloc>
589 const std::string& name,
590 const std::vector<Point, Alloc>& points,
591 const std::vector<unsigned int>& indices,
598 static_cast<const Eigen::Vector4f*
>(
nullptr),
607template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
609 const std::string& name,
610 const std::vector<Point, AllocP>& points,
611 const std::vector<Color, AllocC>& colors,
615 return update_thin_lines(name, points.data(), colors.data(), points.size(), line_strip, line_width, shader_setting);
618template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
620 const std::string& name,
621 const std::vector<Point, AllocP>& points,
622 const std::vector<Color, AllocC>& colors,
623 const std::vector<unsigned int>& indices,
627 return update_thin_lines(name, points.data(), colors.data(), points.size(), indices.data(), indices.size(), line_strip, line_width, shader_setting);
AsyncLightViewerContext(LightViewerContext *context)
void clear()
Clear everything in the viewer (callbacks, filters, drawables, texts).
void set_point_shape(float point_size=1.0f, bool metric=true, bool circle=true)
Set point shape properties.
void update_wire_frustum(const std::string &name, const ShaderSetting &shader_setting)
Register or update a wireframe frustum primitive.
void update_wire_cone(const std::string &name, const ShaderSetting &shader_setting)
Register or update a wireframe cone primitive.
void 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 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 odomet...
void lookat(const Eigen::Vector3f &pt)
Make the camera look at a point.
void use_topdown_camera_control(double distance=80.0, double theta=0.0)
Use top-down camera control useful for 2D SLAM.
void save_camera_settings(const std::string &path)
Save camera settings to a file.
void set_backface_culling_range(const Eigen::Vector2f &range)
Set range of normal.z for backface culling.
void remove_ui_callback(const std::string &name)
Remove a UI callback function.
void 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 ...
void append_text(const std::string &text)
Append debug text to the viewer. This method is thread-safe.
void disable_xy_grid()
Disable XY grid drawing.
Definition async_light_viewer_context.hpp:34
void 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 TPS-like sensor-view camera control .
void use_fps_camera_control(double fovy_deg=60.0)
Use FPS game-like camera control.
void disable_partial_rendering()
Disable partial rendering.
void update_cone(const std::string &name, const ShaderSetting &shader_setting)
Register or update a cone primitive.
void use_orthographic_projection_control(float width=10.0f, float near_=1.0f, float far_=1000.0f)
Use orthographic projection control.
void update_wire_sphere(const std::string &name, const ShaderSetting &shader_setting)
Register or update a wireframe sphere primitive.
void 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.
AsyncLightViewerContext()
void update_drawable_setting(const std::string &name, const ShaderSetting &shader_setting)
Update a drawable's shader setting.
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.
void enable_partial_rendering(double clear_thresh=1e-6)
Enable partial rendering.
void update_frustum(const std::string &name, const ShaderSetting &shader_setting)
Register or update a frustum primitive.
void update_icosahedron(const std::string &name, const ShaderSetting &shader_setting)
Register or update an icosahedron primitive.
void update_coord(const std::string &name, const ShaderSetting &shader_setting)
Register or update a coordinate axes primitive.
void update_sphere(const std::string &name, const ShaderSetting &shader_setting)
Register or update a sphere primitive.
void remove_drawable(const std::regex ®ex)
Remove all drawables that match the given regex.
void save_depth_buffer(const std::string &filename, bool real_scale=true)
Save depth buffer to a file (PNG).
void use_perspective_projection_control(float fovy_deg=30.0f, float near_=1.0f, float far_=1000.0f)
Use perspective projection control.
void clear_drawables()
Clear all drawables.
void 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.
void set_colormap(glk::COLORMAP colormap)
Set colormap used for RAINBOW and VERTEX_COLORMAP modes.
~AsyncLightViewerContext()
void enable_xy_grid()
Enable XY grid drawing.
Definition async_light_viewer_context.hpp:36
void update_points(const std::string &name, const float *vertices, int vertex_stride, const float *colors, int color_stride, int num_points, const ShaderSetting &shader_setting)
Register or update a point cloud buffer with colors.
void lookat(const Eigen::Isometry3f &T_world_sensor)
Make the camera look at a transform.
void update_wire_cube(const std::string &name, const ShaderSetting &shader_setting)
Register or update a wireframe cube primitive.
void remove_drawable(const std::string &name)
Remove a drawable by name.
void register_ui_callback(const std::string &name, const std::function< void()> &callback=0)
Register a UI callback function.
void lookat(const Vector &pt)
Make the camera look at a point.
Definition async_light_viewer_context.hpp:85
LightViewerContext * context
Definition async_light_viewer_context.hpp:362
void clear_text()
Clear texts.
void update_cube(const std::string &name, const ShaderSetting &shader_setting)
Register or update a cube primitive.
void set_draw_xy_grid(bool draw_xy_grid)
Set enable/disable XY grid drawing.
void lookat(const Eigen::Isometry3d &T_world_sensor)
Make the camera look at a transform.
void 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)
void use_arcball_camera_control(double distance=80.0, double theta=0.0, double phi=-60.0f *M_PI/180.0f)
Use arcball camera control.
void enable_backface_culling()
Enable backface culling. Fragments with back-facing normals will not be rendered.
void disable_backface_culling()
Disable backface culling.
void save_color_buffer(const std::string &filename)
Save color buffer to an image file (PNG).
void update_wire_icosahedron(const std::string &name, const ShaderSetting &shader_setting)
Register or update a wireframe icosahedron primitive.
void clear_drawables(const std::function< bool(const std::string &)> &fn)
Clear drawables that satisfy the given condition.
Viewer context.
Definition light_viewer_context.hpp:37
std::enable_if_t< std::is_same< Dst_Scalar, Src_Scalar >::value, std::vector< Eigen::Matrix< Dst_Scalar, Dst_Rows, Dst_Cols >, Allocator< Eigen::Matrix< Dst_Scalar, Dst_Rows, Dst_Cols > > > > convert_to_vector(const Eigen::Matrix< Src_Scalar, Src_Rows, Src_Cols > *points, int num_points)
Definition type_conversion.hpp:49
COLORMAP
Definition colormap.hpp:9
Definition drawable_container.hpp:9
Shader setting class that holds rendering settings.
Definition shader_setting.hpp:187