cgv
cgv::plot::plot_base Class Referenceabstract

#include <plot_base.h>

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

Classes

struct  label_info
 render information stored per label More...
 

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

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 draw (context &)
 overload to draw the content of this drawable
 
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
 

tick render information management

cgv::render::viewview_ptr
 
std::vector< label_infotick_labels
 all tick labels
 
std::vector< label_infolegend_tick_labels
 
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 secondary ticks
 
std::vector< tick_batch_info > legend_tick_batches
 
float layer_depth
 depth offset of a single layer
 

font name handling

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
 
void ensure_font_names ()
 ensure that font names have been enumerate
 

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]
 
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
 
 plot_base (unsigned dim, unsigned nr_attributes=0)
 construct from plot dimension and number of additional attributes with default parameters
 
unsigned get_dim () const
 return nr dimensions of plot
 
void set_view_ptr (cgv::render::view *_view_ptr)
 set the view ptr
 
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
 
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)
 
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 disable_attributes (cgv::render::context &ctx, int i)
 
void update_samples_out_of_date_flag ()
 
virtual bool compute_sample_coordinate_interval (int i, int ai, float &samples_min, float &samples_max)=0
 
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)
 

management of sub plots

unsigned get_nr_sub_plots () const
 return current number of sub plots
 
virtual unsigned add_sub_plot (const std::string &name)=0
 add sub plot and return sub plot index
 
virtual void delete_sub_plot (unsigned i)=0
 delete the i-th sub plot
 
plot_base_configref_sub_plot_config (unsigned i)
 return a reference to the plot base configuration of the i-th plot
 
void set_samples_out_of_date (unsigned i)
 notify plot that samples of given subplot are out of date
 
void set_sub_plot_colors (unsigned i, const rgb &base_color)
 set the colors for all plot features of the i-th sub plot as variation of the given color
 
void set_sub_plot_attribute (unsigned i, unsigned ai, int subplot_index, size_t aj)
 define a sub plot attribute ai from coordinate aj of the i-th internal sample container
 
void set_sub_plot_attribute (unsigned i, unsigned ai, const float *_pointer, size_t count, size_t stride)
 define a sub plot attribute from an external pointer
 
void set_sub_plot_attribute (unsigned i, unsigned ai, const cgv::render::vertex_buffer *_vbo_ptr, size_t _offset, size_t _count, size_t _stride)
 define a sub plot attribute from a vbo (attribute must be stored in float type in vbo)
 
bool init (cgv::render::context &ctx)
 build legend prog and create aab
 
void clear (cgv::render::context &ctx)
 destruct shader programs
 

gui support

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_point_config_gui (cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
 create the gui for a point 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
 
virtual void create_stick_config_gui (cgv::base::base *bp, cgv::gui::provider &p, plot_base_config &pbc)
 create the gui for a stick subplot
 
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_config_gui (cgv::base::base *bp, cgv::gui::provider &p, unsigned i)
 create the gui for a subplot configuration
 
virtual void create_gui (cgv::base::base *bp, cgv::gui::provider &p)
 create a gui for the plot with gui for all configs
 
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)
 

Detailed Description

base class for plot2d and plot3d, which can have several sub plots each

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.

◆ 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: