cgv
Loading...
Searching...
No Matches
plot2d.h
1#pragma once
2
3#include "plot_base.h"
4//#include "mark2d_provider.h"
5#include <cgv/render/shader_program.h>
6
7#include "lib_begin.h"
8
9namespace cgv {
10 namespace plot {
11
12
14struct CGV_API plot2d_config : public plot_base_config
15{
17 plot2d_config(const std::string& _name);
19 void configure_chart(ChartType chart_type);
21 //std::vector<std::pair<mark2d_provider*, mark_style*>> marks;
22};
23
25class CGV_API plot2d : public plot_base
26{
27protected:
30 cgv::render::shader_program rectangle_prog;
32 bool draw_point_plot(cgv::render::context& ctx, int si, int layer_idx);
33 bool draw_line_plot(cgv::render::context& ctx, int si, int layer_idx);
34 bool draw_stick_plot(cgv::render::context& ctx, int si, int layer_idx);
35 void configure_bar_plot(cgv::render::context& ctx);
36 bool draw_bar_plot(cgv::render::context& ctx, int si, int layer_idx);
37 int draw_sub_plots_jointly(cgv::render::context& ctx, int layer_idx);
38 //bool extract_tick_rectangles_and_tick_labels(std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D,
39 // std::vector<label_info>& tick_labels, int ai, int ti, float he, float z_plot = std::numeric_limits<float>::quiet_NaN());
40 void extract_domain_rectangles(std::vector<box2>& R, std::vector<rgb>& C, std::vector<float>& D);
41 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);
42 void draw_domain(cgv::render::context& ctx, int si = -1, bool no_fill = false);
43protected:
44
45 bool compute_sample_coordinate_interval(int i, int ai, float& samples_min, float& samples_max);
47 std::vector<std::vector<vec2> > samples;
49 std::vector <std::vector<unsigned> > strips;
52public:
53 bool disable_depth_mask;
59 plot2d(const std::string& title, unsigned nr_attributes = 0);
61 plot2d& operator=(const plot2d&) = delete;
62 plot2d(const plot2d&) = delete;
64 ~plot2d();
68 unsigned add_sub_plot(const std::string& name);
70 void delete_sub_plot(unsigned i);
72 plot2d_config& ref_sub_plot2d_config(unsigned i = 0);
74 std::vector<vec2>& ref_sub_plot_samples(unsigned i = 0);
76 std::vector<unsigned>& ref_sub_plot_strips(unsigned i = 0);
78
80 bool init(cgv::render::context& ctx);
82 void draw(cgv::render::context& ctx);
84 void clear(cgv::render::context& ctx);
85
87 void create_point_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
89 void create_stick_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
91 void create_bar_config_gui(cgv::base::base* bp, cgv::gui::provider& p, plot_base_config& pbc);
93 void create_config_gui(cgv::base::base* bp, cgv::gui::provider& p, unsigned i);
94 void create_gui(cgv::base::base* bp, cgv::gui::provider& p);
95};
96
97 }
98}
99
100#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
Definition base.h:75
derive from this class to provide a gui to the current viewer
Definition provider.h:64
The plot2d class draws 2d plots with potentially several sub plots of different chart types.
Definition plot2d.h:26
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:49
cgv::render::attribute_array_manager aam_domain
attribute managers for domain rectangles and domain tick labels
Definition plot2d.h:51
plot2d & operator=(const plot2d &)=delete
prevent copy and assignment for now until properly implemented
bool * multi_axis_modes
whether to manage separate axes for each sub plot
Definition plot2d.h:55
vec3 sub_plot_delta
offset in between sub plots in x, y and z direction
Definition plot2d.h:57
std::vector< std::vector< vec2 > > samples
store 2d samples for data series
Definition plot2d.h:47
base class for plot2d and plot3d, which can have several sub plots each
Definition plot_base.h:282
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
a shader program combines several shader code fragments to a complete definition of the shading pipel...
the cgv namespace
Definition print.h:11
extend common plot configuration with parameters specific to 2d plot
Definition plot2d.h:15
plot independent configuration parameters of one sub plot in a 2d or 3d plot
Definition plot_base.h:130