1#ifndef GUIK_ASYNC_LIGHT_VIEWER_CONTEXT_HPP
2#define GUIK_ASYNC_LIGHT_VIEWER_CONTEXT_HPP
30 void set_point_shape(
float point_size = 1.0f,
bool metric =
true,
bool circle =
true);
43 void lookat(
const Eigen::Vector3f& pt);
44 template <
typename Vector>
46 const auto ptf = pt.eval().template cast<float>();
60 template <
typename Scalar,
int Dim>
61 void update_points(
const std::string& name,
const Eigen::Matrix<Scalar, Dim, 1>* points,
int num_points,
const ShaderSetting& shader_setting);
62 template <
typename Scalar,
int Dim,
typename Allocator>
63 void update_points(
const std::string& name,
const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Allocator>& points,
const ShaderSetting& shader_setting);
65 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);
66 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
68 const std::string& name,
69 const Eigen::Matrix<ScalarV, DimV, 1>* points,
70 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
73 template <
typename ScalarV,
int DimV,
typename AllocatorV,
typename ScalarC,
int DimC,
typename AllocatorC>
75 const std::string& name,
76 const std::vector<Eigen::Matrix<ScalarV, DimV, 1>, AllocatorV>& points,
77 const std::vector<Eigen::Matrix<ScalarC, DimC, 1>, AllocatorC>& colors,
81 template <
typename Scalar,
int Dim>
83 const std::string& name,
84 const Eigen::Matrix<Scalar, Dim, 1>* points,
85 const Eigen::Matrix<Scalar, Dim, Dim>* covs,
90 template <
typename Scalar,
int Dim,
typename Alloc1,
typename Alloc2>
92 const std::string& name,
93 const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Alloc1>& points,
94 const std::vector<Eigen::Matrix<Scalar, Dim, Dim>, Alloc2>& covs,
100 const std::string& name,
101 const float* vertices,
104 const unsigned int* indices,
109 template <
typename Scalar,
int Dim>
110 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);
112 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
114 const std::string& name,
115 const Eigen::Matrix<ScalarV, DimV, 1>* points,
116 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
121 template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
123 const std::string& name,
124 const Eigen::Matrix<ScalarV, DimV, 1>* points,
125 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
127 const unsigned int* indices,
132 template <
typename Po
int,
typename Alloc>
135 template <
typename Po
int,
typename Alloc>
137 const std::string& name,
138 const std::vector<Point, Alloc>& points,
139 const std::vector<unsigned int>& indices,
143 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
145 const std::string& name,
146 const std::vector<Point, AllocP>& points,
147 const std::vector<Color, AllocC>& colors,
151 template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
153 const std::string& name,
154 const std::vector<Point, AllocP>& points,
155 const std::vector<Color, AllocC>& colors,
156 const std::vector<unsigned int>& indices,
180template <
typename Scalar,
int Dim>
182 if constexpr (std::is_same<Scalar, float>::value) {
183 return update_points(name,
reinterpret_cast<const float*
>(points),
sizeof(
float) * Dim, num_points, shader_setting);
186 return update_points(name, points_3f.data(), num_points, shader_setting);
190template <
typename Scalar,
int Dim,
typename Allocator>
192 return update_points(name, points.data(), points.size(), shader_setting);
195template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
197 const std::string& name,
198 const Eigen::Matrix<ScalarV, DimV, 1>* points,
199 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
202 if constexpr (std::is_same<ScalarV, float>::value && std::is_same<ScalarC, float>::value) {
205 reinterpret_cast<const float*
>(points),
206 sizeof(
float) * DimV,
207 reinterpret_cast<const float*
>(colors),
208 sizeof(
float) * DimC,
214 return update_points(name, points_3f.data(), colors_4f.data(), num_points, shader_setting);
218template <
typename ScalarV,
int DimV,
typename AllocatorV,
typename ScalarC,
int DimC,
typename AllocatorC>
220 const std::string& name,
221 const std::vector<Eigen::Matrix<ScalarV, DimV, 1>, AllocatorV>& points,
222 const std::vector<Eigen::Matrix<ScalarC, DimC, 1>, AllocatorC>& colors,
224 return update_points(name, points.data(), colors.data(), points.size(), shader_setting);
228template <
typename Scalar,
int Dim,
typename Alloc1,
typename Alloc2>
230 const std::string& name,
231 const std::vector<Eigen::Matrix<Scalar, Dim, 1>, Alloc1>& points,
232 const std::vector<Eigen::Matrix<Scalar, Dim, Dim>, Alloc2>& covs,
235 update_normal_dists(name, points.data(), covs.data(), points.size(), scale, shader_setting);
239template <
typename Scalar,
int Dim>
241 const std::string& name,
242 const Eigen::Matrix<Scalar, Dim, 1>* points,
246 if constexpr (std::is_same<Scalar, float>::value && Dim == 3) {
247 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
nullptr, num_points,
nullptr, 0, line_strip, shader_setting);
250 return update_thin_lines(name, points_3f.data(), num_points, line_strip, shader_setting);
254template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
256 const std::string& name,
257 const Eigen::Matrix<ScalarV, DimV, 1>* points,
258 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
262 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
263 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
reinterpret_cast<const float*
>(colors), num_points,
nullptr, 0, line_strip, shader_setting);
267 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, line_strip, shader_setting);
271template <
typename ScalarV,
int DimV,
typename ScalarC,
int DimC>
273 const std::string& name,
274 const Eigen::Matrix<ScalarV, DimV, 1>* points,
275 const Eigen::Matrix<ScalarC, DimC, 1>* colors,
277 const unsigned int* indices,
281 if constexpr (std::is_same<ScalarV, float>::value && DimV == 3 && std::is_same<ScalarC, float>::value && DimC == 4) {
282 return update_thin_lines(name,
reinterpret_cast<const float*
>(points),
reinterpret_cast<const float*
>(colors), num_points, indices, num_indices, line_strip, shader_setting);
286 return update_thin_lines(name, points_3f.data(), colors_4f.data(), num_points, indices, num_indices, line_strip, shader_setting);
290template <
typename Po
int,
typename Alloc>
292 return update_thin_lines(name, points.data(), points.size(), line_strip, shader_setting);
295template <
typename Po
int,
typename Alloc>
297 const std::string& name,
298 const std::vector<Point, Alloc>& points,
299 const std::vector<unsigned int>& indices,
302 return update_thin_lines(name, points.data(),
static_cast<const Eigen::Vector4f*
>(
nullptr), points.size(), indices.data(), indices.size(), line_strip, shader_setting);
305template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
307 const std::string& name,
308 const std::vector<Point, AllocP>& points,
309 const std::vector<Color, AllocC>& colors,
312 return update_thin_lines(name, points.data(), colors.data(), points.size(), line_strip, shader_setting);
315template <
typename Po
int,
typename AllocP,
typename Color,
typename AllocC>
317 const std::string& name,
318 const std::vector<Point, AllocP>& points,
319 const std::vector<Color, AllocC>& colors,
320 const std::vector<unsigned int>& indices,
323 return update_thin_lines(name, points.data(), colors.data(), points.size(), indices.data(), indices.size(), line_strip, shader_setting);
Async interface to manipulate LightViewerContext. All OpenGL operations will be done in the viewer th...
Definition async_light_viewer_context.hpp:13
AsyncLightViewerContext(LightViewerContext *context)
void set_point_shape(float point_size=1.0f, bool metric=true, bool circle=true)
void update_wire_frustum(const std::string &name, const ShaderSetting &shader_setting)
void update_wire_cone(const std::string &name, const ShaderSetting &shader_setting)
void load_camera_settings(const std::string &path)
void use_orbit_camera_control(double distance=80.0, double theta=0.0, double phi=-60.0f *M_PI/180.0f)
void lookat(const Eigen::Vector3f &pt)
void use_topdown_camera_control(double distance=80.0, double theta=0.0)
void save_camera_settings(const std::string &path)
void remove_ui_callback(const std::string &name)
void use_orbit_camera_control_xz(double distance=80.0, double theta=0.0, double phi=0.0)
void append_text(const std::string &text)
void disable_xy_grid()
Definition async_light_viewer_context.hpp:25
void use_fps_camera_control(double fovy_deg=60.0)
void update_cone(const std::string &name, const ShaderSetting &shader_setting)
void update_wire_sphere(const std::string &name, const ShaderSetting &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 scale, const ShaderSetting &shader_setting)
void update_points(const std::string &name, const float *data, int stride, int num_points, const ShaderSetting &shader_setting)
AsyncLightViewerContext()
void update_drawable_setting(const std::string &name, const ShaderSetting &shader_setting)
void update_frustum(const std::string &name, const ShaderSetting &shader_setting)
void update_icosahedron(const std::string &name, const ShaderSetting &shader_setting)
void update_coord(const std::string &name, const ShaderSetting &shader_setting)
void update_sphere(const std::string &name, const ShaderSetting &shader_setting)
void remove_drawable(const std::regex ®ex)
void save_depth_buffer(const std::string &filename, bool real_scale=true)
void set_colormap(glk::COLORMAP colormap)
~AsyncLightViewerContext()
void enable_xy_grid()
Definition async_light_viewer_context.hpp:26
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)
void update_wire_cube(const std::string &name, const ShaderSetting &shader_setting)
void remove_drawable(const std::string &name)
void register_ui_callback(const std::string &name, const std::function< void()> &callback=0)
void lookat(const Vector &pt)
Definition async_light_viewer_context.hpp:45
LightViewerContext * context
Definition async_light_viewer_context.hpp:175
void update_cube(const std::string &name, const ShaderSetting &shader_setting)
void set_draw_xy_grid(bool draw_xy_grid)
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)
void save_color_buffer(const std::string &filename)
void update_wire_icosahedron(const std::string &name, const ShaderSetting &shader_setting)
void clear_drawables(const std::function< bool(const std::string &)> &fn)
Definition light_viewer_context.hpp:34
COLORMAP
Definition colormap.hpp:9
std::enable_if_t< needs_aligned_allocator< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
Definition make_shared.hpp:20
Definition drawable_container.hpp:9
Shader setting class that holds rendering settings.
Definition shader_setting.hpp:187