1#include "arrow_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
9 static int ref_count = 0;
20 has_directions =
true;
26 has_directions =
false;
29 has_directions =
false;
30 direction_is_end_point =
false;
31 remove_attribute_array(ctx,
"direction");
34 has_directions =
false;
35 direction_is_end_point =
true;
36 remove_attribute_array(ctx,
"direction");
40 prog.allow_context_to_set_color(
false);
50 if (!has_directions) {
51 ctx.
error(
"arrow_renderer::validate_attributes() neither direction nor end_point attribute set");
67 ref_prog().
set_uniform(ctx,
"head_length_relative_to_radius", ars.head_length_relative_to_radius);
68 ref_prog().
set_uniform(ctx,
"head_length_relative_to_length", ars.head_length_relative_to_length);
74 ref_prog().
set_uniform(ctx,
"relative_location_of_position", ars.relative_location_of_position);
83 has_directions =
false;
91 draw_impl(ctx, PT_POINTS, start, count,
false,
false, -1);
99 rh.
reflect_member(
"radius_relative_to_length", radius_relative_to_length) &&
101 rh.
reflect_member(
"head_length_relative_to_radius", head_length_relative_to_radius) &&
102 rh.
reflect_member(
"head_length_relative_to_length", head_length_relative_to_length) &&
107 rh.
reflect_member(
"relative_location_of_position", relative_location_of_position);
117#include <cgv/gui/provider.h>
126 void* value_ptr,
const std::string& value_type,
127 const std::string& gui_type,
const std::string& options,
bool*)
134 p->
add_member_control(b,
"Relative Location of Position", ars_ptr->relative_location_of_position,
"value_slider",
"min=0;max=1;ticks=true");
135 p->
add_member_control(b,
"Color Scale", ars_ptr->color_scale,
"value_slider",
"min=0.01;max=100;log=true;ticks=true");
136 if (p->
begin_tree_node(
"Length", ars_ptr->length_scale,
true,
"level=3")) {
139 p->
add_member_control(b,
"Length Scale", ars_ptr->length_scale,
"value_slider",
"min=0.01;max=100;log=true;ticks=true");
140 p->
add_member_control(b,
"Length Epsilon", ars_ptr->length_eps,
"value_slider",
"min=0.00000001;step=0.000000001;max=1;log=true;ticks=true");
146 p->
add_member_control(b,
"Radius Relative to Length", ars_ptr->radius_relative_to_length,
"value_slider",
"min=0;max=1;ticks=true");
153 p->
add_member_control(b,
"Head Length Mode", ars_ptr->head_length_mode,
"dropdown",
"enums='Relative to Radius=1,Relative to Length=2,Minimum of Radius and Length=3'");
154 p->
add_member_control(b,
"Head Length Relative to Radius", ars_ptr->head_length_relative_to_radius,
"value_slider",
"min=0.1;max=5;ticks=true");
155 p->
add_member_control(b,
"Head Length Relative to Length", ars_ptr->head_length_relative_to_length,
"value_slider",
"min=0;max=1;ticks=true");
170#include "gl/lib_begin.h"
base class for all classes that can be registered with support for dynamic properties (see also secti...
helper template for registration of gui creators
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.
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...
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
bool reflect_base(B &base_ref)
reflect a base class with its members
bool reflect_member(const std::string &member_name, T &member_ref, bool hard_cast=false)
call this to reflect a member by member name and reference to the member.
renderer that supports point splatting
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this before setting attribute arrays to manage attribute array in given manager
bool validate_attributes(const context &ctx) const override
call to validate, whether essential position attribute is defined
void disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
bool enable(context &ctx) override
enables renderer
bool build_shader_program(context &ctx, shader_program &prog, const shader_compile_options &options) const override
build arrow program
void remove_direction_array(const context &ctx)
remove the direction attribute
void remove_end_point_array(const context &ctx)
remove the end point attribute
void draw(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) override
convenience function to render with default settings
bool disable(context &ctx) override
disable renderer
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
virtual void error(const std::string &message, const render_component *rc=0) const
error handling
bool validate_attributes(const context &ctx) const
check additionally the group attributes
void manage_singleton(context &ctx, const std::string &renderer_name, int &ref_count, int ref_count_change)
used by derived classes to manage singletons
bool has_attribute(const context &ctx, const std::string &name)
check for attribute
shader_program & ref_prog()
derived renderer classes have access to shader program
virtual bool build_shader_program(context &ctx, shader_program &prog, const shader_compile_options &options) const
overload to change default behaviour and build a custom shader program based on the passed options
bool attributes_persist() const
return whether attributes persist after a call to disable
void draw_impl(context &ctx, PrimitiveType pt, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
default implementation of draw method with support for indexed rendering and different primitive type...
Stores preprocessor options used for conditionally compiling shader programs.
a shader program combines several shader code fragments to a complete definition of the shading pipel...
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 disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam)
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam)
call this before setting attribute arrays to manage attribute array in given manager
bool disable(context &ctx)
disable renderer
bool enable(context &ctx)
overload to activate group style
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
bool create(provider *p, const std::string &label, void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, bool *)
attempt to create a gui and return whether this was successful
interface for gui creators
this reflection traits implementation is used for external self_reflect implementations of instances ...
float head_radius_scale
scaling factor of head radius with respect to tail radius
float radius_lower_bound
smallest value for the radius
bool use_group_color
whether to use group colors indexed through group index, defaults to false
traits class with a static function get_name() of type const char* that returns the type name of the ...