00001 #ifndef bsvg_plot_h_
00002 #define bsvg_plot_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bsvg_document.h"
00016 #include "bsvg_element.h"
00017
00018
00019
00020
00021
00022
00023 const float default_stroke_width = 2.0f;
00024 const int default_font_size = 15;
00025 const float default_margin = 20.0f;
00026
00027 class bsvg_plot : public bsvg_document
00028 {
00029 public:
00030
00031 bsvg_plot(float w, float h) : bsvg_document(w, h), margin_(default_margin), font_size_(default_font_size) {}
00032 bsvg_plot(float w, float h, float viewBox_x, float viewBox_y, float viewBox_w, float viewBox_h) : bsvg_document(w,h,viewBox_x, viewBox_y, viewBox_w, viewBox_h), margin_(default_margin), font_size_(default_font_size) {}
00033
00034 void add_axes(float x_min, float x_max, float y_min, float y_max, float stroke_width = default_stroke_width);
00035
00036 void add_x_increments(float x_inc, float stroke_width = default_stroke_width);
00037 void add_y_increments(float y_inc, float stroke_width = default_stroke_width);
00038
00039 void set_margin(float m) { margin_ = m; }
00040 void set_font_size(int s) { font_size_ = s; }
00041 void add_title(const vcl_string& t);
00042
00043 void add_line(const vcl_vector<float>& xs, const vcl_vector<float>& ys, const vcl_string& color, float stroke_width = default_stroke_width);
00044
00045
00046 void add_bars(const vcl_vector<float>& heights, const vcl_string& color);
00047 void add_bars(const vcl_vector<float>& heights, const vcl_vector<float>& x_labels, bool vertical_labels, const vcl_string& color);
00048 void add_bars(const vcl_vector<float>& heights, const vcl_vector<vcl_string>& x_labels, bool vertical_labels, const vcl_string& color);
00049
00050
00051 int number_of_bars();
00052
00053
00054
00055
00056 int add_bar(const float height, const vcl_string& color);
00057 int add_bar(const float height, const float x_label, bool vertical_label, const vcl_string& color);
00058 int add_bar(const float height, const vcl_string& label, bool vertical_label, const vcl_string& color);
00059
00060 bsvg_group* add_bars_helper(const vcl_vector<float>& heights, const vcl_string& color);
00061 bsvg_group* add_x_labels_helper(const vcl_vector<vcl_string>& x_labels, const vcl_string& color, bool vertical_labels);
00062
00063
00064
00065 void add_splice(float center_x, float center_y, float radius, float start_angle, float end_angle, const vcl_string& color);
00066
00067 void add_splice(float center_x, float center_y, float radius, float start_angle, float end_angle, unsigned red, unsigned green, unsigned blue);
00068
00069 protected:
00070
00071 float margin_;
00072 int font_size_;
00073
00074 float scale_factor_;
00075 float axes_orig_x_;
00076 float axes_orig_y_;
00077 float h2_x, h2_y;
00078 };
00079
00080 #endif // bsvg_plot_h_