Boost logo

Boost-Commit :

From: jakevoytko_at_[hidden]
Date: 2007-07-22 19:06:34


Author: jakevoytko
Date: 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
New Revision: 7505
URL: http://svn.boost.org/trac/boost/changeset/7505

Log:
Feature additions and bug fixes

Added:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 495 ++++++++++++--------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 411 +++++++++++++++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp | 10
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 417 +++++++++-------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 938 ++++++++++++++++++++++-----------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 66 +-
   6 files changed, 1447 insertions(+), 890 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -11,11 +11,12 @@
 #define _BOOST_SVG_AXIS_PLOT_FRAME_HPP
 
 #include <string>
-#include "svg_style.hpp"
+#include "../svg_style.hpp"
 #include "svg_tag.hpp"
 
 namespace boost{
 namespace svg{
+namespace detail{
 
 template <class Derived>
 class axis_plot_frame
@@ -23,7 +24,7 @@
 protected:
     // -----------------------------------------------------------------
     // We don't use the SVG coordinate transform because then text would
- // be flipped. I'm considering using it to scale the image for resizes
+ // be flipped. I'm considering using it to scale the image for resizes.
     // -----------------------------------------------------------------
     void _transform_point(double &x, double &y)
     {
@@ -41,68 +42,85 @@
         y = derived().y_scale* y + derived().y_shift;
     }
 
- void _draw_x_minor_ticks(double j)
+ void _draw_x_minor_ticks(double j, path_element& tick_path,
+ path_element& grid_path)
     {
         double x1(0.), y1(0.), y2(derived().image.get_y_size());
+
         // draw the grid if needed
- if(derived().x_minor_grid_on)
+ if(derived().use_x_minor_grid)
         {
             _transform_x(x1 = j);
 
- if(!derived().plot_window_on)
+ if(!derived().use_plot_window)
             {
                 // spacing for labels
- if(derived().title_on)
+ if(derived().use_title)
                 {
- y1 += derived().title_font_size * 1.5;
+ y1 += derived().title_info.font_size() * 1.5;
                 }
 
- if(derived().x_label_on)
+ if(derived().use_x_label)
                 {
- y2 -= derived().x_label_font_size * 1.5;
+ y2 -= derived().x_label_info.font_size() * 1.5;
                 }
             }
 
- derived().image.get_g_element(PLOT_X_MINOR_GRID).line(x1, y1, x1, y2);
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ grid_path.M(x1, y1).L(x1, y2);
+ }
         }
 
- y1 = derived().x_axis + derived().x_minor_tick_length/2.;
- y2 = derived().x_axis - derived().x_minor_tick_length/2.;
+ double x_tick_length = derived().x_minor_length / 2.;
 
+ if(derived().use_x_external_style)
+ {
+ y1 = derived().plot_y2;
+ y2 = derived().plot_y2 + x_tick_length;
+ }
+
+ else
+ {
+ y1 = derived().x_axis + x_tick_length;
+ y2 = derived().x_axis - x_tick_length;
+ }
         x1=j;
 
         _transform_x(x1);
 
         //make sure that we are drawing inside of the allowed window
- if(x1 < derived().plot_window_x2)
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
         {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).line(x1, y1, x1, y2);
+ tick_path.M(x1, y1).L(x1, y2);
         }
     }
 
-
- void _draw_x_major_ticks(double i)
+ void _draw_x_major_ticks(double i, path_element& tick_path, path_element& grid_path)
     {
         double x1(i), y1(0.), y2(derived().image.get_x_size());
 
- if(derived().x_major_grid_on)
+ if(derived().use_x_major_grid)
         {
             _transform_x(x1 = i);
 
- if(!derived().plot_window_on)
+ if(!derived().use_plot_window)
             {
- if(derived().title_on)
+ if(derived().use_title)
                 {
- y1 += derived().title_font_size * 1.5;
+ y1 += derived().title_info.font_size() * 1.5;
                 }
 
- if(derived().x_label_on)
+ if(derived().use_x_label)
                 {
- y2 -= derived().x_label_font_size * 1.5;
+ y2 -= derived().x_label_info.font_size() * 1.5;
                 }
             }
 
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).line(x1, y1, x1, y2);
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ grid_path.M(x1, y1).L(x1, y2);
+ }
         }
 
         //draw major tick
@@ -111,21 +129,41 @@
         _transform_x(x1);
 
         //make sure that we are drawing inside of the allowed window
- if(x1 < derived().plot_window_x2)
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
         {
- y1 = derived().x_axis + derived().x_major_tick_length/2;
- y2 = derived().x_axis - derived().x_major_tick_length/2;
+ double x_tick_length = derived().x_major_length / 2.;
             
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).line(x1, y1, x1, y2);
+ if(derived().use_x_external_style)
+ {
+ y1 = derived().plot_y2;
+ y2 = derived().plot_y2 + x_tick_length;
+ }
 
+ else
+ {
+ y1 = derived().x_axis + x_tick_length;
+ y2 = derived().x_axis - x_tick_length;
+ }
             
- if(derived().x_major_labels_on)
+ tick_path.M(x1, y1).L(x1, y2);
+
+ if(derived().use_x_major_labels)
             {
                 std::stringstream fmt;
                 fmt<<i;
 
+ if(derived().use_x_external_style)
+ {
+ y1 += derived().x_major_length;
+ }
+
+ else
+ {
+ y1 += (2 + derived().x_major_length/2);
+ }
+
                 derived().image.get_g_element(PLOT_PLOT_LABELS).text(x1,
- y1 + (2 + derived().x_major_tick_length/2), fmt.str());
+ y1, fmt.str());
             }
         }
     }
@@ -139,36 +177,51 @@
 
         derived().x_axis = y1;
 
- derived().image.get_g_element(PLOT_X_AXIS).line(derived().plot_window_x1, derived().x_axis,
- derived().plot_window_x2, derived().x_axis);
+ path_element& minor_tick_path =
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).path();
+
+ path_element& major_tick_path =
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).path();
+
+ path_element& minor_grid_path =
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).path();
+
+ path_element& major_grid_path =
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).path();
+
+ if(derived().show_x_axis_lines)
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).line(derived().plot_x1, derived().x_axis,
+ derived().plot_x2, derived().x_axis);
+ }
 
         // x_minor_jump is the interval between minor ticks
- double x_minor_jump = derived().x_major_tick/
- ((double) (derived().x_num_minor_ticks + 1.) );
+ double x_minor_jump = derived().x_major/
+ ((double)(derived().x_num_minor + 1.) );
 
         // draw the ticks on the positive side
- for(double i = 0; i < derived().x_max; i += derived().x_major_tick)
+ for(double i = 0; i < derived().x_max; i += derived().x_major)
         {
             for(double j = i + x_minor_jump;
- j < i + derived().x_major_tick;
+ j < i + derived().x_major;
                        j += x_minor_jump)
             {
- _draw_x_minor_ticks(j);
+ _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
             }
 
- _draw_x_major_ticks(i);
+ _draw_x_major_ticks(i, major_tick_path, major_grid_path);
         }
 
         // draw the ticks on the negative side
- for(double i = 0; i > derived().x_min; i -= derived().x_major_tick)
+ for(double i = 0; i > derived().x_min; i -= derived().x_major)
         {
             // draw minor ticks
- for(double j=i; j>i-derived().x_major_tick; j-=derived().x_major_tick / (derived().x_num_minor_ticks+1))
+ for(double j=i; j>i-derived().x_major; j-=derived().x_major / (derived().x_num_minor+1))
             {
- _draw_x_minor_ticks(j);
+ _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
             }
 
- _draw_x_major_ticks(i);
+ _draw_x_major_ticks(i, major_tick_path, major_grid_path);
         }
     }
 
@@ -240,10 +293,10 @@
     void _draw_legend_header(int _x, int _y, int _width)
     {
         // 2 added to y argument for padding.
- text_element legend_header(_x+(_width/2.), _y + derived().legend_title_font_size + 2, "Legend");
+ text_element legend_header(_x+(_width/2.), _y + derived().legend_title_size + 2, "Legend");
 
- legend_header.set_alignment(center_align);
- legend_header.set_font_size(derived().legend_title_font_size);
+ legend_header.alignment(center_align);
+ legend_header.font_size(derived().legend_title_size);
 
         derived().image.get_g_element(PLOT_LEGEND_TEXT).push_back(new text_element(legend_header));
     }
@@ -269,24 +322,24 @@
            legend_width = x_size;
         }
 
- unsigned int legend_x_start(derived().plot_window_x2 + 5);
- unsigned int legend_y_start(derived().plot_window_y1);
+ unsigned int legend_x_start(derived().plot_x2 + 5);
+ unsigned int legend_y_start(derived().plot_y1);
 
- if((unsigned int)(derived().plot_window_x2) >= derived().image.get_x_size())
+ if((unsigned int)(derived().plot_x2) >= derived().image.get_x_size())
         {
             legend_x_start-=160;
             legend_y_start+=5;
         }
 
- if(derived().title_on)
+ if(derived().use_title)
         {
             // -5 removes the padding
- legend_y_start += (int)(derived().title_font_size * 1.5) - 5;
+ legend_y_start += (int)(derived().title_info.font_size() * 1.5) - 5;
         }
 
         // legend_height = title_spacing + (space per element)(num_elements)
         // + (end spacing)
- legend_height = (int)(derived().legend_title_font_size*1.5 + (25 * num_points) + 10);
+ legend_height = (int)(derived().legend_title_size*1.5 + (25 * num_points) + 10);
 
         g_element* g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_BACKGROUND));
 
@@ -305,43 +358,44 @@
         {
             g_inner_ptr = &(g_ptr->add_g_element());
 
- g_inner_ptr->get_style_info().set_fill_color(derived().series[i].point_style.fill_color)
- .set_stroke_color(derived().series[i].point_style.stroke_color);
+ g_inner_ptr->style().fill_color(derived().series[i].point_style.fill_color)
+ .stroke_color(derived().series[i].point_style.stroke_color);
 
             _draw_plot_point(legend_x_start + 25,
- legend_y_start + derived().legend_title_font_size + 20 + i*25,
+ legend_y_start + derived().legend_title_size + 20 + i*25,
                              *g_inner_ptr,
                              derived().series[i].point_style);
             
             g_inner_ptr = &(derived().image.get_g_element(PLOT_LEGEND_TEXT));
 
             g_inner_ptr->push_back(new text_element(legend_x_start + 40,
- legend_y_start + derived().legend_title_font_size + 25 + i*25,
- derived().series[i].title));
+ legend_y_start + derived().legend_title_size + 25 + i*25,
+ derived().series[i].title, derived().legend_title_size,
+ left_align));
         }
     }
 
     void _draw_title()
     {
- if(derived().title_on)
+ if(derived().use_title)
         {
             text_element title(derived().image.get_x_size()/2.,
- derived().title_font_size,
- derived().title);
+ derived().title_info.font_size(),
+ derived().title_info.text());
 
- title.set_alignment(center_align);
- title.set_font_size(derived().title_font_size);
+ title.alignment(center_align);
+ title.font_size(derived().title_info.font_size());
             derived().image.get_g_element(PLOT_TITLE).push_back(new text_element(title));
         }
     }
 
     void _draw_x_label()
     {
- text_element to_use((derived().plot_window_x2 + derived().plot_window_x1) / 2.,
- derived().image.get_y_size() - 8, derived().x_label);
+ text_element to_use((derived().plot_x2 + derived().plot_x1) / 2.,
+ derived().image.get_y_size() - 8, derived().x_label_info.text());
 
- to_use.set_font_size(12);
- to_use.set_alignment(center_align);
+ to_use.font_size(12);
+ to_use.alignment(center_align);
 
         derived().image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
     }
@@ -369,318 +423,334 @@
     const Derived& derived()const{return static_cast<const Derived&>(*this); }
 public:
 
- Derived& set_image_size(unsigned int x, unsigned int y)
+ Derived& image_size(unsigned int x, unsigned int y)
     {
         derived().image.image_size(x, y);
         return derived();
     }
 
- Derived& set_title(const std::string& _title)
+ Derived& title(const std::string& _title)
     {
- derived().title = _title;
+ derived().title_info.text(_title);
         return derived();
     }
 
- Derived& set_title_font_size(unsigned int _size)
+ Derived& title_font_size(unsigned int _size)
     {
- derived().title_font_size = _size;
+ derived().title_info.font_size() = _size;
         return derived();
     }
 
- Derived& set_legend_title_font_size(unsigned int _size)
+ Derived& legend_title_font_size(unsigned int _size)
     {
         derived().legend_title_font_size = _size;
         return derived();
     }
 
- // -----------------------------------------------------------------
- // Commands: Answers to yes or no questions (Example: Show the legend?)
- //
- // set_axis()
- // set_legend()
- // set_plot_window()
- // set_x_label()
- // set_x_major_labels()
- // -----------------------------------------------------------------
-
- Derived& set_axis_on(bool _cmd)
+ Derived& legend_on(bool _cmd)
     {
- derived().axis_on = _cmd;
+ derived().use_legend = _cmd;
+
+ if(_cmd)
+ {
+ derived().image.get_g_element(detail::PLOT_LEGEND_BACKGROUND)
+ .style().fill_color(white)
+ .stroke_color(black);
+ }
         return derived();
     }
 
- Derived& set_legend_on(bool _cmd)
+ Derived& plot_window_on(bool _cmd)
     {
- derived().legend_on = _cmd;
+ derived().use_plot_window = _cmd;
+
+ if(_cmd)
+ {
+ derived().image.get_g_element(detail::PLOT_PLOT_BACKGROUND)
+ .style().fill_color(white)
+ .stroke_color(black);
+ }
         return derived();
     }
 
- Derived& set_plot_window_on(bool _cmd)
+ Derived& x_label_on(bool _cmd)
     {
- derived().plot_window_on = _cmd;
+ derived().use_x_label = _cmd;
         return derived();
     }
 
- Derived& set_x_label_on(bool _cmd)
+ Derived& x_major_labels_on(bool _cmd)
     {
- derived().x_label_on = _cmd;
+ derived().x_major_labels_on = _cmd;
         return derived();
     }
 
- Derived& set_x_major_labels_on(bool _cmd)
+ Derived& title_on(bool _cmd)
     {
- derived().x_major_labels_on = _cmd;
+ derived().use_title = _cmd;
         return derived();
     }
 
- Derived& set_title_on(bool _cmd)
+ Derived& x_major_grid_on(bool _is)
     {
- derived().title_on = _cmd;
+ derived().use_x_major_grid = _is;
         return derived();
     }
 
- Derived& set_x_major_grid_on(bool _is)
+ Derived& x_minor_grid_on(bool _is)
     {
- derived().x_major_grid_on = _is;
+ derived().use_x_minor_grid = _is;
         return derived();
     }
 
- Derived& set_x_minor_grid_on(bool _is)
+ Derived& axis_on(bool _is)
     {
- derived().x_minor_grid_on = _is;
+ derived().show_x_axis_lines = _is;
+ derived().show_y_axis_lines = _is;
         return derived();
     }
 
+ Derived& x_axis_on(bool _is)
+ {
+ derived().show_x_axis_lines = _is;
+ return derived();
+ }
+
+ Derived& y_axis_on(bool _is)
+ {
+ derived().show_y_axis_lines = _is;
+ return derived();
+ }
     // -----------------------------------------------------------------
     // Color settings: Customization of colors found in the plot
     //
- // set_title_color()
- // set_background_color()
- // set_legend_background_color()
- // set_plot_background_color()
- // set_axis_color()
- // set_x_major_tick_color()
- // set_x_minor_tick_color()
+ // title_color()
+ // background_color()
+ // legend_background_color()
+ // plot_background_color()
+ // axis_color()
+ // x_major_tick_color()
+ // x_minor_tick_color()
     // -----------------------------------------------------------------
 
- Derived& set_title_color(svg_color_constant _col)
+ Derived& title_color(svg_color_constant _col)
     {
- set_title_color(constant_to_rgb(_col));
+ title_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_title_color(const svg_color& _col)
+ Derived& title_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_TITLE).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_TITLE).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_TITLE).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_TITLE).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_background_color(svg_color_constant _col)
+ Derived& background_color(svg_color_constant _col)
     {
- set_background_color(constant_to_rgb(_col));
+ background_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_background_color(const svg_color& _col)
+ Derived& background_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_BACKGROUND).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_legend_background_color(svg_color_constant _col)
+ Derived& legend_background_color(svg_color_constant _col)
     {
- set_legend_background_color(constant_to_rgb(_col));
+ legend_background_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_legend_background_color(const svg_color& _col)
+ Derived& legend_background_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_legend_border_color(svg_color_constant _col)
+ Derived& legend_border_color(svg_color_constant _col)
     {
- set_legend_border_color(constant_to_rgb(_col));
+ legend_border_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_legend_border_color(const svg_color& _col)
+ Derived& legend_border_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).get_style_info().set_stroke_color(_col);
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color(_col);
         return derived();
     }
 
- Derived& set_background_border_color(svg_color_constant _col)
+ Derived& background_border_color(svg_color_constant _col)
     {
- derived().image.get_g_element(PLOT_BACKGROUND).get_style_info().set_stroke_color(_col);
+ derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
         return derived();
     }
 
- Derived& set_background_border_color(const svg_color& _col)
+ Derived& background_border_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_BACKGROUND).get_style_info().set_stroke_color(_col);
+ derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
         return derived();
     }
 
- Derived& set_plot_background_color(svg_color_constant _col)
+ Derived& plot_background_color(svg_color_constant _col)
     {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_plot_background_color(const svg_color& _col)
+ Derived& plot_background_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_axis_color(svg_color_constant _col)
+ Derived& x_axis_color(svg_color_constant _col)
     {
- set_x_axis_color(constant_to_rgb(_col));
+ x_axis_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_x_axis_color(const svg_color& _col)
+ Derived& x_axis_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_AXIS).get_style_info()
- .set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_AXIS).style()
+ .fill_color(_col);
 
- derived().image.get_g_element(PLOT_X_AXIS).get_style_info()
- .set_stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_AXIS).style()
+ .stroke_color(_col);
 
         return derived();
     }
 
- Derived& set_x_major_tick_color(const svg_color& _col)
+ Derived& x_major_tick_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_major_tick_color(svg_color_constant _col)
+ Derived& x_major_tick_color(svg_color_constant _col)
     {
- set_x_major_tick_color(constant_to_rgb(_col));
+ x_major_tick_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_x_label_color(const svg_color& _col)
+ Derived& x_label_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_LABEL).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_X_LABEL).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_LABEL).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_label_color(svg_color_constant _col)
+ Derived& x_label_color(svg_color_constant _col)
     {
- set_x_label_color(constant_to_rgb(_col));
+ x_label_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_x_minor_tick_color(const svg_color& _col)
+ Derived& x_minor_tick_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_minor_tick_color(svg_color_constant _col)
+ Derived& x_minor_tick_color(svg_color_constant _col)
     {
- set_x_minor_tick_color(constant_to_rgb(_col));
+ x_minor_tick_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_x_major_grid_color(const svg_color& _col)
+ Derived& x_major_grid_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_major_grid_color(svg_color_constant _col)
+ Derived& x_major_grid_color(svg_color_constant _col)
     {
- set_x_major_grid_color(constant_to_rgb(_col));
+ x_major_grid_color(constant_to_rgb(_col));
         return derived();
     }
 
- Derived& set_x_minor_grid_color(const svg_color& _col)
+ Derived& x_minor_grid_color(const svg_color& _col)
     {
- derived().image.get_g_element(PLOT_X_MINOR_GRID).get_style_info().set_stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MINOR_GRID).get_style_info().set_fill_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().fill_color(_col);
         return derived();
     }
 
- Derived& set_x_minor_grid_color(svg_color_constant _col)
+ Derived& x_minor_grid_color(svg_color_constant _col)
     {
- set_x_minor_grid_color(constant_to_rgb(_col));
+ x_minor_grid_color(constant_to_rgb(_col));
         return derived();
     }
 
     // -----------------------------------------------------------------
     // Axis information: Settings for customization of axis information
     //
- // set_x_axis_width()
- // set_x_major_tick()
- // set_x_major_tick_length()
- // set_x_major_tick_width()
- // set_x_minor_tick_length()
- // set_x_minor_tick_width()
- // set_x_label_text()
- // set_x_num_minor_ticks()
- // set_x_scale()
+ // x_axis_width()
+ // x_major_tick()
+ // x_major_tick_length()
+ // x_major_tick_width()
+ // x_minor_tick_length()
+ // x_minor_tick_width()
+ // x_label_text()
+ // x_num_minor_ticks()
+ // x_scale()
     // -----------------------------------------------------------------
 
- Derived& set_x_axis_width(unsigned int _width)
+ Derived& x_axis_width(unsigned int _width)
     {
- derived().image.get_g_element(PLOT_X_AXIS).get_style_info().set_stroke_width(_width);
+ derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width(_width);
         return derived();
     }
 
- Derived& set_x_label(const std::string& _str)
+ Derived& x_label(const std::string& _str)
     {
- derived().x_label = _str;
+ derived().x_label_info.text(_str);
         return derived();
     }
 
- Derived& set_x_major_tick(double _inter)
+ Derived& x_major_tick(double _inter)
     {
         derived().x_major_tick = _inter;
         return derived();
     }
 
- Derived& set_x_major_tick_length(unsigned int _length)
+ Derived& x_major_tick_length(unsigned int _length)
     {
         derived().x_major_tick_length = _length;
         return derived();
     }
 
- Derived& set_x_major_tick_width(unsigned int _width)
+ Derived& x_major_tick_width(unsigned int _width)
     {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().set_stroke_width(_width);
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(_width);
         return derived();
     }
 
- Derived& set_x_minor_tick_length(unsigned int _length)
+ Derived& x_minor_tick_length(unsigned int _length)
     {
         derived().x_minor_tick_length = _length;
         return derived();
     }
 
- Derived& set_x_minor_tick_width(unsigned int _width)
+ Derived& x_minor_tick_width(unsigned int _width)
     {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().set_stroke_width(_width);
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(_width);
         return derived();
     }
 
- Derived& set_x_num_minor_ticks(unsigned int _num)
+ Derived& x_num_minor_ticks(unsigned int _num)
     {
         derived().x_num_minor_ticks = _num;
         return derived();
     }
 
- Derived& set_x_scale(double x1, double x2)
+ Derived& x_scale(double x1, double x2)
     {
         if(x2 <= x1)
         {
@@ -713,25 +783,19 @@
         return derived().legend_title_font_size;
     }
 
- // commands
- bool get_axis()
- {
- return derived().axis_on;
- }
-
     bool get_legend()
     {
- return derived().legend_on;
+ return derived().use_legend;
     }
 
     bool get_plot_window()
     {
- return derived().plot_window_on;
+ return derived().use_plot_window;
     }
 
     bool get_x_label()
     {
- return derived().x_label_on;
+ return derived().use_x_label;
     }
 
     bool get_x_major_labels()
@@ -742,62 +806,62 @@
     // color information
     svg_color get_title_color()
     {
- return derived().image.get_g_element(PLOT_TITLE).get_style_info().get_fill_color();
+ return derived().image.get_g_element(PLOT_TITLE).style().get_fill_color();
     }
 
     svg_color get_background_color()
     {
- return derived().image.get_g_element(PLOT_BACKGROUND).get_style_info().get_fill_color();
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().get_fill_color();
     }
 
     svg_color get_background_border_color()
     {
- return derived().image.get_g_element(PLOT_BACKGROUND).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().get_stroke_color();
     }
 
     svg_color get_legend_background_color()
     {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).get_style_info().get_fill_color();
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_fill_color();
     }
 
     svg_color get_legend_border_color()
     {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_stroke_color();
     }
 
     svg_color get_plot_background_color()
     {
- return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).get_style_info().get_fill_color();
+ return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().get_fill_color();
     }
 
     svg_color get_x_axis_color()
     {
- return derived().image.get_g_element(PLOT_X_AXIS).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_color();
     }
 
     svg_color get_x_label_color()
     {
- return derived().image.get_g_element(PLOT_X_LABEL).get_style_info().get_fill_color();
+ return derived().image.get_g_element(PLOT_X_LABEL).style().get_fill_color();
     }
 
     svg_color get_x_major_tick_color()
     {
- return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_color();
     }
 
     svg_color get_x_minor_tick_color()
     {
- return derived().image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_color();
     }
 
     svg_color get_x_major_grid_color()
     {
- return derived().image.get_g_element(PLOT_X_MAJOR_GRID).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().get_stroke_color();
     }
 
     svg_color get_x_minor_grid_color()
     {
- return derived().image.get_g_element(PLOT_X_MINOR_GRID).get_style_info().get_stroke_color();
+ return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().get_stroke_color();
     }
 
     // axis information
@@ -813,7 +877,7 @@
 
     unsigned int get_x_axis_width()
     {
- return derived().image.get_g_element(PLOT_X_AXIS).get_style_info().get_stroke_width();
+ return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_width();
     }
 
     double get_x_major_tick()
@@ -838,21 +902,36 @@
 
     unsigned int get_x_major_tick_width()
     {
- return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().get_stroke_width();
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_width();
     }
 
     unsigned int get_x_minor_tick_width()
     {
- return derived().image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().get_stroke_width();
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_width();
     }
 
     std::string get_x_label_text()
     {
         return derived().x_label;
     }
+
+ svg& get_svg()
+ {
+ derived()._update_image();
+
+ return derived().image;
+ }
+
+ const svg& get_svg() const
+ {
+ derived()._update_image();
+
+ return derived().image;
+ }
 };
 
-}
-}
+} // detail
+} // svg
+} // boost
 
 #endif

Added: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -0,0 +1,28 @@
+// svg_style.hpp
+// Copyright (C) Jacob Voytko 2007
+//
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+
+// -----------------------------------------------------------------
+
+#ifndef _BOOST_SVG_SVG_STYLE_DETAIL_HPP
+#define _BOOST_SVG_SVG_STYLE_DETAIL_HPP
+
+namespace boost{
+namespace svg{
+namespace detail{
+
+enum plot_doc_structure{PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND,
+ PLOT_Y_MINOR_GRID, PLOT_Y_MAJOR_GRID, PLOT_X_MINOR_GRID,
+ PLOT_X_MAJOR_GRID, PLOT_Y_AXIS, PLOT_X_AXIS,
+ PLOT_Y_MINOR_TICKS, PLOT_X_MINOR_TICKS, PLOT_Y_MAJOR_TICKS,
+ PLOT_X_MAJOR_TICKS, PLOT_PLOT_LABELS, PLOT_Y_LABEL, PLOT_X_LABEL,
+ PLOT_PLOT_LINES, PLOT_PLOT_POINTS,
+ PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
+ PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
+
+}
+}
+}
+#endif

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -10,12 +10,22 @@
 #ifndef _SVG_TAG_HPP
 #define _SVG_TAG_HPP
 
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4127) // "conditional expression is constant."
+# pragma warning(disable: 4512) // "assignment operator could not be generated."
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+#include <boost/ptr_container/ptr_container.hpp>
+#include "../svg_style.hpp"
+
 #include <sstream>
 #include <string>
-#include <boost/ptr_container/ptr_container.hpp>
-#include <boost/noncopyable.hpp>
 
-#include "svg_style.hpp"
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
 
 namespace boost {
 namespace svg {
@@ -35,17 +45,21 @@
 {
 protected:
     svg_style style_info;
+ std::string id_name;
 
 public:
- virtual void write(std::ostream&) = 0;
+ virtual void write(std::ostream& rhs) = 0;
 
- ~svg_element()
+ virtual ~svg_element()
     {
 
     }
 
- svg_style& get_style_info(){ return style_info; }
- const svg_style& get_style_info() const{ return style_info; }
+ svg_style& style(){ return style_info; }
+ const svg_style& style() const{ return style_info; }
+
+ void id(const std::string& _id) { id_name = _id; }
+ std::string id( ) { return std::string(id_name); }
 };
 
 // -----------------------------------------------------------------
@@ -129,93 +143,92 @@
 class text_element: public svg_element
 {
 private:
- double x, y;
- int font_size;
- std::string text;
- text_style alignment;
+ double x_coord, y_coord;
+ int size;
+ std::string txt;
+ text_style align;
 
 public:
- void set_alignment(text_style _a)
+ void alignment(text_style _a)
     {
- alignment = _a;
+ align = _a;
     }
 
- int get_font_size()
+ int font_size()
     {
- return font_size;
+ return size;
     }
 
- double set_x(double _x)
+ double x(double _x)
     {
- x = _x;
+ x_coord = _x;
     }
 
- double set_y(double _y)
+ double y(double _y)
     {
- y = _y;
+ y_coord = _y;
     }
 
- text_element(double _x, double _y, std::string _text)
- :x(_x), y(_y), text(_text), alignment(left_align), font_size(12)
+ text_element(double _x, double _y, std::string _text, int _size = 12,
+ text_style _align = center_align)
+ :x_coord(_x), y_coord(_y), txt(_text), size(_size), align(_align)
     {
         
     }
 
     void write(std::ostream& rhs)
     {
- std::string align;
+ std::string output;
 
- switch(alignment)
+ switch(align)
         {
         case left_align:
- align = "start";
+ output = "start";
             break;
 
         case right_align:
- align = "end";
+ output = "end";
             break;
 
         case center_align:
- align = "middle";
+ output = "middle";
             break;
 
         default:
- align = "";
+ output = "";
             break;
         }
 
- rhs << "<text x=\"" << x << "\""
- <<" y=\""<<y<<"\" ";
+ rhs << "<text x=\"" << x_coord << "\""
+ <<" y=\"" << y_coord << "\" ";
         
- if(align != "")
+ if(output != "")
         {
- rhs << "text-anchor=\""<<align<<"\" ";
+ rhs << "text-anchor=\"" << output << "\" ";
         }
 
- rhs <<" font-family=\"verdana\"";
+ rhs << " font-family=\"verdana\"";
 
- if(font_size == 0)
+ if(size == 0)
         {
- rhs <<" font-size=\"12\">";
+ rhs << " font-size=\"12\">";
         }
 
         else
         {
- rhs <<" font-size=\""<<font_size<<"\">";
+ rhs << " font-size=\"" << size << "\">";
         }
 
- rhs << text
+ rhs << txt
             <<" </text>";
     }
 
- void set_font_size(unsigned int _size)
- {
- font_size = _size;
- }
+ void font_size(unsigned int _size){ size = _size; }
+ void text(const std::string& _txt) { txt = _txt; }
 
- std::string get_text()
+ std::string text()
     {
- return text;
+ return txt;
     }
 };
 
@@ -244,20 +257,314 @@
 };
 
 
+struct path_point
+{
+ bool relative;
+
+ virtual void write(std::ostream& rhs) = 0;
+
+ virtual ~path_point()
+ {
+
+ }
+
+ path_point(bool _rel): relative(_rel)
+ {
+
+ }
+};
+
+struct m_path: public path_point
+{
+ double x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"m";
+ }
+
+ else
+ {
+ o_str<<"M";
+ }
+
+ o_str<<x<<" "<<y<<" ";
+ }
+
+ m_path(double _x, double _y, bool _rel = false):
+ x(_x), y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct z_path: public path_point
+{
+ void write(std::ostream& o_str)
+ {
+ o_str<<"Z ";
+ }
+
+ z_path():path_point(false){}
+};
+
+struct l_path: public path_point
+{
+ double x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"l";
+ }
+
+ else
+ {
+ o_str<<"L";
+ }
+
+ o_str<<x<<" "<<y<<" ";
+ }
+
+ l_path(double _x, double _y, bool _rel = false):
+ x(_x), y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct h_path: public path_point
+{
+ double x;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"h";
+ }
+
+ else
+ {
+ o_str<<"H";
+ }
+
+ o_str<<x<<" ";
+ }
+
+ h_path(double _x, bool _rel = false):
+ x(_x), path_point(_rel)
+ {
+ }
+};
+
+struct v_path: public path_point
+{
+ double y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"v";
+ }
+
+ else
+ {
+ o_str<<"V";
+ }
+
+ o_str<<y<<" ";
+ }
+
+ v_path(double _y, bool _rel = false):
+ y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct c_path: public path_point
+{
+ double x1, y1, x2, y2, x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"c";
+ }
+
+ else
+ {
+ o_str<<"C";
+ }
+
+ o_str<<x1<<" "<<y1<<" "
+ <<x2<<" "<<y2<<" "
+ <<x<<" "<<y<<" ";
+ }
+
+ c_path(double _x1, double _y1, double _x2, double _y2,
+ double _x, double _y, bool _rel = false):
+ x1(_x1), y1(_y1), x2(_x2), y2(_y2), x(_x), y(_y), path_point(_rel)
+ {
+
+ }
+};
+
+struct q_path: public path_point
+{
+ double x1, y1, x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"q";
+ }
+
+ else
+ {
+ o_str<<"Q";
+ }
+
+ o_str<<x1<<" "<<y1<<" "
+ <<x<<" "<<y<<" ";
+ }
+
+ q_path(double _x1, double _y1,
+ double _x, double _y, bool _rel = false):
+ x1(_x1), y1(_y1), x(_x), y(_y), path_point(_rel)
+ {
+
+ }
+};
+
+class path_element: public svg_element
+{
+private:
+ ptr_vector<path_point> path;
+public:
+
+ path_element(const path_element& rhs)//:path(rhs.path.release())
+ {
+ path = (const_cast<path_element&>(rhs)).path.release();
+ }
+
+ path_element() { }
+
+ path_element& m(double x, double y)
+ {
+ path.push_back(new m_path(x, y, true));
+ return *this;
+ }
+
+ path_element& M(double x, double y)
+ {
+ path.push_back(new m_path(x, y, false));
+ return *this;
+ }
+
+ path_element& z()
+ {
+ path.push_back(new z_path());
+ return *this;
+ }
+
+ path_element& l(double x, double y)
+ {
+ path.push_back(new l_path(x, y, true));
+ return *this;
+ }
+
+ path_element& L(double x, double y)
+ {
+ path.push_back(new l_path(x, y, false));
+ return *this;
+ }
+
+ path_element& h(double x)
+ {
+ path.push_back(new h_path(x, true));
+ return *this;
+ }
+
+ path_element& H(double x)
+ {
+ path.push_back(new h_path(x, false));
+ return *this;
+ }
+
+ path_element& v(double y)
+ {
+ path.push_back(new v_path(y, true));
+ return *this;
+ }
+
+ path_element& V(double y)
+ {
+ path.push_back(new v_path(y, false));
+ return *this;
+ }
+
+ path_element& c(double x1, double y1, double x2, double y2, double x, double y)
+ {
+ path.push_back(new c_path(x1, y1, x2, y2, x, y, true));
+ return *this;
+ }
+
+ path_element& C(double x1, double y1, double x2, double y2, double x, double y)
+ {
+ path.push_back(new c_path(x1, y1, x2, y2, x, y, false));
+ return *this;
+ }
+
+ path_element& q(double x1, double y1, double x, double y)
+ {
+ path.push_back(new q_path(x1, y1, x, y, true));
+ return *this;
+ }
+
+ path_element& Q(double x1, double y1, double x, double y)
+ {
+ path.push_back(new q_path(x1, y1, x, y, false));
+ return *this;
+ }
+
+ void write(std::ostream& o_str)
+ {
+ o_str<<"<path d=\"";
+
+ for(ptr_vector<path_point>::iterator i = path.begin();
+ i!=path.end();
+ ++i)
+ {
+ (*i).write(o_str);
+ }
+ o_str<<"\" ";
+
+ style_info.write(o_str);
+
+ o_str<<"/>";
+ }
+};
+
+
 // -----------------------------------------------------------------
 // The node element of our document tree
 // -----------------------------------------------------------------
 class g_element: public svg_element
 {
 private:
- boost::ptr_vector<svg_element> children;
+ ptr_vector<svg_element> children;
     std::string clip_name;
 
- bool use_clip;
+ bool clip_on;
     
 public:
 
- g_element():use_clip(false)
+ g_element():clip_on(false)
     {
 
     }
@@ -312,14 +619,14 @@
         children.clear();
     }
 
- void set_use_clip(bool _use)
+ void use_clip(bool _use)
     {
- use_clip = _use;
+ clip_on = _use;
     }
      
- void set_clip(const std::string& _name)
+ void clip(const std::string& _name)
     {
- use_clip = true;
+ clip_on = true;
         clip_name = _name;
     }
 
@@ -353,6 +660,12 @@
 
         return *this;
     }
+
+ path_element& path()
+ {
+ children.push_back(new path_element());
+ return *(static_cast<path_element*>(&(children[(unsigned int)(children.size()-1)])));
+ }
 };
 
 }

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -15,7 +15,7 @@
 #include <exception>
 
 #include "detail/svg_tag.hpp"
-#include "detail/svg_style.hpp"
+#include "svg_style.hpp"
 
 namespace boost {
 namespace svg {
@@ -144,12 +144,18 @@
 
         return *this;
     }
+
+ path_element& path()
+ {
+ document.push_back(new path_element());
+ return *(static_cast<path_element*>(&(document[(unsigned int)(document.size()-1)])));
+ }
 
     svg& clip_path(const rect_element& _rect, g_element& _g,
                         const std::string& _id)
     {
         document.push_back(new clip_path_element(_id,_rect));
- _g.set_clip(_id);
+ _g.clip(_id);
 
         return *this;
     }

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -1,36 +1,84 @@
 // svg_1d_plot.hpp
 
 // Copyright (C) Jacob Voytko 2007
+// Copyright Paul A. Bristow 2007
+// Added disable warning 4180 in Boost.Parameter.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // For more information, see http://www.boost.org
 
-// -----------------------------------------------------------------
+// -----------------------------------------------------------------
 
 #ifndef _BOOST_SVG_SVG_1D_PLOT_HPP
 #define _BOOST_SVG_SVG_1D_PLOT_HPP
 
-#include <vector>
-#include <ostream>
-#include <sstream>
-#include <fstream>
-#include <string>
-#include <exception>
+#define BOOST_PARAMETER_MAX_ARITY 11
+
+#include <boost/bind.hpp>
 
-#define BOOST_PARAMETER_MAX_ARITY 10
+#if defined (BOOST_MSVC)
+# pragma warning (push)
+# pragma warning (disable: 4512) // "assignment operator could not be generated."
+# pragma warning (disable: 4180) // qualifier applied to function type has no meaning; ignored
+#endif
+
+// See also pbristow trac ticket #1097 complaining about this ;-)
+// trailing const qualifiers are said to be meaningless.
 
 #include <boost/parameter/preprocessor.hpp>
 #include <boost/parameter/name.hpp>
 #include <boost/iterator/transform_iterator.hpp>
-#include <boost/bind.hpp>
 
 #include "svg.hpp"
-#include "detail/svg_style.hpp"
+#include "svg_style.hpp"
 #include "detail/axis_plot_frame.hpp"
 
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+#include <vector>
+#include <ostream>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include <exception>
+
+
 namespace boost {
 namespace svg {
 
+
+// -----------------------------------------------------------------
+// Parameter names for plot() function
+// -----------------------------------------------------------------
+
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning (disable: 4512) // "assignment operator could not be generated."
+# pragma warning (disable: 4180) // qualifier applied to function type has no meaning; ignored
+#endif
+
+
+#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
+#define BOOST_SVG_BOOST_PARAMETER_NAMES
+
+BOOST_PARAMETER_NAME(my_plot)
+BOOST_PARAMETER_NAME(container)
+BOOST_PARAMETER_NAME(title)
+BOOST_PARAMETER_NAME(stroke_color)
+BOOST_PARAMETER_NAME(fill_color)
+BOOST_PARAMETER_NAME(point_style)
+BOOST_PARAMETER_NAME(size)
+BOOST_PARAMETER_NAME(x_functor)
+
+#endif
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
 // -----------------------------------------------------------------
 // This functor allows any data convertible to doubles to be plotted
 // -----------------------------------------------------------------
@@ -57,56 +105,58 @@
     std::vector<double> series;
     std::string title;
     plot_point_style point_style;
-
- svg_plot_series(std::vector<double> _ctr, const std::string& _title,
+
+ template <class T>
+ svg_plot_series(T _begin, T _end, const std::string& _title,
                     const plot_point_style& _style):
- series(_ctr), title(_title), point_style(_style)
+ series(_begin, _end), title(_title), point_style(_style)
     {
     }
 };
 
-class svg_1d_plot: public axis_plot_frame<svg_1d_plot>
+class svg_1d_plot: public detail::axis_plot_frame<svg_1d_plot>
 {
 protected:
     // stored so as to avoid rewriting style information constantly
     svg image;
 
+ text_element title_info;
+ text_element x_label_info;
+
     // border information for the plot window. Initially will be set
     // to the width and height of the graph
- int plot_window_x1, plot_window_y1,
- plot_window_x2, plot_window_y2;
+ int plot_x1, plot_y1,
+ plot_x2, plot_y2;
 
                  // axis information
- unsigned int x_major_tick_length, x_major_tick_width,
- x_minor_tick_length, x_minor_tick_width,
- x_label_font_size, x_num_minor_ticks,
+ unsigned int x_major_length, x_major_width,
+ x_minor_length, x_minor_width, x_num_minor,
 
                  // misc information
- legend_title_font_size, title_font_size;
+ legend_title_size;
     
- // used for text displayed on the graph
- std::string x_label, title;
-
     // double axis information. y_axis stored as one point because this
     // is a 1D graph
     double x_min, x_max;
     double x_axis;
     
- double x_major_tick;
+ double x_major;
 
     // Yes/no questions
- bool x_major_labels_on;
- bool x_major_grid_on;
- bool x_minor_grid_on;
- bool x_label_on;
-
- bool title_on;
- bool legend_on;
- bool axis_on;
- bool plot_window_on;
+ bool use_x_major_labels;
+ bool use_x_major_grid;
+ bool use_x_minor_grid;
+ bool use_x_label;
+
+ bool use_title;
+ bool use_legend;
+ bool use_plot_window;
+ bool use_x_external_style;
+ bool show_x_axis_lines;
+ bool show_y_axis_lines;
 
 private:
- friend class axis_plot_frame<svg_1d_plot>;
+ friend class detail::axis_plot_frame<svg_1d_plot>;
 
     // where we will be storing the data points for transformation
     std::vector<svg_plot_series> series;
@@ -117,117 +167,184 @@
     
     void _calculate_transform()
     {
- x_scale = (plot_window_x2-plot_window_x1)/(x_max-x_min);
- x_shift = plot_window_x1 - (x_min *(plot_window_x2-plot_window_x1)/
+ x_scale = (plot_x2-plot_x1)/(x_max-x_min);
+ x_shift = plot_x1 - (x_min *(plot_x2-plot_x1)/
                                    (x_max-x_min));
 
         y_scale = 1.;
- y_shift = plot_window_y1 - (plot_window_y1-plot_window_y2)/2.;
+ y_shift = plot_y1 - (plot_y1-plot_y2)/2.;
     }
 
-void _draw_axis()
-{
- double x(0.), y1(0.), y2(image.get_y_size());
+ void _draw_axis()
+ {
+ double x(0.), y1(0.), y2(image.get_y_size());
 
- _transform_x(x);
-
- y1 = 0.;
+ _transform_x(x);
+
+ y1 = 0.;
 
- //draw origin. Make sure it is in the window
- if(x > plot_window_x1 && x < plot_window_x2)
- {
- if(!plot_window_on)
+ //draw origin. Make sure it is in the window
+ if(x > plot_x1 && x < plot_x2 && show_y_axis_lines)
         {
- if(title_on)
+ if(!use_plot_window)
             {
- y1 += title_font_size * 1.5;
+ if(use_title)
+ {
+ y1 += title_info.font_size() * 1.5;
+ }
+ if(use_x_label)
+ {
+ y2 -= x_label_info.font_size() * 1.5;
+ }
             }
- if(x_label_on)
+
+ else
             {
- y2 -= x_label_font_size * 1.5;
+ y1 = plot_y1;
+ y2 = plot_y2;
             }
- }
 
- else
- {
- y1 = plot_window_y1;
- y2 = plot_window_y2;
+ image.get_g_element(detail::PLOT_X_AXIS).line(x, y1, x, y2);
         }
-
- image.get_g_element(PLOT_X_AXIS).line(x, y1, x, y2);
+ _draw_x_axis();
     }
- _draw_x_axis();
-}
+
     void _calculate_plot_window()
     {
- x_axis = (plot_window_y2 + plot_window_y1)/2.;
+ x_axis = (plot_y2 + plot_y1)/2.;
 
- plot_window_x1 = plot_window_y1 = 0;
- plot_window_x2 = image.get_x_size();
- plot_window_y2 = image.get_y_size();
+ plot_x1 = plot_y1 = 0;
+ plot_x2 = image.get_x_size();
+ plot_y2 = image.get_y_size();
 
- if(plot_window_on)
+ if(use_plot_window)
         {
- plot_window_x1+=5;
- plot_window_x2-=5;
- plot_window_y1+=5;
- plot_window_y2-=5;
+ plot_x1+=5;
+ plot_x2-=5;
+ plot_y1+=5;
+ plot_y2-=5;
 
- if(legend_on)
+ if(use_legend)
             {
- plot_window_x2 -= 155;
+ plot_x2 -= 155;
             }
 
- if(x_label_on)
+ if(use_x_label)
             {
- plot_window_y2 -= 20;
+ plot_y2 -= 20;
             }
 
             //for the title. Will take into account font size soon
- plot_window_y1 +=40;
+ plot_y1 +=40;
+
+ image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
+ new rect_element(plot_x1, plot_y1,
+ (plot_x2-plot_x1), plot_y2-plot_y1));
+ }
+ }
+
+ void _update_image()
+ {
+
+ // removes all elements that will show up in a subsequent draw
+ _clear_all();
 
- image.get_g_element(PLOT_PLOT_BACKGROUND).push_back(
- new rect_element(plot_window_x1, plot_window_y1,
- (plot_window_x2-plot_window_x1), plot_window_y2-plot_window_y1));
+ // draw background
+ image.get_g_element(detail::PLOT_BACKGROUND).push_back(
+ new rect_element(0, 0, image.get_x_size(),
+ image.get_y_size()));
+
+ _draw_title();
+ _calculate_plot_window();
+ _calculate_transform();
+
+ if(x_axis)
+ {
+ _draw_axis();
+ }
+
+ if(use_legend)
+ {
+ _draw_legend();
+ }
+
+ if(use_x_label)
+ {
+ _draw_x_label();
+ }
+
+ double x(0), y(0);
+
+ _transform_y(y);
+
+ //draw points
+ for(unsigned int i=0; i<series.size(); ++i)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
+
+ g_ptr.style().fill_color(series[i].point_style.fill_color);
+ g_ptr.style().stroke_color(series[i].point_style.stroke_color);
+
+ for(unsigned int j=0; j<series[i].series.size(); ++j)
+ {
+ x = series[i].series[j];
+ _transform_x(x);
+
+ if(x > plot_x1
+ && x < plot_x2
+ && y > plot_y1
+ && y < plot_y2)
+ {
+ _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
+ }
         }
     }
 
 public:
 
 // see documentation for default settings rationale
-svg_1d_plot(): x_label("X Axis"), title("Plot of data"), x_min(-10), x_max(10),
- legend_on(false), title_on(true),
- axis_on(true), plot_window_on(false), x_label_on(false),
- x_major_grid_on(false), x_minor_grid_on(false),
- x_major_tick(3), x_minor_tick_length(10),
- x_major_tick_length(20), x_num_minor_ticks(2),
- legend_title_font_size(12), x_label_font_size(12),
- title_font_size(30), x_scale(1.), x_shift(0),
+svg_1d_plot(): title_info(0, 0, "Plot of data", 30),
+ x_label_info(0, 0, "X Axis", 12),
+ x_min(-10), x_max(10),
+ use_legend(false), use_title(true),
+ use_plot_window(false), use_x_label(false),
+ use_x_major_grid(false), use_x_minor_grid(false),
+ use_x_external_style(false), show_x_axis_lines(true),
+ show_y_axis_lines(true),
+ x_major(3), x_minor_length(10),
+ x_major_length(20), x_num_minor(2),
+ legend_title_size(12),
+ x_scale(1.), x_shift(0),
                       y_scale(1.), y_shift(0)
 {
- set_image_size(500, 350);
+ image_size(500, 350);
 
     //build the document tree.. add children of the root node
- for(int i=0; i<SVG_PLOT_DOC_CHILDREN; ++i)
+ for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
         image.add_g_element();
     }
 
     // set color defaults
- image.get_g_element(PLOT_BACKGROUND)
- .get_style_info().set_fill_color(white);
+ image.get_g_element(detail::PLOT_BACKGROUND)
+ .style().fill_color(white);
 
- image.get_g_element(PLOT_PLOT_BACKGROUND)
- .get_style_info().set_fill_color(white);
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().stroke_color(black);
 
- image.get_g_element(PLOT_LEGEND_BACKGROUND)
- .get_style_info().set_fill_color(white);
+ image.get_g_element(detail::PLOT_X_AXIS)
+ .style().stroke_color(black);
 
- image.get_g_element(PLOT_X_MAJOR_TICKS)
- .get_style_info().set_stroke_width(2);
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
+ .style().stroke_color(black).stroke_width(2);
+
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_width(1);
 
- image.get_g_element(PLOT_X_MINOR_TICKS)
- .get_style_info().set_stroke_width(1);
 }
 
 // -----------------------------------------------------------------
@@ -254,102 +371,24 @@
 
 svg_1d_plot& write(std::ostream& s_out)
 {
- // removes all elements that will show up in a subsequent draw
- _clear_all();
-
- // draw background
- image.get_g_element(PLOT_BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
- image.get_y_size()));
-
- _draw_title();
- _calculate_plot_window();
- _calculate_transform();
-
- if(axis_on)
- {
- _draw_axis();
- }
-
- if(legend_on)
- {
- _draw_legend();
- }
-
- if(x_label_on)
- {
- _draw_x_label();
- }
-
- double x(0), y(0);
-
- _transform_y(y);
-
- //draw points
- for(unsigned int i=0; i<series.size(); ++i)
- {
- g_element& g_ptr = image.get_g_element(PLOT_PLOT_POINTS).add_g_element();
-
- g_ptr.get_style_info().set_fill_color(series[i].point_style.fill_color);
- g_ptr.get_style_info().set_stroke_color(series[i].point_style.stroke_color);
+ _update_image();
 
- for(unsigned int j=0; j<series[i].series.size(); ++j)
- {
- x = series[i].series[j];
- _transform_x(x);
-
- if(x > plot_window_x1
- && x < plot_window_x2
- && y > plot_window_y1
- && y < plot_window_y2)
- {
- _draw_plot_point(x, y, g_ptr, series[i].point_style);
- }
- }
- }
     image.write(s_out);
 
     return (svg_1d_plot&)*this;
 }
 
-void plot(const std::vector<double>& _ctr,
- const std::string& _title,
- const plot_point_style& _style)
-{
- series.push_back(svg_plot_series(_ctr,
- _title,
- _style));
-}
-
-}; // end svg_1d_plot
-
-// -----------------------------------------------------------------
-// Parameter names for plot() function
-// -----------------------------------------------------------------
-
-// These should be moved to their own namespace
-
-#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
-#define BOOST_SVG_BOOST_PARAMETER_NAMES
-
-BOOST_PARAMETER_NAME(my_plot)
-BOOST_PARAMETER_NAME(container)
-BOOST_PARAMETER_NAME(title)
-BOOST_PARAMETER_NAME(stroke_color)
-BOOST_PARAMETER_NAME(fill_color)
-BOOST_PARAMETER_NAME(point_style)
-BOOST_PARAMETER_NAME(size)
-BOOST_PARAMETER_NAME(x_functor)
-
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning (disable: 4100) // 'args' : unreferenced formal parameter
 #endif
 
-BOOST_PARAMETER_FUNCTION
+BOOST_PARAMETER_MEMBER_FUNCTION
 (
     (void),
     plot,
     tag,
     (required
- (in_out(my_plot), (svg_1d_plot&))
         (container, *)
         (title, (const std::string&))
     )
@@ -366,18 +405,22 @@
     )
 )
 {
- std::vector<double> vect(container.size());
-
- vect.insert(vect.begin(),
+ series.push_back(svg_plot_series(
         boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor));
-
- my_plot.plot(vect, title,
- plot_point_style(fill_color, stroke_color, size, point_style));
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
+ plot_point_style(fill_color, stroke_color, size, point_style)
+ ));
 }
 
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+}; // end svg_1d_plot
 
 }
 }
 
+
 #endif

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -10,7 +10,28 @@
 #ifndef _BOOST_SVG_SVG_2D_PLOT_HPP
 #define _BOOST_SVG_SVG_2D_PLOT_HPP
 
-#define BOOST_PARAMETER_MAX_ARITY 10
+#define BOOST_PARAMETER_MAX_ARITY 11
+
+#include <boost/bind.hpp>
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4512) // "assignment operator could not be generated."
+# pragma warning(disable: 4127) // "conditional expression is constant."
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+#include <boost/parameter/preprocessor.hpp>
+#include <boost/parameter/name.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+
+#include "svg_style.hpp"
+#include "detail/axis_plot_frame.hpp"
+#include "svg.hpp"
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
 
 #include <map>
 #include <string>
@@ -20,19 +41,40 @@
 #include <iterator>
 #include <exception>
 
-#include <boost/parameter/preprocessor.hpp>
-#include <boost/parameter/name.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/bind.hpp>
-
-#include "detail/svg_style.hpp"
-#include "detail/axis_plot_frame.hpp"
-
-#include "svg.hpp"
 
 namespace boost {
 namespace svg {
 
+
+#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
+#define BOOST_SVG_BOOST_PARAMETER_NAMES
+
+BOOST_PARAMETER_NAME(my_plot)
+BOOST_PARAMETER_NAME(container)
+BOOST_PARAMETER_NAME(title)
+BOOST_PARAMETER_NAME(stroke_color)
+BOOST_PARAMETER_NAME(fill_color)
+BOOST_PARAMETER_NAME(point_style)
+BOOST_PARAMETER_NAME(x_functor)
+BOOST_PARAMETER_NAME(size)
+#endif
+
+BOOST_PARAMETER_NAME(line_on)
+BOOST_PARAMETER_NAME(line_color)
+BOOST_PARAMETER_NAME(area_fill_color)
+
+class boost_default_2d_convert
+{
+public:
+ typedef std::pair<double, double> result_type;
+
+ template <class T, class U>
+ std::pair<double, double> operator()(const std::pair<T, U>& a) const
+ {
+ return std::pair<double, double>((double)(a.first), (double)(a.second));
+ }
+};
+
 struct svg_2d_plot_series
 {
     std::multimap<double, double> series;
@@ -40,8 +82,9 @@
     plot_point_style point_style;
     plot_line_style line_style;
 
- svg_2d_plot_series(std::multimap<double, double>::const_iterator _begin,
- std::multimap<double, double>::const_iterator _end,
+ template <class T>
+ svg_2d_plot_series(T _begin,
+ T _end,
                        std::string _title,
                        const plot_point_style& _point,
                        const plot_line_style& _line):
@@ -54,10 +97,10 @@
     }
 };
 
-class svg_2d_plot: public axis_plot_frame<svg_2d_plot>
+class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
 {
 private:
- friend class axis_plot_frame<svg_2d_plot>;
+ friend class detail::axis_plot_frame<svg_2d_plot>;
     
     double x_scale, x_shift;
     double y_scale, y_shift;
@@ -65,38 +108,43 @@
     // stored so as to avoid rewriting style information constantly
     svg image;
 
+ text_element title_info;
+ text_element x_label_info;
+
     // border information for the plot window. Initially will be set to the width
     // and height of the graph
- int plot_window_x1;
- int plot_window_x2;
- int plot_window_y1;
- int plot_window_y2;
-
- // used for text displayed on the graph
- std::string x_label, title;
+ int plot_x1;
+ int plot_x2;
+ int plot_y1;
+ int plot_y2;
 
     // axis information. y_axis stored as one point because this is a 1D graph
     double x_min, x_max;
     double x_axis;
     
- double x_major_tick;
+ double x_major;
 
- unsigned int x_major_tick_length, x_major_tick_width,
- x_minor_tick_length, x_minor_tick_width;
- unsigned int x_num_minor_ticks;
- unsigned int legend_title_font_size, title_font_size,
- x_label_font_size;
+ unsigned int x_major_length, x_major_width,
+ x_minor_length, x_minor_width;
+ unsigned int x_num_minor;
+ unsigned int legend_title_size;
 
     // Yes/no questions
- bool x_major_labels_on;
- bool x_major_grid_on;
- bool x_minor_grid_on;
- bool x_label_on;
-
- bool title_on;
- bool legend_on;
- bool axis_on;
- bool plot_window_on;
+ bool use_x_major_labels;
+ bool use_x_major_grid;
+ bool use_x_minor_grid;
+ bool use_x_label;
+
+ bool use_title;
+ bool use_legend;
+ bool use_axis;
+ bool use_plot_window;
+ bool use_x_external_style;
+ bool use_y_external_style;
+ bool show_x_axis_lines;
+ bool show_y_axis_lines;
+ bool use_y_major_grid;
+ bool use_y_minor_grid;
 
     // where we will be storing the data points for transformation
     std::vector<svg_2d_plot_series> series;
@@ -107,113 +155,195 @@
     // axis information
     double y_min, y_max;
 
- double y_major_tick, y_axis;
+ double y_major, y_axis;
 
- unsigned int y_major_tick_length, y_minor_tick_length,
- y_num_minor_ticks;
+ unsigned int y_major_length, y_minor_length,
+ y_num_minor;
 
- bool y_label_on;
- bool y_major_labels_on;
+ bool use_y_label;
+ bool use_y_major_labels;
 
- void _draw_y_axis()
+
+ void _draw_y_minor_ticks(double j, path_element& tick_path,
+ path_element& grid_path)
     {
- double x1(0.), x2(0.), y1(0.), y2(0.);
+ double y1(0.), x1(0.), x2(image.get_y_size());
+
+ // draw the grid if needed
+ if(use_y_minor_grid)
+ {
+ _transform_y(y1 = j);
 
- // draw the axis line
- _transform_x(x1 );
+ if(!use_plot_window)
+ {
+ // spacing for labels
+ if(use_legend)
+ {
+ x1 -= 155;
+ }
 
- y_axis = x1;
+ if(use_y_label)
+ {
+ x2 -= 12 * 1.5;
+ }
+ }
+
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ grid_path.M(x1, y1).L(x2, y1);
+ }
+ }
 
- image.get_g_element(PLOT_Y_AXIS).line(y_axis, plot_window_y1, y_axis, plot_window_y2);
+ double y_tick_length = y_minor_length / 2.;
 
- // draw the ticks on the positive side
- for(double i = 0; i < y_max; i += y_major_tick)
+ if(use_y_external_style)
         {
- //draw minor ticks
- for(double j=i+(y_major_tick / (y_num_minor_ticks+1));
- j<i+y_major_tick;
- j+=y_major_tick / (y_num_minor_ticks+1))
- {
- x1 = y_axis + y_minor_tick_length/2.;
- x2 = y_axis - y_minor_tick_length/2.;
+ x1 = plot_x1;
+ x2 = plot_x1 - y_tick_length / 2.;
+ }
 
- y1=j;
+ else
+ {
+ x1 = y_axis + y_tick_length / 2.;
+ x2 = y_axis - y_tick_length / 2.;
+ }
+ y1=j;
 
- _transform_y(y1);
+ _transform_y(y1);
 
- //make sure that we are drawing inside of the allowed window
- if(y1 > plot_window_y1)
- {
- image.get_g_element(PLOT_Y_MINOR_TICKS).line(x1, y1, x2, y1);
- }
- }
+ //make sure that we are drawing inside of the allowed window
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ tick_path.M(x1, y1).L(x2, y1);
+ }
+ }
 
- //draw major tick
- y1=i;
- _transform_point(x1, y1);
- _transform_point(x2, y2);
+ void _draw_y_major_ticks(double i, path_element& tick_path, path_element& grid_path)
+ {
+ double y1(i), x1(0.), x2(image.get_y_size());
 
- //make sure that we are drawing inside of the allowed window
- if(y1 > plot_window_y1)
- {
- x1 = y_axis + y_major_tick_length/2;
- x2 = y_axis - y_major_tick_length/2;
+ if(use_y_major_grid)
+ {
+ _transform_y(y1 = i);
 
- image.get_g_element(PLOT_Y_MAJOR_TICKS).line(x1, y1, x2, y1);
-
- if(y_major_labels_on && i != 0)
+ if(!use_plot_window)
+ {
+ if(use_title)
                 {
- std::stringstream fmt;
- fmt<<i;
+ x1 += title_info.font_size() * 1.5;
+ }
 
- image.text(x1, y1 + (2 + x_major_tick_length/2), fmt.str());
+ if(use_y_label)
+ {
+ x2 -= 12 * 1.5;
                 }
             }
+
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ grid_path.M(x1, y1).L(x2, y1);
+ }
         }
 
- // draw the ticks on the negative side
- for(double i = 0; i > y_min; i -= y_major_tick)
+ //draw major tick
+ y1=i;
+
+ _transform_y(y1);
+
+ //make sure that we are drawing inside of the allowed window
+ if(y1 < plot_y2 && y1 > plot_y1)
         {
- //draw minor ticks
- for(double j=i-(y_major_tick / (y_num_minor_ticks+1));
- j>i-y_major_tick;
- j-=y_major_tick / (y_num_minor_ticks+1))
+ double y_tick_length = y_major_length / 2.;
+
+ if(use_y_external_style)
             {
- x1 = y_axis + y_minor_tick_length/2.;
- x2 = y_axis - y_minor_tick_length/2.;
+ x1 = plot_x1;
+ x2 = plot_x1 - y_tick_length/2.;
+ }
 
- y1=j;
+ else
+ {
+ x1 = y_axis + y_tick_length/2.;
+ x2 = y_axis - y_tick_length/2.;
+ }
+
+ tick_path.M(x1, y1).L(x2, y1);
 
- _transform_y(y1);
+ if(use_y_major_labels && i != 0)
+ {
+ std::stringstream fmt;
+ fmt<<i;
 
- //make sure that we are drawing inside of the allowed window
- if(y1 < plot_window_y2)
+ if(use_y_external_style)
                 {
- image.get_g_element(PLOT_Y_MINOR_TICKS).line(x1, y1, x2, y1);
+ x1 -= y_major_length;
                 }
+
+ else
+ {
+ x1 += (2 + y_major_length/2);
+ }
+
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
+ y1, fmt.str());
             }
+ }
+ }
+
+ void _draw_y_axis()
+ {
+ double x1(0.);
+
+ // draw the axis line
+ _transform_x(x1);
+ image.get_g_element(detail::PLOT_Y_AXIS).line(x1, plot_y1, x1, plot_y2);
+
+ y_axis = x1;
+
+ path_element& minor_tick_path =
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).path();
+
+ path_element& major_tick_path =
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).path();
+
+ path_element& minor_grid_path =
+ image.get_g_element(detail::PLOT_Y_MINOR_GRID).path();
 
- //draw major tick
- y1=i;
- _transform_point(x1, y1);
- _transform_point(x2, y2);
+ path_element& major_grid_path =
+ image.get_g_element(detail::PLOT_Y_MAJOR_GRID).path();
 
- //make sure that we are drawing inside of the allowed window
- if(y1 < plot_window_y2)
+ if(show_y_axis_lines)
+ {
+ image.get_g_element(detail::PLOT_Y_AXIS).
+ line(plot_y1, x_axis, plot_x2, x_axis);
+ }
+
+ // y_minor_jump is the interval between minor ticks.
+ double y_minor_jump = y_major/((double)(y_num_minor + 1.) );
+
+ // draw the ticks on the positive side
+ for(double i = 0; i < y_max; i += y_major)
+ {
+ for(double j = i + y_minor_jump;
+ j < i + y_major;
+ j += y_minor_jump)
             {
- x1 = y_axis + y_major_tick_length/2;
- x2 = y_axis - y_major_tick_length/2;
+ _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
 
- image.get_g_element(PLOT_Y_MAJOR_TICKS).line(x1, y1, x2, y1);
-
- if(y_major_labels_on && i != 0)
- {
- std::stringstream fmt;
- fmt<<i;
+ _draw_y_major_ticks(i, major_tick_path, major_grid_path);
+ }
 
- image.text(x1, y1 + (2 + x_major_tick_length/2), fmt.str());
- }
+ // draw the ticks on the negative side
+ for(double i = 0; i > y_min; i -= y_major)
+ {
+ // draw minor ticks
+ for(double j=i; j>i-y_major; j-=y_major / (y_num_minor+1))
+ {
+ _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
             }
+
+ _draw_y_major_ticks(i, major_tick_path, major_grid_path);
         }
     }
 
@@ -225,13 +355,13 @@
 
     void _draw_y_label()
     {
- /* text_element to_use((plot_window_x2 + plot_window_x1) / 2., image.get_y_size() - 8, x_label);
+ /* text_element to_use((plot_x2 + plot_x1) / 2., image.get_y_size() - 8, x_label);
 
- to_use.set_font_size(12);
- to_use.set_alignment(center_align);
+ to_use.font_size(12);
+ to_use.alignment(center_align);
 
- image.get_g_element(PLOT_X_LABEL).set_stroke_color(white);
- image.get_g_element(PLOT_X_LABEL).set_fill_color(white);
+ image.get_g_element(PLOT_X_LABEL).stroke_color(white);
+ image.get_g_element(PLOT_X_LABEL).fill_color(white);
 
 
         image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
@@ -241,133 +371,269 @@
     
     void _calculate_transform()
     {
- x_scale = (plot_window_x2-plot_window_x1)/(x_max-x_min);
- x_shift = plot_window_x1 -
- (x_min *(plot_window_x2-plot_window_x1)/(x_max-x_min));
+ x_scale = (plot_x2 - plot_x1) / (x_max - x_min);
+ x_shift = plot_x1 - x_min *(plot_x2-plot_x1)/(x_max-x_min);
              
- y_scale = -(plot_window_y2-plot_window_y1)/(y_max-y_min);
- y_shift = plot_window_y1 -
- (y_max *(plot_window_y1-plot_window_y2)/(y_max-y_min));
+ y_scale = -(plot_y2-plot_y1)/(y_max-y_min);
+
+ y_shift = plot_y1 - (y_max *(plot_y1-plot_y2)/(y_max-y_min));
     }
 
     void _calculate_plot_window()
     {
- int x_size = image.get_x_size();
- int y_size = image.get_y_size();
-
- plot_window_x1 = plot_window_y1 = 0;
- plot_window_x2 = image.get_x_size();
- plot_window_y2 = image.get_y_size();
+ plot_x1 = plot_y1 = 0;
 
+ plot_x2 = image.get_x_size();
+ plot_y2 = image.get_y_size();
 
- if(x_label_on)
+
+ if(use_x_label)
         {
- plot_window_y2 -= (int)(x_label_font_size * 1.5);
+ plot_y2 -= (int)(x_label_info.font_size() * 1.5);
         }
 
- if(y_label_on)
+ if(use_y_label)
         {
- plot_window_x1 += 20;
+ plot_x1 += 20;
         }
 
- if(title_on)
+ if(use_title)
         {
- plot_window_y1 += (int)(title_font_size * 1.5);
+ plot_y1 += (int)(title_info.font_size() * 1.5);
         }
 
- if(plot_window_on)
+ if(use_plot_window)
         {
             // give the plot window a natural bit of padding
- plot_window_x1+=5;
- plot_window_x2-=5;
- plot_window_y1+=5;
- plot_window_y2-=5;
+ plot_x1+=5;
+ plot_x2-=5;
+ plot_y1+=5;
+ plot_y2-=5;
 
             
- if(legend_on)
+ if(use_legend)
             {
- plot_window_x2 -= 155;
+ plot_x2 -= 155;
             }
 
- image.get_g_element(PLOT_PLOT_BACKGROUND).push_back(
- new rect_element(plot_window_x1, plot_window_y1,
- (plot_window_x2-plot_window_x1), plot_window_y2-plot_window_y1));
+ if(use_y_external_style)
+ {
+ plot_x1 +=
+ y_major_length > y_minor_length ?
+ y_major_length :
+ y_minor_length ;
+ }
+
+ if(use_x_external_style)
+ {
+ plot_y2 -=
+ x_major_length > x_minor_length ?
+ x_major_length :
+ x_minor_length ;
+ }
+
+ image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
+ new rect_element(plot_x1, plot_y1,
+ (plot_x2-plot_x1), plot_y2-plot_y1));
         }
     }
 
     void _draw_plot_lines()
     {
- double prev_x, prev_y;
+ double prev_x, prev_y, temp_x(0.), temp_y(0.);
      
         for(unsigned int i = 0; i < series.size(); ++i)
         {
- g_element& g_ptr = image.get_g_element(PLOT_PLOT_LINES).add_g_element();
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
 
- g_ptr.get_style_info().set_stroke_color(series[i].line_style.color)
- .set_fill_color(series[i].line_style.color);
+ g_ptr.style().stroke_color(series[i].line_style.color);
+
+ path_element& path = g_ptr.path();
 
             if(series[i].series.size() > 1)
             {
                 std::multimap<double, double>::const_iterator j = series[i].series.begin();
                 prev_x = (*j).first;
- prev_y = (*j).second;
+ prev_y = 0.;
+
+ // If we have to fill the area under the plot, we first have to
+ // move from the X-axis to the first point.
 
- _transform_x(prev_x);
- _transform_y(prev_y);
+ _transform_point(prev_x, prev_y);
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ path.style().fill_color(series[i].line_style.area_fill);
+ path.M(prev_x, prev_y);
+ }
+
+
+ _transform_y(prev_y = (*j).second);
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ path.style().fill_color(series[i].line_style.area_fill);
+ path.L(prev_x, prev_y);
+ }
 
+ else
+ {
+ path.M(prev_x, prev_y);
+ }
                 ++j;
 
                 for(; j != series[i].series.end(); ++j)
                 {
- double temp_x((*j).first);
- double temp_y((*j).second);
+ temp_x = (*j).first;
+ temp_y = (*j).second;
 
- _transform_x(temp_x);
- _transform_y(temp_y);
+ _transform_point(temp_x, temp_y);
 
- g_ptr.push_back(
- new line_element(prev_x, prev_y,
- temp_x, temp_y));
+ path.L(temp_x, temp_y);
                     
+ if(series[i].line_style.area_fill == blank)
+ {
+ path.M(temp_x, temp_y);
+ }
+
                     prev_x = temp_x;
                     prev_y = temp_y;
                 }
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ _transform_y(temp_y = 0.);
+ path.L(temp_x, temp_y).z();
+ }
+ }
+ }
+ }
+
+ void _update_image()
+ {
+ _clear_all();
+
+ // draw background
+ image.get_g_element(detail::PLOT_BACKGROUND).push_back(
+ new rect_element(0, 0, image.get_x_size(),
+ image.get_y_size()));
+
+ _draw_title();
+ _calculate_plot_window();
+ _calculate_transform();
+
+ if(use_axis)
+ {
+ _draw_y_axis();
+ _draw_x_axis();
+ }
+
+ if(use_legend)
+ {
+ _draw_legend();
+ }
+
+ if(use_x_label)
+ {
+ _draw_x_label();
+ }
+
+ // draw lines
+
+ _draw_plot_lines();
+
+ // draw points
+ double x(0.), y(0.);
+ for(unsigned int i=0; i<series.size(); ++i)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
+
+ g_ptr.style()
+ .fill_color(series[i].point_style.fill_color)
+ .stroke_color(series[i].point_style.stroke_color);
+
+ for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
+ j!=series[i].series.end(); ++j)
+ {
+ x = j->first;
+ y = j->second;
+
+ _transform_point(x, y);
+
+ if(x > plot_x1 && x < plot_x2
+ && y > plot_y1 && y < plot_y2)
+ {
+ _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
             }
         }
     }
 
 public:
 
-svg_2d_plot(): x_label(""), title("Plot of data"), y_label(""), x_min(-10), x_max(10),
+svg_2d_plot(): title_info(0, 0, "Plot of data", 30),
+ x_label_info(0, 0, "X Axis", 12),
+ x_min(-10), x_max(10),
                       y_min(-10), y_max(10),
- x_major_tick(3), x_num_minor_ticks(2),
- y_major_tick(3), y_label_on(false),
- x_minor_tick_length(10), x_major_tick_length(20),
- x_major_tick_width(2), x_minor_tick_width(1),
- y_minor_tick_length(10), y_num_minor_ticks(2),
- y_major_tick_length(20), legend_title_font_size(12),
- title_font_size(30), x_label_font_size(12),
- x_major_labels_on(true), x_major_grid_on(false),
- x_minor_grid_on(false), x_label_on(false),
- title_on(true), legend_on(false), axis_on(true),
- plot_window_on(false), y_major_labels_on(false)
+ x_major(3), x_num_minor(2),
+ y_major(3), use_y_label(false),
+ x_minor_length(10), x_major_length(20),
+ x_major_width(2), x_minor_width(1),
+ y_minor_length(10), y_num_minor(2),
+ y_major_length(20), legend_title_size(12),
+ use_x_major_labels(true), use_x_major_grid(false),
+ use_x_minor_grid(false), use_x_label(false),
+ use_title(true), use_legend(false), use_axis(true),
+ use_plot_window(false), use_y_major_labels(false),
+ use_x_external_style(false), use_y_external_style(false),
+ show_x_axis_lines(true), show_y_axis_lines(true),
+ use_y_major_grid(false), use_y_minor_grid(false)
 
 {
- set_image_size(500, 350);
+ image_size(500, 350);
 
     //build the document tree.. add children of the root node
- for(int i=0; i<SVG_PLOT_DOC_CHILDREN; ++i)
+ for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
         image.add_g_element();
     }
 
     // set color defaults
- image.get_g_element(PLOT_BACKGROUND).get_style_info().set_fill_color(white);
- image.get_g_element(PLOT_PLOT_BACKGROUND).get_style_info().set_fill_color(white);
- image.get_g_element(PLOT_LEGEND_BACKGROUND).get_style_info().set_fill_color(white);
+ image.get_g_element(detail::PLOT_BACKGROUND)
+ .style().fill_color(white);
+
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_AXIS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
+ .style().stroke_width(2);
+
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_width(1);
+
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
+ .style().stroke_color(black);
 
- image.get_g_element(PLOT_X_MAJOR_TICKS).get_style_info().set_stroke_width(2);
- image.get_g_element(PLOT_X_MINOR_TICKS).get_style_info().set_stroke_width(1);
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
+ .style().stroke_width(2);
+
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
+ .style().stroke_width(1);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS).style().stroke_width(2);
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS).style().stroke_width(1);
 }
 
 
@@ -387,230 +653,71 @@
 
 svg_2d_plot& write(std::ostream& s_out)
 {
- _clear_all();
-
- // draw background
- image.get_g_element(PLOT_BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
- image.get_y_size()));
-
- _draw_title();
- _calculate_plot_window();
- _calculate_transform();
-
- if(axis_on)
- {
- _draw_y_axis();
- _draw_x_axis();
- }
-
- if(legend_on)
- {
- _draw_legend();
- }
-
- if(x_label_on)
- {
- _draw_x_label();
- }
-
- // draw lines
-
- _draw_plot_lines();
+ _update_image();
 
- // draw points
- double x(0.), y(0.);
- for(unsigned int i=0; i<series.size(); ++i)
- {
- g_element& g_ptr = image.get_g_element(PLOT_PLOT_POINTS).add_g_element();
-
- g_ptr.get_style_info()
- .set_fill_color(series[i].point_style.fill_color)
- .set_stroke_color(series[i].point_style.stroke_color);
-
- for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
- j!=series[i].series.end(); ++j)
- {
- x = j->first;
- y = j->second;
+ image.write(s_out);
 
- _transform_point(x, y);
-
- if(x > plot_window_x1
- && x < plot_window_x2
- && y > plot_window_y1
- && y < plot_window_y2)
- {
- _draw_plot_point(x, y, g_ptr, series[i].point_style);
- }
- }
- }
+ return *this;
+}
 
- image.write(s_out);
+svg_2d_plot& y_name_on(bool _cmd)
+{
+ use_y_label = _cmd;
+ return *this;
+}
 
+svg_2d_plot& y_major_labels_on(bool _cmd)
+{
+ use_y_major_labels = _cmd;
     return *this;
 }
 
-// -----------------------------------------------------------------
-// Actually draw data to the plot. Default color information
-// -----------------------------------------------------------------
-void plot(std::multimap<double, double> cont,
- const std::string& _str,
- const plot_point_style& point_style,
- const plot_line_style& line_style)
-{
- series.push_back(svg_2d_plot_series(cont.begin(), cont.end(),
- _str, point_style, line_style));
-}
-
-// -----------------------------------------------------------------
-// Miscellaneous setter methods: those with no clear, definable home
-// in another category
-//
-// set_image_size(): sets image size in pixels. (x,y) corresponds
-// to point at lower right of graph
-//
-// set_title(): adds the text _title to the top of the screen
-//
-// set_title_font_size(): uses an internal variable to save state, to
-// avoid crashes when the title hasn't been
-// set yet
-//
-// set_legend_title_font_size(): As above
-// -----------------------------------------------------------------
-
-
-// -----------------------------------------------------------------
-// Commands: Answers to yes or no questions (Example: Show the legend?)
-//
-// set_axis_on(): Whether or not the axis will show
-//
-// set_legend_on(): Whether or not the legend will show
-//
-// set_plot_window_on(): Whether or not the plot will be full screen or
-// in its own contained window
-//
-// set_x_label_on(): Wrapper for 1d function
-//
-// set_y_label_on(): Sets the label for the y-axis
-//
-// set_x_major_labels_on(): Wrapper for 1d function
-//
-// set_y_major_labels_on(): Determines whether or not y axis major labels
-// will be shown
-// -----------------------------------------------------------------
-
-
-svg_2d_plot& set_y_label_on(bool _cmd)
-{
- y_label_on = _cmd;
-
- return *this;
-}
-
-svg_2d_plot& set_y_major_labels_on(bool _cmd)
-{
- y_major_labels_on = _cmd;
-
- return *this;
-}
-
-// -----------------------------------------------------------------
-// Color settings: Customization of colors found in the plot
-//
-// set_title_color(): Sets the color of the plot title
-//
-// set_background_color(): Sets the color of the background. This is
-// not the same as the plot window background
-//
-// set_legend_background_color():
-// Sets the background color of the legend
-//
-// set_plot_background_color():
-// Sets the background color of the plot area.
-// If plot_window_on is not set true, this
-// does not show
-//
-// set_axis_color(): Color of the x axis + origin
-//
-// set_x_major_tick_color(): Sets the color of the major ticks on
-// the x-axis
-//
-// set_x_minor_tick_color(): As above, but for minor ticks
-// -----------------------------------------------------------------
 
-svg_2d_plot& set_y_axis_color(svg_color_constant _col)
+svg_2d_plot& y_axis_color(svg_color_constant _col)
 {
- set_y_axis_color(constant_to_rgb(_col));
+ y_axis_color(constant_to_rgb(_col));
 
     return (svg_2d_plot&)*this;
 }
 
-svg_2d_plot& set_y_axis_color(const svg_color& _col)
+svg_2d_plot& y_axis_color(const svg_color& _col)
 {
- image.get_g_element(PLOT_Y_AXIS)
- .get_style_info().set_fill_color(_col);
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().fill_color(_col);
 
- image.get_g_element(PLOT_Y_AXIS)
- .get_style_info().set_stroke_color(_col);
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().stroke_color(_col);
 
     return *this;
 }
 
-svg_2d_plot& set_y_major_tick_color(const svg_color& _col)
+svg_2d_plot& y_major_tick_color(const svg_color& _col)
 {
- image.get_g_element(PLOT_Y_MAJOR_TICKS).get_style_info().set_stroke_color(_col);
- image.get_g_element(PLOT_Y_MAJOR_TICKS).get_style_info().set_fill_color(_col);
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(_col);
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().fill_color(_col);
     return *this;
 }
 
-svg_2d_plot& set_y_major_tick_color(svg_color_constant _col)
+svg_2d_plot& y_major_tick_color(svg_color_constant _col)
 {
- set_y_major_tick_color(constant_to_rgb(_col));
+ y_major_tick_color(constant_to_rgb(_col));
     return *this;
 }
 
-svg_2d_plot& set_y_minor_tick_color(const svg_color& _col)
+svg_2d_plot& y_minor_tick_color(const svg_color& _col)
 {
- image.get_g_element(PLOT_Y_MINOR_TICKS).get_style_info().set_stroke_color(_col);
- image.get_g_element(PLOT_Y_MINOR_TICKS).get_style_info().set_fill_color(_col);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(_col);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().fill_color(_col);
     return *this;
 }
 
-svg_2d_plot& set_y_minor_tick_color(svg_color_constant _col)
+svg_2d_plot& y_minor_tick_color(svg_color_constant _col)
 {
- set_y_minor_tick_color(constant_to_rgb(_col));
+ y_minor_tick_color(constant_to_rgb(_col));
     return *this;
 }
 
-// -----------------------------------------------------------------
-// Axis information: Settings for customization of axis information
-//
-// set_x_scale(): sets the left and right max values for the x axis
-//
-// set_x_axis_width(): The width of the x axis
-//
-// set_x_major_tick(): The distance between the ticks of the x_axis
-//
-// set_x_major_tick_length(): How long each tick will be
-//
-// set_x_minor_tick_length(): How long each tick will be
-//
-// set_x_num_minor_ticks(): The number of minor ticks between each
-// major tick
-//
-// set_x_label(): Labelling for the x-axis
-//
-// set_x_major_tick_width(): Stroke width for major ticks
-//
-// set_x_minor_tick_width(): Stroke width for minor ticks
-//
-// All functions defined for x above are also defined for y
-// -----------------------------------------------------------------
-
-//y functions
-
-svg_2d_plot& set_y_scale(double y1, double y2)
+svg_2d_plot& y_range(double y1, double y2)
 {
     y_min = y1;
     y_max = y2;
@@ -623,124 +730,129 @@
     return *this;
 }
 
-svg_2d_plot& set_y_axis_width(unsigned int _width)
+svg_2d_plot& y_axis_width(unsigned int _width)
 {
- image.get_g_element(PLOT_Y_AXIS).get_style_info().set_stroke_width(_width);
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(_width);
 
     return *this;
 }
 
-svg_2d_plot& set_y_major_tick(double _inter)
+svg_2d_plot& y_major_interval(double _inter)
 {
- y_major_tick = _inter;
+ y_major = _inter;
 
     return *this;
 }
 
-svg_2d_plot& set_y_major_tick_length(unsigned int _length)
+svg_2d_plot& y_major_tick_length(unsigned int _length)
 {
- y_major_tick_length = _length;
+ y_major_length = _length;
     return *this;
 }
 
-svg_2d_plot& set_y_minor_tick_length(unsigned int _length)
+svg_2d_plot& y_minor_tick_length(unsigned int _length)
 {
- y_minor_tick_length = _length;
+ y_minor_length = _length;
     return *this;
 }
 
-svg_2d_plot& set_y_num_minor_ticks(unsigned int _num)
+svg_2d_plot& y_num_minor_ticks(unsigned int _num)
 {
- y_num_minor_ticks = _num;
+ y_num_minor = _num;
     return *this;
 }
 
-svg_2d_plot& set_y_label(const std::string& _str)
+svg_2d_plot& y_name(const std::string& _str)
 {
     y_label = _str;
-
     return *this;
 }
 
-svg_2d_plot& set_y_major_tick_width(unsigned int _width)
+svg_2d_plot& y_major_tick_width(unsigned int _width)
 {
- image.get_g_element(PLOT_Y_MAJOR_TICKS).get_style_info().set_stroke_width(_width);
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(_width);
 
     return *this;
 }
 
-svg_2d_plot& set_y_minor_tick_width(unsigned int _width)
+svg_2d_plot& y_minor_tick_width(unsigned int _width)
 {
- image.get_g_element(PLOT_Y_MINOR_TICKS).get_style_info().set_stroke_width(_width);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(_width);
 
     return *this;
 }
 
-};
+svg_2d_plot& axis_external_style(bool _is)
+{
+ use_x_external_style = _is;
+ use_y_external_style = _is;
+ return *this;
+}
 
-class boost_default_2d_convert
+svg_2d_plot& x_external_style_on(bool _is)
 {
-public:
- typedef std::pair<double, double> result_type;
+ use_x_external_style = _is;
 
- template <class T, class U>
- std::pair<double, double> operator()(const std::pair<T, U>& a) const
- {
- return std::pair<double, double>((double)(a.first), (double)(a.second));
- }
-};
+ return *this;
+}
 
-#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
-#define BOOST_SVG_BOOST_PARAMETER_NAMES
+svg_2d_plot& y_external_style_on(bool _is)
+{
+ use_y_external_style = _is;
+ return *this;
+}
 
-BOOST_PARAMETER_NAME(my_plot)
-BOOST_PARAMETER_NAME(container)
-BOOST_PARAMETER_NAME(title)
-BOOST_PARAMETER_NAME(stroke_color)
-BOOST_PARAMETER_NAME(fill_color)
-BOOST_PARAMETER_NAME(point_style)
-BOOST_PARAMETER_NAME(x_functor)
-BOOST_PARAMETER_NAME(size)
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
 #endif
 
-BOOST_PARAMETER_NAME(line_on)
-BOOST_PARAMETER_NAME(line_color)
-
-BOOST_PARAMETER_FUNCTION
+BOOST_PARAMETER_MEMBER_FUNCTION
 (
     (void),
     plot_2d,
     tag,
     (required
- (in_out(my_plot), (svg_2d_plot&))
         (container, *)
         (title, (const std::string&))
     )
     (optional
- (stroke_color, (const svg_color&), svg_color(white))
+ (stroke_color, (const svg_color&), black)
         (point_style, (point_shape), circle)
         (size, (int), 10)
         (line_on, (bool), true)
- (line_color, (const svg_color&), svg_color(black))
+ (line_color, (const svg_color&), black)
+ (area_fill_color, (svg_color_constant), blank)
     )
     (deduced
         (optional
- (fill_color, (const svg_color&), svg_color(black))
+ (fill_color, (const svg_color&), white)
             (x_functor, *, boost_default_2d_convert())
         )
     )
 )
 {
- std::multimap<double, double> cont;
+ plot_line_style line_style(line_color, line_on);
 
- cont.insert(
- boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor));
+ if(area_fill_color != none)
+ {
+ line_style.area_fill=area_fill_color;
+ }
 
- my_plot.plot(cont, title,
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(container.begin(), x_functor),
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
         plot_point_style(fill_color, stroke_color, size, point_style),
- plot_line_style(line_color, line_on));
+ line_style
+ ));
 }
+};
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
 
 }
 }

Added: sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -0,0 +1,271 @@
+// svg_style.hpp
+// Copyright (C) Jacob Voytko 2007
+//
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+
+// -----------------------------------------------------------------
+
+#ifndef _BOOST_SVG_SVG_COLOR_HPP
+#define _BOOST_SVG_SVG_COLOR_HPP
+
+#include <ostream>
+
+
+
+namespace boost {
+namespace svg {
+
+// -----------------------------------------------------------------
+// Deals with colors that have special names. The reason that the
+// underscoring does not match the normal Boost format
+// is that these are the names that are specifically allowed by the
+// SVG standard
+// -----------------------------------------------------------------
+enum svg_color_constant
+{
+ aliceblue, antiquewhite, aqua, aquamarine, azure, beige,
+ bisque, black, blanchedalmond, blue, blueviolet, brown,
+ burlywood, cadetblue, chartreuse, chocolate, coral,
+ cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan,
+ darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki,
+ darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
+ darksalmon, darkseagreen, darkslateblue, darkslategray,
+ darkslategrey, darkturquoise, darkviolet, deeppink,
+ deepskyblue, dimgray, dimgrey, dodgerblue, firebrick,
+ floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold,
+ goldenrod, gray, grey, green, greenyellow, honeydew, hotpink,
+ indianred, indigo, ivory, khaki, lavender, lavenderblush,
+ lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan,
+ lightgoldenrodyellow, lightgray, lightgreen, lightgrey,
+ lightpink, lightsalmon, lightseagreen, lightskyblue,
+ lightslategray, lightslategrey, lightsteelblue, lightyellow,
+ lime, limegreen, linen, magenta, maroon, mediumaquamarine,
+ mediumblue, mediumorchid, mediumpurple, mediumseagreen,
+ mediumslateblue, mediumspringgreen, mediumturquoise,
+ mediumvioletred, midnightblue, mintcream, mistyrose, moccasin,
+ navajowhite, navy, oldlace, olive, olivedrab, orange,
+ orangered, orchid, palegoldenrod, palegreen, paleturquoise,
+ palevioletred, papayawhip, peachpuff, peru, pink, plum,
+ powderblue, purple, red, rosybrown, royalblue, saddlebrown,
+ salmon, sandybrown, seagreen, seashell, sienna, silver,
+ skyblue, slateblue, slategray, slategrey, snow, springgreen,
+ steelblue, tan, teal, thistle, tomato, turquoise, violet,
+ wheat, white, whitesmoke, yellow, yellowgreen, blank
+};
+
+void constant_to_rgb(svg_color_constant _c, unsigned char &r,
+ unsigned char &g, unsigned char &b);
+
+// -----------------------------------------------------------------
+// svg_color is the struct that contains information about sRGB
+// colors.
+//
+// For the constructor: the svg standard specifies that numbers
+// outside the normal rgb range are to be accepted, but are rounded
+// to acceptable values.
+// -----------------------------------------------------------------
+struct svg_color
+{
+ unsigned char r, g, b;
+
+ svg_color(int _r, int _g, int _b)
+ {
+ _r = ( _r < 0 ) ? 0 : _r;
+ _g = ( _g < 0 ) ? 0 : _g;
+ _b = ( _b < 0 ) ? 0 : _b;
+
+ r = (unsigned char)(( _r > 255 ) ? 255 : _r);
+ g = (unsigned char)(( _g > 255 ) ? 255 : _g);
+ b = (unsigned char)(( _b > 255 ) ? 255 : _b);
+ }
+
+ svg_color(svg_color_constant _col)
+ {
+ constant_to_rgb(_col, r, g, b);
+ }
+
+ void write(std::ostream& rhs)
+ {
+ rhs << "rgb(" << (unsigned int)r << "," << (unsigned int) g << ","
+ << (unsigned int)b << ")" ;
+ }
+
+ bool operator==(const svg_color& rhs)
+ {
+ return r == rhs.r && g == rhs.g && b == rhs.b;
+ }
+};
+
+
+svg_color color_array[] =
+{
+ svg_color(240, 248, 255), // aliceblue
+ svg_color(250, 235, 215), // antiquewhite
+ svg_color(0 , 255, 255), // aqua
+ svg_color(127, 255, 212), // aquamarine
+ svg_color(240, 255, 255), // azure
+ svg_color(245, 245, 220), // beige
+ svg_color(255, 228, 196), // bisque
+ svg_color(0 , 0 , 0 ), // black
+ svg_color(255, 235, 205), // blanchedalmond
+ svg_color(0 , 0 , 255), // blue
+ svg_color(138, 43 , 226), // blueviolet
+ svg_color(165, 42 , 42 ), // brown
+ svg_color(222, 184, 135), // burlywood
+ svg_color(95 , 158, 160), // cadetblue
+ svg_color(127, 255, 0 ), // chartreuse
+ svg_color(210, 105, 30 ), // chocolate
+ svg_color(255, 127, 80 ), // coral
+ svg_color(100, 149, 237), // cornflowerblue
+ svg_color(255, 248, 220), // cornsilk
+ svg_color(220, 20 , 60 ), // crimson
+ svg_color(0 , 255, 255), // cyan
+ svg_color(0 , 0 , 139), // darkblue
+ svg_color(0 , 139, 139), // darkcyan
+ svg_color(184, 134, 11 ), // darkgoldenrod
+ svg_color(169, 169, 169), // darkgray
+ svg_color(0 , 100, 0 ), // darkgreen
+ svg_color(169, 169, 169), // darkgrey
+ svg_color(189, 183, 107), // darkkhaki
+ svg_color(139, 0 , 139), // darkmagenta
+ svg_color(85 , 107, 47 ), // darkolivegreen
+ svg_color(255, 140, 0 ), // darkorange
+ svg_color(153, 50 , 204), // darkorchid
+ svg_color(139, 0 , 0 ), // darkred
+ svg_color(233, 150, 122), // darksalmon
+ svg_color(143, 188, 143), // darkseagreen
+ svg_color(72 , 61 , 139), // darkslateblue
+ svg_color(47 , 79 , 79 ), // darkslategray
+ svg_color(47 , 79 , 79 ), // darkslategrey
+ svg_color(0 , 206, 209), // darkturquoise
+ svg_color(148, 0 , 211), // darkviolet
+ svg_color(255, 20 , 147), // deeppink
+ svg_color(0 , 191, 255), // deepskyblue
+ svg_color(105, 105, 105), // dimgray
+ svg_color(105, 105, 105), // dimgrey
+ svg_color(30 , 144, 255), // dodgerblue
+ svg_color(178, 34 , 34 ), // firebrick
+ svg_color(255, 250, 240), // floralwhite
+ svg_color(34 , 139, 34 ), // forestgreen
+ svg_color(255, 0 , 255), // fuchsia
+ svg_color(220, 220, 220), // gainsboro
+ svg_color(248, 248, 255), // ghostwhite
+ svg_color(255, 215, 0 ), // gold
+ svg_color(218, 165, 32 ), // goldenrod
+ svg_color(128, 128, 128), // gray
+ svg_color(128, 128, 128), // grey
+ svg_color(0 , 128, 0 ), // green
+ svg_color(173, 255, 47 ), // greenyellow
+ svg_color(240, 255, 240), // honeydew
+ svg_color(255, 105, 180), // hotpink
+ svg_color(205, 92 , 92 ), // indianred
+ svg_color(75 , 0 , 130), // indigo
+ svg_color(255, 255, 240), // ivory
+ svg_color(240, 230, 140), // khaki
+ svg_color(230, 230, 250), // lavender
+ svg_color(255, 240, 245), // lavenderblush
+ svg_color(124, 252, 0 ), // lawngreen
+ svg_color(255, 250, 205), // lemonchiffon
+ svg_color(173, 216, 230), // lightblue
+ svg_color(240, 128, 128), // lightcoral
+ svg_color(224, 255, 255), // lightcyan
+ svg_color(250, 250, 210), // lightgoldenrodyellow
+ svg_color(211, 211, 211), // lightgray
+ svg_color(144, 238, 144), // lightgreen
+ svg_color(211, 211, 211), // lightgrey
+ svg_color(255, 182, 193), // lightpink
+ svg_color(255, 160, 122), // lightsalmon
+ svg_color(32 , 178, 170), // lightseagreen
+ svg_color(135, 206, 250), // lightskyblue
+ svg_color(119, 136, 153), // lightslategray
+ svg_color(119, 136, 153), // lightslategrey
+ svg_color(176, 196, 222), // lightsteelblue
+ svg_color(255, 255, 224), // lightyellow
+ svg_color(0 , 255, 0 ), // lime
+ svg_color(50 , 205, 50 ), // limegreen
+ svg_color(250, 240, 230), // linen
+ svg_color(255, 0 , 255), // magenta
+ svg_color(128, 0 , 0 ), // maroon
+ svg_color(102, 205, 170), // mediumaquamarine
+ svg_color(0 , 0 , 205), // mediumblue
+ svg_color(186, 85 , 211), // mediumorchid
+ svg_color(147, 112, 219), // mediumpurple
+ svg_color(60 , 179, 113), // mediumseagreen
+ svg_color(123, 104, 238), // mediumslateblue
+ svg_color(0 , 250, 154), // mediumspringgreen
+ svg_color(72 , 209, 204), // mediumturquoise
+ svg_color(199, 21 , 133), // mediumvioletred
+ svg_color(25 , 25 , 112), // midnightblue
+ svg_color(245, 255, 250), // mintcream
+ svg_color(255, 228, 225), // mistyrose
+ svg_color(255, 228, 181), // moccasin
+ svg_color(255, 222, 173), // navajowhite
+ svg_color(0 , 0 , 128), // navy
+ svg_color(253, 245, 230), // oldlace
+ svg_color(128, 128, 0 ), // olive
+ svg_color(107, 142, 35 ), // olivedrab
+ svg_color(255, 165, 0 ), // orange
+ svg_color(255, 69 , 0 ), // orangered
+ svg_color(218, 112, 214), // orchid
+ svg_color(238, 232, 170), // palegoldenrod
+ svg_color(152, 251, 152), // palegreen
+ svg_color(175, 238, 238), // paleturquose
+ svg_color(219, 112, 147), // palevioletred
+ svg_color(255, 239, 213), // papayawhip
+ svg_color(255, 218, 185), // peachpuff
+ svg_color(205, 133, 63 ), // peru
+ svg_color(255, 192, 203), // pink
+ svg_color(221, 160, 221), // plum
+ svg_color(176, 224, 230), // powderblue
+ svg_color(128, 0 , 128), // purple
+ svg_color(255, 0 , 0 ), // red
+ svg_color(188, 143, 143), // rosybrown
+ svg_color(65 , 105, 225), // royalblue
+ svg_color(139, 69 , 19 ), // saddlebrown
+ svg_color(250, 128, 114), // salmon
+ svg_color(244, 164, 96 ), // sandybrown
+ svg_color(46 , 139, 87 ), // seagreen
+ svg_color(255, 245, 238), // seashell
+ svg_color(160, 82 , 45 ), // sienna
+ svg_color(192, 192, 192), // silver
+ svg_color(135, 206, 235), // skyblue
+ svg_color(106, 90 , 205), // slateblue
+ svg_color(112, 128, 144), // slategray
+ svg_color(112, 128, 144), // slategrey
+ svg_color(255, 250, 250), // snow
+ svg_color(0 , 255, 127), // springgreen
+ svg_color(70 , 130, 180), // steelblue
+ svg_color(210, 180, 140), // tan
+ svg_color(0 , 128, 128), // teal
+ svg_color(216, 191, 216), // thistle
+ svg_color(255, 99 , 71 ), // tomato
+ svg_color(64 , 224, 208), // turquoise
+ svg_color(238, 130, 238), // violet
+ svg_color(245, 222, 179), // wheat
+ svg_color(255, 255, 255), // white
+ svg_color(245, 245, 245), // whitesmoke
+ svg_color(255, 255, 0 ), // yellow
+ svg_color(154, 205, 50 ), // yellowgreen
+};
+
+void constant_to_rgb(svg_color_constant _c, unsigned char &r,
+ unsigned char &g, unsigned char &b)
+{
+ svg_color temp(color_array[_c]);
+
+ r = temp.r;
+ g = temp.g;
+ b = temp.b;
+}
+
+svg_color constant_to_rgb(svg_color_constant _c)
+{
+ return color_array[_c];
+}
+
+}//svg
+}//boost
+
+
+#endif

Added: sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -0,0 +1,139 @@
+// svg_style.hpp
+// Copyright (C) Jacob Voytko 2007
+//
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+
+// -----------------------------------------------------------------
+
+#ifndef _BOOST_SVG_SVG_STYLE_HPP
+#define _BOOST_SVG_SVG_STYLE_HPP
+
+#include <ostream>
+#include "svg_color.hpp"
+#include "detail/svg_style_detail.hpp"
+
+namespace boost {
+namespace svg {
+
+enum point_shape{none, circle, square, point};
+
+struct plot_point_style
+{
+ point_shape shape;
+ svg_color stroke_color;
+ svg_color fill_color;
+ int size;
+
+ plot_point_style(const svg_color& _fill,
+ const svg_color& _stroke, int _size = 10, point_shape _shape = circle):
+ fill_color(_fill), stroke_color(_stroke), size(_size), shape(_shape)
+ {
+
+ }
+};
+
+struct plot_line_style
+{
+ svg_color color;
+ svg_color_constant area_fill;
+
+ bool line_on;
+
+ plot_line_style(const svg_color& _col, bool _on):
+ color(_col), line_on(_on), area_fill(blank)
+ {
+ }
+};
+
+// -----------------------------------------------------------------
+// This is the style information for any <g> tag. This will be
+// expanded to include more data from the SVG standard when the
+// time comes.
+// -----------------------------------------------------------------
+class svg_style
+{
+private:
+ svg_color fill;
+ svg_color stroke;
+
+ unsigned int width;
+
+ bool fill_on;
+ bool stroke_on;
+ bool width_on;
+
+public:
+ svg_style():fill(svg_color(0, 0, 0)),
+ stroke(svg_color(0, 0, 0)), width(0),
+ fill_on(false), stroke_on(false), width_on(false)
+ {
+
+ }
+
+ svg_style(const svg_color& _fill, const svg_color& _stroke,
+ unsigned int _width = 0):
+ fill(_fill), stroke(_stroke),
+ width(_width), fill_on(false),
+ stroke_on(false), width_on(false)
+ {
+
+ }
+
+ // setters
+ svg_style& fill_color(const svg_color& _col)
+ {
+ fill = _col;
+ fill_on = true;
+ return *this;
+ }
+
+ svg_style& stroke_color(const svg_color& _col)
+ {
+ stroke = _col;
+ stroke_on = true;
+ return *this;
+ }
+
+ svg_style& stroke_width(unsigned int _width)
+ {
+ width = _width;
+ width_on = true;
+ return *this;
+ }
+
+ // getters
+ svg_color fill_color() { return svg_color(fill); }
+ svg_color stroke_color() { return svg_color(stroke); }
+ unsigned int stroke_width() { return width; }
+
+
+ void write(std::ostream& rhs)
+ {
+ if(stroke_on)
+ {
+ rhs << "stroke=\"";
+ stroke.write(rhs);
+ rhs << "\" ";
+ }
+
+ if(fill_on)
+ {
+ rhs << "fill=\"";
+ fill.write(rhs);
+ rhs<<"\" ";
+ }
+ if(width_on)
+ {
+ rhs << "stroke-width=\""
+ << width
+ << "\" ";
+ }
+ }
+};
+
+}//svg
+}//boost
+
+
+#endif

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp 2007-07-22 19:06:32 EDT (Sun, 22 Jul 2007)
@@ -1,13 +1,12 @@
+#include "svg_1d_plot.hpp"
+#include "svg_2d_plot.hpp"
+
 #include <vector>
 #include <cmath>
 #include <map>
 
-#include "svg_2d_plot.hpp"
-#include "svg_1d_plot.hpp"
-
 using std::multimap;
 using std::vector;
-using namespace boost::svg;
 
 double f(double x)
 {
@@ -16,7 +15,7 @@
 
 double g(double x)
 {
- return -2 + x;
+ return -2 + x*x;
 }
 
 double h(double x)
@@ -38,6 +37,7 @@
 
 int main()
 {
+ using namespace boost::svg;
     std::map<double, double> data1;
     std::map<double, double> data2;
     std::vector<double> data3;
@@ -48,42 +48,46 @@
     for(double i=0; i<10; i+=1)
     {
         data1[i - 5.] = f(i);
- data2[i] = i - 5.;
+ data2[i] = g(i);
         data3.push_back(h(i) - 10.);
     }
 
     // size/scale settings
- my_2d_plot.set_image_size(500, 350);
-
- my_2d_plot.set_title("Hello, operator")
- .set_plot_window_on(true)
- .set_legend_on(true);
-
- my_2d_plot.set_title_on(true)
- .set_x_label_on(true)
- .set_x_label("sqrt(x)")
- .set_x_major_grid_on(false);
-
- my_1d_plot.set_image_size(500, 350);
-
- my_1d_plot.set_title("Hello, operator")
- .set_plot_window_on(true)
- .set_legend_on(true);
+ my_2d_plot.image_size(500, 350);
 
- my_1d_plot.set_title_on(true)
- .set_x_label_on(true)
- .set_x_label("sqrt(x)")
- .set_x_major_grid_on(false);
+ my_2d_plot.title("Hello, operator")
+ .plot_window_on(true)
+ .legend_on(true);
+
+ my_2d_plot.title_on(true)
+ .x_label_on(true)
+ .y_major_labels_on(true)
+ .x_label("sqrt(x)")
+ .x_major_grid_on(false);
+// .y_external_style_on(true)
+// .x_external_style_on(true);
+
+ my_1d_plot.image_size(500, 350);
+
+ my_1d_plot.title("Hello, operator")
+ .plot_window_on(true)
+ .legend_on(true);
+
+ my_1d_plot.title_on(true)
+ .x_label_on(true)
+ .x_label("sqrt(x)");
 
- plot_2d(my_2d_plot, data1, "sqrt(x)");
+ my_2d_plot.plot_2d(data1, "sqrt(x)");
 
- plot_2d(my_2d_plot, data2, "Not sqrt(x)",
- _size = 10,
+ my_2d_plot.plot_2d(data2, "Not sqrt(x)",
+ _size = 6,
         _point_style = square,
         _stroke_color = hotpink,
- _fill_color = yellow);
+ _line_color = black,
+ _fill_color = yellow,
+ _area_fill_color = red);
     
- plot(my_1d_plot, data3, "1D Plot");
+ my_1d_plot.plot(data3, "1D Plot");
 
     my_1d_plot.write("./test1d.svg");
     my_2d_plot.write("./test2d.svg");


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk