cgv
plot3d.h
1 #pragma once
2 
3 #include "plot_base.h"
4 #include <cgv/render/shader_program.h>
5 #include <libs/cgv_gl/box_renderer.h>
6 #include <cgv_gl/rounded_cone_renderer.h>
7 
8 #include "lib_begin.h"
9 
10 namespace cgv {
11  namespace plot {
12 
14 enum PlotFaceIllumination
15 {
16  PFI_NONE,
17  PFI_PER_FACE,
18  PFI_PER_VERTEX
19 };
20 
22 struct CGV_API plot3d_config : public plot_base_config
23 {
27  mapped_size bar_percentual_depth;
29  unsigned samples_per_row;
33  bool wireframe;
37  PlotFaceIllumination face_illumination;
39  void set_colors(const rgb& base_color);
41  plot3d_config(const std::string& _name);
42 };
43 
45 class CGV_API plot3d : public plot_base
46 {
47  cgv::render::shader_program tick_label_prog;
48  cgv::render::shader_program sphere_prog;
50  cgv::render::shader_program wirebox_prog;
51  cgv::render::shader_program stick_prog;
53  //cgv::render::shader_program surface_prog;
55  cgv::render::rounded_cone_render_style rcrs;
57 
58  bool compute_sample_coordinate_interval(int i, int ai, float& samples_min, float& samples_max);
59  void draw_domain(cgv::render::context& ctx);
60  void draw_ticks(cgv::render::context& ctx);
61  void draw_sub_plots(cgv::render::context& ctx);
62 protected:
63  std::vector<std::vector<vec3> > samples;
65  void compute_tick_render_information();
66 public:
68  plot3d(unsigned nr_attributes = 0);
71  unsigned add_sub_plot(const std::string& name);
74  void set_samples_per_row(unsigned i, unsigned N);
76  unsigned get_samples_per_row(unsigned i) const;
78  void delete_sub_plot(unsigned i);
80  plot3d_config& ref_sub_plot3d_config(unsigned i = 0);
82  std::vector<vec3>& ref_sub_plot_samples(unsigned i = 0);
84 
86  void create_line_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
88  void create_bar_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
89  void create_config_gui(cgv::base::base* bp, cgv::gui::provider& p, unsigned i);
90  bool init(cgv::render::context& ctx);
91  void draw(cgv::render::context& ctx);
92  void clear(cgv::render::context& ctx);
93  void create_gui(cgv::base::base* bp, cgv::gui::provider& p);
94 };
95 
96  }
97 }
98 #include <cgv/config/lib_end.h>
cgv::plot::plot3d_config::show_line_orientation
bool show_line_orientation
whether to illustrate line orientation
Definition: plot3d.h:25
cgv::plot::plot3d
Definition: plot3d.h:46
cgv::render::box_render_style
boxes use surface render styles
Definition: box_renderer.h:19
cgv::plot::plot3d_config::wireframe
bool wireframe
whether to turn on wireframe
Definition: plot3d.h:33
cgv::plot::plot3d_config::show_surface
bool show_surface
whether to show faces
Definition: plot3d.h:31
cgv::plot::plot3d_config
Definition: plot3d.h:23
cgv::render::attribute_array_manager
attribute array manager used to upload arrays to gpu
Definition: renderer.h:21
cgv::gui::provider
derive from this class to provide a gui to the current viewer
Definition: provider.h:64
cgv::render::shader_program
Definition: shader_program.h:25
cgv::media::color
Definition: color.h:51
cgv::plot::plot3d_config::surface_color
rgb surface_color
color of faces
Definition: plot3d.h:35
cgv::plot::plot_base
Definition: plot_base.h:274
cgv::plot::plot3d_config::face_illumination
PlotFaceIllumination face_illumination
how to illuminate the surface
Definition: plot3d.h:37
cgv::base::base
Definition: base.h:57
cgv::plot::plot3d_config::samples_per_row
unsigned samples_per_row
if samples per row > 0, the samples are interpreted as regular grid
Definition: plot3d.h:29
cgv::plot::plot3d_config::bar_percentual_depth
mapped_size bar_percentual_depth
provide second dimension of bar extend
Definition: plot3d.h:27
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::context
Definition: context.h:525
cgv::plot::plot_base_config
Definition: plot_base.h:122