cgv
plot2d.h
1 #pragma once
2 
3 #include "plot_base.h"
4 #include <cgv/render/shader_program.h>
5 
6 #include "lib_begin.h"
7 
8 namespace cgv {
9  namespace plot {
10 
12 struct CGV_API plot2d_config : public plot_base_config
13 {
15  plot2d_config(const std::string& _name);
17  void configure_chart(ChartType chart_type);
18 };
19 
21 class CGV_API plot2d : public plot_base
22 {
23 protected:
25  cgv::render::shader_program point_prog;
26  cgv::render::shader_program rectangle_prog;
28  bool draw_point_plot(cgv::render::context& ctx, int si, int layer_idx);
29  bool draw_line_plot(cgv::render::context& ctx, int si, int layer_idx);
30  bool draw_stick_plot(cgv::render::context& ctx, int si, int layer_idx);
31  void configure_bar_plot(cgv::render::context& ctx);
32  bool draw_bar_plot(cgv::render::context& ctx, int si, int layer_idx);
33  int draw_sub_plots_jointly(cgv::render::context& ctx, int layer_idx);
34  //bool extract_tick_rectangles_and_tick_labels(std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D,
35  // std::vector<label_info>& tick_labels, int ai, int ti, float he, float z_plot = std::numeric_limits<float>::quiet_NaN());
36  void extract_domain_rectangles(std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D);
37  void extract_domain_tick_rectangles_and_tick_labels(std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D, std::vector<label_info>& tick_labels, std::vector<tick_batch_info>& tick_batches);
38  void draw_domain(cgv::render::context& ctx, int si = -1, bool no_fill = false);
39 protected:
40 
41  bool compute_sample_coordinate_interval(int i, int ai, float& samples_min, float& samples_max);
43  std::vector<std::vector<vec2> > samples;
45  std::vector <std::vector<unsigned> > strips;
48 public:
49  bool disable_depth_mask;
54 
56  plot2d(const std::string& title, unsigned nr_attributes = 0);
58  ~plot2d();
61  unsigned add_sub_plot(const std::string& name);
64  void delete_sub_plot(unsigned i);
66  plot2d_config& ref_sub_plot2d_config(unsigned i = 0);
68  std::vector<vec2>& ref_sub_plot_samples(unsigned i = 0);
70  std::vector<unsigned>& ref_sub_plot_strips(unsigned i = 0);
72 
74  bool init(cgv::render::context& ctx);
76  void draw(cgv::render::context& ctx);
78  void clear(cgv::render::context& ctx);
79 
81  void create_point_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
83  void create_stick_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
85  void create_bar_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
87  void create_config_gui(cgv::base::base* bp, cgv::gui::provider& p, unsigned i);
88  void create_gui(cgv::base::base* bp, cgv::gui::provider& p);
89 };
90 
91  }
92 }
93 
94 #include <cgv/config/lib_end.h>
cgv::plot::plot2d::sub_plot_delta
vec3 sub_plot_delta
offset in between sub plots in x, y and z direction
Definition: plot2d.h:53
cgv::plot::plot2d::strips
std::vector< std::vector< unsigned > > strips
allow to split series into connected strips that are represented by the number of contained samples
Definition: plot2d.h:45
cgv::math::fvec< float, 3 >
cgv::plot::plot2d_config
Definition: plot2d.h:13
cgv::plot::plot2d::samples
std::vector< std::vector< vec2 > > samples
store 2d samples for data series
Definition: plot2d.h:43
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::plot::plot_base
Definition: plot_base.h:274
cgv::plot::plot2d
Definition: plot2d.h:22
cgv::base::base
Definition: base.h:57
cgv::plot::plot2d::multi_axis_modes
bool * multi_axis_modes
whether to manage separate axes for each sub plot
Definition: plot2d.h:51
cgv::plot::plot2d::aam_domain
cgv::render::attribute_array_manager aam_domain
attribute managers for domain rectangles and domain tick labels
Definition: plot2d.h:47
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