gtsam_points
Loading...
Searching...
No Matches
light_viewer.hpp
Go to the documentation of this file.
1#ifndef GUIK_VIEWER_HPP
2#define GUIK_VIEWER_HPP
3
4#include <mutex>
5#include <deque>
6#include <memory>
7#include <unordered_map>
8
9#include <glk/drawable.hpp>
10#include <guik/gl_canvas.hpp>
15
16namespace guik {
17
18struct PlotData;
19struct PlotStyle;
20using PlotDataConstPtr = std::shared_ptr<const PlotData>;
21using PlotStyleConstPtr = std::shared_ptr<const PlotStyle>;
22
24public:
26 virtual ~LightViewer();
27
28 static LightViewer* instance(const Eigen::Vector2i& size = Eigen::Vector2i(-1, -1), bool background = false, const std::string& title = "screen");
29 static void destroy();
30 static bool running();
31
34 virtual void register_ui_callback(const std::string& name, const std::function<void()>& callback = 0) override;
35
36 // Invoke a task in the visualization thread
37 void invoke(const std::function<void()>& func);
38 // Invoke a task after rendering in the visualization thread
39 void invoke_after_rendering(const std::function<void()>& func);
40 // Invoke a labeled task only once
41 void invoke_once(const std::string& label, const std::function<void()>& func);
42
43 virtual void clear() override;
44 virtual void clear_text() override;
45 virtual void append_text(const std::string& text) override;
47
49 void remove_image(const std::string& name);
50 void update_image(const std::string& name, const std::shared_ptr<glk::Texture>& image, double scale = -1.0, int order = -1);
51
52 std::shared_ptr<LightViewerContext> sub_viewer(const std::string& context_name, const Eigen::Vector2i& canvas_size = Eigen::Vector2i(-1, -1));
53
54 void show_sub_viewers(); // Set all sub viewer windows to be opened
55 std::shared_ptr<LightViewerContext> find_sub_viewer(const std::string& context_name); // Returns nullptr if sub viewer does not exist
56 bool remove_sub_viewer(const std::string& context_name); // Returns false if sub viwewer does not exist
57
58 // Plotting methods
59 void clear_plots(bool clear_settings = true);
60 void remove_plot(const std::string& plot_name, const std::string& label = "");
61 void setup_plot(const std::string& plot_name, int width, int height, int plot_flags = 0, int x_flags = 0, int y_flags = 0, int order = -1);
62 void link_plot_axis(const std::string& plot_name, int link_id, int axis); // axis = ImAxis_X1 or ImAxis_X2, ...
63 void link_plot_axes(const std::string& plot_name, int link_id, int axes = -1); // axes = (1 << ImAxis_X1) | (1 << ImAxis_X2) ...
64 void setup_legend(const std::string& plot_name, int loc, int flags = 0);
65 void fit_plot(const std::string& plot_name);
67 void setup_plot_group_order(const std::string& group_name, int order);
68 void update_plot(const std::string& plot_name, const std::string& label, const std::shared_ptr<const PlotData>& plot);
69
70 // Plotting update methods
71 void update_plot_line(const std::string& plot_name, const std::string& label, const std::vector<double>& ys, int line_flags = 0, size_t max_num_data = 8192 * 12);
73 const std::string& plot_name,
74 const std::string& label,
75 const std::vector<double>& xs,
76 const std::vector<double>& ys,
77 int line_flags = 0,
78 size_t max_num_data = 8192 * 12);
79 void update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<double>& ys, int scatter_flags = 0);
80 void update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<double>& xs, const std::vector<double>& ys, int scatter_flags = 0);
81 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<double>& ys, int stairs_flags = 0);
82 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<double>& xs, const std::vector<double>& ys, int stairs_flags = 0);
84 const std::string& plot_name,
85 const std::string& label,
86 const std::vector<double>& xs,
87 int bins = -2,
88 const Eigen::Vector2d& range = Eigen::Vector2d(0.0, 0.0),
89 int histogram_flags = 0);
91 const std::string& plot_name,
92 const std::string& label,
93 const std::vector<double>& xs,
94 const std::vector<double>& ys,
95 int x_bins = -2,
96 int y_bins = -2,
97 const Eigen::Vector2d& x_range = Eigen::Vector2d(0.0, 0.0),
98 const Eigen::Vector2d& y_range = Eigen::Vector2d(0.0, 0.0),
99 int histogram_flags = 0);
100
101 // Plotting update template methods
102 template <typename T>
103 auto update_plot_line(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int line_flags = 0, size_t max_num_data = 8192 * 12)
104 -> std::enable_if_t<std::is_arithmetic_v<T>, void>;
105 template <typename T1, typename T2>
106 void update_plot_line(
107 const std::string& plot_name,
108 const std::string& label,
109 const std::vector<T1>& xs,
110 const std::vector<T2>& ys,
111 int line_flags = 0,
112 size_t max_num_data = 8192 * 12);
113 template <typename T, int D, typename Alloc>
114 void update_plot_line(
115 const std::string& plot_name,
116 const std::string& label,
117 const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data,
118 int line_flags = 0,
119 size_t max_num_data = 8192 * 12);
120 template <typename T, typename Func>
121 auto
122 update_plot_line(const std::string& plot_name, const std::string& label, const std::vector<T>& data, const Func& transform, int line_flags = 0, size_t max_num_data = 8192 * 12)
123 -> std::enable_if_t<!std::is_arithmetic_v<decltype(transform(data[0]))>, void> {
124 std::vector<double> xs(data.size());
125 std::vector<double> ys(data.size());
126 for (size_t i = 0; i < data.size(); i++) {
127 const auto pt = transform(data[i]);
128 xs[i] = pt[0];
129 ys[i] = pt[1];
130 }
131 update_plot_line(plot_name, label, xs, ys, line_flags, max_num_data);
132 }
133 template <typename T, typename Func>
134 auto
135 update_plot_line(const std::string& plot_name, const std::string& label, const std::vector<T>& data, const Func& transform, int line_flags = 0, size_t max_num_data = 8192 * 12)
136 -> std::enable_if_t<std::is_arithmetic_v<decltype(transform(data[0]))>, void> {
137 std::vector<double> xs(data.size());
138 std::vector<double> ys(data.size());
139 for (size_t i = 0; i < data.size(); i++) {
140 const auto pt = transform(data[i]);
141 xs[i] = i;
142 ys[i] = pt;
143 }
144 update_plot_line(plot_name, label, xs, ys, line_flags, max_num_data);
145 }
146
147 template <typename T>
148 auto update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int scatter_flags = 0)
149 -> std::enable_if_t<std::is_arithmetic_v<T>, void>;
150 template <typename T1, typename T2>
151 void update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<T1>& xs, const std::vector<T2>& ys, int scatter_flags = 0);
152 template <typename T, int D, typename Alloc>
153 void update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data, int scatter_flags = 0);
154 template <typename T, typename Func>
156 const std::string& plot_name,
157 const std::string& label,
158 const std::vector<T>& data,
159 const Func& transform,
160 int scatter_flags = 0,
161 size_t max_num_data = 8192 * 12) -> std::enable_if_t<!std::is_arithmetic_v<decltype(transform(data[0]))>, void> {
162 std::vector<double> xs(data.size());
163 std::vector<double> ys(data.size());
164 for (size_t i = 0; i < data.size(); i++) {
165 const auto pt = transform(data[i]);
166 xs[i] = pt[0];
167 ys[i] = pt[1];
168 }
169 update_plot_scatter(plot_name, label, xs, ys, scatter_flags);
170 }
171 template <typename T, typename Func>
173 const std::string& plot_name,
174 const std::string& label,
175 const std::vector<T>& data,
176 const Func& transform,
177 int scatter_flags = 0,
178 size_t max_num_data = 8192 * 12) -> std::enable_if_t<std::is_arithmetic_v<decltype(transform(data[0]))>, void> {
179 std::vector<double> xs(data.size());
180 std::vector<double> ys(data.size());
181 for (size_t i = 0; i < data.size(); i++) {
182 const auto pt = transform(data[i]);
183 xs[i] = i;
184 ys[i] = pt;
185 }
186 update_plot_scatter(plot_name, label, xs, ys, scatter_flags);
187 }
188
189 template <typename T>
190 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int stairs_flags = 0);
191 template <typename T1, typename T2>
192 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T1>& xs, const std::vector<T2>& ys, int stairs_flags = 0);
193 template <typename T, int D, typename Alloc>
194 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data, int stairs_flags = 0);
195 template <typename T, typename Func>
196 void update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T>& data, const Func& transform, int stairs_flags = 0);
197
198 template <typename T>
200 const std::string& plot_name,
201 const std::string& label,
202 const std::vector<T>& xs,
203 int bins = -2,
204 const Eigen::Vector2d& range = Eigen::Vector2d(0.0, 0.0),
205 int histogram_flags = 0);
206 template <typename T1, typename T2>
208 const std::string& plot_name,
209 const std::string& label,
210 const std::vector<T1>& xs,
211 const std::vector<T2>& ys,
212 int x_bins = -2,
213 int y_bins = -2,
214 const Eigen::Vector2d& x_range = Eigen::Vector2d(0.0, 0.0),
215 const Eigen::Vector2d& y_range = Eigen::Vector2d(0.0, 0.0),
216 int histogram_flags = 0);
217 template <typename T, int D, typename Alloc>
219 const std::string& plot_name,
220 const std::string& label,
221 const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data,
222 int x_bins = -2,
223 int y_bins = -2,
224 const Eigen::Vector2d& x_range = Eigen::Vector2d(0.0, 0.0),
225 const Eigen::Vector2d& y_range = Eigen::Vector2d(0.0, 0.0),
226 int histogram_flags = 0);
227 template <typename T, typename Func>
229 const std::string& plot_name,
230 const std::string& label,
231 const std::vector<T>& data,
232 const Func& transform,
233 int x_bins = -2,
234 int y_bins = -2,
235 const Eigen::Vector2d& x_range = Eigen::Vector2d(0.0, 0.0),
236 const Eigen::Vector2d& y_range = Eigen::Vector2d(0.0, 0.0),
237 int histogram_flags = 0);
238
239 // Plotting style methods
240 void set_plot_style(const std::string& plot_name, const std::string& label, const PlotStyleConstPtr& style);
241 void set_line_style(const std::string& plot_name, const std::string& label, const Eigen::Vector4f& color = Eigen::Vector4f(0, 0, 0, -1), float weight = -1);
243 const std::string& plot_name,
244 const std::string& label,
245 int marker = 0,
246 float size = -1,
247 const Eigen::Vector4f& fill = Eigen::Vector4f(0, 0, 0, -1),
248 float weight = -1,
249 const Eigen::Vector4f& outline = Eigen::Vector4f(0, 0, 0, -1));
250
253
254private:
255 class ViewerUI;
256 class InfoWindow;
257
258 virtual bool init(const Eigen::Vector2i& size, const char* glsl_version, bool background, const std::string& title) override;
259 virtual void framebuffer_size_callback(const Eigen::Vector2i& size) override;
260
261 virtual void draw_ui() override;
262 virtual void draw_gl() override;
263
264private:
265 static std::unique_ptr<LightViewer> inst;
266
267 std::unique_ptr<ViewerUI> viewer_ui;
268 std::unique_ptr<InfoWindow> info_window;
269
270 std::mutex texts_mutex;
271 int max_texts_size;
272 std::deque<std::string> texts;
273
274 bool toggle_spin_stop_flag;
275
276 std::unordered_map<std::string, std::function<void()>> ui_callbacks;
277
278 std::unordered_map<std::string, std::tuple<double, std::shared_ptr<glk::Texture>, int>> images;
279 std::vector<std::shared_ptr<glk::Texture>> images_in_rendering;
280
281 std::unordered_map<int, Eigen::Matrix<double, 6, 2>> plot_linked_axis_limits;
282 std::unordered_map<std::string, PlotSetting> plot_settings;
283 std::unordered_map<std::string, int> plot_group_orders;
284 std::unordered_map<std::string, std::vector<std::pair<PlotStyleConstPtr, PlotDataConstPtr>>> plot_data;
285
286 std::unordered_map<std::string, std::shared_ptr<LightViewerContext>> sub_contexts;
287
288 std::mutex invoke_requests_mutex;
289 std::deque<std::function<void()>> invoke_requests;
290 std::unordered_set<std::string> invoke_once_called;
291
292 std::mutex post_render_invoke_requests_mutex;
293 std::deque<std::function<void()>> post_render_invoke_requests;
294};
295
296inline LightViewer* viewer(const Eigen::Vector2i& size = Eigen::Vector2i(-1, -1), bool background = false, const std::string& title = "screen") {
297 return LightViewer::instance(size, background, title);
298}
299
300inline LightViewer* viewer(const std::string& title, const Eigen::Vector2i& size = Eigen::Vector2i(-1, -1), bool background = false) {
301 return LightViewer::instance(size, background, title);
302}
303
304inline void destroy() {
306}
307
308inline bool running() {
309 return LightViewer::running();
310}
311
312// Template methods
313
314template <typename T>
315auto LightViewer::update_plot_line(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int line_flags, size_t max_num_data)
316 -> std::enable_if_t<std::is_arithmetic_v<T>, void> {
317 std::vector<double> ys_(ys.size());
318 std::copy(ys.begin(), ys.end(), ys_.begin());
319 update_plot_line(plot_name, label, ys_, line_flags, max_num_data);
320}
321
322template <typename T1, typename T2>
324 const std::string& plot_name,
325 const std::string& label,
326 const std::vector<T1>& xs,
327 const std::vector<T2>& ys,
328 int line_flags,
329 size_t max_num_data) {
330 std::vector<double> xs_(xs.size());
331 std::vector<double> ys_(ys.size());
332 std::copy(xs.begin(), xs.end(), xs_.begin());
333 std::copy(ys.begin(), ys.end(), ys_.begin());
334 update_plot_line(plot_name, label, xs_, ys_, line_flags, max_num_data);
335}
336
337template <typename T, int D, typename Alloc>
339 const std::string& plot_name,
340 const std::string& label,
341 const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data,
342 int line_flags,
343 size_t max_num_data) {
344 std::vector<double> xs(data.size());
345 std::vector<double> ys(data.size());
346 std::transform(data.begin(), data.end(), xs.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[0]; });
347 std::transform(data.begin(), data.end(), ys.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[1]; });
348 update_plot_line(plot_name, label, xs, ys, line_flags, max_num_data);
349}
350
351template <typename T>
352auto LightViewer::update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int scatter_flags)
353 -> std::enable_if_t<std::is_arithmetic_v<T>, void> {
354 std::vector<double> ys_(ys.size());
355 std::copy(ys.begin(), ys.end(), ys_.begin());
356 update_plot_scatter(plot_name, label, ys_, scatter_flags);
357}
358
359template <typename T1, typename T2>
360void LightViewer::update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<T1>& xs, const std::vector<T2>& ys, int scatter_flags) {
361 std::vector<double> xs_(xs.size());
362 std::vector<double> ys_(ys.size());
363 std::copy(xs.begin(), xs.end(), xs_.begin());
364 std::copy(ys.begin(), ys.end(), ys_.begin());
365 update_plot_scatter(plot_name, label, xs_, ys_, scatter_flags);
366}
367
368template <typename T, int D, typename Alloc>
369void LightViewer::update_plot_scatter(const std::string& plot_name, const std::string& label, const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data, int scatter_flags) {
370 std::vector<double> xs(data.size());
371 std::vector<double> ys(data.size());
372 std::transform(data.begin(), data.end(), xs.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[0]; });
373 std::transform(data.begin(), data.end(), ys.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[1]; });
374 update_plot_scatter(plot_name, label, xs, ys, scatter_flags);
375}
376
377template <typename T>
378void LightViewer::update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T>& ys, int stairs_flags) {
379 std::vector<double> ys_(ys.size());
380 std::copy(ys.begin(), ys.end(), ys_.begin());
381 update_plot_stairs(plot_name, label, ys_, stairs_flags);
382}
383
384template <typename T1, typename T2>
385void LightViewer::update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T1>& xs, const std::vector<T2>& ys, int stairs_flags) {
386 std::vector<double> xs_(xs.size());
387 std::vector<double> ys_(ys.size());
388 std::copy(xs.begin(), xs.end(), xs_.begin());
389 std::copy(ys.begin(), ys.end(), ys_.begin());
390 update_plot_stairs(plot_name, label, xs_, ys_, stairs_flags);
391}
392
393template <typename T, int D, typename Alloc>
394void LightViewer::update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data, int stairs_flags) {
395 std::vector<double> xs(data.size());
396 std::vector<double> ys(data.size());
397 std::transform(data.begin(), data.end(), xs.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[0]; });
398 std::transform(data.begin(), data.end(), ys.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[1]; });
399 update_plot_stairs(plot_name, label, xs, ys, stairs_flags);
400}
401
402template <typename T, typename Func>
403void LightViewer::update_plot_stairs(const std::string& plot_name, const std::string& label, const std::vector<T>& data, const Func& transform, int stairs_flags) {
404 std::vector<double> xs(data.size());
405 std::vector<double> ys(data.size());
406 for (size_t i = 0; i < data.size(); i++) {
407 const auto pt = transform(data[i], xs[i], ys[i]);
408 xs[i] = pt[0];
409 ys[i] = pt[1];
410 }
411 update_plot_stairs(plot_name, label, xs, ys, stairs_flags);
412}
413
414template <typename T>
416 const std::string& plot_name,
417 const std::string& label,
418 const std::vector<T>& xs,
419 int bins,
420 const Eigen::Vector2d& range,
421 int histogram_flags) {
422 std::vector<double> xs_(xs.size());
423 std::copy(xs.begin(), xs.end(), xs_.begin());
424 update_plot_histogram(plot_name, label, xs_, bins, range, histogram_flags);
425}
426
427template <typename T1, typename T2>
429 const std::string& plot_name,
430 const std::string& label,
431 const std::vector<T1>& xs,
432 const std::vector<T2>& ys,
433 int x_bins,
434 int y_bins,
435 const Eigen::Vector2d& x_range,
436 const Eigen::Vector2d& y_range,
437 int histogram_flags) {
438 std::vector<double> xs_(xs.size());
439 std::vector<double> ys_(ys.size());
440 std::copy(xs.begin(), xs.end(), xs_.begin());
441 std::copy(ys.begin(), ys.end(), ys_.begin());
442 update_plot_histogram(plot_name, label, xs_, ys_, x_bins, y_bins, x_range, y_range, histogram_flags);
443}
444
445template <typename T, int D, typename Alloc>
447 const std::string& plot_name,
448 const std::string& label,
449 const std::vector<Eigen::Matrix<T, D, 1>, Alloc>& data,
450 int x_bins,
451 int y_bins,
452 const Eigen::Vector2d& x_range,
453 const Eigen::Vector2d& y_range,
454 int histogram_flags) {
455 std::vector<double> xs(data.size());
456 std::vector<double> ys(data.size());
457 std::transform(data.begin(), data.end(), xs.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[0]; });
458 std::transform(data.begin(), data.end(), ys.begin(), [](const Eigen::Matrix<T, D, 1>& v) { return v[1]; });
459 update_plot_histogram(plot_name, label, xs, ys, x_bins, y_bins, x_range, y_range, histogram_flags);
460}
461
462template <typename T, typename Func>
464 const std::string& plot_name,
465 const std::string& label,
466 const std::vector<T>& data,
467 const Func& transform,
468 int x_bins,
469 int y_bins,
470 const Eigen::Vector2d& x_range,
471 const Eigen::Vector2d& y_range,
472 int histogram_flags) {
473 std::vector<double> xs(data.size());
474 std::vector<double> ys(data.size());
475 for (size_t i = 0; i < data.size(); i++) {
476 const auto pt = transform(data[i], xs[i], ys[i]);
477 xs[i] = pt[0];
478 ys[i] = pt[1];
479 }
480 update_plot_histogram(plot_name, label, xs, ys, x_bins, y_bins, x_range, y_range, histogram_flags);
481}
482
483} // namespace guik
484
485#endif
Definition imgui_application.hpp:12
Definition light_viewer_context.hpp:34
std::string context_name
Definition light_viewer_context.hpp:254
Eigen::Vector2i canvas_size() const
Definition light_viewer_context.hpp:129
Definition info_window.hpp:9
Definition viewer_ui.hpp:11
Definition light_viewer.hpp:23
virtual void clear_text() override
void invoke_after_rendering(const std::function< void()> &func)
auto update_plot_line(const std::string &plot_name, const std::string &label, const std::vector< T > &data, const Func &transform, int line_flags=0, size_t max_num_data=8192 *12) -> std::enable_if_t< std::is_arithmetic_v< decltype(transform(data[0]))>, void >
Definition light_viewer.hpp:135
void update_plot_scatter(const std::string &plot_name, const std::string &label, const std::vector< double > &xs, const std::vector< double > &ys, int scatter_flags=0)
void update_plot_histogram(const std::string &plot_name, const std::string &label, const std::vector< double > &xs, const std::vector< double > &ys, int x_bins=-2, int y_bins=-2, const Eigen::Vector2d &x_range=Eigen::Vector2d(0.0, 0.0), const Eigen::Vector2d &y_range=Eigen::Vector2d(0.0, 0.0), int histogram_flags=0)
void set_line_style(const std::string &plot_name, const std::string &label, const Eigen::Vector4f &color=Eigen::Vector4f(0, 0, 0, -1), float weight=-1)
bool remove_sub_viewer(const std::string &context_name)
void set_scatter_style(const std::string &plot_name, const std::string &label, int marker=0, float size=-1, const Eigen::Vector4f &fill=Eigen::Vector4f(0, 0, 0, -1), float weight=-1, const Eigen::Vector4f &outline=Eigen::Vector4f(0, 0, 0, -1))
std::shared_ptr< LightViewerContext > find_sub_viewer(const std::string &context_name)
void update_plot_line(const std::string &plot_name, const std::string &label, const std::vector< double > &xs, const std::vector< double > &ys, int line_flags=0, size_t max_num_data=8192 *12)
void update_plot_stairs(const std::string &plot_name, const std::string &label, const std::vector< double > &ys, int stairs_flags=0)
void setup_legend(const std::string &plot_name, int loc, int flags=0)
virtual void append_text(const std::string &text) override
void link_plot_axes(const std::string &plot_name, int link_id, int axes=-1)
void invoke_once(const std::string &label, const std::function< void()> &func)
void update_image(const std::string &name, const std::shared_ptr< glk::Texture > &image, double scale=-1.0, int order=-1)
std::shared_ptr< LightViewerContext > sub_viewer(const std::string &context_name, const Eigen::Vector2i &canvas_size=Eigen::Vector2i(-1, -1))
static void destroy()
static bool running()
void invoke(const std::function< void()> &func)
void update_plot_line(const std::string &plot_name, const std::string &label, const std::vector< double > &ys, int line_flags=0, size_t max_num_data=8192 *12)
auto update_plot_scatter(const std::string &plot_name, const std::string &label, const std::vector< T > &data, const Func &transform, int scatter_flags=0, size_t max_num_data=8192 *12) -> std::enable_if_t< std::is_arithmetic_v< decltype(transform(data[0]))>, void >
Definition light_viewer.hpp:172
void fit_plot(const std::string &plot_name)
static LightViewer * instance(const Eigen::Vector2i &size=Eigen::Vector2i(-1, -1), bool background=false, const std::string &title="screen")
void setup_plot(const std::string &plot_name, int width, int height, int plot_flags=0, int x_flags=0, int y_flags=0, int order=-1)
void set_max_text_buffer_size(int size)
auto update_plot_line(const std::string &plot_name, const std::string &label, const std::vector< T > &data, const Func &transform, int line_flags=0, size_t max_num_data=8192 *12) -> std::enable_if_t<!std::is_arithmetic_v< decltype(transform(data[0]))>, void >
Definition light_viewer.hpp:122
void clear_plots(bool clear_settings=true)
void update_plot_scatter(const std::string &plot_name, const std::string &label, const std::vector< double > &ys, int scatter_flags=0)
void update_plot_histogram(const std::string &plot_name, const std::string &label, const std::vector< double > &xs, int bins=-2, const Eigen::Vector2d &range=Eigen::Vector2d(0.0, 0.0), int histogram_flags=0)
void remove_plot(const std::string &plot_name, const std::string &label="")
void remove_image(const std::string &name)
auto update_plot_scatter(const std::string &plot_name, const std::string &label, const std::vector< T > &data, const Func &transform, int scatter_flags=0, size_t max_num_data=8192 *12) -> std::enable_if_t<!std::is_arithmetic_v< decltype(transform(data[0]))>, void >
Definition light_viewer.hpp:155
void set_plot_style(const std::string &plot_name, const std::string &label, const PlotStyleConstPtr &style)
void update_plot_stairs(const std::string &plot_name, const std::string &label, const std::vector< double > &xs, const std::vector< double > &ys, int stairs_flags=0)
virtual void register_ui_callback(const std::string &name, const std::function< void()> &callback=0) override
void update_plot(const std::string &plot_name, const std::string &label, const std::shared_ptr< const PlotData > &plot)
virtual ~LightViewer()
virtual void clear() override
void setup_plot_group_order(const std::string &group_name, int order)
void link_plot_axis(const std::string &plot_name, int link_id, int axis)
Definition drawable_container.hpp:9
void destroy()
Definition light_viewer.hpp:304
LightViewer * viewer(const Eigen::Vector2i &size=Eigen::Vector2i(-1, -1), bool background=false, const std::string &title="screen")
Definition light_viewer.hpp:296
std::shared_ptr< const PlotData > PlotDataConstPtr
Definition light_viewer.hpp:20
std::shared_ptr< const PlotStyle > PlotStyleConstPtr
Definition light_viewer.hpp:21
bool running()
Definition light_viewer.hpp:308