1#include <cgv/base/base.h>
2#include <cgv/base/node.h>
3#include <cgv/render/drawable.h>
4#include <cgv/base/find_action.h>
52 std::vector<view*> views;
54 if (views.empty() || view_idx > views.size())
56 return views[view_idx];
65 const dmat4* DPV_ptr, *DPV_other_ptr;
66 int x_other, y_other, vp_col_idx, vp_row_idx, vp_width, vp_height;
67 int eye_panel = V.
get_modelview_projection_window_matrices(x, y, ctx.get_width(), ctx.get_height(), &DPV_ptr, &DPV_other_ptr, &x_other, &y_other, &vp_col_idx, &vp_row_idx, &vp_width, &vp_height);
70 double z = ctx.get_window_z(x, y);
71 double z_other = ctx.get_window_z(x_other, y_other);
74 if (DPV_ptr->
ncols() != 4)
77 world_location = ctx.get_model_point(x, y, z, *DPV_ptr);
82 if (DPV_other_ptr->
ncols() != 4)
84 world_location = ctx.get_model_point(x_other, y_other, z_other, *DPV_other_ptr);
86 *window_z_ptr = z_other;
93 cgv::dmat4 iMPW = inverse(modelview_projection_window_matrix);
99 eye = view_ptr->get_eye();
102 eye = (iMPW * p_window).clip();
159 current_render_pass = -1;
160 render_pass_recursion_depth = 0;
165 if (current_render_pass != -1)
167 render_pass_recursion_depth = ctx.get_render_pass_recursion_depth();
173 current_render_pass = rp_idx;
174 unsigned rpf = (ctx.get_render_pass_flags() & ~excluded_flags) | included_flags;
180 current_render_pass = rp_idx;
185 if (current_render_pass == -1)
187 if (ctx.get_render_pass_user_data() !=
this)
188 if (render_pass_recursion_depth != ctx.get_render_pass_recursion_depth())
195 if (render_pass_recursion_depth != ctx.get_render_pass_recursion_depth())
197 current_render_pass = -1;
The node class keeps a pointer to its parent.
traverse_policy(int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1)
construct default traverse policy that visits everything
static constexpr unsigned ncols()
number of columns
base class for all drawables, which is independent of the used rendering API.
virtual unsigned int get_height() const =0
return the height of the window
virtual void post_redraw()=0
the context will be redrawn when the system is idle again
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 po...
context * get_context() const
access the current context. The context will be available latestly in the init method but not in the ...
virtual void init_frame(context &)
this method is called in one pass over all drawables before the draw method
cgv::ray3 get_world_ray(int x, int y, view *view_ptr, const cgv::dmat4 &modelview_projection_window_matrix) const
compute ray from eye of given view_ptr through pixel at given mouse location (x,y) according to given...
void set_context(context *_ctx)
set the current focus context, this should only be called by the context itself
virtual void finish_draw(context &)
this method is called when the current drawable is left in a tree traversal that calls the draw metho...
virtual void destruct(context &) final
do not use destruct for a drawable but clear!!
virtual void draw(context &)
overload to draw the content of this drawable
void force_redraw()
forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw,...
virtual void resize(unsigned int w, unsigned int h)
callback to announce resizing of the output window
void hide()
hide the drawable
virtual void after_finish(context &)
this method is called in one pass over all drawables after finish frame
virtual void finish_frame(context &)
this method is called in one pass over all drawables after drawing
drawable()
default construction
virtual bool init(context &)
this method is called after creation or recreation of the context, return whether all necessary funct...
virtual void clear(context &)
clear all objects living in the context like textures or display lists
view * find_view_as_node(size_t view_idx=0) const
convenience function to find the view control in the current hierarchy
void show()
show the drawable
void post_redraw()
posts a redraw event to the current context if one is available
bool is_visible() const
check whether the drawable is visible
bool multi_pass_terminate(const context &ctx)
check in after_finish method, whether this was the terminating render pass
void perform_render_pass(context &ctx, int rp_idx, RenderPass rp=RP_USER_DEFINED, int excluded_flags=RPF_HANDLE_SCREEN_SHOT, int included_flags=0)
call to initiate a render pass in the init_frame method after initiate_render_pass_recursion() has su...
bool initiate_render_pass_recursion(context &ctx)
call in init_frame method to check whether the recursive render passes need to be initiated
bool multi_pass_ignore_finish(const context &ctx)
check in after_finish method, whether this should be directly exited with a return statement
void initiate_terminal_render_pass(int rp_idx)
call after last recursive render pass to use current render pass for last render pass
multi_pass_drawable()
construct to be not inside of a render pass
defines a symmetric view with the following quantities:
virtual int get_modelview_projection_window_matrices(int x, int y, int width, int height, const dmat4 **MPW_pptr, const dmat4 **MPW_other_pptr=0, int *x_other_ptr=0, int *y_other_ptr=0, int *vp_col_idx_ptr=0, int *vp_row_idx_ptr=0, int *vp_width_ptr=0, int *vp_height_ptr=0, int *vp_center_x_ptr=0, int *vp_center_y_ptr=0, int *vp_center_x_other_ptr=0, int *vp_center_y_other_ptr=0) const
given an opengl pixel location and the size in pixels of the opengl window, return the modelview_proj...
the base namespace holds the base hierarchy, support for plugin registration and signals
data::ref_ptr< base, true > base_ptr
ref counted pointer to base
void find_interface(base_ptr start, std::vector< X * > &result)
collect all nodes that implement interface X
namespace for api independent GPU programming
RenderPass
Enumeration of different render passes, which can be queried from the context and used to specify a n...
RenderPassFlags
available flags that can be queried from the context and set for a new render pass
this header is dependency free
cgv::math::fray< float, 3 > ray3
3d ray using 32 bit single precision floating point type
cgv::math::fvec< double, 4 > dvec4
declare type of 4d double precision floating point vectors (used for homogeneous coordinates)
cgv::math::fvec< double, 3 > dvec3
declare type of 3d double precision floating point vectors
cgv::math::fmat< double, 4, 4 > dmat4
declare type of 4x4 matrices