cgv
cgv::plot::plot2d Class Reference

#include <plot2d.h>

Inheritance diagram for cgv::plot::plot2d:
cgv::plot::plot_base cgv::render::drawable cgv::signal::tacker cgv::base::traverse_policy

Public Types

typedef cgv::media::color< float, cgv::media::RGB > rgb
 declare rgb color type
 
typedef cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
 declare rgba color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB > rgb8
 declare rgb color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB, cgv::media::OPACITY > rgba8
 declare rgba color type
 
typedef cgv::math::fvec< float, 2 > vec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< float, 3 > vec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< float, 4 > vec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< float > vecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< float, 2, 2 > mat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< float, 3, 3 > mat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< float, 4, 4 > mat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< float, 3, 4 > mat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< float > matn
 declare type of matrices of varying dimensions
 
typedef cgv::math::fvec< double, 2 > dvec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< double, 3 > dvec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< double, 4 > dvec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< double > dvecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< double, 2, 2 > dmat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< double, 3, 3 > dmat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< double, 4, 4 > dmat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< double, 3, 4 > dmat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< double > dmatn
 declare type of matrices of varying dimensions
 
typedef cgv::media::axis_aligned_box< float, 2 > box2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< float, 3 > box3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< float, 4 > box4
 declare type of 4d boxes
 
typedef cgv::media::axis_aligned_box< double, 2 > dbox2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< double, 3 > dbox3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< double, 4 > dbox4
 declare type of 4d boxes
 
typedef cgv::math::quaternion< float > quat
 declare type of quaternion
 
typedef cgv::math::quaternion< double > dquat
 declare type of double quaternion
 
typedef cgv::math::fvec< int32_t, 2 > ivec2
 declare type of 2d integer vectors
 
typedef cgv::math::fvec< int32_t, 3 > ivec3
 declare type of 3d integer vectors
 
typedef cgv::math::fvec< int32_t, 4 > ivec4
 declare type of 4d integer vectors
 
typedef cgv::math::fvec< uint32_t, 2 > uvec2
 declare type of 2d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 3 > uvec3
 declare type of 3d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 4 > uvec4
 declare type of 4d unsigned integer vectors
 

Public Member Functions

 plot2d (const std::string &title, unsigned nr_attributes=0)
 construct 2D plot with given number of additional attributes and default parameters More...
 
void hide ()
 hide the drawable
 
void show ()
 show the drawable
 
bool is_visible () const
 check whether the drawable is visible
 
context * get_context () const
 access the current context. The context will be available latestly in the init method but not in the contructor.
 
void set_context (context *_ctx)
 set the current focus context, this should only be called by the context itself
 
cgv::render::viewfind_view_as_node (size_t view_idx=0) const
 convenience function to find the view control in the current hierarchy More...
 
bool get_world_location (int x, int y, const cgv::render::view &V, cgv::math::fvec< double, 3 > &world_location, double *window_z_ptr=0) const
 use given view together with depth buffer of context in order to compute the world location of the point at mouse pointer location (x,y) More...
 
void post_redraw ()
 posts a redraw event to the current context if one is available
 
void force_redraw ()
 forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw, finish_frame and clear
 
virtual void resize (unsigned int w, unsigned int h)
 callback to announce resizing of the output window More...
 
virtual void init_frame (context &)
 this method is called in one pass over all drawables before the draw method
 
virtual void finish_draw (context &)
 this method is called when the current drawable is left in a tree traversal that calls the draw method
 
virtual void finish_frame (context &)
 this method is called in one pass over all drawables after drawing
 
virtual void after_finish (cgv::render::context &)
 this method is called in one pass over all drawables after finish frame
 
int get_policy () const
 return the policy without the stop on success flag
 
bool stop_on_success () const
 return whether to stop on success
 
bool stop_on_failure () const
 return whether to stop on failure
 
void set_policy (int _policy)
 set a new policy, always add stop on success flag if needed
 
int get_focused_child () const
 return the focused child or -1 if none is focused
 
void set_focused_child (int _focused_child)
 set the focused child
 
bool get_active () const
 return whether the current node is active
 
void set_active (bool _active)
 set the active flag of the current node
 
void tack (signal_base *s) const
 keep track of the given signal
 
void untack (signal_base *s) const
 forget the given signal
 
void untack_all () const
 forget all signals
 
management of sub plots
unsigned add_sub_plot (const std::string &name)
 add sub plot and return sub plot index
 
void delete_sub_plot (unsigned i)
 delete the i-th sub plot
 
plot2d_configref_sub_plot2d_config (unsigned i=0)
 return a reference to the plot1d configuration of the i-th plot More...
 
std::vector< vec2 > & ref_sub_plot_samples (unsigned i=0)
 return the samples of the i-th sub plot
 
std::vector< unsigned > & ref_sub_plot_strips (unsigned i=0)
 return the strip definition of the i-th sub plot
 
bool init (cgv::render::context &ctx)
 construct shader programs
 
void draw (cgv::render::context &ctx)
 draw plot
 
void clear (cgv::render::context &ctx)
 destruct shader programs
 
void create_point_config_gui (cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
 create the gui for a point subplot
 
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 create_bar_config_gui (cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
 create the gui for a bar subplot
 
void create_config_gui (cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
 create the gui for a subplot configuration
 
void create_gui (cgv::base::base *bp, cgv::gui::provider &p)
 create a gui for the plot with gui for all configs
 

Public Attributes

bool * multi_axis_modes
 whether to manage separate axes for each sub plot
 
vec3 sub_plot_delta
 offset in between sub plots in x, y and z direction
 

Protected Attributes

std::vector< std::vector< vec2 > > samples
 store 2d samples for data series
 
std::vector< std::vector< unsigned > > strips
 allow to split series into connected strips that are represented by the number of contained samples
 
cgv::render::attribute_array_manager aam_domain
 attribute managers for domain rectangles and domain tick labels
 

font name handling

void ensure_font_names ()
 ensure that font names have been enumerate
 
static std::vector< const char * > font_names
 store a vector with all fonts on the system
 
static std::string font_name_enum_def
 concatenate font names to enum definition for dropdown control
 

placement of plot

quat orientation
 orientiation quaternion mapping from domain to world coordinates
 
vec3 center_location
 center location of domain in world coordinates
 
vec3 world_space_from_plot_space (const vecn &pnt_plot) const
 
vec3 transform_to_world (const vecn &pnt_attr) const
 transform from attribute space to world space
 

visual attribute mapping

cgv::media::font::font_ptr label_font
 store pointer to label font
 
cgv::media::font::font_face_ptr label_font_face
 store pointer to label font face
 
cgv::media::font::font_ptr title_font
 store pointer to title font
 
cgv::media::font::font_face_ptr title_font_face
 store pointer to title font face
 
cgv::render::vertex_buffer vbo_legend
 vbo for legend drawing
 
cgv::render::attribute_array_binding aab_legend
 manage attributes for legend drawing
 
std::vector< attribute_source_arrayattribute_source_arrays
 attribute sources
 
cgv::render::rectangle_render_style rrs
 render style of rectangles
 
cgv::render::rectangle_render_style font_rrs
 
cgv::render::attribute_array_manager aam_legend
 
cgv::render::attribute_array_manager aam_legend_ticks
 
cgv::render::attribute_array_manager aam_title
 
ivec4 out_of_range_mode
 handling of values that are out of range
 
int color_mapping [MAX_NR_COLOR_MAPPINGS]
 index of attribute mapped to primary and secondary color
 
cgv::media::ColorScale color_scale_index [MAX_NR_COLOR_MAPPINGS]
 color scale indices of primary and secondary color mapping
 
float color_scale_gamma [MAX_NR_COLOR_MAPPINGS]
 gamma adjustments for primary and secondary color mapping
 
float window_zero_position [MAX_NR_COLOR_MAPPINGS]
 window space position of zero for primary and secondary color mapping
 
int opacity_mapping [MAX_NR_OPACITY_MAPPINGS]
 index of attribute mapped to primary and secondary opacity
 
float opacity_gamma [MAX_NR_OPACITY_MAPPINGS]
 gamma adjustments for primary and secondary opacity mapping
 
bool opacity_is_bipolar [MAX_NR_OPACITY_MAPPINGS]
 flag whether opacity mapping is bipolar for primary and secondary opacity mapping
 
float opacity_window_zero_position [MAX_NR_OPACITY_MAPPINGS]
 window space position of zero for primary and secondary opacity mapping
 
float opacity_min [MAX_NR_OPACITY_MAPPINGS]
 minimum opacity value for primary and secondary opacity mapping
 
float opacity_max [MAX_NR_OPACITY_MAPPINGS]
 maximum opacity value for primary and secondary opacity mapping
 
int size_mapping [MAX_NR_SIZE_MAPPINGS]
 index of attribute mapped to size
 
float size_gamma [MAX_NR_SIZE_MAPPINGS]
 and independent gamma adjustments
 
float size_min [MAX_NR_SIZE_MAPPINGS]
 min and max of mapped size
 
float size_max [MAX_NR_SIZE_MAPPINGS]
 
void on_legend_axis_change (cgv::gui::provider &p, cgv::gui::control< int > &ctrl)
 
void on_font_selection ()
 callback to change fonts
 
void on_font_face_selection ()
 callback to change font face
 
void set_plot_uniforms (cgv::render::context &ctx, cgv::render::shader_program &prog)
 set the uniforms for plot configurations
 
void set_mapping_uniforms (cgv::render::context &ctx, cgv::render::shader_program &prog)
 set the uniforms for defining the mappings to visual variables
 
size_t enable_attributes (cgv::render::context &ctx, int i, const std::vector< std::vector< vec2 >> &samples)
 set vertex shader input attributes based on attribute source information
 
size_t enable_attributes (cgv::render::context &ctx, int i, const std::vector< std::vector< vec3 >> &samples)
 set vertex shader input attributes based on attribute source information
 
void draw_rectangles (cgv::render::context &ctx, cgv::render::attribute_array_manager &aam, std::vector< box2 > &R, std::vector< rgb > &C, std::vector< float > &D, size_t offset=0)
 
void draw_tick_labels (cgv::render::context &ctx, cgv::render::attribute_array_manager &aam_ticks, std::vector< label_info > &tick_labels, std::vector< tick_batch_info > &tick_batches, float depth)
 
void disable_attributes (cgv::render::context &ctx, int i)
 
void update_samples_out_of_date_flag ()
 
void draw_sub_plot_samples (int count, const plot_base_config &spc, bool strip=false)
 
void draw_title (cgv::render::context &ctx, vec2 pos, float depth, int si=-1)
 
void draw_legend (cgv::render::context &ctx, int layer_idx=0, bool is_first=true, bool *multi_axis_modes=0)
 
bool extract_tick_rectangles_and_tick_labels (std::vector< box2 > &R, std::vector< rgb > &C, std::vector< float > &D, std::vector< label_info > &tick_labels, int ai, int ci, int ti, float he, float z_plot, float plot_scale=1.0f, vec2 plot_offset=vec2(0.0f, 0.0f), float d=0.0f, bool multi_axis=true)
 
void extract_legend_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, float d, bool clear_cache=false, bool is_first=true, bool *multi_axis_modes=0)
 
unsigned get_dim () const
 return nr dimensions of plot
 
void set_view_ptr (cgv::render::view *_view_ptr)
 set the view ptr
 
static const unsigned MAX_NR_COLOR_MAPPINGS = 2
 define maximum number of color mappings
 
static const unsigned MAX_NR_OPACITY_MAPPINGS = 2
 define maximum number of opacity mappings
 
static const unsigned MAX_NR_SIZE_MAPPINGS = 2
 define maximum number of size mappings
 

gui support

void update_ref_opacity (unsigned i, cgv::gui::provider &p)
 
void update_ref_opacity_index (unsigned i, cgv::gui::provider &p)
 
void update_ref_size (unsigned i, cgv::gui::provider &p)
 
void update_ref_size_index (unsigned i, cgv::gui::provider &p)
 
void update_ref_color (unsigned i, cgv::gui::provider &p)
 
void update_ref_color_index (unsigned i, cgv::gui::provider &p)
 
void add_mapped_size_control (cgv::gui::provider &p, cgv::base::base *bp, const std::string &name, mapped_size &ms, std::string options="")
 
void add_mapped_rgb_control (cgv::gui::provider &p, cgv::base::base *bp, const std::string &name, mapped_rgb &ms)
 
void add_mapped_rgba_control (cgv::gui::provider &p, cgv::base::base *bp, const std::string &name, mapped_rgba &ms)
 
void add_mapped_opacity_control (cgv::gui::provider &p, cgv::base::base *bp, const std::string &name, mapped_opacity &ms)
 
virtual void create_plot_gui (cgv::base::base *bp, cgv::gui::provider &p)
 create the gui for the plot without gui for sub plots
 
virtual void create_base_config_gui (cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
 create the gui for base subplot settings
 
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
 

Detailed Description

The plot2d class draws 2d plots with potentially several sub plots of different chart types

Constructor & Destructor Documentation

◆ plot2d()

cgv::plot::plot2d::plot2d ( const std::string &  title,
unsigned  nr_attributes = 0 
)

construct 2D plot with given number of additional attributes and default parameters

construct empty plot with default domain [0..1,0..1]

Member Function Documentation

◆ find_view_as_node()

cgv::render::view * cgv::render::drawable::find_view_as_node ( size_t  view_idx = 0) const
inherited

convenience function to find the view control in the current hierarchy

this only works if your class inherits from the cgv::base::node class.

◆ get_world_location()

bool cgv::render::drawable::get_world_location ( int  x,
int  y,
const cgv::render::view V,
cgv::math::fvec< double, 3 > &  world_location,
double *  window_z_ptr = 0 
) const
inherited

use given view together with depth buffer of context in order to compute the world location of the point at mouse pointer location (x,y)

returns true if a world location could be computed which is the case when the context pointer of the drawable has been set and when the mouse location points inside a valid view panel.

◆ ref_sub_plot2d_config()

plot2d_config & cgv::plot::plot2d::ref_sub_plot2d_config ( unsigned  i = 0)

return a reference to the plot1d configuration of the i-th plot

return a reference to the plot base configuration of the i-th plot

◆ resize()

void cgv::render::drawable::resize ( unsigned int  w,
unsigned int  h 
)
virtualinherited

callback to announce resizing of the output window

callback to anounce resizing of the output window


The documentation for this class was generated from the following files: