cgv
axis_config.h
1 #pragma once
2 
3 #include <vector>
4 #include <cgv/media/axis_aligned_box.h>
5 #include <cgv/render/render_types.h>
6 #include <cgv/media/color.h>
7 #include <cgv/gui/provider.h>
8 
9 #include "lib_begin.h"
10 
11 namespace cgv {
12  namespace plot {
13 
15 enum TickType
16 {
17  TT_NONE,
18  TT_DASH,
19  TT_LINE,
20  TT_PLANE
21 };
22 
24 struct CGV_API tick_config
25 {
27  TickType type;
29  float step;
31  float line_width;
33  float length;
35  bool label;
37  int precision;
39  bool operator == (const tick_config& tc) const;
41  tick_config(bool primary);
42 };
43 
45 class CGV_API axis_config : public cgv::render::render_types
46 {
47 private:
49  float min_tick_value;
51  float max_tick_value;
53  void update_tick_range();
55  float min_attribute_value_backup, max_attribute_value_backup;
56 protected:
62  bool log_scale;
64  float log_minimum;
67 public:
69  std::string name;
71  float get_attribute_min() const { return min_attribute_value; }
73  float get_attribute_max() const { return max_attribute_value; }
75  void put_backup_attribute_range(float& min_val, float& max_val) const;
77  float get_attribute_extent() const { return get_attribute_max() - get_attribute_min(); }
79  bool get_log_scale() const { return log_scale; }
81  float get_log_minimum() const { return log_minimum; }
83  void set_attribute_range(float _min, float _max);
85  void backup_attribute_range();
87  void restore_attribute_range();
89  void set_attribute_minimum(float _min);
91  void set_attribute_maximum(float _max);
93  void set_log_scale(bool enabled);
95  void set_log_minimum(float _min);
97  void set_log_config(bool enabled, float _min);
99  float extent;
101  float line_width;
109  bool operator == (const axis_config& ac) const;
111  float tick_space_from_attribute_space(float value) const;
113  float window_space_from_tick_space(float value) const;
115  float tick_space_from_window_space(float value) const;
117  float attribute_space_from_tick_space(float value) const;
119  float plot_space_from_window_space(float value) const;
121  float window_space_from_plot_space(float value) const;
123  float plot_space_from_attribute_space(float value) const;
125  float attribute_space_from_plot_space(float value) const;
127  axis_config();
129  void adjust_tick_marks_to_range(unsigned max_nr_secondary_ticks);
131  void create_gui(cgv::base::base* bp, cgv::gui::provider& p);
132 };
133 
134  }
135 }
136 
137 #include <cgv/config/lib_end.h>
cgv::plot::tick_config::length
float length
tick length relative to domain extent
Definition: axis_config.h:33
cgv::plot::tick_config::precision
int precision
number of digits after decimal point, defaults to -1 which gives adaptive precision
Definition: axis_config.h:37
cgv::plot::tick_config
tickmark configuration of one tickmark type
Definition: axis_config.h:25
cgv::plot::axis_config::extent
float extent
extent in world space
Definition: axis_config.h:99
cgv::plot::axis_config::secondary_ticks
tick_config secondary_ticks
configuration of secondary tickmarks
Definition: axis_config.h:107
cgv::plot::axis_config::log_minimum
float log_minimum
minimum of logarithmic value in case that 0 is included in attribute range
Definition: axis_config.h:64
cgv::plot::axis_config::get_attribute_max
float get_attribute_max() const
read access to attrbribute maximum value
Definition: axis_config.h:73
cgv::plot::axis_config
configuration information stored per domain axis
Definition: axis_config.h:46
cgv::plot::axis_config::get_log_scale
bool get_log_scale() const
read access to log scale flag
Definition: axis_config.h:79
cgv::plot::tick_config::line_width
float line_width
line width
Definition: axis_config.h:31
cgv::gui::provider
derive from this class to provide a gui to the current viewer
Definition: provider.h:64
cgv::media::color
Definition: color.h:51
cgv::plot::tick_config::type
TickType type
type of tick
Definition: axis_config.h:27
cgv::plot::axis_config::get_log_minimum
float get_log_minimum() const
read access to minimum attribute value for robust log transformation
Definition: axis_config.h:81
cgv::plot::axis_config::color
rgb color
color of axis
Definition: axis_config.h:103
cgv::plot::axis_config::log_scale
bool log_scale
whether axis is drawn with logarithmic scale
Definition: axis_config.h:62
cgv::plot::axis_config::min_attribute_value
float min_attribute_value
minimum attribute value
Definition: axis_config.h:58
cgv::plot::tick_config::label
bool label
whether to show text labels at tick
Definition: axis_config.h:35
cgv::plot::axis_config::get_attribute_min
float get_attribute_min() const
read access to attrbribute minimum value
Definition: axis_config.h:71
cgv::base::base
Definition: base.h:57
cgv::plot::axis_config::max_attribute_value
float max_attribute_value
maximum attribute value
Definition: axis_config.h:60
cgv::plot::axis_config::name
std::string name
name of axis
Definition: axis_config.h:69
cgv::plot::axis_config::get_attribute_extent
float get_attribute_extent() const
compute the extent in attribute space
Definition: axis_config.h:77
cgv::plot::tick_config::step
float step
step width between two ticks along axis
Definition: axis_config.h:29
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::plot::axis_config::auto_adjust_max_snd_ticks
unsigned auto_adjust_max_snd_ticks
maximum number of secondary ticks for auto adjustment of ticks on changes to attribute range
Definition: axis_config.h:66
cgv::plot::axis_config::primary_ticks
tick_config primary_ticks
configuration of primary tickmarks
Definition: axis_config.h:105
cgv::plot::axis_config::line_width
float line_width
line width
Definition: axis_config.h:101