1#include "axis_config.h"
15 step = primary ? 5.0f : 1.0f;
16 type = primary ? TT_LINE : TT_DASH;
18 length = primary ? 12.0f : 8.0f;
23void axis_config::update_tick_range()
48 min_val = min_attribute_value_backup;
49 max_val = max_attribute_value_backup;
97float axis_config::attribute_space_from_tick_space(
float value)
const
102 return pow(10.0f, value);
104 return -pow(10.0f, 2 * log10(
log_minimum) - 2 - value);
107float axis_config::window_space_from_tick_space(
float value)
const
115 return (value - min_value) / (max_value - min_value);
117float axis_config::tick_space_from_window_space(
float value)
const
125 return value* (max_value - min_value) + min_value;
129 return extent * (value - 0.5f);
133 return value /
extent + 0.5f;
144void test_axis_config()
151 for (i = 0; i < 16; ++i) {
153 std::cout << v <<
" -> " << l <<
" -> " << ac.attribute_space_from_tick_space(l) << std::endl;
158 std::cout << v <<
" -> " << l <<
" -> " << ac.attribute_space_from_tick_space(l) << std::endl;
160 for (i = 0; i < 16; ++i) {
162 std::cout << v <<
" -> " << l <<
" -> " << ac.attribute_space_from_tick_space(l) << std::endl;
191 float reference_step = de / max_nr_secondary_ticks;
192 float scale = (float)pow(10, -floor(log10(reference_step)));
195 static float magic_numbers[9] = {
200 for (
unsigned i = 0; i < 9; i += 3)
201 if (scale * reference_step < magic_numbers[i]) {
212 cgv::signal::rebind(
this, &axis_config::update_tick_range));
218 cgv::signal::rebind(
this, &axis_config::update_tick_range));
220 cgv::signal::rebind(
this, &axis_config::update_tick_range));
222 cgv::signal::rebind(
this, &axis_config::update_tick_range));
226 cgv::signal::rebind(
this, &axis_config::update_tick_range));
230 const char* tn[2] = {
"Primary Tick",
"Secondary Tick" };
232 for (
unsigned ti = 0; ti < 2; ++ti) {
233 bool vis = p.
begin_tree_node(tn[ti], tc[ti]->label,
false,
"level=3;options='w=132';align=' '");
237 p.
add_member_control(bp,
"Type", tc[ti]->type,
"dropdown",
"enums='None,Dash,Line,Plane'");
240 p.
add_member_control(bp,
"Length", tc[ti]->length,
"value_slider",
"min=1;max=20;log=true;ticks=true");
241 p.
add_member_control(bp,
"Precision", tc[ti]->precision,
"value_slider",
"min=-1;max=5;ticks=true");
base class for all classes that can be registered with support for dynamic properties (see also secti...
derive from this class to provide a gui to the current viewer
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...
configuration information stored per domain axis
unsigned auto_adjust_max_snd_ticks
maximum number of secondary ticks for auto adjustment of ticks on changes to attribute range
tick_config primary_ticks
configuration of primary tickmarks
void set_attribute_range(float _min, float _max)
write access to attribute range
void create_gui(cgv::base::base *bp, cgv::gui::provider &p)
create gui for axis
float extent
extent in world space
float log_minimum
minimum of logarithmic value in case that 0 is included in attribute range
void restore_attribute_range()
store current range from backup members
float attribute_space_from_plot_space(float value) const
convenience function
axis_config()
set default values
float extent_scaling
potential constraint for scaling of plot extent in world space
void set_log_minimum(float _min)
write access to minimum attribute value for robust log transformation
bool operator==(const axis_config &ac) const
compare members relevant for drawing geometry precomputation for equality
bool log_scale
whether axis is drawn with logarithmic scale
void set_attribute_minimum(float _min)
write access to attribute minimum value
void set_attribute_maximum(float _max)
write access to attribute maximum value
void set_log_config(bool enabled, float _min)
write access to log scale flag and minimum
float line_width
line width
float max_attribute_value
maximum attribute value
float window_space_from_plot_space(float value) const
convert from plot to window space
void backup_attribute_range()
store current range in backup members
float plot_space_from_attribute_space(float value) const
convenience function
std::string name
name of axis
float get_attribute_max() const
read access to attrbribute maximum value
float min_attribute_value
minimum attribute value
float tick_space_from_attribute_space(float value) const
perform transformation from attribute space to tick mark space by applying log transformation if acti...
void put_backup_attribute_range(float &min_val, float &max_val) const
read access to backup attribute range
float plot_space_from_window_space(float value) const
convert from window to plot space
void adjust_tick_marks_to_range(unsigned max_nr_secondary_ticks)
adjust tick marks to attribute range based on given maximum number of secondary ticks
void set_log_scale(bool enabled)
write access to log scale flag
tick_config secondary_ticks
configuration of secondary tickmarks
float get_attribute_min() const
read access to attrbribute minimum value
bool multi_axis_ticks
whether to show tick marks on both axes boundaries
tickmark configuration of one tickmark type
float line_width
line width
bool label
whether to show text labels at tick
bool operator==(const tick_config &tc) const
implement equality check
tick_config(bool primary)
set tick config defaults
int precision
number of digits after decimal point, defaults to -1 which gives adaptive precision
float step
step width between two ticks along axis
float length
tick length relative to domain extent
TickType type
type of tick