2#include <libs/cgv_gl/gl/gl.h> 
    3#include <cgv/math/ftransform.h> 
   42bool plot3d::compute_sample_coordinate_interval(
int i, 
int ai, 
float& samples_min, 
float& samples_max)
 
   45    bool found_sample = 
false;
 
   46    float min_value, max_value;
 
   47    for (
unsigned j = 0; j < samples[i].size(); ++j) {
 
   49            min_value = std::min(min_value, samples[i][j](ai));
 
   50            max_value = std::max(max_value, samples[i][j](ai));
 
   53            min_value = samples[i][j](ai);
 
   54            max_value = samples[i][j](ai);
 
   69    acs[0].name = 
"x"; acs[0].color = 
rgb(0.4f, 0.2f, 0.2f);
 
   70    acs[1].name = 
"y"; acs[1].color = 
rgb(0.2f, 0.4f, 0.2f);
 
   71    acs[2].name = 
"z"; acs[2].color = 
rgb(0.2f, 0.2f, 0.4f);
 
 
   98    samples.push_back(std::vector<vec3>());
 
 
  113    samples.erase(samples.begin() + i);
 
 
  147        std::cerr << 
"could not build GLSL program from plot3d_sphere.glpr" << std::endl;
 
  150        sphere_prog.allow_context_to_set_color(
false);
 
  153        std::cerr << 
"could not build GLSL program from plot3d_stick.glpr" << std::endl;
 
  156        stick_prog.allow_context_to_set_color(
false);
 
  157    if (!tick_label_prog.
build_program(ctx, 
"plot3d_tick_label.glpr")) {
 
  159        std::cerr << 
"could not build GLSL program from plot3d_tick_label.glpr" << std::endl;
 
  162        tick_label_prog.allow_context_to_set_color(
false);
 
  164        std::cerr << 
"could not build GLSL program from plot3d_box.glpr" << std::endl;
 
  168        box_prog.allow_context_to_set_color(
false);
 
  169    if (!wirebox_prog.
build_program(ctx, 
"plot3d_box_wire.glpr")) {
 
  171        std::cerr << 
"could not build GLSL program from plot3d_box_wire.glpr" << std::endl;
 
  174        wirebox_prog.allow_context_to_set_color(
false);
 
  175    if (!tube_prog.
build_program(ctx, 
"plot3d_tube.glpr", 
true)) {
 
  176        std::cerr << 
"could not build GLSL program from plot3d_tube.glpr" << std::endl;
 
  180        tube_prog.
set_uniform(ctx, 
"map_color_to_material", 3);
 
  181        tube_prog.allow_context_to_set_color(
false);
 
  189    aam_domain.init(ctx);
 
 
  199    double y_view_angle = 45.0f;
 
  202    float pixel_extent_per_depth = (float)(2.0 * tan(0.5 * 0.0174532925199 * y_view_angle) / ctx.
get_height());
 
  205        size_t count = enable_attributes(ctx, i, samples);
 
  213                    sphere_prog.
set_uniform(ctx, 
"map_color_to_material", 7);
 
  215                    sphere_prog.
set_uniform(ctx, 
"pixel_extent_per_depth", pixel_extent_per_depth);
 
  216                    sphere_prog.
set_uniform(ctx, 
"halo_width_in_pixel", 0.0f);
 
  217                    sphere_prog.
set_uniform(ctx, 
"halo_color_strength", 1.0f);
 
  229                    draw_sub_plot_samples(
int(count), spc);
 
  233                    unsigned N = (unsigned)count;
 
  234                    unsigned M = (unsigned)count;
 
  245                        wirebox_prog.
set_uniform(ctx, 
"box_width", box_width);
 
  246                        wirebox_prog.
set_uniform(ctx, 
"box_depth", box_depth);
 
  248                        wirebox_prog.
set_uniform(ctx, 
"box_base_window", spc.bar_base_window);
 
  250                        wirebox_prog.
set_uniform(ctx, 
"secondary_color_index", -1);
 
  252                        wirebox_prog.
set_uniform(ctx, 
"secondary_opacity_index", -1);
 
  257                        draw_sub_plot_samples(
int(count), spc);
 
  262                    box_prog.
set_uniform(ctx, 
"map_color_to_material", 7);
 
  265                    box_prog.
set_uniform(ctx, 
"box_base_window", spc.bar_base_window);
 
  268                    box_prog.
set_uniform(ctx, 
"secondary_color_index", -1);
 
  270                    box_prog.
set_uniform(ctx, 
"secondary_opacity_index", -1);
 
  275                    draw_sub_plot_samples(
int(count), spc);
 
  284                    stick_prog.
set_uniform(ctx, 
"map_color_to_material", 7);
 
  286                    stick_prog.
set_uniform(ctx, 
"secondary_color_index", -1);
 
  288                    stick_prog.
set_uniform(ctx, 
"secondary_opacity_index", -1);
 
  290                    stick_prog.
set_uniform(ctx, 
"secondary_size_index", -1);
 
  296                    draw_sub_plot_samples(
int(count), spc);
 
  303                    tube_prog.
set_uniform(ctx, 
"map_color_to_material", 7);
 
  305                    tube_prog.
set_uniform(ctx, 
"secondary_color_index", -1);
 
  307                    tube_prog.
set_uniform(ctx, 
"secondary_opacity_index", -1);
 
  309                    tube_prog.
set_uniform(ctx, 
"secondary_size_index", -1);
 
  313                    draw_sub_plot_samples(
int(count), spc, 
true);
 
  318        disable_attributes(ctx, i);
 
  333        bool tmp = br.
ref_prog().does_context_set_color();
 
  334        br.
ref_prog().allow_context_to_set_color(
false);
 
  341        br.
ref_prog().allow_context_to_set_color(tmp);
 
  346    std::vector<float> R;
 
  348    for (
unsigned ai = 0; ai < 3; ++ai) {
 
  349        int aj = (ai + 1) % 3;
 
  350        int ak = (ai + 2) % 3;
 
  354        float lw = rs * ac.line_width;
 
  358        float c[5][2] = { {-D[aj],-D[ak]}, {D[aj],-D[ak]}, {D[aj],D[ak]}, {-D[aj],D[ak]} };
 
  360        if (ao.get_attribute_min() < 0 && ao.get_attribute_max() > 0 &&
 
  361            ap.get_attribute_min() < 0 && ap.get_attribute_max() > 0) {
 
  362            c[cnt][0] = ao.plot_space_from_attribute_space(0.0f);
 
  363            c[cnt][1] = ap.plot_space_from_attribute_space(0.0f);
 
  367        for (
unsigned ci = 0; ci < cnt; ++ci) {
 
  379            for (
unsigned ti = 0; ti < 2; ++ti) {
 
  380                tick_config& tc = ti == 0 ? ac.primary_ticks : ac.secondary_ticks;
 
  381                if (tc.type == TT_NONE)
 
  384                float min_tick = ac.tick_space_from_attribute_space(ac.get_attribute_min());
 
  385                float max_tick = ac.tick_space_from_attribute_space(ac.get_attribute_max());
 
  386                int min_i = (int)ceil(min_tick / tc.step - std::numeric_limits<float>::epsilon());
 
  387                int max_i = (int)((max_tick - fmod(max_tick, tc.step)) / tc.step);
 
  389                if (ti == 1 && min_i * tc.step - min_tick < std::numeric_limits<float>::epsilon())
 
  391                if (ti == 1 && max_i * tc.step - max_tick > -std::numeric_limits<float>::epsilon())
 
  395                for (
int i = min_i; i <= max_i; ++i) {
 
  396                    float c_tick = (float)(i * tc.step);
 
  397                    float c_attr = ac.attribute_space_from_tick_space(c_tick);
 
  398                    std::string label_str;
 
  401                    float c_plot = ac.plot_space_from_window_space(ac.window_space_from_tick_space(c_tick));
 
  414                        if (!label_str.empty())
 
  434                            if (!label_str.empty())
 
  439                            p[aj] = c[(ci + 1) % 4][0];
 
  440                            p[ak] = c[(ci + 1) % 4][1];
 
  449                            if (!label_str.empty())
 
  479    rcr.set_render_style(rcrs);
 
  480    rcr.enable_attribute_array_manager(ctx, aam_domain);
 
  481    rcr.set_position_array(ctx, P);
 
  482    rcr.set_color_array(ctx, C);
 
  483    rcr.set_radius_array(ctx, R);
 
  484    rcr.render(ctx, 0, P.size());
 
  485    rcr.disable_attribute_array_manager(ctx, aam_domain);
 
  493    for (
const auto& tbc : 
tick_batches) if (tbc.label_count > 0) {
 
  495        for (
unsigned i = tbc.first_label; i < tbc.first_label + tbc.label_count; ++i) {
 
  497            ctx.
set_cursor(li.position, li.label, li.align);
 
  508    GLboolean blend = glIsEnabled(GL_BLEND); 
 
  509    GLenum blend_src, blend_dst, depth;
 
  510    glGetIntegerv(GL_BLEND_DST, 
reinterpret_cast<GLint*
>(&blend_dst));
 
  511    glGetIntegerv(GL_BLEND_SRC, 
reinterpret_cast<GLint*
>(&blend_src));
 
  512    glGetIntegerv(GL_DEPTH_FUNC, 
reinterpret_cast<GLint*
>(&depth));
 
  515    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  516    glDepthFunc(GL_LEQUAL);
 
  535    glBlendFunc(blend_src, blend_dst);
 
 
  548    aam_domain.destruct(ctx);
 
 
  562    add_mapped_size_control(p, bp, 
"depth", p3bc.
bar_percentual_depth, 
"min=0.01;max=1;log=true;ticks=true");
 
 
base class for all classes that can be registered with support for dynamic properties (see also secti...
 
derive from this class to provide a gui to the current viewer
 
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.
 
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
 
void align(const std::string &_align)
send pure alignment information
 
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.
 
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
 
void end_tree_node(const T &value)
template specialization that allows to specify value reference plus node_instance by using the result...
 
data::ref_ptr< view< T > > add_view(const std::string &label, const T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
use this to add a new view to the gui with a given value type, gui type and init options
 
vec< T > to_vec() const
conversion to vector type
 
void put_homogeneous_matrix(hmat_type &M) const
compute equivalent homogeneous 4x4 rotation matrix
 
The plot3d class draws 2d plots with potentially several sub plots of different plot configuration.
 
std::vector< vec3 > & ref_sub_plot_samples(unsigned i=0)
return the samples of the i-th sub plot
 
void draw(cgv::render::context &ctx)
overload to draw the content of this drawable
 
void compute_tick_render_information()
overloaded in derived classes to compute complete tick render information
 
plot3d_config & ref_sub_plot3d_config(unsigned i=0)
return a reference to the plot3d configuration of the i-th plot
 
bool init(cgv::render::context &ctx)
this method is called after creation or recreation of the context, return whether all necessary funct...
 
void create_bar_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a bar subplot
 
void clear(cgv::render::context &ctx)
clear all objects living in the context like textures or display lists
 
void create_gui(cgv::base::base *bp, cgv::gui::provider &p)
create a gui for the plot with gui for all configs
 
void set_samples_per_row(unsigned i, unsigned N)
set the number of samples of the i-th sub plot to N
 
void delete_sub_plot(unsigned i)
delete the i-th sub plot
 
unsigned get_samples_per_row(unsigned i) const
return the number of samples per row
 
void create_line_config_gui(cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
create the gui for a line subplot
 
plot3d(unsigned nr_attributes=0)
construct 3d plot with given number of additional attributes and default parameters
 
unsigned add_sub_plot(const std::string &name)
add sub plot and return reference to samples
 
void create_config_gui(cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
create the gui for a subplot configuration
 
base class for plot2d and plot3d, which can have several sub plots each
 
virtual void create_config_gui(cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
create the gui for a subplot configuration
 
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
 
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
 
const domain_config * get_domain_config_ptr() const
return const pointer to domain configuration
 
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
 
std::vector< attribute_source_array > attribute_source_arrays
attribute sources
 
vecn get_extent() const
query the plot extend in 2D coordinates
 
quat orientation
orientiation quaternion mapping from domain to world 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
 
std::vector< plot_base_config * > configs
store one configuration per sub plot
 
std::vector< label_info > tick_labels
all tick labels
 
plot_base_config & ref_sub_plot_config(unsigned i)
return a reference to the plot base configuration of the i-th plot
 
unsigned nr_attributes
number of additional attributes
 
void prepare_extents()
prepare extents for drawing
 
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
 
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...
 
void set_extent(const vecn &new_extent)
set the plot extend in 2D coordinates
 
void set_plot_uniforms(cgv::render::context &ctx, cgv::render::shader_program &prog)
set the uniforms for plot configurations
 
bool init(cgv::render::context &ctx)
build legend prog and create aab
 
cgv::media::font::font_face_ptr label_font_face
store pointer to label font face
 
vec3 extent
extents used for drawing current
 
renderer that supports point splatting
 
void set_extent(const context &ctx, const T &extent)
specify a single extent for all boxes
 
void set_position_is_center(bool _position_is_center)
set the flag, whether the position is interpreted as the box center, true by default
 
base class for all drawables, which is independent of the used rendering API.
 
virtual std::ostream & output_stream()
returns an output stream whose output is printed at the current cursor location, which is managed by ...
 
virtual void mul_modelview_matrix(const dmat4 &MV)
multiply given matrix from right to current modelview matrix
 
virtual void set_color(const rgba &clr)
set the current color
 
virtual unsigned int get_height() const =0
return the height of the window
 
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
 
virtual void set_cursor(int x, int y)
flush the output_stream and set a new cursor position given in opengl coordinates with (0,...
 
void pop_modelview_matrix()
see push_V for an explanation
 
void push_modelview_matrix()
push the current viewing matrix onto a matrix stack for viewing matrices.
 
void show()
show the drawable
 
shader_program & ref_prog()
derived renderer classes have access to shader program
 
void set_color(const context &ctx, const T &color)
templated method to set the color attribute from a single color of type T
 
void set_render_style(const render_style &rs)
reference given render style
 
void set_position(const context &ctx, const T &position)
templated method to set the position attribute from a single position of type T
 
virtual bool render(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
Convenience function that draws vertex or indexed element with this renderer.
 
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,...
 
void destruct(const context &ctx)
destruct shader program
 
bool set_attribute(const context &ctx, const std::string &name, const T &value)
set constant default value of a vertex attribute by attribute name, if name does not specify an attri...
 
bool build_program(const context &ctx, const std::string &file_name, bool show_error=false)
successively calls create, attach_program and link.
 
double get_y_view_angle() const
query opening angle (degrees) of view in y-direction
 
@ TA_BOTTOM
center of bottom edge of text bounds
 
@ TA_LEFT
center of left edge of text bounds
 
cone_renderer & ref_cone_renderer(context &ctx, int ref_count_change)
reference to a singleton cone renderer that is shared among drawables
 
box_renderer & ref_box_renderer(context &ctx, int ref_count_change)
reference to a singleton box renderer that is shared among drawables
 
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
 
T min_value(ForwardIt first, ForwardIt last, T fallback)
Find the minimum value in the range [first, last) or return fallback if the range is empty.
 
T max_value(ForwardIt first, ForwardIt last, T fallback)
Find the maximum value in the range [first, last) or return fallback if the range is empty.
 
cgv::math::vec< float > vecn
declare type of single precision floating point vector with varying dimension
 
cgv::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
 
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
 
struct that manages attribute sources and corresponding gpu objects per subplot
 
store source of a single plot attribute (one coordinate axis or one float attribute)
 
float reference_size
store size of virtual pixel based measurement
 
std::vector< axis_config > axis_configs
store a vector of axis configurations (2/3 for plot2/3d plus several attribute axes)
 
rgb color
color of the domain fill
 
float blend_width_in_pixel
store blend width in screen pixels used for antialiasing
 
extend common plot configuration with parameters specific to 2d plot
 
rgb surface_color
color of faces
 
PlotFaceIllumination face_illumination
how to illuminate the surface
 
unsigned samples_per_row
if samples per row > 0, the samples are interpreted as regular grid
 
void set_colors(const rgb &base_color)
add tube and surface color
 
mapped_size bar_percentual_depth
provide second dimension of bar extend
 
plot3d_config(const std::string &_name)
construct with default values
 
bool wireframe
whether to turn on wireframe
 
bool show_line_orientation
whether to illustrate line orientation
 
bool show_surface
whether to show faces
 
plot independent configuration parameters of one sub plot in a 2d or 3d plot
 
int bar_coordinate_index
extended bar information
 
virtual void set_colors(const rgb &base_color)
set all colors from reference color
 
mapped_size line_width
line width
 
mapped_size bar_percentual_width
percentual width of bar computed assuming a uniform y-sampling distance
 
std::string name
name of sub plot
 
float stick_base_window
base window position of stick
 
bool show_lines
whether to connect data points with lines
 
mapped_rgba stick_color
color of the stick line
 
bool show_bars
whether to show bars
 
mapped_size bar_outline_width
line width of bar outlines
 
bool show_points
whether to show data points
 
mapped_size stick_width
line width of stick
 
mapped_rgba bar_color
bar fill color
 
mapped_rgba point_color
point color
 
int stick_coordinate_index
extended stick information
 
bool show_plot
whether to show sub plot
 
bool show_sticks
whether to show straight lines to the bottom of the plot, which are called sticks
 
mapped_rgba line_color
line color
 
mapped_size point_halo_width
width of point halo in pixel
 
mapped_rgba bar_outline_color
bar outline color
 
mapped_size point_size
point size in pixels
 
mapped_rgba point_halo_color
color of point halo
 
CullingMode culling_mode
culling mode for point splats, defaults to CM_OFF
 
ColorMapping map_color_to_material
material side[s] where color is to be mapped to the diffuse material component, defaults to CM_COLOR ...
 
IlluminationMode illumination_mode
illumination mode defaults to IM_ONE_SIDED
 
cgv::media::illum::surface_material::color_type surface_color
default value for color when map color to material is used