cgv
Loading...
Searching...
No Matches
plot_base.cxx
1#include "plot_base.h"
2
3#include <algorithm>
4
5#include <cgv/math/ftransform.h>
6#include <cgv/media/color_scale.h>
7#include <cgv/render/attribute_array_binding.h>
8#include <cgv/render/color_scale.h>
9#include <cgv/render/shader_program.h>
10#include <cgv/signal/rebind.h>
11#include <libs/cgv_gl/gl/gl.h>
12#include <libs/cgv_gl/rectangle_renderer.h>
13#include <libs/tt_gl_font/tt_gl_font.h>
14
15namespace cgv {
16 namespace plot {
17
18std::vector<const char*> plot_base::font_names;
20
24
25plot_base::tick_batch_info::tick_batch_info(int _ai, int _aj, bool _primary, unsigned _first_vertex, unsigned _first_label)
26 : ai(_ai), aj(_aj), primary(_primary), first_vertex(_first_vertex), first_label(_first_label)
27{
28}
29domain_config::domain_config(unsigned dim, unsigned nr_attrs) : color(0.85f,0.85f,0.85f), axis_configs(dim+nr_attrs)
30{
31 show_domain = true;
32 fill = true;
33 reference_size = 0.001f;
36 label_font_size = 24.0f;
37 label_ffa = cgv::media::font::FFA_REGULAR;
38 show_title = true;
40 title_color = rgba(0.2f, 0.2f, 0.2f, 1.0f);
42 title_font_size = 36.0f;
43 title_ffa = cgv::media::font::FFA_REGULAR;
44 title_pos.zeros(dim);
45}
46
47plot_base_config::plot_base_config(const std::string& _name, unsigned dim) : name(_name)
48{
49 show_plot = true;
50 begin_sample = 0;
51 end_sample = size_t(-1);
52 ref_size = 8;
53 ref_color = rgb(1, 0, 0);
54 ref_opacity = 1.0f;
56 //point_halo_width = 1.0f;
57 //point_halo_color = rgba(0.5f, 0.5f, 0.5f, 1.0f);
59 stick_base_window = 0.0f;
61 bar_base_window = 0.0;
62 sub_plot_influence = SPI_ALL;
63 set_colors(ref_color.color);
65 set_sizes(ref_size.size);
66 configure_chart(CT_BAR_CHART);
67}
68void plot_base_config::configure_chart(ChartType chart_type)
69{
70 switch (chart_type) {
71 case CT_POINT :
72 case CT_LINE_CHART:
73 show_points = true;
74 show_sticks = false;
75 show_bars = false;
76 break;
77 case CT_BAR_CHART:
78 show_points = false;
79 show_sticks = false;
80 show_bars = true;
81 break;
82 }
83}
84void plot_base_config::set_colors(const rgb& base_color)
85{
86 ref_color.color = base_color;
87 if ((sub_plot_influence & SPI_POINT) != 0)
88 point_color.color = base_color;
89 if ((sub_plot_influence & SPI_POINT_HALO) != 0) {
91 hls_base.S() *= 0.6f;
92 point_halo_color.color = hls_base;
93 }
94 if ((sub_plot_influence & SPI_LINE) != 0)
95 line_color.color = 0.25f * rgb(1, 1, 1) + 0.75f * base_color;
96 if ((sub_plot_influence & SPI_LINE_HALO) != 0) {
98 hls_base.S() *= 0.6f;
99 line_halo_color.color = hls_base;
100 }
101 if ((sub_plot_influence & SPI_STICK) != 0)
102 stick_color.color = 0.25f * rgb(0, 0, 0) + 0.75f * base_color;
103 if ((sub_plot_influence & SPI_BAR) != 0)
104 bar_color.color = 0.5f * rgb(1, 1, 1) + 0.5f * base_color;
105 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
106 bar_outline_color.color = base_color;
107}
108void plot_base_config::set_color_indices(int idx)
109{
110 if ((sub_plot_influence & SPI_POINT) != 0)
111 point_color.color_idx = idx;
112 if ((sub_plot_influence & SPI_POINT_HALO) != 0)
113 point_halo_color.color_idx = idx;
114 if ((sub_plot_influence & SPI_LINE) != 0)
115 line_color.color_idx = idx;
116 if ((sub_plot_influence & SPI_LINE_HALO) != 0)
117 line_halo_color.color_idx = idx;
118 if ((sub_plot_influence & SPI_STICK) != 0)
119 stick_color.color_idx = idx;
120 if ((sub_plot_influence & SPI_BAR) != 0)
121 bar_color.color_idx = idx;
122 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
123 bar_outline_color.color_idx = idx;
124}
126{
127 ref_size.size = _size;
128 if ((sub_plot_influence & SPI_POINT) != 0)
129 point_size.size = _size;
130 if ((sub_plot_influence & SPI_POINT_HALO) != 0)
131 point_halo_width.size = 0.2f * _size;
132 if ((sub_plot_influence & SPI_LINE) != 0)
133 line_width.size = 0.5f * _size;
134 if ((sub_plot_influence & SPI_LINE_HALO) != 0)
135 line_halo_width.size = 0.1f * _size;
136 if ((sub_plot_influence & SPI_STICK) != 0)
137 stick_width.size = 0.4f * _size;
138 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
139 bar_outline_width.size = 0.2f * _size;
140}
141void plot_base_config::set_size_indices(int idx)
142{
143 if ((sub_plot_influence & SPI_POINT) != 0)
144 point_size.size_idx = idx;
145 if ((sub_plot_influence & SPI_POINT_HALO) != 0)
146 point_halo_width.size_idx = idx;
147 if ((sub_plot_influence & SPI_LINE) != 0)
148 line_width.size_idx = idx;
149 if ((sub_plot_influence & SPI_LINE_HALO) != 0)
150 line_halo_width.size_idx = idx;
151 if ((sub_plot_influence & SPI_STICK) != 0)
152 stick_width.size_idx = idx;
153 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
154 bar_outline_width.size_idx = idx;
155}
157{
158 ref_opacity = _opa;
159 if ((sub_plot_influence & SPI_POINT) != 0)
160 point_color.color.alpha() = _opa;
161 if ((sub_plot_influence & SPI_POINT_HALO) != 0)
162 point_halo_color.color.alpha() = _opa;
163 if ((sub_plot_influence & SPI_LINE) != 0)
164 line_color.color.alpha() = pow(_opa, 0.8f);
165 if ((sub_plot_influence & SPI_LINE_HALO) != 0)
166 line_halo_color.color.alpha() = _opa;
167 if ((sub_plot_influence & SPI_STICK) != 0)
168 stick_color.color.alpha() = pow(_opa, 0.9f);
169 if ((sub_plot_influence & SPI_BAR) != 0)
170 bar_outline_color.color.alpha() = pow(_opa, 0.7f);
171 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
172 bar_color.color.alpha() = pow(_opa, 0.7f);
173}
174void plot_base_config::set_opacity_indices(int idx)
175{
176 if ((sub_plot_influence & SPI_POINT) != 0)
177 point_color.opacity_idx = idx;
178 if ((sub_plot_influence & SPI_POINT_HALO) != 0)
179 point_halo_color.opacity_idx = idx;
180 if ((sub_plot_influence & SPI_LINE) != 0)
181 line_color.opacity_idx = idx;
182 if ((sub_plot_influence & SPI_LINE_HALO) != 0)
183 line_halo_color.opacity_idx = idx;
184 if ((sub_plot_influence & SPI_STICK) != 0)
185 stick_color.opacity_idx = idx;
186 if ((sub_plot_influence & SPI_BAR) != 0)
187 bar_outline_color.opacity_idx = idx;
188 if ((sub_plot_influence & SPI_BAR_OUTLINE) != 0)
189 bar_color.opacity_idx = idx;
190}
194
195attribute_source::attribute_source() : source(AS_NONE), pointer(0), offset(0), count(0), stride(0)
196{}
197attribute_source::attribute_source(int _sub_plot_index, size_t ai, size_t _count, size_t _stride) :
198 source(AS_SAMPLE_CONTAINER), sub_plot_index(_sub_plot_index), offset(ai), count(_count), stride(_stride) {}
199attribute_source::attribute_source(const float* _pointer, size_t _count, size_t _stride) :
200 source(AS_POINTER), pointer(_pointer), offset(0), count(_count), stride(_stride) {}
201attribute_source::attribute_source(const cgv::render::vertex_buffer* _vbo_ptr, size_t _offset, size_t _count, size_t _stride) :
202source(AS_VBO), vbo_ptr(_vbo_ptr), offset(_offset), count(_count), stride(_stride) {}
204{
205 source = as.source;
206 switch (source) {
207 case AS_NONE: pointer = 0; offset = count = stride = 0; break;
208 case AS_SAMPLE_CONTAINER: sub_plot_index = as.sub_plot_index; break;
209 case AS_POINTER: pointer = as.pointer; break;
210 case AS_VBO: vbo_ptr = as.vbo_ptr; break;
211 }
212 offset = as.offset;
213 count = as.count;
214 stride = as.stride;
215}
216attribute_source_array::attribute_source_array() : vbo(cgv::render::VBT_VERTICES, cgv::render::VBU_STREAM_DRAW)
217{
218 samples_out_of_date = true;
219 sources_out_of_date = true;
220 count = 0;
221}
222
223void plot_base::draw_rectangles(cgv::render::context& ctx, cgv::render::attribute_array_manager& aam,
224 std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D, size_t offset)
225{
227 rr.set_render_style(rrs);
228 rr.enable_attribute_array_manager(ctx, aam);
229 rr.set_rectangle_array(ctx, R);
230 rr.set_color_array(ctx, C);
231 rr.set_depth_offset_array(ctx, D);
232 rr.render(ctx, offset, R.size() - offset);
233 rr.disable_attribute_array_manager(ctx, aam);
234}
235
236
237void plot_base::draw_sub_plot_samples(int count, const plot_base_config& spc, bool strip)
238{
239 if (spc.begin_sample >= spc.end_sample) {
240 glDrawArrays(strip ? GL_LINE_STRIP : GL_POINTS, GLint(spc.begin_sample), GLsizei(count - spc.begin_sample));
241 if (strip) {
242 GLint indices[2] = { count - 1, 0 };
243 glDrawElements(GL_LINES, 2, GL_UNSIGNED_INT, indices);
244 }
245 if (spc.end_sample > 0)
246 glDrawArrays(strip ? GL_LINE_STRIP : GL_POINTS, 0, GLsizei(spc.end_sample));
247 }
248 else {
249 if (spc.end_sample == size_t(-1))
250 glDrawArrays(strip ? GL_LINE_STRIP : GL_POINTS, GLint(spc.begin_sample), GLsizei(count - spc.begin_sample));
251 else
252 if (spc.begin_sample < spc.end_sample)
253 glDrawArrays(strip ? GL_LINE_STRIP : GL_POINTS, GLint(spc.begin_sample), GLsizei(spc.end_sample - spc.begin_sample));
254 }
255}
256vec3 plot_base::world_space_from_plot_space(const vecn& pnt_plot) const
257{
258 vec3 pnt(pnt_plot(0), pnt_plot(1), pnt_plot.size() >= 3 ? pnt_plot(2) : 0.0f);
259 return orientation.apply(pnt) + center_location;
260}
262{
263 unsigned n = pnt_attr.size();
264 vecn pnt_plot(n);
265 const auto& acs = get_domain_config_ptr()->axis_configs;
266 unsigned m = acs.size() < n ? unsigned(acs.size()) : n;
267 for (unsigned ai = 0; ai < m; ++ai) {
268 pnt_plot(ai) =
269 acs[ai].plot_space_from_window_space(
270 acs[ai].window_space_from_tick_space(
271 acs[ai].tick_space_from_attribute_space(pnt_attr[ai])));
272 }
273 return world_space_from_plot_space(pnt_plot);
274}
276{
277 if (font_names.empty()) {
279 if (font_names.empty())
280 return;
281 font_name_enum_def = std::string("enums='") + font_names[0];
282 for (unsigned i = 1; i < font_names.size(); ++i) {
283 font_name_enum_def += ',';
285 }
286 font_name_enum_def += "'";
287 }
288 if (!label_font) {
291 if(font_ptr) {
292 std::string font_name = font_ptr->get_name();
293 for(auto iter = font_names.begin(); iter != font_names.end(); ++iter)
294 if(std::string(*iter) == font_name) {
295 get_domain_config_ptr()->label_font_index = (unsigned)(iter - font_names.begin());
296 break;
297 }
298 }
300 }
301 if (!title_font) {
304 if(font_ptr) {
305 std::string font_name = font_ptr->get_name();
306 for(auto iter = font_names.begin(); iter != font_names.end(); ++iter)
307 if(std::string(*iter) == font_name) {
308 get_domain_config_ptr()->title_font_index = (unsigned)(iter - font_names.begin());
309 break;
310 }
311 }
313 }
314}
315
316void plot_base::on_legend_axis_change(cgv::gui::provider& p, cgv::gui::control<int>& ctrl)
317{
318 if (ctrl.get_old_value() != ctrl.get_value()) {
319 std::swap(legend_extent[0], legend_extent[1]);
320 std::swap(legend_location[0], legend_location[1]);
325 }
326}
328{
329 if (get_domain_config_ptr()->label_font_index != -1)
331 if (get_domain_config_ptr()->title_font_index != -1)
334}
336{
337 if (label_font)
338 label_font_face = label_font->get_font_face(get_domain_config_ptr()->label_ffa);
339 if (title_font)
340 title_font_face = title_font->get_font_face(get_domain_config_ptr()->title_ffa);
341}
342
344{
345 extent = vec3(0.0f);
346 unsigned max_ai = std::min(unsigned(get_domain_config_ptr()->axis_configs.size()), get_dim());
347 unsigned F_count = 0;
348 float F;
349 for (unsigned ai = 0; ai < max_ai; ++ai) {
350 const auto& ac = get_domain_config_ptr()->axis_configs[ai];
351 extent[ai] = ac.extent;
352 if (ac.extent_scaling == 0.0f)
353 continue;
354 // (E1 * ES1) / A1 = (E2 * ES2) / A2 = F
355 // F = E * ES / A;
356 // E = F * A / ES;
357 float f = ac.extent * ac.extent_scaling / ac.get_attribute_extent();
358 if (F_count)
359 F = std::min(F, f);
360 else
361 F = f;
362 ++F_count;
363 }
364 if (F_count > 1) {
365 for (unsigned ai = 0; ai < max_ai; ++ai) {
366 const auto& ac = get_domain_config_ptr()->axis_configs[ai];
367 if (ac.extent_scaling == 0.0f)
368 continue;
369 extent[ai] = F * ac.get_attribute_extent() / ac.extent_scaling;
370 }
371 }
372}
373
375{
376 vecn attribute_min(8u, 0.0f), attribute_max(8u, 1.0f), axis_log_minimum(8u, 0.000001f);
377 cgv::math::vec<int> axis_log_scale(8u, 0);
378 for (unsigned ai = 0; ai < get_domain_config_ptr()->axis_configs.size(); ++ai) {
379 const auto& ac = get_domain_config_ptr()->axis_configs[ai];
380 attribute_min(ai) = ac.get_attribute_min();
381 attribute_max(ai) = ac.get_attribute_max();
382 axis_log_scale(ai) = ac.get_log_scale() ? 1 : 0;
383 axis_log_minimum(ai) = ac.get_log_minimum();
384 }
385 vec3 E(extent.size(), &extent(0));
386 prog.set_uniform(ctx, "extent", E);
387 prog.set_uniform(ctx, "out_of_range_mode", out_of_range_mode);
388 prog.set_uniform_array(ctx, "attribute_min", attribute_min);
389 prog.set_uniform_array(ctx, "attribute_max", attribute_max);
390 prog.set_uniform_array(ctx, "axis_log_scale", axis_log_scale);
391 prog.set_uniform_array(ctx, "axis_log_minimum", axis_log_minimum);
392 prog.set_uniform(ctx, "orientation", orientation);
393 prog.set_uniform(ctx, "center_location", center_location);
394}
396{
397 prog.set_uniform_array(ctx, "color_mapping", color_mapping, MAX_NR_COLOR_MAPPINGS);
398 prog.set_uniform_array(ctx, "opacity_mapping", opacity_mapping, MAX_NR_COLOR_MAPPINGS);
399 prog.set_uniform_array(ctx, "size_mapping", size_mapping, MAX_NR_COLOR_MAPPINGS);
400 if (prog.get_uniform_location(ctx, "color_scale_gamma[0]") != -1) {
402 prog.set_uniform_array(ctx, "color_scale_gamma", color_scale_gamma, MAX_NR_COLOR_MAPPINGS);
403 }
404 if (prog.get_uniform_location(ctx, "opacity_gamma[0]") != -1) {
405 prog.set_uniform_array(ctx, "opacity_gamma", opacity_gamma, MAX_NR_OPACITY_MAPPINGS);
406 prog.set_uniform_array(ctx, "opacity_min", opacity_min, MAX_NR_OPACITY_MAPPINGS);
407 prog.set_uniform_array(ctx, "opacity_max", opacity_max, MAX_NR_OPACITY_MAPPINGS);
409 for (int oi=0;oi< MAX_NR_OPACITY_MAPPINGS;++oi)
410 opa[oi] = opacity_is_bipolar[oi] ? 1 : 0;
411 prog.set_uniform_array(ctx, "opacity_is_bipolar", opa, MAX_NR_OPACITY_MAPPINGS);
412 prog.set_uniform_array(ctx, "opacity_window_zero_position", opacity_window_zero_position, MAX_NR_OPACITY_MAPPINGS);
413 }
414 if (prog.get_uniform_location(ctx, "size_mapping[0]") != -1) {
415 prog.set_uniform_array(ctx, "size_gamma", size_gamma, MAX_NR_SIZE_MAPPINGS);
416 prog.set_uniform_array(ctx, "size_min", size_min, MAX_NR_SIZE_MAPPINGS);
417 prog.set_uniform_array(ctx, "size_max", size_max, MAX_NR_SIZE_MAPPINGS);
418 }
419}
420
421void plot_base::set_sub_plot_attribute(unsigned i, unsigned ai, int subplot_index, size_t aj)
422{
423 assert(attribute_source_arrays.size() > i);
424 auto& ass = attribute_source_arrays[i].attribute_sources;
425 if (ass.size() <= ai)
426 ass.resize(ai + 1);
427 ass[ai] = attribute_source(subplot_index, aj, 0, get_dim() * sizeof(float));
428 attribute_source_arrays[i].sources_out_of_date = true;
429}
430void plot_base::set_sub_plot_attribute(unsigned i, unsigned ai, const float* _pointer, size_t count, size_t stride)
431{
432 assert(attribute_source_arrays.size() > i);
433 auto& ass = attribute_source_arrays[i].attribute_sources;
434 if (ass.size() <= ai)
435 ass.resize(ai + 1);
436 ass[ai] = attribute_source(_pointer, count, stride);
437 attribute_source_arrays[i].sources_out_of_date = true;
438}
439void plot_base::set_sub_plot_attribute(unsigned i, unsigned ai, const cgv::render::vertex_buffer* _vbo_ptr, size_t _offset, size_t _count, size_t _stride)
440{
441 assert(attribute_source_arrays.size() > i);
442 auto& ass = attribute_source_arrays[i].attribute_sources;
443 while (ass.size() <= ai)
444 ass.resize(ai + 1);
445 ass[ai] = attribute_source(_vbo_ptr, _offset, _count, _stride);
446 attribute_source_arrays[i].sources_out_of_date = true;
447}
448
449template <uint32_t N>
451{
452 const std::vector<std::vector<cgv::math::fvec<float, N>>>& samples;
453 vecn_sample_access(const std::vector < std::vector<cgv::math::fvec<float, N>>>& _samples) : samples(_samples) {}
454 size_t size(unsigned i) const { return samples[i].size(); }
455 float operator() (unsigned i, unsigned k, unsigned o) const { return samples[i][k][o]; }
456};
457size_t plot_base::enable_attributes(cgv::render::context& ctx, int i, const sample_access& sa)
458{
459 auto& asa = attribute_source_arrays[i];
460 auto& ass = asa.attribute_sources;
461 // first check whether we need to update vbo
462 unsigned ai = 0, j;
463 bool update_vbo = false;
464 size_t vbo_nr_floats = 0;
465 for (ai = 0; ai < ass.size(); ++ai) {
466 auto& as = ass[ai];
467 switch (as.source) {
468 case AS_SAMPLE_CONTAINER:
469 j = as.sub_plot_index == -1 ? i : as.sub_plot_index;
470 if (attribute_source_arrays[j].samples_out_of_date) {
471 update_vbo = true;
472 as.count = sa.size(j);
473 vbo_nr_floats += as.count;
474 }
475 break;
476 case AS_POINTER:
477 if (asa.samples_out_of_date) {
478 update_vbo = true;
479 vbo_nr_floats += as.count;
480 }
481 break;
482 default:
483 break;
484 }
485 }
486 // update vbo if necessary
487 if (update_vbo) {
488 // copy data into CPU buffer
489 std::vector<float> buffer(vbo_nr_floats);
490 float* dest = buffer.data();
491 for (ai = 0; ai < ass.size(); ++ai) {
492 const auto& as = ass[ai];
493 switch (as.source) {
494 case AS_SAMPLE_CONTAINER:
495 j = as.sub_plot_index == -1 ? i : as.sub_plot_index;
496 if (attribute_source_arrays[j].samples_out_of_date) {
497 for (int k = 0; k < as.count; ++k)
498 *dest++ = sa(j,k,(unsigned)as.offset);
499 }
500 break;
501 case AS_POINTER:
502 if (asa.samples_out_of_date) {
503 const float* src = as.pointer;
504 unsigned stride = unsigned(as.stride/sizeof(float));
505 for (int k = 0; k < as.count; ++k, src += stride)
506 *dest++ = *src;
507 }
508 break;
509 default:
510 break;
511 }
512 }
513 if (asa.vbo.get_size_in_bytes() != vbo_nr_floats * sizeof(float)) {
514 asa.vbo.destruct(ctx);
515 asa.vbo.create(ctx, buffer);
516 }
517 else
518 asa.vbo.replace(ctx, 0, buffer.data(), buffer.size());
519 asa.sources_out_of_date = true;
520 }
521 // update attribute bindings
522 if (!asa.aab.is_created()) {
523 asa.aab.create(ctx);
524 asa.sources_out_of_date = true;
525 }
526 if (asa.sources_out_of_date) {
527 size_t count = -1;
528 size_t vbo_offset = 0;
529 float f;
530 for (ai = 0; ai < ass.size(); ++ai) {
531 const auto& as = ass[ai];
532 switch (as.source) {
533 case AS_SAMPLE_CONTAINER: {
534 j = as.sub_plot_index == -1 ? i : as.sub_plot_index;
535 asa.aab.set_attribute_array(ctx, ai, cgv::render::get_element_type(f), asa.vbo, vbo_offset, sa.size(j), 0);
536 count = std::min(sa.size(j), count);
537 vbo_offset += count * sizeof(float);
538 break;
539 }
540 case AS_POINTER:
541 asa.aab.set_attribute_array(ctx, ai, cgv::render::get_element_type(f), asa.vbo, vbo_offset, as.count, 0);
542 count = std::min(as.count, count);
543 vbo_offset += count * sizeof(float);
544 break;
545 case AS_VBO:
546 asa.aab.set_attribute_array(ctx, ai, cgv::render::get_element_type(f), *as.vbo_ptr, as.count, as.offset, (unsigned)as.stride);
547 count = std::min(as.count, count);
548 break;
549 }
550 }
551 asa.count = count;
552 asa.sources_out_of_date = false;
553 }
554 // enable and return count
555 asa.aab.enable(ctx);
556 return asa.count;
557}
558size_t plot_base::enable_attributes(cgv::render::context& ctx, int i, const std::vector<std::vector<vec2>>& samples)
559{
560 return enable_attributes(ctx, i, vecn_sample_access<2>(samples));
561}
562size_t plot_base::enable_attributes(cgv::render::context& ctx, int i, const std::vector<std::vector<vec3>>& samples)
563{
564 return enable_attributes(ctx, i, vecn_sample_access<3>(samples));
565}
566void plot_base::disable_attributes(cgv::render::context& ctx, int i)
567{
568 attribute_source_arrays[i].aab.disable(ctx);
569}
570void plot_base::update_samples_out_of_date_flag()
571{
572 for (auto& asa : attribute_source_arrays)
573 asa.samples_out_of_date = false;
574}
575
576plot_base::plot_base(unsigned _dim, unsigned _nr_attributes) : dom_cfg(_dim, _nr_attributes),
577 vbo_legend(cgv::render::VBT_VERTICES, cgv::render::VBU_STREAM_DRAW)
578{
579 dim = _dim;
581 view_ptr = 0;
582 nr_attributes = _nr_attributes;
583 layer_depth = 0.00001f;
585 rrs.illumination_mode = cgv::render::IM_OFF;
586 rrs.map_color_to_material = cgv::render::CM_COLOR_AND_OPACITY;
587 legend_components = LC_HIDDEN;
588 legend_location = vec3(0.8f, 0.6f, 0.0f);
589 legend_extent = vec2(0.05f,0.7f);
590 legend_axis = 1;
591 legend_color = rgba(0.3f, 0.2f, 0.8f, 1.0f);
592 orientation = quat(1.0f, 0.0f, 0.0f, 0.0f);
593 center_location = vec3(0.0f);
594
595 for (int ci = 0; ci < MAX_NR_COLOR_MAPPINGS; ++ci) {
596 color_mapping[ci] = -1;
597 color_scale_index[ci] = cgv::media::CS_TEMPERATURE;
598 color_scale_gamma[ci] = 1;
599 window_zero_position[ci] = 0.5f;
600 }
601 for (int oi = 0; oi < MAX_NR_OPACITY_MAPPINGS; ++oi) {
602 opacity_mapping[oi] = -1;
603 opacity_gamma[oi] = 1.0f;
604 opacity_is_bipolar[oi] = false;
606 opacity_min[oi] = 0.1f;
607 opacity_max[oi] = 1.0f;
608 }
609
610 for (int si = 0; si < MAX_NR_SIZE_MAPPINGS; ++si) {
611 size_mapping[si] = -1;
612 size_min[si] = 0.1f;
613 size_max[si] = 1.0f;
614 size_gamma[si] = 1.0f;
615 }
616}
618{
619 view_ptr = _view_ptr;
620}
621
622bool plot_base::extract_tick_rectangles_and_tick_labels(
623 std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D,
624 std::vector<label_info>& tick_labels, int ai, int ci, int ti, float he,
625 float z_plot, float plot_scale, vec2 plot_offset, float d, bool multi_axis)
626{
628 float acw = 1.5f * ac.line_width * get_domain_config_ptr()->reference_size;
629 tick_config& tc = ti == 0 ? ac.primary_ticks : ac.secondary_ticks;
630 if (tc.type == TT_NONE)
631 return false;
632 float min_tick = ac.tick_space_from_attribute_space(ac.get_attribute_min());
633 float max_tick = ac.tick_space_from_attribute_space(ac.get_attribute_max());
634 int min_i = (int)ceil(min_tick / tc.step - std::numeric_limits<float>::epsilon());
635 int max_i = (int)((max_tick - fmod(max_tick, tc.step)) / tc.step);
636 // ignore secondary ticks on domain boundary
637 if (multi_axis) {
638 if (ti == 1 && min_i * tc.step - min_tick < std::numeric_limits<float>::epsilon())
639 ++min_i;
640 if (ti == 1 && max_i * tc.step - max_tick > -std::numeric_limits<float>::epsilon())
641 --max_i;
642 }
643 float lw = 0.5f * get_domain_config_ptr()->reference_size * tc.line_width;
644 float dl = 0.5f * get_domain_config_ptr()->reference_size * tc.length;
645 for (int i = min_i; i <= max_i; ++i) {
646 float c_tick = (float)(i * tc.step);
647 float c_attr = ac.attribute_space_from_tick_space(c_tick);
648 // ignore ticks on axes
649 if (multi_axis && (fabs(c_attr) < std::numeric_limits<float>::epsilon()))
650 continue;
651 // ignore secondary ticks on primary ticks
652 if (ti == 1 && fabs(fmod(c_tick, ac.primary_ticks.step)) < 0.00001f)
653 continue;
654 std::string label_str;
655 if (tc.label)
656 label_str = cgv::utils::to_string(c_attr);
657 float c_plot = plot_scale*ac.plot_space_from_window_space(ac.window_space_from_tick_space(c_tick))+plot_offset(ci);
658 vec2 mn, mx;
659 mn[ci] = c_plot - lw;
660 mx[ci] = c_plot + lw;
661 switch (tc.type) {
662 case TT_DASH:
663 mn[1 - ci] = -he + plot_offset(1-ci);
664 mx[1 - ci] = -he + dl + plot_offset(1 - ci);
665 R.push_back(box2(mn, mx));
666 C.push_back(ac.color);
667 D.push_back(d);
668 if (!label_str.empty()) {
669 mx[1 - ci] += acw;
670 tick_labels.push_back(label_info(mx.to_vec(), label_str, ci == 0 ? cgv::render::TA_BOTTOM : cgv::render::TA_LEFT));
671 if (ti == 1)
672 tick_labels.back().scale = 0.75f;
673 }
674 if (multi_axis) {
675 mn[1 - ci] = he - dl + plot_offset(1 - ci);
676 mx[1 - ci] = he + plot_offset(1 - ci);
677 R.push_back(box2(mn, mx));
678 C.push_back(ac.color);
679 D.push_back(d);
680 if (!label_str.empty()) {
681 mn[1 - ci] -= acw;
682 tick_labels.push_back(label_info(mn.to_vec(), label_str, ci == 0 ? cgv::render::TA_TOP : cgv::render::TA_RIGHT));
683 if (ti == 1)
684 tick_labels.back().scale = 0.75f;
685 }
686 if (z_plot != std::numeric_limits<float>::quiet_NaN()) {
687 mn[1 - ci] = z_plot - dl + plot_offset(1 - ci);
688 mx[1 - ci] = z_plot + dl + plot_offset(1 - ci);
689 R.push_back(box2(mn, mx));
690 C.push_back(ac.color);
691 D.push_back(d);
692 }
693 }
694 break;
695 case TT_LINE:
696 case TT_PLANE:
697 mn[1 - ci] = -he + plot_offset(1-ci);
698 mx[1 - ci] = he + plot_offset(1-ci);
699 R.push_back(box2(mn, mx));
700 C.push_back(ac.color);
701 D.push_back(d);
702 if (!label_str.empty()) {
703 mn[1 - ci] += acw;
704 mx[1 - ci] -= acw;
705 mn[ci] += 2.5f * lw;
706 mx[ci] += 2.5f * lw;
707 if (multi_axis) {
708 tick_labels.push_back(label_info(mx.to_vec(), label_str, cgv::render::TextAlignment(ci == 0 ? cgv::render::TA_TOP + cgv::render::TA_LEFT : cgv::render::TA_RIGHT + cgv::render::TA_BOTTOM)));
709 if (ti == 1)
710 tick_labels.back().scale = 0.75f;
711 }
712 tick_labels.push_back(label_info(mn.to_vec(), label_str, cgv::render::TextAlignment(ci == 0 ? cgv::render::TA_BOTTOM + cgv::render::TA_LEFT : cgv::render::TA_LEFT + cgv::render::TA_BOTTOM)));
713 if (ti == 1)
714 tick_labels.back().scale = 0.75f;
715
716 }
717 break;
718 }
719 }
720 return true;
721}
722
723void plot_base::extract_legend_tick_rectangles_and_tick_labels(
724 std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D,
725 std::vector<label_info>& tick_labels, std::vector<tick_batch_info>& tick_batches, float d,
726 bool clear_cache, bool is_first, bool* multi_axis_modes)
727{
728 if (clear_cache) {
729 tick_labels.clear();
730 tick_batches.clear();
731 }
732 const unsigned nr_lcs = 4;
733 static LegendComponent lcs[nr_lcs] = { LC_PRIMARY_COLOR, LC_PRIMARY_OPACITY, LC_SECONDARY_COLOR, LC_SECONDARY_OPACITY };
734 int ai[nr_lcs] = { color_mapping[0], opacity_mapping[0], color_mapping[1], opacity_mapping[1] };
735 const axis_config* acs[2] = { &get_domain_config_ptr()->axis_configs[0], &get_domain_config_ptr()->axis_configs[1] };
736 vec2 loc0(acs[0]->plot_space_from_window_space(legend_location(0)),
737 acs[1]->plot_space_from_window_space(legend_location(1)));
738 int l = 1 - legend_axis;
739 float main_extent = legend_extent[legend_axis] * acs[legend_axis]->extent;
740 float side_extent = legend_extent[l] * acs[l]->extent;
741 for (unsigned ti = 0; ti < 2; ++ti) {
742 vec2 loc = loc0;
743 for (int j = 0; j < nr_lcs; ++j) {
744
745 if ((legend_components & lcs[j]) != 0) {
746 if (ai[j] == -1)
747 continue;
748 if (multi_axis_modes && !is_first && !multi_axis_modes[ai[j]])
749 continue;
750 tick_batch_info tbi(ai[j], 1 - legend_axis, ti == 0, 0, (unsigned)tick_labels.size());
751 if (extract_tick_rectangles_and_tick_labels(R, C, D, tick_labels, ai[j], legend_axis, ti,
752 0.5f*side_extent, std::numeric_limits<float>::quiet_NaN(), main_extent, loc, d, false)) {
753 if ((tbi.label_count = (unsigned)(tick_labels.size() - tbi.first_label)) > 0)
754 tick_batches.push_back(tbi);
755 }
756 loc[l] += 1.2f*side_extent;
757 }
758 }
759 }
760}
761
762void plot_base::draw_title(cgv::render::context& ctx, vec2 pos, float depth, int si)
763{
764 // enable title font face
766 return;
767 cgv::tt_gl_font_face_ptr ff = dynamic_cast<cgv::tt_gl_font_face*>(&(*title_font_face));
768 if (!ff)
769 return;
770 float rs = 0.2f * get_domain_config_ptr()->reference_size;
771 ctx.enable_font_face(ff, 5 * get_domain_config_ptr()->title_font_size);
772
773 // collect all colored quads
774 std::vector<cgv::render::textured_rectangle> Q;
775 std::vector<rgba> C;
776
777 auto* cfg = get_domain_config_ptr();
778 if (si <= 0 && get_domain_config_ptr()->show_title) {
779 vec2 pos_aligned = ff->align_text(pos, cfg->title, cgv::render::TA_NONE, rs);
780 unsigned cnt = ff->text_to_quads(pos_aligned, cfg->title, Q, rs);
781 for (unsigned j = 0; j < cnt; ++j)
782 C.push_back(cfg->title_color);
783 }
784 if(get_domain_config_ptr()->show_sub_plot_names) {
785 pos[1] -= 5.0f * cfg->title_font_size * rs;
786 for(unsigned i = 0; i < get_nr_sub_plots(); ++i) {
787 if(si != -1 && i != si)
788 continue;
789 const auto& spc = ref_sub_plot_config(i);
790 vec2 pos_aligned = ff->align_text(pos, cfg->title, cgv::render::TA_NONE, rs);
791 unsigned cnt = ff->text_to_quads(pos_aligned, spc.name, Q, 0.8f * rs);
792 for(unsigned j = 0; j < cnt; ++j)
793 C.push_back(spc.ref_color.color);
794 pos[1] -= 4.0f * cfg->title_font_size * rs;
795 }
796 }
797 if (Q.empty())
798 return;
799
801 font_rrs.default_depth_offset = depth;
802 rr.set_render_style(font_rrs);
803 rr.enable_attribute_array_manager(ctx, aam_title);
804 rr.set_textured_rectangle_array(ctx, Q);
805 rr.set_color_array(ctx, C);
806 ff->ref_texture(ctx).enable(ctx);
807 rr.render(ctx, 0, Q.size());
808 ff->ref_texture(ctx).disable(ctx);
809 rr.disable_attribute_array_manager(ctx, aam_title);
810}
811
812void plot_base::draw_tick_labels(cgv::render::context& ctx, cgv::render::attribute_array_manager& aam_ticks,
813 std::vector<label_info>& tick_labels, std::vector<tick_batch_info>& tick_batches, float depth)
814{
815 if (tick_labels.empty() || label_font_face.empty())
816 return;
817
818 cgv::tt_gl_font_face_ptr ff = dynamic_cast<cgv::tt_gl_font_face*>(&(*label_font_face));
819 if (!ff) {
821 for (const auto& tbc : tick_batches) if (tbc.label_count > 0) {
822 ctx.set_color(get_domain_config_ptr()->axis_configs[tbc.ai].color);
823 for (unsigned i = tbc.first_label; i < tbc.first_label + tbc.label_count; ++i) {
824 const label_info& li = tick_labels[i];
825 ctx.set_cursor(li.position, li.label, li.align);
826 ctx.output_stream() << li.label;
827 ctx.output_stream().flush();
828 }
829 }
830 return;
831 }
832 else {
833 float rs = 0.2f * get_domain_config_ptr()->reference_size;
834 ctx.enable_font_face(ff, 5 * get_domain_config_ptr()->label_font_size);
835 std::vector<cgv::render::textured_rectangle> Q;
836 std::vector<rgba> C;
837 for (const auto& tbc : tick_batches) if (tbc.label_count > 0) {
838 for (unsigned i = tbc.first_label; i < tbc.first_label + tbc.label_count; ++i) {
839 const label_info& li = tick_labels[i];
840 vec2 pos = vec2::from_vec(li.position);
841 pos = ff->align_text(pos, li.label, li.align, li.scale * rs);
842 unsigned cnt = ff->text_to_quads(pos, li.label, Q, li.scale * rs);
843 for (unsigned i = 0; i < cnt; ++i)
844 C.push_back(get_domain_config_ptr()->axis_configs[tbc.ai].color);
845 }
846 }
847 if (Q.empty())
848 return;
850 font_rrs.default_depth_offset = depth;
851 rr.set_render_style(font_rrs);
852 rr.enable_attribute_array_manager(ctx, aam_ticks);
853 rr.set_textured_rectangle_array(ctx, Q);
854 rr.set_color_array(ctx, C);
855 ff->ref_texture(ctx).enable(ctx);
856 rr.render(ctx, 0, Q.size());
857 ff->ref_texture(ctx).disable(ctx);
858 rr.disable_attribute_array_manager(ctx, aam_ticks);
859 }
860}
861
862void plot_base::draw_legend(cgv::render::context& ctx, int layer_idx, bool is_first, bool* multi_axis_modes)
863{
864 // draw legend rectangles with legend program
866 legend_prog.set_uniform(ctx, "extent", E);
867 vec3 loc = legend_location;
868 legend_prog.set_uniform(ctx, "legend_extent", legend_extent);
869 set_mapping_uniforms(ctx, legend_prog);
870 aab_legend.enable(ctx);
871 legend_prog.enable(ctx);
874 legend_prog.set_uniform(ctx, "depth_offset", -layer_idx * layer_depth);
875 int j = 1 - legend_axis;
876 int off = 4*j;
877 if ((legend_components & LC_PRIMARY_COLOR) != 0) {
878 if (!multi_axis_modes || is_first || color_mapping[0] == -1 || multi_axis_modes[color_mapping[0]]) {
879 legend_prog.set_uniform(ctx, "legend_location", loc);
880 legend_prog.set_uniform(ctx, "color_index", 0);
881 legend_prog.set_uniform(ctx, "opacity_index", -1);
882 glDrawArrays(GL_TRIANGLE_STRIP, off, 4);
883 }
884 loc[j] += 1.2f * legend_extent[j];
885 }
886 if ((legend_components & LC_PRIMARY_OPACITY) != 0) {
887 if (!multi_axis_modes || is_first || opacity_mapping[0] == -1 || multi_axis_modes[opacity_mapping[0]]) {
888 legend_prog.set_uniform(ctx, "legend_location", loc);
889 legend_prog.set_uniform(ctx, "color_index", -1);
890 legend_prog.set_uniform(ctx, "opacity_index", 0);
891 glDrawArrays(GL_TRIANGLE_STRIP, off, 4);
892 }
893 loc[j] += 1.2f * legend_extent[j];
894 }
895 if ((legend_components & LC_SECONDARY_COLOR) != 0) {
896 if (!multi_axis_modes || is_first || color_mapping[1] == -1 || multi_axis_modes[color_mapping[1]]) {
897 legend_prog.set_uniform(ctx, "legend_location", loc);
898 legend_prog.set_uniform(ctx, "color_index", 1);
899 legend_prog.set_uniform(ctx, "opacity_index", -1);
900 glDrawArrays(GL_TRIANGLE_STRIP, off, 4);
901 }
902 loc[j] += 1.2f * legend_extent[j];
903 }
904 if ((legend_components & LC_SECONDARY_OPACITY) != 0) {
905 if (!multi_axis_modes || is_first || opacity_mapping[0] == -1 || multi_axis_modes[opacity_mapping[1]]) {
906 legend_prog.set_uniform(ctx, "legend_location", loc);
907 legend_prog.set_uniform(ctx, "color_index", -1);
908 legend_prog.set_uniform(ctx, "opacity_index", 1);
909 glDrawArrays(GL_TRIANGLE_STRIP, off, 4);
910 }
911 loc[j] += 1.2f * legend_extent[j];
912 }
913 legend_prog.disable(ctx);
914 aab_legend.disable(ctx);
915 // extract tickmark information for legend and draw it
916 std::vector<box2> R;
917 std::vector<rgb> C;
918 std::vector<float> D;
919 ++layer_idx;
920 extract_legend_tick_rectangles_and_tick_labels(R, C, D, legend_tick_labels, legend_tick_batches, -layer_idx*layer_depth, true, is_first, multi_axis_modes);
921 if (R.empty())
922 return;
924 ctx.mul_modelview_matrix(cgv::math::translate4<float>(0.0f, 0.0f, E[2] * (legend_location[2] - 0.5f)));
925 draw_rectangles(ctx, aam_legend, R, C, D);
926 std::string title;
927 rgba title_color;
928 ++layer_idx;
929 draw_tick_labels(ctx, aam_legend_ticks, legend_tick_labels, legend_tick_batches, -layer_idx * layer_depth);
931}
932
934{
935 const auto& acs = get_domain_config_ptr()->axis_configs;
936 return box2(vec2(acs[0].get_attribute_min(),acs[1].get_attribute_min()),
937 vec2(acs[0].get_attribute_max(), acs[1].get_attribute_max()));
938}
940{
941 const auto& acs = get_domain_config_ptr()->axis_configs;
942 return box3(vec3(acs[0].get_attribute_min(), acs[1].get_attribute_min(), get_dim() == 2 ? 0 : acs[2].get_attribute_min()),
943 vec3(acs[0].get_attribute_max(), acs[1].get_attribute_max(), get_dim() == 2 ? 0 : acs[2].get_attribute_max()));
944}
946{
947 auto& acs = get_domain_config_ptr()->axis_configs;
948 acs[0].set_attribute_range(dom.get_min_pnt()(0), dom.get_max_pnt()(0));
949 acs[1].set_attribute_range(dom.get_min_pnt()(1), dom.get_max_pnt()(1));
950}
952{
953 auto& acs = get_domain_config_ptr()->axis_configs;
954 unsigned n = std::min(get_dim(), 3u);
955 for (unsigned ai = 0; ai < n; ++ai)
956 acs[ai].set_attribute_range(dom.get_min_pnt()(ai), dom.get_max_pnt()(ai));
957}
959{
960 const auto& acs = get_domain_config_ptr()->axis_configs;
962 for (unsigned ai = 0; ai < get_dim(); ++ai)
963 extent(ai) = acs[ai].extent;
964 return extent;
965}
966void plot_base::set_extent(const vecn& new_extent)
967{
968 auto& acs = get_domain_config_ptr()->axis_configs;
969 unsigned n = std::min(get_dim(), new_extent.size());
970 for (unsigned ai = 0; ai < n; ++ai)
971 acs[ai].extent = new_extent(ai);
972}
973
974void plot_base::set_extent_scaling(float x_scale, float y_scale, float z_scale)
975{
976 auto& acs = get_domain_config_ptr()->axis_configs;
977 acs[0].extent_scaling = x_scale;
978 acs[1].extent_scaling = y_scale;
979 if (get_dim() > 2)
980 acs[2].extent_scaling = z_scale;
981}
982
983void plot_base::set_width(float new_width, bool constrained)
984{
985 auto& acs = get_domain_config_ptr()->axis_configs;
986 acs[0].extent = new_width;
987 if (constrained) {
988 acs[1].extent = new_width *
989 (acs[1].tick_space_from_attribute_space(acs[1].get_attribute_max()) - acs[1].tick_space_from_attribute_space(acs[1].get_attribute_max())) /
990 (acs[0].tick_space_from_attribute_space(acs[0].get_attribute_max()) - acs[0].tick_space_from_attribute_space(acs[0].get_attribute_max()));
991 }
992}
993void plot_base::set_height(float new_height, bool constrained)
994{
995 auto& acs = get_domain_config_ptr()->axis_configs;
996 acs[1].extent = new_height;
997 if (constrained) {
998 acs[0].extent = new_height *
999 (acs[0].tick_space_from_attribute_space(acs[0].get_attribute_max()) - acs[0].tick_space_from_attribute_space(acs[0].get_attribute_max())) /
1000 (acs[1].tick_space_from_attribute_space(acs[1].get_attribute_max()) - acs[1].tick_space_from_attribute_space(acs[1].get_attribute_max()));
1001 }
1002}
1004{
1005 orientation = q;
1006}
1007void plot_base::place_origin(const vec3& new_origin_location)
1008{
1009 center_location += new_origin_location - get_origin();
1010}
1011void plot_base::place_center(const vec3& new_center_location)
1012{
1013 center_location = new_center_location;
1014}
1015void plot_base::place_corner(unsigned corner_index, const vec3& new_corner_location)
1016{
1017 center_location += new_corner_location - get_corner(corner_index);
1018}
1020{
1021 return transform_to_world(get_domain3().get_min_pnt().to_vec());
1022}
1024{
1025 return orientation;
1026}
1028{
1029 return center_location;
1030}
1032{
1033 box3 B = get_domain3();
1034 vec3 c3 = B.get_corner(i);
1035 vecn c(get_dim());
1036 for (unsigned j = 0; j < get_dim(); ++j)
1037 c(j) = c3(j);
1038 return transform_to_world(c);
1039}
1040const vec3 plot_base::get_axis_direction(unsigned ai) const
1041{
1042 vec3 a(0.0f);
1043 a(ai) = 1.0f;
1044 return orientation.apply(a);
1045}
1046
1047bool plot_base::determine_axis_extent_from_subplot(unsigned ai, unsigned i, float& samples_min, float& samples_max)
1048{
1049 if (attribute_source_arrays.size() <= i)
1050 return false;
1051 if (attribute_source_arrays[i].attribute_sources.size() <= ai)
1052 return false;
1053 const attribute_source& as = attribute_source_arrays[i].attribute_sources[ai];
1054 if (as.source == AS_NONE)
1055 return false;
1056 bool new_found_sample = false;
1057 float new_samples_min, new_samples_max;
1058 switch (as.source) {
1059 case AS_SAMPLE_CONTAINER:
1060 {
1061 int j = as.sub_plot_index == -1 ? i : as.sub_plot_index;
1062 new_found_sample = compute_sample_coordinate_interval(j, (int)as.offset, new_samples_min, new_samples_max);
1063 break;
1064 }
1065 case AS_POINTER:
1066 {
1067 const float* ptr = as.pointer;
1068 for (unsigned j = 0; j < as.count; ++j) {
1069 if (new_found_sample) {
1070 new_samples_min = std::min(new_samples_min, *ptr);
1071 new_samples_max = std::max(new_samples_max, *ptr);
1072 }
1073 else {
1074 new_samples_min = new_samples_max = *ptr;
1075 new_found_sample = true;
1076 }
1077 reinterpret_cast<const char*&>(ptr) += as.stride;
1078 }
1079 break;
1080 }
1081 case AS_VBO:
1082 return false;
1083 }
1084 if (!new_found_sample)
1085 return false;
1086
1087 samples_min = new_samples_min;
1088 samples_max = new_samples_max;
1089 return true;
1090}
1091
1092void plot_base::adjust_domain_axis_to_data(unsigned ai, bool adjust_min, bool adjust_max, bool only_visible)
1093{
1094 bool found_sample = false;
1095 float samples_min, samples_max;
1096 for (unsigned i = 0; i < configs.size(); ++i) {
1097 if (only_visible && !ref_sub_plot_config(i).show_plot)
1098 continue;
1099 float new_samples_min, new_samples_max;
1100 if (determine_axis_extent_from_subplot(ai, i, new_samples_min, new_samples_max)) {
1101 if (found_sample) {
1102 samples_min = std::min(samples_min, new_samples_min);
1103 samples_max = std::max(samples_max, new_samples_max);
1104 }
1105 else {
1106 samples_min = new_samples_min;
1107 samples_max = new_samples_max;
1108 found_sample = true;
1109 }
1110 }
1111 }
1112 auto& acs = get_domain_config_ptr()->axis_configs;
1113 if (!found_sample) {
1114 if (adjust_min)
1115 acs[ai].set_attribute_minimum(0.0f);
1116 if (adjust_max)
1117 acs[ai].set_attribute_maximum(1.0f);
1118 return;
1119 }
1120 if (adjust_min)
1121 acs[ai].set_attribute_minimum(samples_min);
1122 if (adjust_max)
1123 acs[ai].set_attribute_maximum(samples_max);
1124 if (acs[ai].get_attribute_min() == acs[ai].get_attribute_max())
1125 acs[ai].set_attribute_maximum(acs[ai].get_attribute_max() + 1);
1126}
1127
1128void plot_base::adjust_tick_marks(unsigned max_nr_secondary_ticks, bool adjust_to_attribute_ranges)
1129{
1130 auto& acs = get_domain_config_ptr()->axis_configs;
1131 for (unsigned ai = 0; ai < acs.size(); ++ai) {
1132 acs[ai].adjust_tick_marks_to_range(max_nr_secondary_ticks);
1133 if (!adjust_to_attribute_ranges && ai + 1 == get_dim())
1134 break;
1135 }
1136}
1138{
1139 auto& acs = get_domain_config_ptr()->axis_configs;
1140 for (int ai = 0; ai < (int)get_dim(); ++ai) {
1141 if (ai == preserve_ai)
1142 continue;
1143 acs[ai].extent = acs[preserve_ai].extent*acs[ai].get_attribute_extent()/acs[preserve_ai].get_attribute_extent();
1144 }
1145}
1147{
1148 auto& acs = get_domain_config_ptr()->axis_configs;
1149 for (unsigned aj = 0; aj < get_dim(); ++aj) {
1150 if (aj == ai)
1151 continue;
1152 if (acs[aj].get_attribute_min() > 0)
1153 acs[aj].set_attribute_minimum(0);
1154 if (acs[aj].get_attribute_max() < 0)
1155 acs[aj].set_attribute_maximum(0);
1156 }
1157}
1159{
1160 unsigned n = unsigned(get_domain_config_ptr()->axis_configs.size());
1161 for (unsigned ai=0; ai < n; ++ai)
1162 adjust_domain_axis_to_data(ai, true, true, only_visible);
1163}
1164void plot_base::set_label_font(float font_size, cgv::media::font::FontFaceAttributes ffa, const std::string& font_name)
1165{
1168 if (!font_name.empty()) {
1169 for (auto iter = font_names.begin(); iter != font_names.end(); ++iter)
1170 if (font_name == *iter) {
1171 get_domain_config_ptr()->label_font_index = (unsigned)(iter - font_names.begin());
1173 break;
1174 }
1175 }
1176 else
1178}
1179
1181{
1182 return dom_cfg_ptr;
1183}
1189{
1190 if (_new_ptr)
1191 dom_cfg_ptr = _new_ptr;
1192 else
1194}
1196{
1197 return (unsigned) configs.size();
1198}
1200{
1201 return *configs[i];
1202}
1204{
1205 attribute_source_arrays[i].samples_out_of_date = true;
1206}
1207void plot_base::set_sub_plot_colors(unsigned i, const rgb& base_color)
1208{
1209 ref_sub_plot_config(i).set_colors(base_color);
1210}
1211
1213{
1214 font_rrs = cgv::ref_rectangle_render_style();
1217 aam_title.init(ctx);
1218 aam_legend.init(ctx);
1219 aam_legend_ticks.init(ctx);
1220 if (!legend_prog.build_program(ctx, "plot_legend.glpr", true)) {
1221 std::cerr << "could not build GLSL program from plot_legend.glpr" << std::endl;
1222 return false;
1223 }
1224 // construct legend vbo and aab
1225 std::vector<vec4> P;
1226 P.push_back(vec4(-0.5f, -0.5f, 0.0f, 0.0f));
1227 P.push_back(vec4( 0.5f, -0.5f, 0.0f, 0.0f));
1228 P.push_back(vec4(-0.5f, 0.5f, 0.0f, 1.0f));
1229 P.push_back(vec4( 0.5f, 0.5f, 0.0f, 1.0f));
1230 P.push_back(vec4(-0.5f, -0.5f, 0.0f, 0.0f));
1231 P.push_back(vec4(0.5f, -0.5f, 0.0f, 1.0f));
1232 P.push_back(vec4(-0.5f, 0.5f, 0.0f, 0.0f));
1233 P.push_back(vec4(0.5f, 0.5f, 0.0f, 1.0f));
1234 vbo_legend.create(ctx, P);
1235 aab_legend.create(ctx);
1236 int pos_idx = legend_prog.get_attribute_location(ctx, "position");
1237 int val_idx = legend_prog.get_attribute_location(ctx, "value");
1238 aab_legend.enable_array(ctx, pos_idx);
1239 aab_legend.enable_array(ctx, val_idx);
1240 vec3& p0 = reinterpret_cast<vec3&>(P[0]);
1241 float& v0 = P[0][3];
1242 aab_legend.set_attribute_array(ctx, pos_idx, cgv::render::get_element_type(p0), vbo_legend, 0, P.size(), sizeof(vec4));
1243 aab_legend.set_attribute_array(ctx, val_idx, cgv::render::get_element_type(v0), vbo_legend, sizeof(vec3), P.size(), sizeof(vec4));
1244 return true;
1245}
1246
1248{
1250 aam_title.destruct(ctx);
1251 aam_legend.destruct(ctx);
1252 aam_legend_ticks.destruct(ctx);
1253 aab_legend.destruct(ctx);
1254 vbo_legend.destruct(ctx);
1255 legend_prog.destruct(ctx);
1256 for (unsigned i = 0; i < get_nr_sub_plots(); ++i) {
1257 attribute_source_arrays[i].aab.destruct(ctx);
1258 attribute_source_arrays[i].vbo.destruct(ctx);
1259 }
1260}
1261
1263{
1265 p.add_member_control(bp, "Reference Size", get_domain_config_ptr()->reference_size, "value_slider", "min=0.0001;step=0.00001;max=1;log=true;ticks=true");
1266 p.add_member_control(bp, "Blend Width (px)", get_domain_config_ptr()->blend_width_in_pixel, "value_slider", "min=0.0001;step=0.0;max=3.0;ticks=true");
1267
1268 if (p.begin_tree_node("Visual Variables", dim, false, "level=3")) {
1269 std::string attribute_enums = "off=-1";
1270 for (unsigned ai = 0; ai < get_dim() + nr_attributes; ++ai)
1271 attribute_enums += std::string(",")+get_domain_config_ptr()->axis_configs[ai].name;
1272 std::string dropdown_options("w=92;enums='" + attribute_enums + "'");
1273 p.align("\a");
1274 bool show;
1275 unsigned nr = std::max(MAX_NR_COLOR_MAPPINGS, std::max(MAX_NR_SIZE_MAPPINGS, MAX_NR_OPACITY_MAPPINGS));
1276 static const char* prefixes[] = { "Primary ", "Secondary ", "Ternary " };
1277 for (unsigned idx = 0; idx < nr; ++idx) {
1278 std::string prefix(prefixes[idx]);
1279 if (idx < MAX_NR_COLOR_MAPPINGS) {
1280 show = p.begin_tree_node(prefix + "Color", color_mapping[idx], false, "level=3;align=' ';options='w=100'");
1281 p.add_member_control(bp, "", (cgv::type::DummyEnum&)color_mapping[idx], "dropdown", dropdown_options);
1282 if (show) {
1283 p.align("\a");
1284 p.add_member_control(bp, prefix + "Color Scale", (cgv::type::DummyEnum&)color_scale_index[idx], "dropdown", cgv::media::get_color_scale_enum_definition());
1285 p.add_member_control(bp, prefix + "Color Gamma", color_scale_gamma[idx], "value_slider", "min=0.1;step=0.01;max=10;log=true;ticks=true");
1286 p.add_member_control(bp, prefix + "Window Zero Position", window_zero_position[idx], "value_slider", "min=0;max=1;ticks=true");
1287 p.align("\b");
1289 }
1290 }
1291 if (idx < MAX_NR_OPACITY_MAPPINGS) {
1292 show = p.begin_tree_node(prefix + "Opacity", opacity_mapping[idx], false, "level=3;align=' ';options='w=100'");
1293 p.add_member_control(bp, "", (cgv::type::DummyEnum&)opacity_mapping[idx], "dropdown", dropdown_options);
1294 if (show) {
1295 p.align("\a");
1296 p.add_member_control(bp, prefix + "Opacity Gamma", opacity_gamma[idx], "value_slider", "min=0.1;step=0.01;max=10;log=true;ticks=true");
1297 p.add_member_control(bp, prefix + "Opacity Is Bipolar", opacity_is_bipolar[idx], "check");
1298 p.add_member_control(bp, prefix + "Opacity Window Zero Position", opacity_window_zero_position[idx], "value_slider", "min=0;max=1;ticks=true");
1299 p.add_member_control(bp, prefix + "Opacity Min", opacity_min[idx], "value_slider", "min=0;step=0.01;max=1;ticks=true");
1300 p.add_member_control(bp, prefix + "Opacity Max", opacity_max[idx], "value_slider", "min=0;step=0.01;max=1;ticks=true");
1301 p.align("\b");
1303 }
1304 }
1305 if (idx < MAX_NR_SIZE_MAPPINGS) {
1306 show = p.begin_tree_node(prefix + "Size", size_mapping[idx], false, "level=3;align=' ';options='w=100'");
1307 p.add_member_control(bp, "", (cgv::type::DummyEnum&)size_mapping[idx], "dropdown", dropdown_options);
1308 if (show) {
1309 p.align("\a");
1310 p.add_member_control(bp, prefix + "Size Gamma", size_gamma[idx], "value_slider", "min=0.1;step=0.01;max=10;log=true;ticks=true");
1311 p.add_member_control(bp, prefix + "Size Min", size_min[idx], "value_slider", "min=0.1;step=0.01;max=10;log=true;ticks=true");
1312 p.add_member_control(bp, prefix + "Size Max", size_max[idx], "value_slider", "min=0.1;step=0.01;max=10;log=true;ticks=true");
1313 p.align("\b");
1315 }
1316 }
1317 }
1318 p.align("\b");
1319 p.end_tree_node(dim);
1320 }
1321 if (p.begin_tree_node("Legend", legend_components, false, "level=3")) {
1322 p.align("\a");
1323 p.add_member_control(bp, "Legend Color", legend_color);
1324 p.add_gui("Legend Components", legend_components, "bit_field_control", "enums='Primary Color=1,Secondary Color=2,Primary Opacity=4,Secondary Opacity=8,Primary Size=16,Secondary Size=32'");
1325 p.add_gui("Center", legend_location, "vector", "main_label='heading';gui_type='value_slider';options='min=-1.2;max=1.2;log=true;ticks=true'");
1326 p.add_gui("Extent", legend_extent, "vector", "main_label='heading';gui_type='value_slider';options='min=0.01;max=10;step=0.001;log=true;ticks=true'");
1327 p.add_member_control(bp, "Axis", legend_axis, "value_slider", "min=0;max=1");
1328 connect_copy(p.find_control(legend_axis)->value_change,
1329 cgv::signal::rebind(this, &plot_base::on_legend_axis_change,cgv::signal::_r(p),cgv::signal::_1));
1330
1331 p.align("\b");
1333 }
1334
1335 if (p.begin_tree_node("Placement", center_location, false, "level=3")) {
1336 p.align("\a");
1337 p.add_gui("Center", center_location, "vector", "main_label='heading';gui_type='value_slider';options='min=-100;max=100;log=true;ticks=true'");
1338 p.add_gui("Orientation", reinterpret_cast<vec4&>(orientation), "direction", "main_label='heading';gui_type='value_slider'");
1339 p.align("\b");
1341 }
1342 bool open = p.begin_tree_node("Domain", get_domain_config_ptr()->show_domain, false, "level=3;options='w=107';align=' '");
1343 p.add_member_control(bp, "Fill", get_domain_config_ptr()->fill, "toggle", "w=40", "%x+=1");
1344 p.add_member_control(bp, "Show", get_domain_config_ptr()->show_domain, "toggle", "w=40");
1345 if (open) {
1346 p.align("\a");
1347 p.add_member_control(bp, "Out of Range Mode X", (cgv::type::DummyEnum&)out_of_range_mode[0], "dropdown", "enums='Keep,Discard,Clamp'");
1348 p.add_member_control(bp, "Out of Range Mode Y", (cgv::type::DummyEnum&)out_of_range_mode[1], "dropdown", "enums='Keep,Discard,Clamp'");
1349 if (get_dim() == 2) {
1350 p.add_member_control(bp, "Out of Range Mode A0", (cgv::type::DummyEnum&)out_of_range_mode[2], "dropdown", "enums='Keep,Discard,Clamp'");
1351 p.add_member_control(bp, "Out of Range Mode A1", (cgv::type::DummyEnum&)out_of_range_mode[3], "dropdown", "enums='Keep,Discard,Clamp'");
1352 }
1353 else {
1354 p.add_member_control(bp, "Out of Range Mode Z", (cgv::type::DummyEnum&)out_of_range_mode[2], "dropdown", "enums='Keep,Discard,Clamp'");
1355 p.add_member_control(bp, "Out of Range Mode A", (cgv::type::DummyEnum&)out_of_range_mode[3], "dropdown", "enums='Keep,Discard,Clamp'");
1356 }
1357 p.add_member_control(bp, "Fill Color", get_domain_config_ptr()->color);
1358 for (unsigned i = 0; i < get_domain_config_ptr()->axis_configs.size(); ++i)
1359 get_domain_config_ptr()->axis_configs[i].create_gui(bp, p);
1361 p.add_member_control(bp, "Show Title", get_domain_config_ptr()->show_title, "toggle", "w=99", "%x+=1");
1362 p.add_member_control(bp, "Show Names", get_domain_config_ptr()->show_sub_plot_names, "toggle", "w=100");
1363 p.add_member_control(bp, "Title Pos X", get_domain_config_ptr()->title_pos[0], "value_slider", "min=-1;max=1;step=0.02;ticks=true");
1364 p.add_member_control(bp, "Title Pos Y", get_domain_config_ptr()->title_pos[1], "value_slider", "min=-1;max=1;step=0.02;ticks=true");
1365 if (get_dim() == 3)
1366 p.add_member_control(bp, "Title Pos Z", get_domain_config_ptr()->title_pos[2], "value_slider", "min=-1;max=1;step=0.02;ticks=true");
1367 p.add_member_control(bp, "Title Font Size", get_domain_config_ptr()->title_font_size, "value_slider", "min=8;max=40;log=false;ticks=true");
1369 connect_copy(p.find_control((cgv::type::DummyEnum&)get_domain_config_ptr()->title_font_index)->value_change,
1370 cgv::signal::rebind(this, &plot_base::on_font_selection));
1371 p.add_member_control(bp, "Title Font Face", get_domain_config_ptr()->title_ffa, "dropdown", "enums='Regular,Bold,Italics,Bold Italics'");
1372 connect_copy(p.find_control(get_domain_config_ptr()->title_ffa)->value_change,
1373 cgv::signal::rebind(this, &plot_base::on_font_face_selection));
1374
1375 p.add_member_control(bp, "Label Font Size", get_domain_config_ptr()->label_font_size, "value_slider", "min=8;max=40;log=false;ticks=true");
1376 p.add_member_control(bp, "Label Font", (cgv::type::DummyEnum&)get_domain_config_ptr()->label_font_index, "dropdown", font_name_enum_def);
1377 connect_copy(p.find_control((cgv::type::DummyEnum&)get_domain_config_ptr()->label_font_index)->value_change,
1378 cgv::signal::rebind(this, &plot_base::on_font_selection));
1379 p.add_member_control(bp, "Label Font Face", get_domain_config_ptr()->label_ffa, "dropdown", "enums='Regular,Bold,Italics,Bold Italics'");
1380 connect_copy(p.find_control(get_domain_config_ptr()->label_ffa)->value_change,
1381 cgv::signal::rebind(this, &plot_base::on_font_face_selection));
1382 p.align("\b");
1383 p.end_tree_node(get_domain_config_ptr()->show_domain);
1384 }
1385 if (p.begin_tree_node("Rectangle", rrs, false, "level=3")) {
1386 p.align("\a");
1387 p.add_member_control(bp, "Layer Depth", layer_depth, "value_slider", "min=0.000001;max=0.01;step=0.0000001;log=true;ticks=true");
1388 p.add_gui("Rectangle Style", rrs);
1389 p.align("\b");
1390 p.end_tree_node(rrs);
1391 }
1392}
1393void plot_base::update_ref_opacity(unsigned i, cgv::gui::provider& p)
1394{
1396 pbc.set_opacities(pbc.ref_opacity.opacity);
1397 p.update_member(&pbc.point_color.color.alpha());
1398 p.update_member(&pbc.point_halo_color.color.alpha());
1399 p.update_member(&pbc.line_color.color.alpha());
1400 p.update_member(&pbc.line_halo_color.color.alpha());
1401 p.update_member(&pbc.stick_color.color.alpha());
1402 p.update_member(&pbc.bar_color.color.alpha());
1403 p.update_member(&pbc.bar_outline_color.color.alpha());
1404}
1405void plot_base::update_ref_opacity_index(unsigned i, cgv::gui::provider& p)
1406{
1407 plot_base_config& pbc = ref_sub_plot_config(i);
1408 pbc.set_opacity_indices(pbc.ref_opacity.opacity_idx);
1409 p.update_member(&pbc.point_color.opacity_idx);
1410 p.update_member(&pbc.point_halo_color.opacity_idx);
1411 p.update_member(&pbc.line_color.opacity_idx);
1412 p.update_member(&pbc.line_halo_color.opacity_idx);
1413 p.update_member(&pbc.stick_color.opacity_idx);
1414 p.update_member(&pbc.bar_color.opacity_idx);
1415 p.update_member(&pbc.bar_outline_color.opacity_idx);
1416}
1417void plot_base::update_ref_color(unsigned i, cgv::gui::provider& p)
1418{
1419 plot_base_config& pbc = ref_sub_plot_config(i);
1420 pbc.set_colors(pbc.ref_color.color);
1421 p.update_member(&pbc.point_color.color);
1422 p.update_member(&pbc.point_halo_color.color);
1423 p.update_member(&pbc.line_color.color);
1424 p.update_member(&pbc.line_halo_color.color);
1425 p.update_member(&pbc.stick_color.color);
1426 p.update_member(&pbc.bar_color.color);
1427 p.update_member(&pbc.bar_outline_color.color);
1428}
1429void plot_base::update_ref_color_index(unsigned i, cgv::gui::provider& p)
1430{
1431 plot_base_config& pbc = ref_sub_plot_config(i);
1432 pbc.set_color_indices(pbc.ref_color.color_idx);
1433 p.update_member(&pbc.point_color.color_idx);
1434 p.update_member(&pbc.point_halo_color.color_idx);
1435 p.update_member(&pbc.line_color.color_idx);
1436 p.update_member(&pbc.line_halo_color.color_idx);
1437 p.update_member(&pbc.stick_color.color_idx);
1438 p.update_member(&pbc.bar_color.color_idx);
1439 p.update_member(&pbc.bar_outline_color.color_idx);
1440}
1441void plot_base::update_ref_size(unsigned i, cgv::gui::provider& p)
1442{
1443 plot_base_config& pbc = ref_sub_plot_config(i);
1444 pbc.set_sizes(pbc.ref_size.size);
1445 p.update_member(&pbc.point_size.size);
1446 p.update_member(&pbc.point_halo_width.size);
1447 p.update_member(&pbc.line_width.size);
1448 p.update_member(&pbc.stick_width.size);
1449 p.update_member(&pbc.bar_outline_width.size);
1450}
1451void plot_base::update_ref_size_index(unsigned i, cgv::gui::provider& p)
1452{
1453 plot_base_config& pbc = ref_sub_plot_config(i);
1454 p.update_member(&pbc.point_size.size_idx);
1455 p.update_member(&pbc.point_halo_width.size_idx);
1456 p.update_member(&pbc.line_width.size_idx);
1457 p.update_member(&pbc.line_halo_width.size_idx);
1458 p.update_member(&pbc.stick_width.size_idx);
1459 p.update_member(&pbc.bar_outline_width.size_idx);
1460}
1462{
1464 p.add_member_control(bp, "Name", pbc.name);
1465 p.add_gui("Sub Plot Influence", pbc.sub_plot_influence, "bit_field_control",
1466 "gui_type='toggle';align='%x+=1';options='w=32;x=2';enums='Pnt=1,Halo=2,Line=4,Stk=8,Bar=16,Out=32'");
1467 p.align("\n");
1468 connect_copy(p.add_member_control(bp, "Color", pbc.ref_color.color, "", "w=100", " ")->value_change,
1469 cgv::signal::rebind(this, &plot_base::update_ref_color, cgv::signal::_c(i), cgv::signal::_r(p)));
1470 connect_copy(p.add_member_control(bp, "", (cgv::type::DummyEnum&)pbc.ref_color.color_idx, "dropdown", "w=88;enums='Off=-1,Primary=0,Secondary=1'")->value_change,
1471 cgv::signal::rebind(this, &plot_base::update_ref_color_index, cgv::signal::_c(i), cgv::signal::_r(p)));
1472
1473 connect_copy(p.add_member_control(bp, "Opacity", pbc.ref_opacity.opacity, "value_slider", "min=0;max=1;ticks=true;w=100", " ")->value_change,
1474 cgv::signal::rebind(this, &plot_base::update_ref_opacity, cgv::signal::_c(i), cgv::signal::_r(p)));
1475 connect_copy(p.add_member_control(bp, "", (cgv::type::DummyEnum&)pbc.ref_opacity.opacity_idx, "dropdown", "w=88;enums='Off=-1,Primary=0,Secondary=1'")->value_change,
1476 cgv::signal::rebind(this, &plot_base::update_ref_opacity_index, cgv::signal::_c(i), cgv::signal::_r(p)));
1477
1478 connect_copy(p.add_member_control(bp, "Size", pbc.ref_size.size, "value_slider", "min=1;max=20;log=true;ticks=true;w=100", " ")->value_change,
1479 cgv::signal::rebind(this, &plot_base::update_ref_size, cgv::signal::_c(i), cgv::signal::_r(p)));
1480 connect_copy(p.add_member_control(bp, "", (cgv::type::DummyEnum&)pbc.ref_size.size_idx, "dropdown", "w=88;enums='Off=-1,Primary=0,Secondary=1'")->value_change,
1481 cgv::signal::rebind(this, &plot_base::update_ref_size_index, cgv::signal::_c(i), cgv::signal::_r(p)));
1482
1483 p.add_member_control(bp, "Begin", pbc.begin_sample, "value_slider", "min=0;ticks=true")->set("max", attribute_source_arrays[i].attribute_sources.front().count - 1);
1484 p.add_member_control(bp, "End", pbc.end_sample, "value_slider", "min=-1;ticks=true")->set("max", attribute_source_arrays[i].attribute_sources.front().count - 1);
1485}
1486void add_mapped_size_control(cgv::gui::provider& p, cgv::base::base* bp, const std::string& name, mapped_size& ms, std::string options)
1487{
1488 if (options.empty())
1489 options = "min=1;max=20;log=true;ticks=true;w=120";
1490 else
1491 options += ";w=120";
1492 p.add_member_control(bp, name, ms.size, "value_slider", options, " ");
1493 p.add_member_control(bp, "Si", (cgv::type::DummyEnum&)ms.size_idx, "dropdown", "enums='Off=-1,Primary,Secondary';w=58;tooltip='Size mapping index'");
1494}
1495void add_mapped_rgb_control(cgv::gui::provider& p, cgv::base::base* bp, const std::string& name, mapped_rgb& ms)
1496{
1497 p.add_member_control(bp, name, ms.color, "", "w=80", " ");
1498 p.add_member_control(bp, "Ci", (cgv::type::DummyEnum&)ms.color_idx, "dropdown", "enums='Off=-1,Primary,Secondary';w=58;tooltip='Color mapping index'");
1499}
1500void add_mapped_rgba_control(cgv::gui::provider& p, cgv::base::base* bp, const std::string& name, mapped_rgba& ms)
1501{
1502 p.add_member_control(bp, name, ms.color, "", "w=36", " ");
1503 p.add_member_control(bp, "Ci", (cgv::type::DummyEnum&)ms.color_idx, "dropdown", "enums='Off=-1,Primary,Secondary';w=58;tooltip='Color mapping index'", " ");
1504 p.add_member_control(bp, "Oi", (cgv::type::DummyEnum&)ms.opacity_idx, "dropdown", "enums='Off=-1,Primary,Secondary';w=58;tooltip='Opacity mapping index'");
1505}
1506void add_mapped_opacity_control(cgv::gui::provider& p, cgv::base::base* bp, const std::string& name, mapped_opacity& ms)
1507{
1508 p.add_member_control(bp, name, ms.opacity, "", "w=80", " ");
1509 p.add_member_control(bp, "Oi", (cgv::type::DummyEnum&)ms.opacity_idx, "dropdown", "enums='Off=-1,Primary,Secondary';w=58;tooltip='Opacity mapping index'");
1510}
1512{
1513 add_mapped_rgba_control(p, bp, "Color", pbc.point_color);
1514 add_mapped_rgba_control(p, bp, "Halo Color", pbc.point_halo_color);
1515 add_mapped_size_control(p, bp, "Size", pbc.point_size);
1516 add_mapped_size_control(p, bp, "Halo Width", pbc.point_halo_width, "min=-8;max=8;ticks=true");
1517}
1519{
1520 add_mapped_rgba_control(p, bp, "Color", pbc.line_color);
1521 add_mapped_rgba_control(p, bp, "Halo Color", pbc.line_halo_color);
1522 add_mapped_size_control(p, bp, "Width", pbc.line_width);
1523 add_mapped_size_control(p, bp, "Halo Width", pbc.line_halo_width, "min=0;max=20;log=true;ticks=true");
1524}
1526{
1527 p.add_member_control(bp, "Coordinate Index", pbc.stick_coordinate_index, "value_slider", "min=0;max=1;ticks=true")
1528 ->set("max", get_dim()-1);
1529 p.add_member_control(bp, "Base", pbc.stick_base_window, "value_slider", "min=0;max=1;ticks=true");
1530 add_mapped_rgba_control(p, bp, "Color", pbc.stick_color);
1531 add_mapped_size_control(p, bp, "Width", pbc.stick_width);
1532}
1534{
1535 p.add_member_control(bp, "Coordinate Index", pbc.bar_coordinate_index, "value_slider", "min=0;max=1;ticks=true")
1536 ->set("max", get_dim() - 1);
1537 p.add_member_control(bp, "Base", pbc.bar_base_window, "value_slider", "min=0;max=1;ticks=true");
1538 add_mapped_rgba_control(p, bp, "Color", pbc.bar_color);
1539 add_mapped_rgba_control(p, bp, "Outline", pbc.bar_outline_color);
1540 add_mapped_size_control(p, bp, "Outline Width", pbc.bar_outline_width, "min=0;max=20;log=true;ticks=true");
1541 add_mapped_size_control(p, bp, "Width", pbc.bar_percentual_width, "min=0.0;max=1.05;log=true;ticks=true");
1542}
1544{
1546 bool show = p.begin_tree_node("General", pbc.show_plot, true, "level=3;options='w=142'");
1547 if (show) {
1548 p.align("\a");
1549 create_base_config_gui(bp, p, i);
1550 p.align("\b");
1551 p.end_tree_node(pbc.show_plot);
1552 }
1553 show = p.begin_tree_node("Points", pbc.show_points, false, "level=3;options='w=142';align=' '");
1554 p.add_member_control(bp, "Show", pbc.show_points, "toggle", "w=50");
1555 if (show) {
1556 p.align("\a");
1557 create_point_config_gui(bp, p, pbc);
1558 p.align("\b");
1560 }
1561 show = p.begin_tree_node("Lines", pbc.show_lines, false, "level=3;options='w=142';align=' '");
1562 p.add_member_control(bp, "Show", pbc.show_lines, "toggle", "w=50");
1563 if (show) {
1564 p.align("\a");
1565 create_line_config_gui(bp, p, pbc);
1566 p.align("\b");
1568 }
1569 show = p.begin_tree_node("Sticks", pbc.show_sticks, false, "level=3;options='w=142';align=' '");
1570 p.add_member_control(bp, "Show", pbc.show_sticks, "toggle", "w=50");
1571 if (show) {
1572 p.align("\a");
1573 create_stick_config_gui(bp, p, pbc);
1574 p.align("\b");
1576 }
1577 show = p.begin_tree_node("Bars", pbc.show_bars, false, "level=3;options='w=142';align=' '");
1578 p.add_member_control(bp, "Show", pbc.show_bars, "toggle", "w=50");
1579 if (show) {
1580 p.align("\a");
1581 create_bar_config_gui(bp, p, pbc);
1582 p.align("\b");
1583 p.end_tree_node(pbc.show_bars);
1584 }
1585}
1587{
1588 create_plot_gui(bp, p);
1589 p.add_decorator("Subplots", "heading", "level=3;font_style=regular;align=i", "%y-=8\n");
1590 p.add_decorator("", "separator", "h=2");
1591 for (unsigned i=0; i<get_nr_sub_plots(); ++i) {
1593 bool show = p.begin_tree_node(pbc.name, pbc.name, false, "level=3;options='w=138;font_style=italic';align=' '");
1594 connect_copy(p.add_member_control(bp, "", pbc.ref_color.color, "", "w=10", "")->value_change,
1595 cgv::signal::rebind(this, &plot_base::update_ref_color, cgv::signal::_c(i), cgv::signal::_r(p)));
1596 p.add_member_control(bp, "Show", pbc.show_plot, "toggle", "w=40");
1597 if (show) {
1598 p.align("\a");
1599 create_config_gui(bp, p, i);
1600 p.align("\b");
1601 p.end_tree_node(pbc.name);
1602 }
1603 }
1604}
1605
1606 }
1607}
1608
1609#ifdef REGISTER_SHADER_FILES
1610#include <cgv/base/register.h>
1611#include <plot_shader_inc.h>
1612#endif
base class for all classes that can be registered with support for dynamic properties (see also secti...
Definition base.h:75
bool empty() const
check if pointer is not yet set
Definition ref_ptr.h:230
const T get_value() const
return a reference to the current value
Definition control.h:138
const T & get_old_value() const
return the old value to the callbacks attached to the change_value signal
Definition control.h:144
derive from this class to provide a gui to the current viewer
Definition provider.h:64
bool add_gui(const std::string &label, T &value, const std::string &gui_type="", const std::string &options="")
Add a composed gui of the given gui_type for the given value.
Definition provider.h:247
cgv::base::base_ptr add_decorator(const std::string &label, const std::string &decorator_type, const std::string &options="", const std::string &align="\n")
add a newly created decorator to the group
Definition provider.cxx:168
void align(const std::string &_align)
send pure alignment information
Definition provider.cxx:36
bool begin_tree_node(const std::string &label, const T &value, bool initial_visibility=false, const std::string &options="", gui_group_ptr ggp=gui_group_ptr())
Begin a sub tree of a tree structured gui.
Definition provider.h:212
virtual void update_member(void *member_ptr)
call this to update all views and controls of a member
Definition provider.cxx:72
data::ref_ptr< control< T > > add_member_control(cgv::base::base *base_ptr, const std::string &label, T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
add control with callback to cgv::base::on_set method on cgv::gui::control::value_change
Definition provider.h:137
void end_tree_node(const T &value)
template specialization that allows to specify value reference plus node_instance by using the result...
Definition provider.h:222
data::ref_ptr< control< T > > find_control(T &value, int *idx_ptr=0)
find a control of a given class member
Definition provider.h:330
static fvec< float, N > from_vec(const vec< float > &)
conversion from vector
Definition fvec.h:738
vec< T > to_vec() const
conversion to vector type
Definition fvec.h:730
static cgv::type::uint32_type size()
return number of elements
Definition fvec.h:179
vec_type apply(const vec_type &v) const
rotate vector according to quaternion
Definition quaternion.h:219
unsigned size() const
number of elements
Definition vec.h:59
void zeros()
fill the vector with zeros
Definition vec.h:470
fpnt_type get_corner(int i) const
return the i-th corner where the lower N bits of i are used to select between min (bit = 0) and max (...
const fpnt_type & get_max_pnt() const
return a const reference to corner 7
const fpnt_type & get_min_pnt() const
return a const reference to corner 0
configuration information stored per domain axis
Definition axis_config.h:45
tick_config primary_ticks
configuration of primary tickmarks
float line_width
line width
float get_attribute_max() const
read access to attrbribute maximum value
Definition axis_config.h:72
float tick_space_from_attribute_space(float value) const
perform transformation from attribute space to tick mark space by applying log transformation if acti...
rgb color
color of axis
float plot_space_from_window_space(float value) const
convert from window to plot space
tick_config secondary_ticks
configuration of secondary tickmarks
float get_attribute_min() const
read access to attrbribute minimum value
Definition axis_config.h:70
unsigned get_dim() const
return nr dimensions of plot
Definition plot_base.h:488
cgv::render::rectangle_render_style rrs
render style of rectangles
Definition plot_base.h:449
static const unsigned MAX_NR_SIZE_MAPPINGS
define maximum number of size mappings
Definition plot_base.h:407
int color_mapping[MAX_NR_COLOR_MAPPINGS]
index of attribute mapped to primary and secondary color
Definition plot_base.h:383
const vec3 get_axis_direction(unsigned ai) const
return true world direction of x, y or z axis
void adjust_domain_axis_to_data(unsigned ai, bool adjust_min=true, bool adjust_max=true, bool only_visible=true)
adjust the domain with respect to ai th axis to the visible or all data depending on last parameter
static std::string font_name_enum_def
concatenate font names to enum definition for dropdown control
Definition plot_base.h:330
bool opacity_is_bipolar[MAX_NR_OPACITY_MAPPINGS]
flag whether opacity mapping is bipolar for primary and secondary opacity mapping
Definition plot_base.h:398
int size_mapping[MAX_NR_SIZE_MAPPINGS]
index of attribute mapped to size
Definition plot_base.h:409
virtual void create_config_gui(cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
create the gui for a subplot configuration
void on_font_selection()
callback to change fonts
virtual void create_bar_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a bar subplot
static std::vector< const char * > font_names
store a vector with all fonts on the system
Definition plot_base.h:328
virtual void create_line_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a line subplot
int opacity_mapping[MAX_NR_OPACITY_MAPPINGS]
index of attribute mapped to primary and secondary opacity
Definition plot_base.h:394
const domain_config * get_domain_config_ptr() const
return const pointer to domain configuration
void set_width(float new_width, bool constrained=true)
set the plot width to given value and if constrained == true the height, such that the aspect ration ...
virtual void create_base_config_gui(cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
create the gui for base subplot settings
float size_gamma[MAX_NR_SIZE_MAPPINGS]
and independent gamma adjustments
Definition plot_base.h:411
void set_label_font(float font_size, cgv::media::font::FontFaceAttributes ffa=cgv::media::font::FFA_REGULAR, const std::string &font_name="")
configure the label font
float opacity_window_zero_position[MAX_NR_OPACITY_MAPPINGS]
window space position of zero for primary and secondary opacity mapping
Definition plot_base.h:400
rgba legend_color
color and opacity of legend
Definition plot_base.h:374
void clear(cgv::render::context &ctx)
destruct shader programs
unsigned get_nr_sub_plots() const
return current number of sub plots
LegendComponent legend_components
whether to show legend
Definition plot_base.h:366
void place_origin(const vec3 &new_origin_location)
place the origin of the plot in 3D to the given location
std::vector< attribute_source_array > attribute_source_arrays
attribute sources
Definition plot_base.h:429
void ensure_font_names()
ensure that font names have been enumerate
vecn get_extent() const
query the plot extend in 2D coordinates
void adjust_domain_to_data(bool only_visible=true)
adjust selected axes of domain to the visible or all data depending on last parameter
bool determine_axis_extent_from_subplot(unsigned ai, unsigned i, float &sample_min, float &sample_max)
adjust the domain with respect to ai th axis to the i-th subplot
float opacity_gamma[MAX_NR_OPACITY_MAPPINGS]
gamma adjustments for primary and secondary opacity mapping
Definition plot_base.h:396
cgv::render::vertex_buffer vbo_legend
vbo for legend drawing
Definition plot_base.h:425
static const unsigned MAX_NR_OPACITY_MAPPINGS
define maximum number of opacity mappings
Definition plot_base.h:392
float layer_depth
depth offset of a single layer
Definition plot_base.h:323
float size_min[MAX_NR_SIZE_MAPPINGS]
min and max of mapped size
Definition plot_base.h:413
float opacity_max[MAX_NR_OPACITY_MAPPINGS]
maximum opacity value for primary and secondary opacity mapping
Definition plot_base.h:404
void set_view_ptr(cgv::render::view *_view_ptr)
set the view ptr
void on_font_face_selection()
callback to change font face
vec2 legend_extent
width of legend
Definition plot_base.h:370
quat orientation
orientiation quaternion mapping from domain to world coordinates
Definition plot_base.h:354
void set_domain_config_ptr(domain_config *_new_ptr)
set the domain configuration to an external configuration in order to synch several plots,...
unsigned dim
dimension of plot
Definition plot_base.h:340
float window_zero_position[MAX_NR_COLOR_MAPPINGS]
window space position of zero for primary and secondary color mapping
Definition plot_base.h:389
domain_config dom_cfg
domain configuration
Definition plot_base.h:344
vec3 get_corner(unsigned i) const
return the i-th plot corner in 3D coordinates
void set_mapping_uniforms(cgv::render::context &ctx, cgv::render::shader_program &prog)
set the uniforms for defining the mappings to visual variables
vec3 center_location
center location of domain in world coordinates
Definition plot_base.h:356
std::vector< plot_base_config * > configs
store one configuration per sub plot
Definition plot_base.h:348
vec3 transform_to_world(const vecn &pnt_attr) const
transform from attribute space to world space
cgv::media::ColorScale color_scale_index[MAX_NR_COLOR_MAPPINGS]
color scale indices of primary and secondary color mapping
Definition plot_base.h:385
ivec4 out_of_range_mode
handling of values that are out of range
Definition plot_base.h:379
void place_center(const vec3 &new_center_location)
place the plot extent center in 3D to the given location (this might can change the current origin lo...
float opacity_min[MAX_NR_OPACITY_MAPPINGS]
minimum opacity value for primary and secondary opacity mapping
Definition plot_base.h:402
float color_scale_gamma[MAX_NR_COLOR_MAPPINGS]
gamma adjustments for primary and secondary color mapping
Definition plot_base.h:387
std::vector< label_info > tick_labels
all tick labels
Definition plot_base.h:319
static const unsigned MAX_NR_COLOR_MAPPINGS
define maximum number of color mappings
Definition plot_base.h:381
void set_height(float new_height, bool constrained=true)
set the plot height to given value and if constrained == true the width, such that the aspect ration ...
void adjust_tick_marks(unsigned max_nr_secondary_ticks=20, bool adjust_to_attribute_ranges=true)
adjust tick marks of all axes based on maximum number of secondary ticks and domain min and max in co...
plot_base(unsigned dim, unsigned nr_attributes=0)
construct from plot dimension and number of additional attributes with default parameters
cgv::render::attribute_array_binding aab_legend
manage attributes for legend drawing
Definition plot_base.h:427
void set_samples_out_of_date(unsigned i)
notify plot that samples of given subplot are out of date
domain_config * dom_cfg_ptr
pointer to currently used domain config
Definition plot_base.h:346
plot_base_config & ref_sub_plot_config(unsigned i)
return a reference to the plot base configuration of the i-th plot
void set_orientation(const quat &_orientation)
set new orientation quaternion
vec3 get_origin() const
return the current origin in 3D coordinates
unsigned nr_attributes
number of additional attributes
Definition plot_base.h:342
void prepare_extents()
prepare extents for drawing
cgv::media::font::font_face_ptr title_font_face
store pointer to title font face
Definition plot_base.h:423
int legend_axis
coordinate direction along which to draw legend
Definition plot_base.h:372
virtual void create_gui(cgv::base::base *bp, cgv::gui::provider &p)
create a gui for the plot with gui for all configs
vec3 legend_location
center location of legend in domain coordinates
Definition plot_base.h:368
cgv::media::font::font_ptr title_font
store pointer to title font
Definition plot_base.h:421
void set_sub_plot_attribute(unsigned i, unsigned ai, int subplot_index, size_t aj)
define a sub plot attribute ai from coordinate aj of the i-th internal sample container
void set_domain(const box2 &dom)
set the domain for 2d plots
const quat & get_orientation() const
get current orientation quaternion
virtual void create_point_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a point subplot
virtual void create_plot_gui(cgv::base::base *bp, cgv::gui::provider &p)
create the gui for the plot without gui for sub plots
std::vector< tick_batch_info > tick_batches
twice number of axis pairs with index of first tick label and number of tick labels for primary and s...
Definition plot_base.h:321
void set_extent(const vecn &new_extent)
set the plot extend in 2D coordinates
const box3 get_domain3() const
return 3d domain shown in plot
cgv::media::font::font_ptr label_font
store pointer to label font
Definition plot_base.h:417
virtual void create_stick_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a stick subplot
void include_axis_to_domain(unsigned ai)
extend domain such that given axis is included
const box2 get_domain() const
return 2d domain shown in plot
void set_plot_uniforms(cgv::render::context &ctx, cgv::render::shader_program &prog)
set the uniforms for plot configurations
void adjust_extent_to_domain_aspect_ratio(int preserve_ai=0)
adjust the extent such that it has same aspect ration as domain
void set_domain3(const box3 &dom)
set the domain for 3d plots
void set_sub_plot_colors(unsigned i, const rgb &base_color)
set the colors for all plot features of the i-th sub plot as variation of the given color
bool init(cgv::render::context &ctx)
build legend prog and create aab
void place_corner(unsigned corner_index, const vec3 &new_corner_location)
place a corner (0 .. lower left, 1 .. lower right, 2 .. upper left, 3 .. upper right) to a given 3D l...
const vec3 & get_center() const
return the current plot center in 3D coordinates
cgv::media::font::font_face_ptr label_font_face
store pointer to label font face
Definition plot_base.h:419
void set_extent_scaling(float x_scale, float y_scale, float z_scale=0)
set extent_scaling values for all axes
vec3 extent
extents used for drawing current
Definition plot_base.h:437
bool enable(context &ctx)
enable whole the attribute array binding object
bool create(const context &ctx)
create the attribute array binding object
void destruct(const context &ctx)
destruct attribute array binding object
bool disable(context &ctx)
disable whole attribute array binding object
bool enable_array(const context &ctx, int loc)
enable array for vertex attribute at location loc
bool set_attribute_array(const context &ctx, int loc, const T &array)
set vertex attribute location to given array and enable array
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
virtual std::ostream & output_stream()
returns an output stream whose output is printed at the current cursor location, which is managed by ...
Definition context.cxx:901
virtual void mul_modelview_matrix(const dmat4 &MV)
multiply given matrix from right to current modelview matrix
Definition context.cxx:1808
virtual void set_color(const rgba &clr)
set the current color
Definition context.cxx:1617
virtual void enable_font_face(media::font::font_face_ptr font_face, float font_size)
enable the given font face with the given size in pixels
Definition context.cxx:906
virtual void set_cursor(int x, int y)
flush the output_stream and set a new cursor position given in opengl coordinates with (0,...
Definition context.cxx:1959
void pop_modelview_matrix()
see push_V for an explanation
Definition context.cxx:1814
void push_modelview_matrix()
push the current viewing matrix onto a matrix stack for viewing matrices.
Definition context.cxx:1802
void show()
show the drawable
Definition drawable.cxx:26
a shader program combines several shader code fragments to a complete definition of the shading pipel...
bool enable(context &ctx)
enable the shader program
bool disable(context &ctx)
disable shader program and restore fixed functionality
bool set_uniform(const context &ctx, const std::string &name, const T &value, bool generate_error=false)
Set the value of a uniform by name, where the type can be any of int, unsigned, float,...
bool set_uniform_array(const context &ctx, const std::string &name, const T &array)
set uniform array from array array where number elements can be derived from array through array_desc...
void destruct(const context &ctx)
destruct shader program
int get_attribute_location(const context &ctx, const std::string &name) const
query location index of an attribute
int get_uniform_location(const context &ctx, const std::string &name) const
query location index of an uniform
bool build_program(const context &ctx, const std::string &file_name, bool show_error=false, const shader_define_map &defines=shader_define_map())
successively calls create, attach_program and link.
a vertex buffer is an unstructured memory block on the GPU.
bool create(const context &ctx, size_t size_in_bytes)
create empty vertex buffer of size size given in bytes
void destruct(const context &ctx)
destruct the render buffer
defines a symmetric view with the following quantities:
Definition view.h:22
font_ptr find_font(const std::string &font_name)
find an installed font by name
Definition font.cxx:32
FontFaceAttributes
declaration of supported attributes of font faces
Definition font.h:21
font_ptr default_font(bool mono_space)
return platform dependend default font
Definition font.cxx:57
void enumerate_font_names(std::vector< const char * > &font_names)
enumerate the names of all installed fonts
Definition font.cxx:65
TextAlignment
different text alignments
Definition context.h:273
@ TA_TOP
center of top edge of text bounds
Definition context.h:277
@ TA_BOTTOM
center of bottom edge of text bounds
Definition context.h:278
@ TA_NONE
no alignment
Definition context.h:274
@ TA_RIGHT
center of right edge of text bounds
Definition context.h:276
@ TA_LEFT
center of left edge of text bounds
Definition context.h:275
rectangle_renderer & ref_rectangle_renderer(context &ctx, int ref_count_change)
reference to a singleton plane renderer that can be shared among drawables
void configure_color_scale(cgv::render::context &ctx, cgv::render::shader_program &prog, cgv::media::ColorScale cs, float window_zero_position)
convenience function to configure a shader that uses color_scale.glsl with a single color scale
DummyEnum
some enum to mark an integral parameter to be of enum type
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
the cgv namespace
Definition print.h:11
cgv::math::fvec< float, 4 > vec4
declare type of 4d single precision floating point vectors (used for homogeneous coordinates)
Definition fvec.h:671
cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
declare rgba color type with 32 bit components
Definition color.h:855
cgv::math::quaternion< float > quat
declare type of quaternion
Definition quaternion.h:370
cgv::media::axis_aligned_box< float, 3 > box3
declare type of 3d single precision floating point axis-aligned boxes
cgv::math::fvec< int32_t, 4 > ivec4
declare type of 4d 32 bit integer vectors
Definition fvec.h:698
cgv::math::vec< float > vecn
declare type of single precision floating point vector with varying dimension
Definition vec.h:1187
cgv::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
Definition color.h:853
cgv::math::fvec< float, 2 > vec2
declare type of 2d single precision floating point vectors
Definition fvec.h:667
cgv::media::axis_aligned_box< float, 2 > box2
declare type of 2d single precision floating point axis-aligned boxes
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
Definition fvec.h:669
T S() const
convert color to HLS and return S component
Definition color.h:448
store source of a single plot attribute (one coordinate axis or one float attribute)
Definition plot_base.h:228
attribute_source()
construct an empty attribute sources
rgba title_color
color of the title
Definition plot_base.h:50
bool show_domain
whether to show the coordinate axes including tickmarks and labels
Definition plot_base.h:36
unsigned title_font_index
store index of selected title font
Definition plot_base.h:64
float title_font_size
store selected title font size
Definition plot_base.h:66
float reference_size
store size of virtual pixel based measurement
Definition plot_base.h:52
unsigned label_font_index
store index of selected label font
Definition plot_base.h:58
bool fill
whether to fill the domain
Definition plot_base.h:38
std::string title
plot title
Definition plot_base.h:40
vecn title_pos
position of title
Definition plot_base.h:46
cgv::media::font::FontFaceAttributes label_ffa
store selected label font face attributes
Definition plot_base.h:62
std::vector< axis_config > axis_configs
store a vector of axis configurations (2/3 for plot2/3d plus several attribute axes)
Definition plot_base.h:56
cgv::media::font::FontFaceAttributes title_ffa
store selected title font face attributes
Definition plot_base.h:68
rgb color
color of the domain fill
Definition plot_base.h:48
float label_font_size
store selected label font size
Definition plot_base.h:60
float blend_width_in_pixel
store blend width in screen pixels used for antialiasing
Definition plot_base.h:54
bool show_title
whether to show the plot title
Definition plot_base.h:42
bool show_sub_plot_names
whether to show the sub plot names
Definition plot_base.h:44
plot independent configuration parameters of one sub plot in a 2d or 3d plot
Definition plot_base.h:130
mapped_size line_halo_width
width of line halo in pixel
Definition plot_base.h:170
virtual void set_sizes(float _size)
set all sizes from reference size
int bar_coordinate_index
extended bar information
Definition plot_base.h:188
virtual void set_colors(const rgb &base_color)
set all colors from reference color
Definition plot_base.cxx:84
mapped_size line_width
line width
Definition plot_base.h:166
mapped_size bar_percentual_width
percentual width of bar computed assuming a uniform y-sampling distance
Definition plot_base.h:194
virtual void configure_chart(ChartType chart_type)
configure the sub plot to a specific chart type
Definition plot_base.cxx:68
std::string name
name of sub plot
Definition plot_base.h:132
float stick_base_window
base window position of stick
Definition plot_base.h:179
bool show_lines
whether to connect data points with lines
Definition plot_base.h:164
mapped_rgba stick_color
color of the stick line
Definition plot_base.h:183
bool show_bars
whether to show bars
Definition plot_base.h:186
mapped_size bar_outline_width
line width of bar outlines
Definition plot_base.h:192
mapped_opacity ref_opacity
reference opacity, when changed, all opcities are adapted with set_opacity()
Definition plot_base.h:147
bool show_points
whether to show data points
Definition plot_base.h:152
plot_base_config(const std::string &_name, unsigned dim)
set default values
Definition plot_base.cxx:47
mapped_size stick_width
line width of stick
Definition plot_base.h:181
mapped_rgba bar_color
bar fill color
Definition plot_base.h:196
SubPlotInfluence sub_plot_influence
store bit field to define which sub plots are influenced by reference values
Definition plot_base.h:143
mapped_rgba line_halo_color
color of line halo
Definition plot_base.h:172
mapped_rgba point_color
point color
Definition plot_base.h:157
mapped_size ref_size
reference size, when changed, all sizes are adapted with set_size()
Definition plot_base.h:149
size_t begin_sample
offset into samples defaults to 0, if larger than end_sample vector is split into two parts
Definition plot_base.h:135
int stick_coordinate_index
extended stick information
Definition plot_base.h:177
bool show_plot
whether to show sub plot
Definition plot_base.h:140
bool show_sticks
whether to show straight lines to the bottom of the plot, which are called sticks
Definition plot_base.h:175
mapped_rgba line_color
line color
Definition plot_base.h:168
mapped_rgb ref_color
reference color, when changed, all colors are adapted with set_colors()
Definition plot_base.h:145
mapped_size point_halo_width
width of point halo in pixel
Definition plot_base.h:159
virtual ~plot_base_config()
virtual constructor in order to allow to extend the configuration for derived classes
mapped_rgba bar_outline_color
bar outline color
Definition plot_base.h:198
virtual void set_opacities(float _opa)
set all opacities from reference opacity
mapped_size point_size
point size in pixels
Definition plot_base.h:154
mapped_rgba point_halo_color
color of point halo
Definition plot_base.h:161
size_t end_sample
defaults to -1 and effectively is always the end of the sample vector
Definition plot_base.h:137
tickmark configuration of one tickmark type
Definition axis_config.h:24
float line_width
line width
Definition axis_config.h:30
bool label
whether to show text labels at tick
Definition axis_config.h:34
float step
step width between two ticks along axis
Definition axis_config.h:28
float length
tick length relative to domain extent
Definition axis_config.h:32
TickType type
type of tick
Definition axis_config.h:26
float default_depth_offset
default depth offset added to depth value of fragment. (default: 0.0f)
ColorMapping map_color_to_material
material side[s] where color is to be mapped to the diffuse material component, defaults to MS_FRONT_...
IlluminationMode illumination_mode
illumination mode defaults to IM_ONE_SIDED