cgv
Loading...
Searching...
No Matches
cgv::render::drawable Class Reference

base class for all drawables, which is independent of the used rendering API. More...

#include <drawable.h>

Inheritance diagram for cgv::render::drawable:
cgv::base::traverse_policy cgv::app::gizmo cgv::app::overlay cgv::plot::plot_base cgv::render::callback_drawable cgv::render::gl::gl_implicit_surface_drawable_base cgv::render::gl::image_drawable cgv::render::gl::mesh_drawable cgv::render::multi_pass_drawable vr_emulator vr_test

Public Member Functions

 drawable ()
 default construction
 
void hide ()
 hide the drawable
 
void show ()
 show the drawable
 
bool is_visible () const
 check whether the drawable is visible
 
contextget_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
 
viewfind_view_as_node (size_t view_idx=0) const
 convenience function to find the view control in the current hierarchy
 
bool get_world_location (int x, int y, const view &V, dvec3 &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)
 
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 bool init (context &)
 this method is called after creation or recreation of the context, return whether all necessary functionality is supported
 
virtual void resize (unsigned int w, unsigned int h)
 callback to announce resizing of the output window
 
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 (context &)
 this method is called in one pass over all drawables after finish frame
 
virtual void clear (context &)
 clear all objects living in the context like textures or display lists
 
- Public Member Functions inherited from cgv::base::traverse_policy
 traverse_policy (int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1)
 construct default traverse policy that visits everything
 
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
 

Additional Inherited Members

- Protected Attributes inherited from cgv::base::traverse_policy
TraversePolicy policy
 
bool active
 
int focus
 

Detailed Description

base class for all drawables, which is independent of the used rendering API.

Definition at line 14 of file drawable.h.

Constructor & Destructor Documentation

◆ drawable()

cgv::render::drawable::drawable ( )

default construction

Definition at line 14 of file drawable.cxx.

Member Function Documentation

◆ after_finish()

void cgv::render::drawable::after_finish ( context )
virtual

this method is called in one pass over all drawables after finish frame

Reimplemented in cgv::app::canvas_overlay, cgv::render::callback_drawable, and cgv::app::performance_monitor.

Definition at line 125 of file drawable.cxx.

Referenced by cgv::app::performance_monitor::after_finish(), and cgv::render::context::render_pass().

◆ clear()

◆ draw()

void cgv::render::drawable::draw ( context )
virtual

◆ find_view_as_node()

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

convenience function to find the view control in the current hierarchy

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

Definition at line 49 of file drawable.cxx.

Referenced by cgv::render::gl::mesh_drawable::center_view(), cgv::app::gizmo::finish_frame(), vr_test::init(), and cgv::app::navigator::init_frame().

◆ finish_draw()

void cgv::render::drawable::finish_draw ( context )
virtual

this method is called when the current drawable is left in a tree traversal that calls the draw method

Reimplemented in cgv::render::callback_drawable, cgv::app::navigator, vr_test, and cgv::render::gl::mesh_drawable.

Definition at line 116 of file drawable.cxx.

Referenced by cgv::render::context::render_pass().

◆ finish_frame()

void cgv::render::drawable::finish_frame ( context )
virtual

this method is called in one pass over all drawables after drawing

Reimplemented in vr_emulator, cgv::app::gizmo, cgv::render::callback_drawable, and cgv::render::gl::gl_implicit_surface_drawable_base.

Definition at line 120 of file drawable.cxx.

Referenced by cgv::render::context::render_pass().

◆ force_redraw()

void cgv::render::drawable::force_redraw ( )

forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw, finish_frame and clear

Definition at line 92 of file drawable.cxx.

References cgv::render::context::force_redraw().

◆ get_context()

context * cgv::render::drawable::get_context ( ) const

access the current context. The context will be available latestly in the init method but not in the contructor.

Definition at line 37 of file drawable.cxx.

Referenced by get_world_location(), cgv::app::gizmo::handle(), cgv::app::color_map_editor::handle_member_change(), cgv::app::performance_monitor::handle_member_change(), cgv::app::navigator::handle_mouse_event(), and cgv::app::color_map_editor::handle_mouse_event().

◆ get_world_location()

bool cgv::render::drawable::get_world_location ( int  x,
int  y,
const view V,
dvec3 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)

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.

Definition at line 59 of file drawable.cxx.

References get_context(), cgv::render::context::get_height(), cgv::render::context::get_model_point(), cgv::render::view::get_modelview_projection_window_matrices(), cgv::render::context::get_width(), cgv::render::context::get_window_z(), and cgv::math::fmat< T, N, M >::ncols().

◆ hide()

void cgv::render::drawable::hide ( )

hide the drawable

Definition at line 21 of file drawable.cxx.

Referenced by cgv::app::overlay::set_visibility().

◆ init()

◆ init_frame()

void cgv::render::drawable::init_frame ( context )
virtual

this method is called in one pass over all drawables before the draw method

Reimplemented in vr_emulator, cgv::render::callback_drawable, cgv::app::navigator, cgv::render::gl::mesh_drawable, vr_test, cgv::app::color_map_editor, cgv::app::color_map_legend, cgv::app::color_selector, and cgv::app::performance_monitor.

Definition at line 108 of file drawable.cxx.

◆ is_visible()

◆ post_redraw()

◆ resize()

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

callback to announce resizing of the output window

callback to anounce resizing of the output window

Definition at line 104 of file drawable.cxx.

◆ set_context()

void cgv::render::drawable::set_context ( context _ctx)

set the current focus context, this should only be called by the context itself

Definition at line 9 of file drawable.cxx.

Referenced by cgv::render::context::configure_new_child().

◆ show()


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