Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2007-11-22 16:53:48


Author: pbristow
Date: 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
New Revision: 41309
URL: http://svn.boost.org/trac/boost/changeset/41309

Log:
Update of work in progress 22 Nov 07.
Text files modified:
   sandbox/SOC/2007/visualization/Jamrules | 2
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 2608 ++++++++++++++++++++++++++-------------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp | 35
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp | 64
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp | 32
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp | 91
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 1626 +++++++++++++++++-------
   sandbox/SOC/2007/visualization/boost/svg_plot/stylesheet.hpp | 45
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp | 775 ++++++++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 763 ++++++-----
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 1851 ++++++++++++++++------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp | 481 +++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp | 94
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 238 ++-
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 | 8
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html | 7
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/acknowledgements.html | 12
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_limits.html | 12
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_stylesheets.html | 42
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/color.html | 82
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/howtouse.html | 98
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_1d_plot_interface.html | 67
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_2d_plot_interface.html | 24
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_boxplot_interface.html | 40
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_interface.html | 267 +++
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/1d_defaults.html | 30
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/2d_defaults.html | 8
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial/svg_boxplot_tutorial_simple.html | 20
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/todo.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_simple_code_example.html | 10
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_special.html | 50
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/full_2d_layout.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/1d_special.html | 24
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/full_1d_layout.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/tutorial_code_1d_example.html | 20
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_stylesheet.html | 28
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk | 397 +++++
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp | 35
   sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp | 3
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_bezier.cpp | 10
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp | 4
   sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_color_consistency.cpp | 425 +++++
   sandbox/SOC/2007/visualization/libs/svg_plot/test/2d_color_consistency.cpp | 154 +
   sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 | 2
   52 files changed, 7046 insertions(+), 3604 deletions(-)

Modified: sandbox/SOC/2007/visualization/Jamrules
==============================================================================
--- sandbox/SOC/2007/visualization/Jamrules (original)
+++ sandbox/SOC/2007/visualization/Jamrules 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -11,5 +11,5 @@
 path-global BOOST_ROOT : . ;
 
 # The current version of Boost.
-BOOST_VERSION ?= 1.34.0 ;
+BOOST_VERSION ?= 1.34.1 ;
 

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-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,29 +1,26 @@
 // axis_plot_frame.hpp
 
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-
-// -----------------------------------------------------------------
-
-// TODO PAB
-// I am not clear yet which items need BOTH fill and stroke?
-// If both are set, which is returned?
-// I think it would be better to rename all get_XXX() to just XXX()
-// And to place the setter and getters together,
-// so one can see that boht are present, and that they match.
-// I've corrected one test failure in x_label_color.
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_SVG_AXIS_PLOT_FRAME_HPP
 #define BOOST_SVG_AXIS_PLOT_FRAME_HPP
 
-#include <string>
 #include "../svg_style.hpp"
 #include "../svg.hpp"
 #include "svg_tag.hpp"
 #include "numeric_limits_handling.hpp"
 
+#include <string>
+// using std::string;
+
+#include <iostream> // for testing only.
+// using std::cerr and std::endl
+
 namespace boost
 {
 namespace svg
@@ -31,901 +28,1722 @@
 namespace detail
 {
 
-template <class Derived>
-class axis_plot_frame
-{
-protected:
- // -----------------------------------------------------------------
+ template <class Derived>
+ class axis_plot_frame
+ {
+ // axis_plot_frame is used as base class, for example:
+ // class svg_1d_plot : public detail::axis_plot_frame<svg_1d_plot>
+ // class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
+ 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.
- // -----------------------------------------------------------------
- void _transform_point(double &x, double &y)
- {
- x = derived().x_scale* x + derived().x_shift;
- y = derived().y_scale* y + derived().y_shift;
+ // --------------------------------------------------------------------
 
- _adjust_limits(x, y);
- }
-
- void _transform_x(double &x)
- {
- x = derived().x_scale* x + derived().x_shift;
- }
-
- void _transform_y(double &y)
- {
- y = derived().y_scale* y + derived().y_shift;
- }
-
- 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().use_x_minor_grid)
- {
- _transform_x(x1 = j);
-
- if(!derived().use_plot_window)
- {
- // spacing for labels
- if(derived().use_title)
- {
- y1 += derived().title_info.font_size() * 1.5;
- }
-
- if(derived().use_x_label)
- {
- y2 -= derived().x_label_info.font_size() * 1.5;
- }
- }
-
- else
- {
- y1 = derived().plot_y1 + 1;
- y2 = derived().plot_y2 - 1;
- }
-
- grid_path.M(x1, y1).L(x1, y2);
+ // protected member functions (defined below):
 
+ // void transform_point(double &x, double &y);
+ // void transform_x(double &x);
+ // void transform_y(double &y);
+ // void draw_x_minor_ticks(double j, path_element& tick_path, path_element& grid_path); // (& grid).
+ // void draw_x_major_ticks(double i, path_element& tick_path, path_element& grid_path); // (& grid).
+ // void draw_x_axis();
+ // void draw_legend();
+ // void draw_title();
+ // void adjust_limits(double& x, double& y);
+ // void draw_plot_point(double x, double y, g_element& g_ptr, const plot_point_style& sty);
+
+ // Clear functions.
+ // void clear_all(); // Calls all the other clear_* functions.
+ // void clear_legend();
+ // void clear_background();
+ // void clear_x_axis();
+ // void clear_y_axis();
+ // void clear_title();
+ // void clear_points();
+ // void clear_plot_background();
+ // void clear_grids();
+
+ void transform_point(double& x, double& y)
+ { // Scale & shift both x & y to graph coordinate.
+ x = derived().x_scale * x + derived().x_shift;
+ y = derived().y_scale * y + derived().y_shift;
+ adjust_limits(x, y); // In case either hits max, min, infinity or NaN.
+ }
+ // TODO do we need to adjust_limit(x); // In case hits max, min, infinity or NaN?
+ // This implies that user's choice of X-axis range is wrong?
+ // So more drastic action like throwing might be least worst action?
+
+ void transform_x(double & x)
+ { // Scale and shift x only.
+ x = derived().x_scale * x + derived().x_shift;
+ }
+
+ void transform_y(double & y)
+ { // Scale and shift y only.
+ y = derived().y_scale * y + derived().y_shift;
+ }
+
+ void draw_x_minor_ticks(double value, path_element& tick_path, path_element& grid_path)
+ { // draw X-axis minor ticks, and optionaloly grid.
+ // value is NOT (yet) shown beside the minor tick.
+ double x1(value);
+ transform_x(x1);
+ double y1(0.);
+ double y2(derived().image.y_size());
+
+ // Draw the minor grid, if wanted.
+ if(derived().use_x_minor_grid)
+ {
+ if(!derived().use_plot_window)
+ { // Use whole image.
+ // Make space for title and X-axis labels.
+ if(derived().use_title)
+ { // Allow text_margin * font_size around text (pixels).
+ y1 += derived().title_info.font_size() * derived().text_margin;
+ }
+ if(derived().use_x_label)
+ {
+ y2 -= derived().x_label_info.font_size() * derived().text_margin;
+ }
         }
-
- 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_x2 && x1 > derived().plot_x1)
- {
- tick_path.M(x1, y1).L(x1, y2);
- }
- }
-
- 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().use_x_major_grid)
- {
- _transform_x(x1 = i);
-
- if(!derived().use_plot_window)
- {
- if(derived().use_title)
- {
- y1 += derived().title_info.font_size() * 1.5;
- }
-
- if(derived().use_x_label)
- {
- y2 -= derived().x_label_info.font_size() * 1.5;
- }
- }
-
- else
- {
- y1 = derived().plot_y1;
- y2 = derived().plot_y2;
- }
- grid_path.M(x1, y1).L(x1, y2);
-
- }
-
- // Draw major tick.
- x1=i;
-
- _transform_x(x1);
-
- // Make sure that we are drawing inside of the allowed window.
- if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
- {
- double x_tick_length = derived().x_major_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;
- }
-
- 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, fmt.str());
- }
- }
- }
-
- void _draw_x_axis()
- {
- double y1(0.);
-
- // draw the axis line
- _transform_y(y1);
-
- derived().x_axis = y1;
-
- 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/
- ((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)
- {
- for(double j = i + x_minor_jump;
- j < i + derived().x_major;
- j += x_minor_jump)
- {
- _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _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)
- {
- // draw minor ticks
- for(double j=i; j>i-derived().x_major; j-=derived().x_major / (derived().x_num_minor+1))
- {
- _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _draw_x_major_ticks(i, major_tick_path, major_grid_path);
- }
- }
-
- // -----------------------------------------------------------------
- // When writing to multiple documents, the contents of the plot
- // may change significantly between. Rather than figuring out what
- // has and has not changed, just erase the contents of the legend
- // in the document and start over.
- // -----------------------------------------------------------------
- void _clear_all()
- {
- _clear_legend();
- _clear_background();
- _clear_x_axis();
- _clear_y_axis();
- _clear_title();
- _clear_points();
- _clear_plot_background();
- _clear_grids();
- }
-
- void _clear_background()
- {
- derived().image.get_g_element(PLOT_BACKGROUND).clear();
- }
-
- void _clear_title()
- {
- derived().image.get_g_element(PLOT_TITLE).clear();
- }
-
- void _clear_points()
- {
- derived().image.get_g_element(PLOT_PLOT_POINTS).clear();
- }
-
- void _clear_plot_background()
- {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).clear();
- }
-
- void _clear_legend()
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).clear();
- derived().image.get_g_element(PLOT_LEGEND_POINTS).clear();
- derived().image.get_g_element(PLOT_LEGEND_TEXT).clear();
- }
-
- void _clear_x_axis()
- {
- derived().image.get_g_element(PLOT_X_AXIS).clear();
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).clear();
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).clear();
- derived().image.get_g_element(PLOT_X_LABEL).clear();
- derived().image.get_g_element(PLOT_PLOT_LABELS).clear();
- }
-
- void _clear_y_axis()
- {
- derived().image.get_g_element(PLOT_Y_AXIS).clear();
- }
-
- void _clear_grids()
- {
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).clear();
- derived().image.get_g_element(PLOT_X_MINOR_GRID).clear();
- }
-
- 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_size + 2, "Legend");
-
- 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));
- }
-
- // -----------------------------------------------------------------
- // Important note: there are a lot of magic numbers that are temporary
- // fill-ins for the time when the legend system is more configurable.
- // This will happen bit-by-bit, as I give the user options to change
- // these values
- // -----------------------------------------------------------------
- void _draw_legend()
- {
- int num_points = (int)(derived().series.size());
-
- int legend_width(150);
- int legend_height(25);
-
- int x_size = derived().image.get_x_size();
-
- // Figure out how wide the legend should be
- if(x_size < 200)
- {
- legend_width = x_size;
+ { // use_plot_window == true.
+ y1 = derived().plot_y1 + 1; // Top. Why +1 and -1?
+ y2 = derived().plot_y2 - 1; // Bottom. Ensure *inside* window?
+ }
+ // Make sure that we are drawing inside the allowed window.
+ if((x1 >= derived().plot_x1) && (x1 <= derived().plot_x2)) // allow = too?
+ {
+ //std::cerr << "Writing draw_x_minor_ticks grid inside plot window: x1 = "
+ // << x1 << ", plot_x1 = " << derived().plot_x1 << ", plot_x2 = " << derived().plot_x2 << std::endl;
+ grid_path.M(x1, y1).L(x1, y2);
         }
-
- unsigned int legend_x_start(derived().plot_x2 + 5);
- unsigned int legend_y_start(derived().plot_y1);
-
- if((unsigned int)(derived().plot_x2) >= derived().image.get_x_size())
- {
- legend_x_start-=160;
- legend_y_start+=5;
- }
-
+ else
+ { // This will happen but is designed to be ignored!
+ // TODO check this is best. See comment in draw_x_axis
+ std::cerr << "Writing draw_x_minor_ticks grid OUTside plot window: x1 = "
+ << x1 << ", plot_x1 = " << derived().plot_x1 << ", plot_x2 = " << derived().plot_x2 << std::endl;
+ }
+ } // use_x_minor_grid
+
+ double x_tick_length = derived().x_minor_tick_length_;
+ if(derived().use_x_ticks_on_plot_window_)
+ { // Put minor ticks on the plot window border.
+ y1 = derived().plot_y2; // on the window line.
+ y2 = derived().plot_y2; // y1 = upper, y2 = lower end of tick.
+ if(derived().use_up_ticks)
+ { //
+ y1 -= x_tick_length; // up.
+ }
+ if (derived().use_down_ticks)
+ {
+ y2 += x_tick_length; // down.
+ }
+ }
+ else
+ { // Internal style, draw tick up and/or down from the central X axis line.
+ y1 = derived().x_axis; // X-axis line.
+ y2 = derived().x_axis;
+ if(derived().use_up_ticks)
+ {
+ y1 -= x_tick_length; // up
+ }
+ if (derived().use_down_ticks)
+ {
+ y2 += x_tick_length; // down.
+ }
+ }
+ // Make sure that we are drawing inside the allowed window.
+ if((x1 >= derived().plot_x1) && (x1 <= derived().plot_x2)) // TODO allow < or <=
+ {
+ //std::cerr << "Writing draw_x_minor_ticks inside plot window: x1 = "
+ // << x1 << ", plot_x1 = " << derived().plot_x1 << ", plot_x2 = " << derived().plot_x2 << std::endl;
+ tick_path.M(x1, y1).L(x1, y2);
+ // No value labels on minor ticks, at present.
+ }
+ else
+ { // This will happen but is designed to be ignored!
+ // TODO check this is best. See comment in draw_x_axis
+ //std::cerr << "Writing draw_x_minor_ticks OUTside plot window: x1 = "
+ // << x1 << ", plot_x1 = " << derived().plot_x1 << ", plot_x2 = " << derived().plot_x2 << std::endl;
+ }
+ } // void draw_x_minor_ticks
+
+ void draw_x_major_ticks(double value, path_element& tick_path, path_element& grid_path)
+ { // draw ticks - and grid too if wanted.
+ // If use_x_major_labels then value may be shown beside the major tick.
+ double x1(value); //
+ transform_x(x1);
+ double y1(0.); // // y1 = upper,
+ double y2(derived().image.x_size()); // y2 = lower end of tick.
+ if(derived().use_x_major_grid)
+ { // Draw major grid vertical line.
+ if(!derived().use_plot_window)
+ { // Allow a modest margin around text of title and X-axis labels, if in use.
         if(derived().use_title)
         {
- // -5 removes the padding
- 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_size*1.5 + (25 * num_points) + 10);
-
- g_element* g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_BACKGROUND));
-
- g_ptr->push_back(new rect_element(legend_x_start,
- legend_y_start,
- legend_width,
- legend_height));
-
- _draw_legend_header(legend_x_start, legend_y_start, legend_width);
-
- g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_POINTS));
-
- g_element* g_inner_ptr = g_ptr;
-
- for(unsigned int i=0; i<derived().series.size(); ++i)
- {
- g_inner_ptr = &(g_ptr->add_g_element());
-
- 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_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_size + 25 + i*25,
- derived().series[i].title, derived().legend_title_size,
- left_align));
- }
- }
-
- void _draw_title()
- {
- text_element title(derived().image.get_x_size()/2.,
- derived().title_info.font_size(),
- derived().title_info.text());
-
- 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_x2 + derived().plot_x1) / 2.,
- derived().image.get_y_size() - 8, derived().x_label_info.text());
-
- 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));
- }
-
- void _adjust_limits(double& _x, double& _y)
- {
- if(detail::limit_max(_x))
- {
- _x = derived().plot_x2;
+ y1 += derived().title_info.font_size() * derived().text_margin;
         }
- if(detail::limit_max(_y))
- {
- _y = derived().plot_y1;
- }
- if(detail::limit_min(_x))
- {
- _x = derived().plot_x1;
- }
- if(detail::limit_min(_y))
- {
- _y = derived().plot_y1;
- }
- if(detail::limit_NaN(_x))
- {
- _x = 0;
- _transform_x(_x);
- }
- if(detail::limit_NaN(_y))
- {
- _y = 0;
- _transform_y(_y);
- }
- }
-
- void _draw_plot_point(double _x, double _y,
- g_element& g_ptr, const plot_point_style& _sty)
- {
- int size = _sty.size;
- double half_size = size / 2.;
-
- switch(_sty.shape)
- {
- case circle:
- g_ptr.circle(_x, _y, half_size);
- break;
- case square:
- g_ptr.rect(_x - half_size, _y - half_size, size, size);
- break;
- }
- }
+ if(derived().use_x_label)
+ { // If use_x_major_labels then value may be shown beside the major tick.
+ y2 -= derived().x_label_info.font_size() * derived().text_margin;
+ }
+ }
+ else
+ { // use_plot_window == true
+ y1 = derived().plot_y1; // Bottom of plot window.
+ y2 = derived().plot_y2; // Top of plot window.
+ }
+ grid_path.M(x1, y1).L(x1, y2); // Vertical grid line.
+ } // use_x_major_grid
+
+ // Draw major tick (perhaps as well as grid - ticks might be wider than grid).
+ // Make sure that we are drawing inside the allowed plot window.
+ if((x1 > derived().plot_x1) && (x1 < derived().plot_x2)) // < or <= ???
+ {
+ double x_tick_length = derived().x_major_tick_length_;
+ if(derived().use_x_ticks_on_plot_window_)
+ { // Put the ticks on the plot window border (was external).
+ y1 = derived().plot_y2; // on the window line.
+ y2 = derived().plot_y2; // y1 = upper, y2 = lower.
+ if(derived().use_up_ticks)
+ {
+ y1 -= x_tick_length; // up
+ }
+ if (derived().use_down_ticks)
+ {
+ y2 += x_tick_length; // down.
+ }
+ }
+ else
+ { // Internal_style, draw tick from the central X axis line.
+ y1 = derived().x_axis; // X-axis line.
+ y2 = derived().x_axis;
+ if(derived().use_up_ticks)
+ {
+ y1 -= x_tick_length; // up
+ }
+ if (derived().use_down_ticks)
+ {
+ y2 += x_tick_length; // down.
+ }
+ }
+ tick_path.M(x1, y1).L(x1, y2);
+
+ if(derived().use_x_major_labels )
+ { // Show value by the tick.
+ std::stringstream fmt;
+ fmt << value; // TODO precision problems here?
+ // TODO if 2-D, don NOT want a "0" here - cut in two by the Y-axis line!
+ // But DO want it if 1-D. How do we tell if 2-D?
+ if(fmt.str() != "0") // && is_2D) wanted here.
+ {
+ if(derived().use_x_ticks)
+ {
+ y2 += derived().text_margin;
+ // move down by a font height?
+ if (derived().use_down_ticks)
+ { // Move down a tick.
+ y2 += derived().x_major_tick_length_;
+ }
+ }
+ else
+ { // ! internal_style
+ y2 += derived().text_margin + x_tick_length; // Move down.
+ }
+ derived().image.get_g_element(PLOT_PLOT_LABELS).text(x1, y2, fmt.str());
+ }
+ }// use_x_major_labels
+ }
+ else
+ { // Outside plot window - so do nothing? Warning?
+ //std::cerr << "Writing draw_x_major_ticks OUTside plot window: "
+ // "x1 = " << x1 << ", plot_x1 = " << derived().plot_x1 << ", plot_x2 = " << derived().plot_x2 << std::endl;
+ }
+ } // draw_x_major_ticks
+
+ void draw_x_axis()
+ {
+ double y1(0.); // Draw the horizontal X-axis line at y = 0.
+ transform_y(y1);
+ derived().x_axis = y1;
+ // Access the paths for the ticks & grids, ready for additions.
+ 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().use_x_axis_lines_)
+ { // Draw the horizontal X-axis line.
+ 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 /
+ ((double)(derived().x_num_minor_ticks_ + 1.) );
+
+ // TODO Problem here when using floating point??
+ // Was i < y_max; but didn't show the tick and value at y_max so now i <= y_max;
+ // But may still fail if a least significant bit or few out??
+
+ // Draw the ticks on the positive side (right of zero).
+ for(double x = 0; x <= derived().x_max; x += derived().x_major)
+ {
+ for(double j = x + x_minor_jump; j < x + derived().x_major; j += x_minor_jump)
+ { // This will output 'orphaned' minor ticks that are beyond the plot window,
+ // if the last major tick does not coincide with the plot window.
+ // These are just ignored in draw_x_minor_ticks.
+ // There might be 9 of them,
+ // if you have the common 9 minor tick between major ticks!
+ // TODO this seems ugly - as does the negative ones below.
+ draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+ draw_x_major_ticks(x, major_tick_path, major_grid_path);
+ }
+
+ // Draw the ticks on the negative side (left of zero).
+ for(double x = 0; x >= derived().x_min; x -= derived().x_major)
+ {
+ // Draw minor ticks.
+ for(double j = x; j > x-derived().x_major; j-= derived().x_major / (derived().x_num_minor_ticks_+1))
+ {
+ draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+ draw_x_major_ticks(x, major_tick_path, major_grid_path);
+ }
+ } // void draw_x_axis()
+
+ // --------------------------------------------------------------------
+ // Draw functions - legend & title (if any).
+ // --------------------------------------------------------------------
+
+ void draw_title()
+ {
+ // text_element::text_element(double x, double y,
+ // const std::string&,
+ // int size,
+ // const std::string& font,
+ // const std::string& style, const std::string& weight,
+ // const std::string& stretch, const std::string& decoration,
+ // int align, int rotate);
+
+ // Update title_info with position.
+ derived().title_info.x(derived().image.x_size() / 2.); // Center of image.
+ // Assumes align = center_align.
+ double y;
+ if (derived().use_plot_window)
+ {
+ y = derived().plot_y1; // plot_y1 IS now assigned in calculate_plot_window
+ // Center the title in the space between top and plot window top.
+ y /= 2;
+ }
+ else
+ { // use all image.
+ y = derived().title_info.font_size() * derived().text_margin; // Leave a linespace above.
+ }
+ derived().title_info.y(y);
+ derived().image.get_g_element(PLOT_TITLE).push_back(new text_element(derived().title_info));
+ } // void draw_title()
+
+ void draw_legend()
+ {
+ size_t num_points = derived().series.size();
+ int font_size = derived().legend_header.font_size();
+ int point_size = derived().series[0].point_style.size;
+ // Use whichever is the biggest of point marker and font.
+
+ double spacing = (std::max)(font_size, point_size);
+ bool is_header = (derived().legend_header.text() != "");
+ // std::cerr << spacing << ' ' << font_size << ' ' << point_size << endl;
+ double legend_width(0); //
+ size_t longest = 0;
+ for(unsigned int i = 0; i < derived().series.size(); ++i)
+ { // Find the longest text in all the data series.
+ std::string s = derived().series[i].title;
+ size_t siz = s.size();
+ if (siz > longest)
+ {
+ longest = siz;
+ }
+ }
+ legend_width = (6 + longest /2) * spacing;
+ // font_size is not exact because width varies.
+ // Allow for a leading space, data marker symbol, space,
+ // line in color (only if 2-D and line option selected TODO)
+ // space, text, trailing space before box margin.
+
+ // legend_height must be *at least* enough for
+ // the legend title and text_margins around it
+ // (if any) plus a text_margin top and bottom.
+ // Add more height depending on the number of lines of text.
+ double legend_height = 2. * spacing;
+ if (derived().use_title) // plot title
+ // && derived().legend_header.text() != "" leave space even if no string?
+ {
+ legend_height += spacing;
+ }
+ legend_height += num_points * spacing * 2; // Space for the point symbols & text.
+ // legend_height += spacing; // At bottom. Not needed?
+
+ // x, y position of legend 'box' top left, level with top right of plot window.
+ double legend_x_start(derived().plot_x2);
+ legend_x_start += spacing; // leave a space between plot window and legend box.
+ double legend_y_start(derived().plot_y1);
+
+ int x_size = derived().image.x_size();
+ if((legend_x_start + legend_width) > x_size)
+ { // Use all the image width available.
+ std::cout << "Legend text line was too long by "
+ << ((legend_x_start + legend_width) - x_size)
+ << " pixels, & so truncated. legend_width == " << legend_width << std::endl;
+ // For example:
+ // "Legend text line was too long by about 84 pixels & so truncated. legend_width == 252"
+ legend_width = x_size - legend_x_start - derived().text_margin;
+ // text_margin just allows the border box to show.
+ }
+
+ // Draw border box round legend.
+ g_element* g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_BACKGROUND));
+ g_ptr->push_back(new rect_element(legend_x_start, legend_y_start,
+ legend_width, legend_height));
+
+ double legend_y_pos = legend_y_start + derived().text_margin * spacing;
+ if (is_header)
+ { // Draw the legend text.
+ derived().legend_header.x(legend_x_start + legend_width / 2.); // / 2. to center in legend box.
+ derived().legend_header.y(legend_y_pos);
+ derived().image.get_g_element(PLOT_LEGEND_TEXT).push_back(new text_element(derived().legend_header));
+ legend_y_pos += 2 * spacing;
+ }
+
+ g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_POINTS));
+ g_element* g_inner_ptr = g_ptr;
+ g_inner_ptr = &(derived().image.get_g_element(PLOT_LEGEND_TEXT));
+
+ for(unsigned int i = 0; i < derived().series.size(); ++i)
+ { // Show point marker, text info and perhaps line for all the data series.
+ double legend_x_pos = legend_x_start;
+ g_inner_ptr = &(g_ptr->add_g_element());
+ // Use both fill & stroke colors from the point's style.
+ 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( // Plot point like circle, square...
+ legend_x_start + spacing, // space before point marker.
+ legend_y_pos,
+ *g_inner_ptr,
+ derived().series[i].point_style);
+ legend_x_pos += 2 * spacing ;
+
+ // TODO line markers properly
+ // only really applicable to 2-D sets plot_line_style,
+ // but svg_1d_plot does NOT DEFINE line_style.
+ // Meanwhile use svg_1d_plot .use_line and point color.
+ // SHOULD use both fill & stroke colors from the line's style.
+ // bool line_on = derived().series[i].plot_line_style.line_on;
+ // svg_color col = derived().series[i].plot_line_style.color;
+ if (derived().use_line)
+ { // Need to draw a short line to show color for that data series.
+ g_inner_ptr->style() // Use fill & stroke colors from point style. (Should be plot_line_style!)
+ .fill_color(derived().series[i].point_style.fill_color)
+ .stroke_color(derived().series[i].point_style.stroke_color);
+ g_inner_ptr->push_back(new line_element(
+ legend_x_pos,
+ legend_y_pos,
+ legend_x_pos + spacing, // line sample is one char long.
+ legend_y_pos));
+ legend_x_pos += 2 * spacing; // line & space.
+ } // use_line
+
+ // Legend text for each Data Series added to the plot.
+ g_inner_ptr = &(derived().image.get_g_element(PLOT_LEGEND_TEXT));
+ g_inner_ptr->push_back(new text_element(
+ legend_x_pos, // allow space for the marker.
+ legend_y_pos,
+ derived().series[i].title, // Text for this data series.
+ derived().legend_header.font_size(), // font size
+ "", "", "", "", "", // TODO full font info for legend needed here?
+ left_align));
+ legend_y_pos += 2 * spacing;
+ } // for
+
+ // TODO reconsider this.
+ //if(derived().plot_x2 >= (int)derived().image.x_size())
+ //{ // Put legend above plot because image is tall & thin.
+ // // TODO this properly.
+ //}
+ } // void draw_legend()
+
+ void draw_x_label()
+ {
+ // color set in constructor.
+ //image.get_g_element(detail::PLOT_X_LABEL).style().stroke_color(black);
+
+ std::string label = derived().x_label_info.text(); // x_axis label, and optional units.
+ if (derived().use_x_label_units && (derived().x_units_info.text() != ""))
+ { // Append the units, if any, providing brackets ().
+ label += " (" + derived().x_units_info.text() + ")";
+ }
+
+ double y(0.);
+ transform_y(y);
+ derived().x_axis = y; // X-axis line at y = 0.
+ y += derived().x_label_font_size() * 2.5; // values & label & half line space.
+ if (derived().use_down_ticks)
+ { // Make space for ticks down.
+ y += derived().x_major_tick_length(); // down.
+ // TODO actually want (std::max)::(derived().x_major_tick_length(), derived().x_minor_tick_length())?
+ //TODO where do the brackets go??
+
+ }
+
+ derived().image.get_g_element(PLOT_X_LABEL).push_back(new text_element(
+ ( // x position relative to the x-axis which is middle of plot window.
+ derived().plot_x2 + derived().plot_x1) / 2, // x coordinate - middle.
+ // y position is down from plot window.
+ derived().plot_y2 + (derived().x_label_font_size() * derived().text_margin),
+ label,
+ derived().x_label_font_size(),
+ derived().x_label_font_family(), "", "", "", "", center_align, horizontal)
+ );
+ } // void draw_x_label()
+
+ // TODO split into adjust_limit(double& x) and call twice?,
+ // and TODO use to check 1-D for limit values too?
+ void adjust_limits(double& x, double& y)
+ { // If value reaches limit of max, min, infinity,
+ // use the appropriate plot min or max.
+ if(detail::limit_max(x))
+ {
+ x = derived().plot_x2;
+ }
+ if(detail::limit_max(y))
+ {
+ y = derived().plot_y1;
+ }
+ if(detail::limit_min(x))
+ {
+ x = derived().plot_x1;
+ }
+ if(detail::limit_min(y))
+ {
+ y = derived().plot_y1;
+ }
+ // If value is NaN, use zero instead.
+ // TODO Do we want/get a different color or shape for NaNs??
+ if(detail::limit_NaN(x))
+ {
+ x = 0;
+ transform_x(x);
+ }
+ if(detail::limit_NaN(y))
+ {
+ y = 0;
+ transform_y(y);
+ }
+ } // void adjust_limits
+
+ void draw_plot_point(double x, double y,
+ g_element& g_ptr,
+ const plot_point_style& sty)
+ {
+ int size = sty.size;
+ double half_size = size / 2.;
+
+ // For 1-D plots, the points do not *need* to be centered on the X-axis,
+ // and putting them just above, or sitting on, the X-axis is much clearer.
+ // For 2-D plots, the symbol center should, of course,
+ // be *centered exactly* on x, y.
+ // circle and ellipse are naturally centered on the point.
+ // for rect x and y half_size offset centers square on the point.
+ // But symbols are in a rectangular box and the offset is different for x & y
+ // even assuming that the symbol is centered in the rectangle.
+ // the vertical and horizontal ticks are deliberately offset above the axes.
+ // TODO Not sure this is fully resolved.
+
+ switch(sty.shape) // from enum point_shape none, round, square, point, egg
+ {
+ case round:
+ g_ptr.circle(x, y, half_size);
+ break;
+ case square:
+ g_ptr.rect(x - half_size, y - half_size, size, size);
+ break;
+ case egg:
+ g_ptr.ellipse(x, y, half_size, size * 2.); // Tall thin egg!
+ break;
+
+ // Offset from center is not an issue with vertical or horizontal ticks.
+ // TODO stroke color of line seems to be FILL color, not the stroke color.
+ // This is OK-ish, but I'm not sure why.
+
+ //svg_color sc = sty.stroke_color;
+ //svg_color fc = sty.fill_color;
+
+ case vertical_tick: // Especially neat for 1-D points.
+ g_ptr.line(x, y, x , y - size); // tick up from axis.
+ break;
+ case vertical_line:
+ g_ptr.line(x, y + size, x , y - size); // line up & down from axis.
+ break;
+ case horizontal_tick:
+ // horizontal_tick is pretty useless for 1-D because the horizontal line is on the X-axis.
+ g_ptr.line(x, y, x + size, y ); // tick right from axis.
+ break;
+ case horizontal_line:
+ g_ptr.line(x, y - size, x + size, y ); // line left & right from axis.
+ // horizontal_line is pretty useless for 1-D because the horizontal line is on the X-axis.
+ break;
+
+ case symbol:
+ g_ptr.text(x, y + half_size, sty.symbols, size, "Lucida Sans Unicode"); // symbol(s), size and centre.
+ // TODO Need to provide way to set style.symbols when Boost.Parameter is unravelled.
+
+ // Unicode symbols that work on most browsers are listed at
+ // boost\math_toolkit\libs\math\doc\sf_and_dist\html4_symbols.qbk,
+ // http://www.htmlhelp.com/reference/html40/entities/symbols.html
+ // and http://www.alanwood.net/demos/ent4_frame.html
+ // The Unicode value in decimal 9830 or hex x2666 must be prefixed with & and terminated with ;
+ // for example &x2666; for xml
+ // and then enveloped with "" to convert to a std::string, for example: "&#x2666;" for diamond.
+
+ break;
+ case diamond:
+ g_ptr.text(x, y, "&#x2666;", size, "Lucida Sans Unicode");
+ // size / 4. puts bottom tip on the X-axis,
+ // size / 2. put center above the X-axis
+ // x, y, put on the X-axis - probably what is needed for 2-D plots.
+ // diamond, spades, clubs & hearts fill with expected fill_color.
+ break;
+ case asterisk:
+ g_ptr.text(x, y - size / 3., "&#x2217;", size, "Lucida Sans Unicode");
+ // asterisk is black filled.
+ // size /3 puts the bottom tip on the X-axis.
+ break;
+ case lozenge:
+ g_ptr.text(x, y - size / 3., "&#x25CA;", size, "Lucida Sans Unicode");
+ // size / 3 to get tip of lozenge just on the X-axis.
+ // lozenge seems not to fill?
+ break;
+ case club:
+ g_ptr.text(x, y, "&#x2663;", size, "Lucida Sans Unicode");
+ // x, y, puts club just on the X-axis
+ break;
+ case spade:
+ g_ptr.text(x, y, "&#x2660;", size, "Lucida Sans Unicode");
+ //
+ break;
+ case heart:
+ g_ptr.text(x, y , "&#x2665;", size, "Lucida Sans Unicode");
+ //
+ break;
+ case cone: // Pointing down triangle.
+ g_ptr.triangle(x - half_size, y - size, x + half_size, y - size, x, y, false);
+ // Last point puts the bottom tip of the triangle on the X-axis.
+ // This may not be wanted for 2-D.
+ break;
+ case cross:
+ g_ptr.line(x, y + size, x , y - size); // line up & down from axis,
+ g_ptr.line(x, y - size, x + size, y ); // & line left & right from axis.
+ // Cross is pretty useless for 1-D because the horizontal line is on the X-axis.
+
+ break;
+ // TODO Other point_shapes do nothing yet.
+ }
+ } // void draw_plot_point
+
+ // -----------------------------------------------------------------
+ // Clear Functions.
+ // When writing to multiple documents, the contents of the plot
+ // may change significantly between. Rather than figuring out what
+ // has and has not changed, just erase the contents of the
+ // legend, title... in the document and start over.
+ // -----------------------------------------------------------------
+
+ void clear_all()
+ {
+ clear_legend();
+ clear_background();
+ clear_x_axis();
+ clear_y_axis();
+ clear_title();
+ clear_points();
+ clear_plot_background();
+ clear_grids();
+ }
+
+ void clear_background()
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).clear();
+ }
+
+ void clear_title()
+ {
+ derived().image.get_g_element(PLOT_TITLE).clear();
+ }
+
+ void clear_points()
+ {
+ derived().image.get_g_element(PLOT_PLOT_POINTS).clear();
+ }
+
+ void clear_plot_background()
+ {
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).clear();
+ }
+
+ void clear_legend()
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).clear();
+ derived().image.get_g_element(PLOT_LEGEND_POINTS).clear();
+ derived().image.get_g_element(PLOT_LEGEND_TEXT).clear();
+ }
+
+ void clear_x_axis()
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).clear();
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).clear();
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).clear();
+ derived().image.get_g_element(PLOT_X_LABEL).clear();
+ derived().image.get_g_element(PLOT_PLOT_LABELS).clear();
+ }
+
+ void clear_y_axis()
+ {
+ derived().image.get_g_element(PLOT_Y_AXIS).clear();
+ }
+
+ void clear_grids()
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).clear();
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).clear();
+ }
 
 private:
- Derived& derived() { return static_cast<Derived&>(*this); }
- const Derived& derived()const{return static_cast<const Derived&>(*this); }
+ Derived& derived()
+ {
+ return static_cast<Derived&>(*this); // Why is cast required?
+ // error C2440: 'return' : cannot convert from 'boost::svg::detail::axis_plot_frame<Derived>' to 'boost::svg::svg_1d_plot &'
+ }
+ const Derived& derived()const
+ {
+ return static_cast<const Derived&>(*this);
+ }
 public:
-
- Derived& image_size(unsigned int x, unsigned int y)
- {
- derived().image.image_size(x, y);
- return derived();
- }
-
- Derived& title(const std::string& _title)
- {
- derived().title_info.text(_title);
- return derived();
- }
-
- Derived& title_font_size(unsigned int _size)
- {
- derived().title_info.font_size(_size);
- return derived();
- }
-
- Derived& legend_title_font_size(unsigned int _size)
- {
- derived().legend_title_size = _size;
- return derived();
- }
-
- Derived& legend_on(bool _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& plot_window_on(bool _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& x_external_style_on(bool _cmd)
- {
- derived().use_x_external_style = _cmd;
- return derived();
- }
-
- Derived& x_label_on(bool _cmd)
- {
- derived().use_x_label = _cmd;
- return derived();
- }
-
- Derived& x_major_labels_on(bool _cmd)
- {
- derived().use_x_major_labels = _cmd;
- return derived();
- }
-
- Derived& title_on(bool _cmd)
- {
- derived().use_title = _cmd;
- return derived();
- }
-
- Derived& x_major_grid_on(bool _is)
- {
- derived().use_x_major_grid = _is;
- return derived();
- }
-
- Derived& x_minor_grid_on(bool _is)
- {
- derived().use_x_minor_grid = _is;
- return derived();
- }
-
- Derived& axis_on(bool _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.
- //
- // title_color()
- // background_color()
- // legend_background_color()
- // plot_background_color()
- // axis_color()
- // x_major_tick_color()
- // x_minor_tick_color()
- // -----------------------------------------------------------------
-
- Derived& title_color(const svg_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& background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& legend_background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
-
- Derived& legend_border_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color(_col);
- return derived();
- }
-
- Derived& background_border_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
- return derived();
- }
-
- Derived& plot_background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_axis_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_AXIS).style().fill_color(_col);
- derived().image.get_g_element(PLOT_X_AXIS).style().stroke_color(_col);
- return derived();
- }
-
- Derived& x_major_tick_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color(_col);
- return derived();
- }
-
- Derived& x_label_color(const svg_color& _col)
- { // add fill as well PAB
- derived().image.get_g_element(PLOT_X_LABEL).style().fill_color(_col);
- derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color(_col);
- return derived();
- }
-
- Derived& x_minor_tick_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color(_col);
- return derived();
- }
-
- Derived& x_major_grid_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color(_col);
- return derived();
- }
-
- Derived& x_minor_grid_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color(_col);
- return derived();
- }
-
- // -----------------------------------------------------------------
- // Axis information: Settings for customization of axis information.
- //
- // 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& x_axis_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_label(const std::string& _str)
- {
- derived().x_label_info.text(_str);
- return derived();
- }
-
- Derived& y_label(const std::string& _str)
- { // Added PAB 17 Oct 07
- derived().y_label_info.text(_str);
- return derived();
- }
-
- Derived& x_major_interval(double _inter)
- {
- derived().x_major = _inter;
- return derived();
- }
-
- Derived& x_major_tick_length(unsigned int _length)
- {
- derived().x_major_length = _length;
- return derived();
- }
-
- Derived& x_major_tick_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_minor_tick_length(unsigned int _length)
- {
- derived().x_minor_length = _length;
- return derived();
- }
-
- Derived& x_minor_tick_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_num_minor_ticks(unsigned int _num)
- {
- derived().x_num_minor = _num;
- return derived();
- }
-
- Derived& x_range(double x1, double x2)
- {
- if(x2 <= x1)
- {
- throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
- }
-
- derived().x_min = x1;
- derived().x_max = x2;
-
- return derived();
- }
-
- Derived& load_stylesheet(const std::string& file)
- {
- derived().image.load_stylesheet(file);
- return derived();
- }
-
- // Get member functions:
-
- unsigned int get_image_x_size()
- {
- return derived().image.get_x_size();
- }
-
- unsigned int get_image_y_size()
- {
- return derived().image.get_x_size();
- }
-
- std::string get_title()
- {
- return derived().title;
- }
-
- unsigned int get_title_font_size()
- { // added pab
- return static_cast<unsigned int>(derived().title_font_size);
- }
-
- unsigned int get_legend_title_font_size()
- { // added static_cast
- return static_cast<unsigned int>(derived().legend_title_font_size);
- }
-
- bool get_legend()
- {
- return derived().use_legend;
- }
-
- bool get_plot_window()
- {
- return derived().use_plot_window;
- }
-
- bool get_x_label()
- {
- return derived().use_x_label;
- }
-
- bool get_x_major_labels()
- {
- return derived().use_x_major_labels;
- }
-
- // Color information.
- svg_color get_title_color()
- { // Function title_color sets both fill and stroke.
- return derived().image.get_g_element(PLOT_TITLE).style().stroke_color();
- }
-
- svg_color get_background_color()
- {
- return derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color();
- }
-
- svg_color get_background_border_color()
- {
- return derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color();
- }
-
- svg_color get_legend_background_color()
- {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color();
- }
-
- svg_color get_legend_border_color()
- {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color();
- }
-
- svg_color get_plot_background_color()
- {
- return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color();
- }
-
- svg_color get_x_axis_color()
- {
- return derived().image.get_g_element(PLOT_X_AXIS).style().stroke_color();
- }
-
- svg_color get_x_label_color()
- {
- return derived().image.get_g_element(PLOT_X_LABEL).style().fill_color();
- }
-
- svg_color get_x_major_tick_color()
- {
- return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color();
- }
-
- svg_color get_x_minor_tick_color()
- {
- return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color();
- }
-
- svg_color get_x_major_grid_color()
- {
- return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color();
- }
-
- svg_color get_x_minor_grid_color()
- {
- return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color();
- }
-
- // X-axis information.
- double get_x_min()
- {
- return derived().x_min;
- }
-
- double get_x_max()
- {
- return derived().x_max;
- }
-
- unsigned int get_x_axis_width()
- {
- return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_width();
- }
-
- double get_x_major_tick()
- {
- return derived().x_major;
- }
-
- unsigned int get_x_major_tick_length()
- {
- return derived().x_major_length;
- }
-
- unsigned int get_x_minor_tick_length()
- {
- return derived().x_minor_length;
- }
-
- unsigned int get_x_num_minor_ticks()
- {
- return derived().x_num_minor;
- }
-
- unsigned int get_x_major_tick_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).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;
- }
-};
+ // Set & get member function Declarations:
+ // See svg_fwd.hpp
+ // -----------------------------------------------------------------
+
+ // Get functions:
+ // =========== Image & plot window ==============
+ // Derived& image_size(unsigned int x, unsigned int y);
+ // unsigned int image_x_size();
+ // unsigned int image_y_size()
+ // bool plot_window_on()
+ // svg_color background_color()
+ // svg_color background_border_color()
+ // svg_color plot_background_color()
+ //
+ // std::pair<double, double> plot_window_x()
+ // std::pair<double, double> plot_window_y()
+
+ // ========= Title & legend ============
+ // bool title_on()
+ // const std::string title()
+ // unsigned int title_font_size()
+ // const std::string title_font()
+ // svg_color title_color()
+ // bool legend_on()
+ // const std::string legend_title()
+ // svg_color legend_background_color()
+ // svg_color legend_border_color()
+ // unsigned int legend_title_font_size()
+ // ========= Axes & Ticks ============
+ // bool x_axis_on()
+ // unsigned int x_axis_width()
+ // bool x_external_style_on()
+ // bool x_ticks_up_on()
+ // bool x_ticks_down_on()
+ // std::pair<double, double> x_range()
+ // double x_minimum()
+ // double x_maximum()
+ // double x_major_interval()
+ // unsigned int x_num_minor__ticks()
+ // double x_major_tick()
+ // svg_color x_major_tick_color()
+ // svg_color x_minor_tick_color()
+ // unsigned int x_major_tick_length()
+ // unsigned int x_major_tick_width_()
+ // unsigned int x_minor_tick_length_()
+ // unsigned int x_minor_tick_width_()
+ // ========= Labels ============
+ // bool x_label_on() // Show X-axis label text.
+ // std::string x_label()
+ // bool x_label_units_on() //
+ // std::string x_label_units() // Show X-axis units text.
+ // bool x_major_labels_on()
+ // svg_color x_label_color()
+ // bool axes_on()
+ // svg_color x_axis_color()
+ // bool y_axis_on()
+ // svg_color y_axis_color()
+ // std::string y_label()
+ // svg_color y_label_color()
+ // ========= grid ============
+ // bool x_major_grid_on()
+ // bool x_minor_grid_on()
+ // unsigned int x_major_grid_width()
+ // unsigned int x_minor_grid_width()
+ // svg_color x_major_grid_color()
+ // svg_color x_minor_grid_color()
+
+ // Set functions:
+
+//Derived& image_size(unsigned int x, unsigned int y)
+//Derived& image_x_size(unsigned int x);
+//Derived& image_y_size(unsigned int y);
+
+//Derived& title(const std::string& title)
+
+//Derived& document_title(const std::string&);
+//Derived& description(const std::string&);
+//Derived& copyright_date(const std::string&);
+//Derived& copyright_holder(const std::string&);
+
+//Derived& title_font_size(unsigned int size)
+//Derived& legend_title_font_size(unsigned int size)
+//Derived& legend_on(bool cmd)
+//Derived& plot_window_on(bool cmd)
+//Derived& plot_window_x(unsigned int min_x, unsigned int max_x)
+//Derived& plot_window_y(unsigned int min_y, unsigned int max_y)
+//Derived& x_external_style_on(bool cmd)
+//Derived& x_ticks_up_on(bool cmd)
+//Derived& x_ticks_down_on(bool cmd)
+//Derived& x_label_on(bool cmd)
+//Derived& x_label_units_on(bool cmd)
+//Derived& x_major_labels_on(bool cmd)
+//Derived& title_on(bool cmd)
+//Derived& x_major_grid_on(bool is)
+//Derived& x_minor_grid_on(bool is)
+//Derived& axes_on(bool is)
+//Derived& x_axis_on(bool is)
+//Derived& y_axis_on(bool is);
+//Derived& title_color(const svg_color& col)
+//Derived& background_color(const svg_color& col)
+//Derived& legend_background_color(const svg_color& col)
+//Derived& legend_border_color(const svg_color& col)
+//Derived& background_border_color(const svg_color& col)
+//Derived& plot_background_color(const svg_color& col)
+//Derived& x_axis_color(const svg_color& col)
+//Derived& y_axis_color(const svg_color& col)
+//Derived& x_label_color(const svg_color& col)
+//Derived& x_label_color(const svg_color& col)
+//Derived& y_label_color(const svg_color& col)
+//Derived& x_major_tick_color(const svg_color& col)
+//Derived& x_minor_tick_color(const svg_color& col)
+//Derived& x_major_grid_color(const svg_color& col)
+//Derived& x_major_grid_width(unsigned int w)
+//Derived& x_minor_grid_color(const svg_color& col)
+//Derived& x_minor_grid_width(unsigned int w)
+//Derived& x_axis_width(unsigned int width)
+//Derived& x_label(const std::string& str)
+//Derived& x_label_units(const std::string& str)
+//Derived& y_label(const std::string& str)
+//Derived& x_major_interval(double inter)
+//Derived& x_major_tick_length(unsigned int length)
+//Derived& x_major_tick_width_(unsigned int width)
+//Derived& x_minor_tick_length_(unsigned int length)
+//Derived& x_minor_tick_width_(unsigned)
+//Derived& x_major_tick(double d) int width)
+//Derived& x_num_minor_ticks(unsigned int num)
+//Derived& x_range(double min_x, double max_x)
+//Derived& x_minimum(double min_x)
+//Derived& x_maximum(double max_x)
+//Derived& load_stylesheet(const std::string& file)
+// svg& get_svg()
+
+// Shapes and glyphs need BOTH fill and stroke to be set.
+// Both are usually the same in this application.
+// If both are set, stroke is considered 'more important',
+// and so is returned by get functions.
+
+
+ // Member functions to set plot options.
+ // All return derived() == *this to permit chaining.
+
+ //-------------------------------------------------------
+
+ Derived& image_size(unsigned int x, unsigned int y)
+ { // Might put default sizes here?
+ // Might also alow to set x and y separately?
+ // Check on sanity of these values?
+ derived().image.image_size(x, y);
+ return derived();
+ }
+
+ unsigned int image_x_size()
+ {
+ return derived().image.x_size();
+ }
+
+ Derived& image_x_size(unsigned int i)
+ {
+ derived().image.x_size(i);
+ return derived();
+ }
+
+ unsigned int image_y_size()
+ {
+ return derived().image.y_size();
+ }
+
+ Derived& image_y_size(unsigned int i)
+ {
+ derived().image.y_size(i);
+ return derived();
+ }
+
+ Derived& description(const std::string d)
+ { // Writes description to the document(for header as <desc>).
+ derived().image.description(d);
+ return derived();
+ }
+
+ const std::string& description()
+ { // Gets description of the document(for header as <desc>).
+ return derived().image.description();
+ }
+
+ Derived& document_title(const std::string d)
+ { // Writes document title to the document(for header as <title>)..
+ derived().image.document_title(d);
+ return derived();
+ }
+ std::string document_title()
+ { // Get document title to the document(for header as <title>)..
+ return derived().image.document_title();
+ }
+
+ Derived& copyright_holder(const std::string d)
+ { // Writes copyright_holder to the document
+ // (for header as <!-- SVG Plot Copyright Paul A. Bristow 2007 --> )
+ // and as metadata: meta name="copyright" content="Paul A. Bristow" />
+ derived().image.copyright_holder(d);
+ return derived();
+ }
+
+ const std::string copyright_holder()
+ { // Get copyright_holder.
+ return derived().image.copyright_holder();
+ }
+
+ Derived& copyright_date(const std::string d)
+ { // Writes copyright_date to the document.
+ // and as metadata <meta name="date" content="2007" />
+ derived().image.copyright_date(d);
+ return derived();
+ }
+
+ const std::string copyright_date()
+ { // Get copyright_date.
+ return derived().image.copyright_date();
+ }
+
+ Derived& license(std::string repro, std::string distrib, std::string attrib, std::string commercial)
+ { // Might check these are "permits", "requires", or "prohibits"?
+ // Default is permits.
+ derived().image.license(repro, distrib, attrib, commercial);
+ return derived();
+ }
+
+ Derived& coord_precision(int digits)
+ { // Precision of coordinates in decimal digits (default 3).
+ derived().image.coord_precision(digits);
+ return derived();
+ }
+
+ int coord_precision()
+ { //
+ return derived().image.coord_precision();
+ }
+
+ Derived& title(const std::string title)
+ { // Plot title.
+ derived().title_info.text(title);
+ return derived();
+ }
+
+ const std::string title()
+ {
+ return derived().title_info.text();
+ }
+
+ Derived& title_font_size(unsigned int i)
+ {
+ derived().title_info.font_size(i);
+ return derived();
+ }
+
+ unsigned int title_font_size()
+ {
+ return derived().title_info.font_size();
+ }
+
+ Derived& title_font_family(const std::string& family)
+ {
+ derived().title_info.font_family(family);
+ return derived();
+ }
+
+ const std::string& title_font_family()
+ {
+ return derived().title_info.font_family();
+ }
+
+ Derived& title_font_style(const std::string& style)
+ {
+ derived().title_info.font_style(style);
+ return derived();
+ }
+
+ const std::string& title_font_style()
+ {
+ return derived().title_info.font_style();
+ }
+
+ Derived& title_font_weight(const std::string& weight)
+ {
+ derived().title_info.font_weight(weight);
+ return derived();
+ }
+
+ const std::string& title_font_weight()
+ {
+ return derived().title_info.font_weight();
+ }
+
+ Derived& title_font_stretch(const std::string& stretch)
+ {
+ derived().title_info.font_stretch(stretch);
+ return derived();
+ }
+
+ const std::string& title_font_stretch()
+ {
+ return derived().title_info.font_stretch();
+ }
+
+ Derived& title_font_decoration(const std::string& decoration)
+ {
+ derived().title_info.font_decoration(decoration);
+ return derived();
+ }
+
+ const std::string& title_font_decoration()
+ {
+ return derived().title_info.font_decoration();
+ }
+
+ Derived& title_font_rotation(int rotate)
+ { // Degrees (0 to 360).
+ derived().title_info.font_rotation(rotate);
+ return derived();
+ }
+
+ int title_font_rotation()
+ {
+ return derived().title_info.font_rotation();
+ }
+
+ Derived& title_font_alignment(align_style alignment)
+ {
+ derived().title_info.font_alignment(alignment);
+ return derived();
+ }
+
+ align_style title_font_alignment()
+ {
+ return derived().title_info.font_alignment();
+ }
+
+ Derived& legend_title(const std::string title)
+ {
+ derived().legend_header.text(title);
+ return derived();
+ }
+
+ const std::string legend_title()
+ {
+ return derived().legend_header.text();
+ }
+
+ Derived& legend_title_font_size(unsigned int size)
+ {
+ derived().legend_header.font_size(size);
+ return derived();
+ }
+
+ unsigned int legend_title_font_size()
+ {
+ return derived().legend_header.font_size();
+ }
+
+ Derived& line_on(bool is)
+ {
+ derived().use_line = is;
+ return derived();
+ }
+
+ bool line_on()
+ {
+ return derived().use_line;
+ }
+
+ Derived& legend_on(bool 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();
+ }
+
+ bool legend_on()
+ {
+ return derived().use_legend;
+ }
+
+ Derived& plot_window_on(bool cmd)
+ {
+ derived().use_plot_window = cmd;
+
+ if(cmd)
+ { // set plot window color and border color.
+ // TODO - allow user to change these.
+ derived().image.get_g_element(detail::PLOT_PLOT_BACKGROUND)
+ .style().fill_color(white)
+ .stroke_color(black);
+ }
+ return derived();
+ }
+
+ bool plot_window_on()
+ {
+ return derived().use_plot_window;
+ }
+
+ Derived& plot_window_x(unsigned int min_x, unsigned int max_x)
+ { // This is normally calculated from other plot values.
+ if(max_x <= min_x)
+ {
+ throw std::runtime_error("plot_window_x: X range: x_max < x_min");
+ }
+ derived().plot_x1 = min_x;
+ derived().plot_x2 = max_x;
+ return derived();
+ }
+
+ Derived& plot_window_y(unsigned int min_y, unsigned int max_y)
+ { // This is normally calculated from other plot values.
+ if(max_y <= min_y)
+ {
+ throw std::runtime_error("plot_window_y : Y range: y_max < y_min");
+ }
+ derived().plot_y1 = min_y;
+ derived().plot_y2 = max_y;
+ return derived();
+ }
+
+ std::pair<unsigned int, unsigned int> plot_window_x()
+ {
+ std::pair<unsigned int, unsigned int> r;
+ r.first = derived().plot_x1;
+ r.second = derived().plot_x2;
+ return r;
+ }
+
+ std::pair<unsigned int, unsigned int> plot_window_y()
+ {
+ std::pair<unsigned int, unsigned int> r;
+ r.first = derived().plot_y1;
+ r.second = derived().plot_y2;
+ return r;
+ }
+
+ Derived& x_ticks_up_on(bool cmd)
+ {
+ derived().use_up_ticks = cmd;
+ return derived();
+ }
+
+ bool x_ticks_up_on()
+ {
+ return derived().use_up_ticks;
+ }
+
+ Derived& x_ticks_down_on(bool cmd)
+ {
+ derived().use_down_ticks = cmd;
+ return derived();
+ }
+
+ bool x_ticks_down_on()
+ {
+ return derived().use_down_ticks;
+ }
+ // Only need y_ticks_left_on & y_ticks_right_on in 2D
+
+ Derived& x_label_on(bool cmd)
+ { // Show X-axis label text.
+ derived().use_x_label = cmd;
+ return derived();
+ }
+
+ bool x_label_on()
+ {
+ return derived().use_x_label;
+ }
+
+ Derived& x_label_font_size(unsigned int i)
+ { // TODO May be best to tie these two font sizes together?
+ derived().x_label_info.font_size(i);
+ derived().x_units_info.font_size(i);
+ return derived();
+ }
+
+ unsigned int x_label_font_size()
+ {
+ return derived().x_label_info.font_size();
+ }
+
+
+ Derived& x_label_font_family(const std::string& family)
+ {
+ derived().x_label_info.font_family(family);
+ return derived();
+ }
+
+ const std::string& x_label_font_family()
+ {
+ return derived().x_label_info.font_family();
+ }
+
+ Derived& x_axis_label_color(const svg_color& col)
+ { // Set BOTH stroke and fill to the same color.
+ image.get_g_element(detail::PLOT_X_LABEL).style().fill_color(col);
+ image.get_g_element(detail::PLOT_X_LABEL).style().stroke_color(col);
+ return *this;
+ }
+
+ svg_color x_axis_label_color()
+ { // But only return the stroke color.
+ return image.get_g_element(detail::PLOT_X_LABEL).style().stroke_color();
+ }
+
+ Derived& x_axis_value_color(const svg_color& col)
+ { // Set BOTH stroke and fill to the same color.
+ image.get_g_element(detail::PLOT_PLOT_LABELS).style().fill_color(col);
+ image.get_g_element(detail::PLOT_PLOT_LABELS).style().stroke_color(col);
+ return *this;
+ }
+
+ svg_color x_axis_value_color()
+ { // But only return the stroke color.
+ return image.get_g_element(detail::PLOT_PLOT_LABELS).style().stroke_color();
+ }
+
+ Derived& use_x_ticks_on_plot_window(bool cmd)
+ { // Was External style.
+ derived().use_x_ticks_on_plot_window_ = cmd;
+ return derived();
+ }
+
+ bool use_x_ticks_on_plot_window()
+ {
+ return derived().use_x_ticks_on_plot_window_;
+ }
+
+ Derived& x_label_units_on(bool cmd)
+ {
+ derived().use_x_label_units = cmd;
+ return derived();
+ }
+
+ bool x_label_units_on()
+ {
+ return derived().use_x_label_units;
+ }
+
+ Derived& x_major_labels_on(bool cmd)
+ {
+ derived().use_x_major_labels = cmd;
+ return derived();
+ }
+
+ bool x_major_labels_on()
+ {
+ return derived().use_x_major_labels;
+ }
+
+ Derived& title_on(bool cmd)
+ {
+ derived().use_title = cmd;
+ return derived();
+ }
+
+ bool title_on()
+ {
+ return derived().use_title;
+ }
+
+ Derived& x_major_grid_on(bool is)
+ {
+ derived().use_x_major_grid = is;
+ return derived();
+ }
+
+ bool x_major_grid_on()
+ {
+ return derived().use_x_major_grid;
+ }
+
+ Derived& x_minor_grid_on(bool is)
+ {
+ derived().use_x_minor_grid = is;
+ return derived();
+ }
+
+ bool x_minor_grid_on()
+ {
+ return derived().use_x_minor_grid;
+ }
+
+ Derived& axes_on(bool is)
+ { // Draw *both* x and y axes (note plural).
+ derived().use_x_axis_lines_ = is;
+ derived().use_y_axis_lines_ = is;
+ return derived();
+ }
+
+ bool axes_on()
+ { // Used X in preference to Y for 1D, but now require *both* x and y axis on.
+ return derived().use_x_axis_lines_ && derived().use_y_axis_lines_;
+ }
+
+ Derived& x_axis_on(bool is)
+ {
+ derived().use_x_axis_lines_ = is;
+ return derived();
+ }
+
+ bool x_axis_on()
+ { // Use X in preference to Y for 1D
+ return derived().use_x_axis_lines_;
+ }
+
+ Derived& y_axis_on(bool is)
+ {
+ derived().use_x_axis_lines_ = is;
+ return derived();
+ }
+
+ bool y_axis_on()
+ { // Should be always false for 1D.
+ return derived().use_x_axis_lines_;
+ }
+
+ // enums like PLOT_TITLE provide a std:string like "title"
+ // colors .stroke_color, .stroke_width and font are set in the appropriate g_element.
+
+ Derived& title_color(const svg_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();
+ }
+
+ svg_color title_color()
+ { // Function title_color sets both fill and stroke,
+ // but stroke (outside) is considered 'more important'.
+ return derived().image.get_g_element(PLOT_TITLE).style().stroke_color();
+ }
+
+ Derived& background_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(col);
+ return derived();
+ }
+
+ svg_color background_color()
+ {
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color();
+ }
+
+ Derived& legend_background_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color(col);
+ return derived();
+ }
+
+ svg_color legend_background_color()
+ {
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color();
+ }
+
+ Derived& legend_border_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color legend_border_color()
+ {
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color();
+ }
+
+ Derived& background_border_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color background_border_color()
+ {
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color();
+ }
+
+ Derived& plot_background_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(col);
+ return derived();
+ }
+
+ svg_color plot_background_color()
+ {
+ return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color();
+ }
+
+ Derived& x_axis_color(const svg_color& col)
+ { // Note BOTH fill and stroke color are set (and are the same).
+ // stroke is the outside of any character, fill the center color.
+ // TODO But the axis is only a line, so set both for tidyness?
+ derived().image.get_g_element(PLOT_X_AXIS).style().fill_color(col);
+ derived().image.get_g_element(PLOT_X_AXIS).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_axis_color()
+ { // Assumes that fill and stroke colors are the same.
+ return derived().image.get_g_element(PLOT_X_AXIS).style().stroke_color();
+ }
+
+ Derived& y_axis_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_Y_AXIS).style().fill_color(col);
+ derived().image.get_g_element(PLOT_Y_AXIS).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color y_axis_color()
+ {
+ return derived().image.get_g_element(PLOT_Y_AXIS).style().stroke_color();
+ }
+
+ Derived& x_label_color(const svg_color& col)
+ { // add fill as well PAB Oct 07
+ derived().image.get_g_element(PLOT_X_LABEL).style().fill_color(col);
+ derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_label_color()
+ {
+ return derived().image.get_g_element(PLOT_X_LABEL).style().fill_color();
+ }
+
+ Derived& y_label_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_Y_LABEL).style().fill_color(col);
+ derived().image.get_g_element(PLOT_Y_LABEL).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color y_label_color()
+ {
+ return derived().image.get_g_element(PLOT_Y_LABEL).style().fill_color();
+ }
+
+ Derived& x_major_tick_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_major_tick_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color();
+ }
+
+ Derived& x_minor_tick_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_minor_tick_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color();
+ }
+
+ Derived& x_major_grid_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_major_grid_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color();
+ }
+
+ Derived& x_major_grid_width(unsigned int w)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_width(w);
+ return derived();
+ }
+
+ unsigned int x_major_grid_width()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_width();
+ }
+
+ Derived& x_minor_grid_color(const svg_color& col)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color(col);
+ return derived();
+ }
+
+ svg_color x_minor_grid_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color();
+ }
+
+ Derived& x_minor_grid_width(unsigned int w)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_width(w);
+ return derived();
+ }
+
+ unsigned int x_minor_grid_width()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_width();
+ }
+
+ Derived& x_axis_width(unsigned int width)
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width(width);
+ return derived();
+ }
+
+ unsigned int x_axis_width()
+ {
+ return derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width();
+ }
+
+ Derived& x_label(const std::string& str)
+ {
+ derived().x_label_info.text(str);
+ return derived();
+ }
+
+ std::string x_label()
+ {
+ return derived().x_label_info.text();
+ }
+
+ Derived& x_label_units(const std::string& str)
+ {
+ derived().x_units_info.text(str);
+ return derived();
+ }
+
+ std::string x_label_units()
+ {
+ return derived().x_units_info.text();
+ }
+
+ // y_label not needed in 1D.
+ Derived& y_label(const std::string& str)
+ {
+ derived().y_label_info.text(str);
+ return derived();
+ }
+
+ std::string y_label()
+ {
+ return derived().y_label_info.text();
+ }
+
+ Derived& x_major_interval(double inter)
+ {
+ derived().x_major = inter;
+ return derived();
+ }
+
+ double x_major_interval()
+ {
+ return derived().x_major;
+ }
+
+ Derived& x_major_tick_length(unsigned int length)
+ {
+ derived().x_major_tick_length_ = length;
+ return derived();
+ }
+
+ unsigned int x_major_tick_length()
+ {
+ return derived().x_major_tick_length_;
+ }
+
+ Derived& x_major_tick_width(unsigned int width)
+ {
+ derived().x_major_tick_width_ = width; // Redundant?
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(width);
+ return derived();
+ }
+
+ unsigned int x_major_tick_width()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width();
+ }
+
+ Derived& x_minor_tick_length(unsigned int length)
+ {
+ derived().x_minor_tick_length_ = length;
+ // TODO ?? derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(width);
+ return derived();
+ }
+
+ unsigned int x_minor_tick_length()
+ {
+ return derived().x_minor_tick_length_;
+ }
+
+ Derived& x_minor_tick_width(unsigned int width)
+ {
+ derived().x_minor_tick_width_ = width;
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(width);
+ return derived();
+ }
+
+ unsigned int x_minor_tick_width()
+ {
+ // return derived().x_minor_tick_width_; // should be the same but store in stroke_width is definitive.
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width();
+ }
+
+ Derived& x_major_tick(double d)
+ { // Interval (Cartesian units) between major ticks.
+ derived().x_major = d;
+ }
+
+ double x_major_tick()
+ { // Interval (Cartesian units) between major ticks.
+ return derived().x_major;
+ }
+
+ Derived& x_num_minor_ticks(unsigned int num)
+ {
+ derived().x_num_minor_ticks_ = num;
+ return derived();
+ }
+
+ unsigned int x_num_minor_ticks()
+ {
+ return derived().x_num_minor_ticks_;
+ }
+
+ Derived& x_range(double min_x, double max_x)
+ {
+ if(max_x <= min_x)
+ {
+ throw std::runtime_error("Illegal Argument: X range: x_max < x_min");
+ }
+ derived().x_min = min_x;
+ derived().x_max = max_x;
+ return derived();
+ }
+
+ std::pair<double, double> x_range()
+ {
+ std::pair<double, double> r;
+ r.first = derived().x_min;
+ r.second = derived().x_max;
+ return r;
+ }
+
+ // Can't use names x_min or x_max because clashes
+ // with class svg_1d_plot variable x_min & x_max,
+ // so use longer x_minimum, x_maximum ...
+ Derived& x_minimum(double min_x)
+ {
+ // Can't check here that x_max > x_min because may not have set x_max yet.
+ // TODO check that there is another check somewhere.
+ derived().x_min = min_x;
+ return derived();
+ }
+
+ double x_minimum()
+ {
+ return derived().x_min;
+ }
+
+ Derived& x_maximum(double x)
+ {
+ // Can't check here that x_max > x_min because may not have set x_min yet.
+ // TODO check that there is another check somewhere.
+ derived().x_max = x;
+ return derived();
+ }
+
+ double x_maximum()
+ {
+ return derived().x_max;
+ }
+
+ // Stylesheet.
+
+ Derived& load_stylesheet(const std::string& file)
+ {
+ derived().image.load_stylesheet(file);
+ return derived();
+ }
+
+ // Image info (& identical const version).
+
+ svg& get_svg()
+ {
+ derived()._update_image();
+ return derived().image;
+ }
+
+ const svg& get_svg() const
+ {
+ derived()._update_image();
+ return derived().image;
+ }
+}; // template <class Derived> class axis_plot_frame
 
 } // detail
 } // svg
 } // boost
 
-#endif
+#endif // BOOST_SVG_AXIS_PLOT_FRAME_HPP

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,18 +1,22 @@
 // functors.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_DETAIL_FUNCTORS_HPP
-#define _BOOST_SVG_DETAIL_FUNCTORS_HPP
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+// -----------------------------------------------------------------
+
+#ifndef BOOST_SVG_DETAIL_FUNCTORS_HPP
+#define BOOST_SVG_DETAIL_FUNCTORS_HPP
 
 namespace boost {
 namespace svg {
 namespace detail {
 
 // -----------------------------------------------------------------
-// This functor allows any data convertible to doubles to be plotted
+// This functor allows any data convertible to doubles to be plotted.
 // -----------------------------------------------------------------
 class boost_default_convert
 {
@@ -24,7 +28,7 @@
     {
         return (double)val;
     }
-};
+}; // class boost_default_convert
 
 // -----------------------------------------------------------------
 // This functor allows any data convertible to type
@@ -34,12 +38,11 @@
 {
 public:
     typedef std::pair<double, double> result_type;
-
     double i;
 
- void start(double _i)
+ void start(double i)
     {
- i = _i;
+ i = i;
     }
 
     template <class T, class U>
@@ -53,10 +56,10 @@
     {
         return std::pair<double, double>(i++, (double)a);
     }
-};
+}; // class boost_default_2d_convert
 
-}
-}
-}
+} // namespace detail
+} // namespace svg
+} // namespace boost
 
-#endif
+#endif // BOOST_SVG_DETAIL_FUNCTORS_HPP

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,21 +1,45 @@
 // numeric_limits_handling.hpp
 
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-// -----------------------------------------------------------------
+// Copyright Jacob Voytko 2007
+// Copyright Paul A. Bristow 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+// -----------------------------------------------------------------
 
 #ifndef BOOST_SVG_NUMERIC_LIMITS_HANDLING_DETAIL_HPP
 #define BOOST_SVG_NUMERIC_LIMITS_HANDLING_DETAIL_HPP
 
+#include <boost\math\special_functions\fpclassify.hpp>
+
+// TODO use the boost version instead to be more portable?
+// Since only double is used, template versions are not needed,
+// and TR1 should provide max, min, denorm_min, infinity and isnan,
+// but older comilers and libraries may not provide all these.
+
+// using boost::math::fpclassify
+// boost::math::
+// template <class T>bool isfinite (T);
+// template <class T>bool isinf (T);
+// template <class T> bool isnan (T);
+
 #include <limits>
-using std::numeric_limits;
-#include <cmath>
+ // using std::numeric_limits;
+#include <cmath> // Why?
+
 
-namespace boost{
-namespace svg{
-namespace detail{
+// Allows NaNs to be displayed differently from just too big or too small values.
+
+namespace boost
+{
+namespace svg
+{
+namespace detail
+{
+ // Provide checks on data values to be plotted.
+ // Test if at max or +infinity, or min or - infinity, or NaN.
 
 inline bool limit_max(double a)
 {
@@ -31,23 +55,22 @@
 }
 
 inline bool limit_NaN(double a)
-{
- // Ternary operator used to remove warning of casting int to bool.
- // TODO there is a better way of doing this in the Math Toolkit.
+{ // Separate test for NaNs.
 #if defined (BOOST_MSVC)
     return _isnan(a) ? true : false;
+ // Ternary operator used to remove warning of casting int to bool.
 #else
- return std::fpclassify(a) == FP_NAN;
+ return (std::fpclassify(a) == FP_NAN);
 #endif
 }
 
 inline bool is_limit(double a)
-{
+{ // Is at some limit -
     return limit_max(a) || limit_min(a) || limit_NaN(a);
 }
 
 inline bool pair_is_limit(std::pair<double, double> a)
-{
+{ // Check on both x and y data points.
         return limit_max(a.first) || limit_min(a.first) || limit_NaN(a.first)
         || limit_max(a.second) || limit_min(a.second) || limit_NaN(a.second);
 }
@@ -55,4 +78,13 @@
 } // namespace detail
 } // namespace svg
 } // namespace boost
+
+
+// Defines :
+bool boost::svg::detail::limit_max(double); // true if max or +infinity.
+bool boost::svg::detail::limit_min(double); // true if min or -infinity.
+bool boost::svg::detail::limit_NaN(double); // true if NaN.
+bool boost::svg::detail::is_limit(double); // max, min, infinity or NaN - not a proper data value.
+bool boost::svg::detail::pair_is_limit(std::pair<double, double>); // x and/or y not a proper data value.
+
 #endif // BOOST_SVG_NUMERIC_LIMITS_HANDLING_DETAIL_HPP

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,24 +1,30 @@
-// svg_boxplot_detail.hpp
-// Copyright (C) Jacob Voytko 2007
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-// -----------------------------------------------------------------
+// svg_boxplot_detail.hpp
 
-#ifndef _BOOST_SVG_BOXPLOT_DETAIL_HPP
-#define _BOOST_SVG_BOXPLOT_DETAIL_HPP
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SVG_BOXPLOT_DETAIL_HPP
+#define BOOST_SVG_BOXPLOT_DETAIL_HPP
 
 namespace boost{
 namespace svg{
 namespace boxplot{
 
-enum boxplot_doc_structure{BACKGROUND, PLOT_BACKGROUND,
+enum boxplot_doc_structure
+{
+ BACKGROUND, PLOT_BACKGROUND,
     Y_MAJOR_TICKS, Y_MINOR_TICKS,
     X_TICKS, PLOT_LABELS, Y_LABEL, X_LABEL,
     BOX_AXIS, BOX, MEDIAN, WHISKER, MILD_OUTLIERS, EXTREME_OUTLIERS,
- TITLE, BOXPLOT_DOC_CHILDREN};
+ TITLE, BOXPLOT_DOC_CHILDREN
+};
 
-}
-}
-}
+} // namespace boxplot
+} // namespace svg
+} // namespace boost
 
-#endif
+#endif // BOOST_SVG_BOXPLOT_DETAIL_HPP

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,40 +1,71 @@
-// 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
+// svg_style.hpp
+
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 // -----------------------------------------------------------------
 
-#ifndef _BOOST_SVG_SVG_STYLE_DETAIL_HPP
-#define _BOOST_SVG_SVG_STYLE_DETAIL_HPP
+#ifndef BOOST_SVG_SVG_STYLE_DETAIL_HPP
+#define BOOST_SVG_SVG_STYLE_DETAIL_HPP
 
 #include <string>
+// using std::string;
 
-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_LIMIT_POINTS,
- PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
- PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
+// This module provides an id string from named parameter
+// so, for example, document_ids[PLOT_BACKGROUND] == "background".
+
+namespace boost
+{
+namespace svg
+{
+namespace detail
+{
 
-std::string _document_ids[]=
+// Caution: these two enum and ids must match because
+// the enum value is used to index the array of id strings.
+// void set_ids() copies all strings to matching image.get_g_element(i).id()
+// Add any new id items to both!
+enum plot_doc_structure
 {
- "background", "plotBackground", "yMinorGrid", "yMajorGrid",
- "xMinorGrid", "xMajorGrid", "yAxis", "xAxis", "yMinorTicks",
- "xMinorTicks", "yMajorTicks", "xMajorTicks", "plotLabels",
- "yLabel", "xLabel", "plotLines", "plotPoints", "limitPoints",
- "legendBackground", "legendPoints", "legendText", "title"
+ PLOT_BACKGROUND = 0, // Must be zero to index array document_ids[]
+ // TODO better PLOT_IMAGE_BACKGROUND ?
+ PLOT_PLOT_BACKGROUND, // 1
+ // TODO better PLOT_WINDOW_BACKGROUND ??? Maybe OK?
+ PLOT_Y_MINOR_GRID, PLOT_Y_MAJOR_GRID, // 2, 3
+ 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, // tick values 10, 20, 30 ...
+ PLOT_Y_LABEL, PLOT_X_LABEL,
+ PLOT_PLOT_LINES, PLOT_PLOT_POINTS, PLOT_LIMIT_POINTS,
+ PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
+ PLOT_TITLE,
+ SVG_PLOT_DOC_CHILDREN // Last enum value used as count of children (22).
 };
-
-}
 
-}
-}
-#endif
+std::string document_ids[]= // TODO change to document_ids_ because private member data.
+{ //
+ "background", // TODO "imageBackground" better?
+ "plotBackground",
+ "yMinorGrid", "yMajorGrid",
+ "xMinorGrid", "xMajorGrid",
+ "yAxis", "xAxis",
+ "yMinorTicks", "xMinorTicks",
+ "yMajorTicks", "xMajorTicks",
+ "plotLabels", // TODO tickValueLabels better name???
+ "yLabel", "xLabel",
+ "plotLines", "plotPoints", "limitPoints",
+ "legendBackground", "legendPoints", "legendText",
+ "title",
+ "plotDocChildren" // This last string is not used.
+}; // std::string document_ids
+
+} // namespace detail
+} // namespace svg
+} // namespace boost
+#endif // BOOST_SVG_SVG_STYLE_DETAIL_HPP

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-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,15 +1,21 @@
 // svg_tag.hpp
 
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
+// Copyright Jacob Voytko 2007
+// Copyright Paul A Bristow 2007
 
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 // -----------------------------------------------------------------
 
 #ifndef BOOST_SVG_TAG_HPP
 #define BOOST_SVG_TAG_HPP
 
+// -------------------------------------------------------------------------------
+// This file svg_tag.hpp defines all classes that can occur in the SVG parse tree.
+// -------------------------------------------------------------------------------
+
 #if defined (BOOST_MSVC)
 # pragma warning(push)
 # pragma warning(disable: 4127) // "conditional expression is constant."
@@ -18,665 +24,1265 @@
 #endif
 
 #include <boost/ptr_container/ptr_container.hpp>
+// using boost::vec_ptr;
+#include <boost/array.hpp>
+// using boost::array;
+
 #include "../svg_style.hpp"
 
-#include <sstream>
+#include <ostream>
+// using std::ostream;
 #include <string>
+// using std::string;
+#include <vector>
+// using std::vector;
 
 #if defined (BOOST_MSVC)
 # pragma warning(pop)
 #endif
 
-namespace boost {
-namespace svg {
-
-// -----------------------------------------------------------------
-// This file defines all classes that can occur in the SVG parse tree.
-// -----------------------------------------------------------------
-
-// -----------------------------------------------------------------
-// The base class for all leaf elements
-// -----------------------------------------------------------------
-
-class svg_element
+namespace boost
 {
-protected:
- svg_style style_info;
- std::string id_name;
- std::string clip_name;
+namespace svg
+{
+ // Forward declarations of classes defined in this module.
+ // Copied to svg_fwd.hpp TODO delete?
+
+ class svg_element; // svg_element is base class for:
+ // g_element (group element)
+ // rect_element, circle_element, line_element, text_element,
+ // polyline_element, polygon_element, path_element, clip_path_element,
+ class text_element; // text with position, size, font, (& styles) & orientation.
+ class rect_element; // clipping path restricts the region to which paint can be applied.
+ class circle_element; // Represents a single circle.
+ class ellipse_element; // Represents a single ellipse.
+ class line_element; // Represents a single line.
+ struct path_point; // Base class for m_path, z_path, q_path, h_path, v_path, c_path, s_path.
+ struct poly_path_point; // for polyline & polygon
+ class polygon_element; // closed shape consisting of a set of connected straight line segments.
+ class polyline_element; // a set of connected straight line segments.
+ class path_element; // d= moveto, lineto...
+ class clip_path_element; // Restricts the region to which paint can be applied.
+ struct m_path; // moveto coordinates (x, y), outputs "M1.2,3.4"
+ struct l_path; // lineto coordinates (x, y).
+ struct z_path; // z indicates a closepath.
+ struct h_path; // Draws a horizontal line from the current point (cpx, cpy) to (x, cpy).
+ struct v_path; // Draws a vertical line from the current point (cpx, cpy) to (cpx, y).
+ struct c_path; // Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1).
+ struct q_path; // Draws a quadratic Bézier curve from the current point to (x,y).
+ struct s_path; // Draws a cubic Bézier curve from the current point to (x,y).
+ struct t_path; // Draws a quadratic Bézier curve from the current point to (x,y).
+ struct a_path; // Draws a elliptical arc from the current point to (x,y).
+ struct P_path; // Adds another (absolute) point to a polyline or polygon.
+ class g_element; // 'g' element is a container element, <g ... /> </g>
+ // for grouping together related graphics elements, for example:
+ // <g stroke="rgb(255,0,0)" <rect x="0" y="0" width="500" height="600"/> </g>
+
+ // -----------------------------------------------------------------------------
+ // svg_element is base class for all the leaf elements:
+ // rect_element, circle_element, line_element, text_element,
+ // polygon_element, polyline_element, path_element, clip_path_element, g_element
+ // g_element ('g' element is a container element
+ // for grouping together related graphics elements).
+ // http://www.w3.org/TR/SVG/struct.html#NewDocument 5.2.1 Overview
+ // -----------------------------------------------------------------------------
+
+ class svg_element
+ { // Base class
+ protected:
+ svg_style style_info; // fill, stroke, width, get by function style.
+ std::string id_name; // set & get by function id.
+ std::string clip_name; // set & get by function clip_id.
 
     void write_attributes(std::ostream& s_out)
- {
- if(id_name.size())
- {
- s_out << " id=\"" << id_name << "\"";
- }
-
- if(clip_name.size())
- {
- s_out << " clip-path=\"url(#" << clip_name << ")\"";
- }
- }
+ { // group_element id and clip-path.
+ if(id_name.size() != 0)
+ {
+ s_out << " id=\"" << id_name << "\""; // Prefix with space.
+ }
+ if(clip_name.size() != 0)
+ {
+ s_out << " clip-path=\"url(#" << clip_name << ")\""; // Prefix with space.
+ }
+ // Other references, 5.3.1, like color, fill, stroke, gradients...
+ // Example id: <g id="yMinorGrid" ></g>
+ // Example URI: fill="url(#Gradient01) // local URL
+ } // void write_attributes(std::ostream& s_out)
 
-public:
+ public:
     virtual void write(std::ostream& rhs) = 0;
-
     virtual ~svg_element()
     {
-
     }
 
- 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 id_name; }
-
- void clip_id(const std::string& _id) { clip_name = _id; }
- std::string clip_id() { return clip_name; }
-}; // class svg_element
-
-// -----------------------------------------------------------------
-// Represents a single block of text.
-// -----------------------------------------------------------------
-class rect_element: public svg_element
-{
-private:
- double x, y, height, width;
-
-public:
+ bool operator==(const svg_element& lhs)
+ { // might be useful for Boost.Test.
+ return lhs.id_name == id_name;
+ }
 
- rect_element(double _x, double _y, double _w, double _h)
- :x(_x), y(_y), width(_w), height(_h)
+ // Set and get member functions.
+ svg_style& style()
     {
+ return style_info;
+ }
 
+ const svg_style& style() const
+ { // const version.
+ return style_info;
     }
 
- void write(std::ostream& rhs)
- {
- rhs << "<rect ";
- write_attributes(rhs);
- rhs << " x=\""<<x<<"\""
- <<" y=\""<<y<<"\" "
- <<" width=\""<<width<<"\" "
- <<" height=\""<<height<<"\"/>"
- ;
+ void id(const std::string& id)
+ { // Unique name for an element.
+ // http://www.w3.org/TR/SVG/struct.html#IDAttribute
+ // 5.10.1 Attributes common to all elements: id and xml:base
+ // The id and xml:base attributes are available on all SVG elements:
+ // Attribute definitions:
+ // id = "name"
+ // Standard XML attribute for assigning a unique name to an element.
+ // Refer to the "Extensible Markup Language (XML) 1.0" Recommendation [XML10].
+ // xml:base = "<uri>"
+ // Specifies a base URI other than the base URI of the document or external entity.
+ // Refer to the "XML Base" specification [XML-BASE].
+ // A group of elements, as well as individual objects,
+ // can be given a name using the id attribute.
+ // Named groups are needed for several purposes such as animation and re-usable objects.
+ id_name = id;
+ // Example: id="plotBackground"
     }
-}; // class rect_element
 
-// -----------------------------------------------------------------
-// Represents a single circle.
-// -----------------------------------------------------------------
-class circle_element: public svg_element
-{
-private:
- double x, y, radius;
+ std::string id()
+ { // Unique name for an element.
+ return id_name;
+ }
 
-public:
- circle_element(double _x, double _y, double _radius = 5):x(_x), y(_y),
- radius(_radius)
- {
+ void clip_id(const std::string& id)
+ { // Named clip, for example: g_ptr.clip_id(plot_window_clip);
+ clip_name = id;
     }
 
- void write(std::ostream& rhs)
+ std::string clip_id()
     {
- rhs<<"<circle";
- write_attributes(rhs);
- rhs<<" cx=\""
- <<x<<"\" cy=\""
- <<y<<"\" r=\""
- <<radius<<"\"/>";
+ return clip_name;
     }
-}; // class circle_element
+ }; // class svg_element
 
-// -----------------------------------------------------------------
-// Represents a line
-// -----------------------------------------------------------------
-class line_element: public svg_element
-{
-private:
- double x1, x2, y1, y2, y;
+ // Derived elements whose write member functions
+ // output SVG XML for line, circle, rectangle, text...
+ // Reminder: Within a literal C string, \" is needed to output a " ;-)
+
+ // -----------------------------------------------------------------
+ // Represents a line
+ // -----------------------------------------------------------------
+ class line_element: public svg_element
+ {
+ private:
+ double x1; // Line from (x1, x2) to (y1, y2)
+ double x2;
+ double y1;
+ double y2;
 
-public:
- line_element(double _x1, double _y1, double _x2,
- double _y2):x1(_x1), y1(_y1),
- x2(_x2), y2(_y2)
+ public:
+ line_element(double x1, double y1, double x2, double y2)
+ : x1(x1), y1(y1), x2(x2), y2(y2)
     {
     }
 
     void write(std::ostream& rhs)
     {
- rhs<<"<line x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
- <<y2<<"\"/>";
+ rhs << "<line x1=\"" << x1 << "\" y1=\"" << y1
+ << "\" x2=\"" << x2 << "\" y2=\"" << y2 << "\"/>";
+ // Example: <line x1="5" y1="185" x2="340" y2="185"/>
     }
-}; // class line_element
+ }; // class line_element
+ // --------------------------------------------------
+ // class rect_element; Represents a single rectangle.
+ // --------------------------------------------------
 
-// -----------------------------------------------------------------
-// Represents a single block of text
-// -----------------------------------------------------------------
-enum text_style{left_align, right_align, center_align};
+ class rect_element : public svg_element
+ {
+ friend bool operator==(const rect_element&, const rect_element&);
+ friend bool operator!=(const rect_element&, const rect_element&);
 
-class text_element: public svg_element
-{
-private:
- double x_coord, y_coord;
- int size;
- std::string txt;
- text_style align;
- int rotation;
+ private:
+ double x_;
+ double y_;
+ double height_;
+ double width_;
+ public:
 
-public:
- void alignment(text_style _a)
- {
- align = _a;
+ rect_element(double x, double y, double w, double h)
+ : x_(x), y_(y), width_(w), height_(h)
+ { // Constructor defines all private data (no defaults).
     }
 
- int font_size() const
+ double x() const
     {
- return size;
+ return x_;
     }
 
- void rotate(int val)
+ double y() const
     {
- rotation = val;
+ return y_;
     }
 
- int rotate() const
+ double width() const
     {
- return rotation;
+ return width_;
     }
 
- double x(double _x)
+ double height() const
     {
- x_coord = _x;
+ return height_;
     }
 
- double y(double _y)
- {
- y_coord = _y;
+ void write(std::ostream& rhs)
+ { // SVG xml
+ rhs << "<rect";
+ write_attributes(rhs); // id (& clip_path)
+ rhs << " x=\"" << x_ << "\""
+ << " y=\"" << y_ << "\""
+ << " width=\"" << width_ << "\""
+ << " height=\""<< height_<< "\"/>";
+ // For example: <rect x="0" y="0" width="500" height="350"/>
+ }
+
+ bool operator==(const rect_element& lhs)
+ { // Useful for Boost.Test.
+ return (lhs.x() == x_) && (lhs.y() == y_) && (lhs.width() == width_) && (lhs.height() == height_);
+ }
+ bool operator!=(const rect_element& lhs)
+ {
+ return (lhs.x() != x_) || (lhs.y() != y_) || (lhs.width() != width_) || (lhs.height() != height_);
+ }
+ }; // class rect_element
+
+ bool operator==(const rect_element& lhs, const rect_element& rhs)
+ { //
+ return (lhs.x() == rhs.x()) && (lhs.y() == rhs.y()) && (lhs.width() == rhs.width()) && (lhs.height() == rhs.height());
+ }
+
+ bool operator!=(const rect_element& lhs, const rect_element& rhs)
+ { //
+ return (lhs.x() != rhs.x()) || (lhs.y() == rhs.y()) || (lhs.width() == rhs.width()) || (lhs.height() == rhs.height());
+ }
+
+ std::ostream& operator<< (std::ostream& os, const rect_element& r)
+ { //
+ os << "rect(" << r.x() << ", " << r.y()
+ << ", " << r.width() << ", " << r.height() << ")" ;
+ // Usage: rect_element r(20, 20, 50, 50); cout << r << endl;
+ // Outputs: rect(20, 20, 50, 50)
+ return os;
+ } // std::ostream& operator<<
+
+ // -----------------------------------------------------------------
+ // class circle_element Represents a single circle.
+ // -----------------------------------------------------------------
+ class circle_element : public svg_element
+ {
+ private:
+ double x;
+ double y;
+ double radius;
+ public:
+ circle_element(double x, double y, double radius = 5)
+ : x(x), y(y), radius(radius)
+ { // Define all private data.
     }
 
- text_element(double _x, double _y, std::string _text, int _size = 12,
- text_style _align = center_align, int _rotation = 0)
- :x_coord(_x), y_coord(_y), txt(_text), size(_size), align(_align)
- , rotation(_rotation)
+ void write(std::ostream& rhs)
     {
-
+ rhs << "<circle";
+ write_attributes(rhs);
+ rhs << " cx=\"" << x << "\" cy=\"" << y << "\" r=\"" << radius << "\"/>";
+ // Example: <circle cx="9.78571" cy="185" r="5"/>
+ }
+ }; // class circle_element
+
+
+ // -----------------------------------------------------------------
+ // Represents a single ellipse.
+ // -----------------------------------------------------------------
+ class ellipse_element : public svg_element
+ { // http://www.w3.org/TR/SVG/shapes.html#EllipseElement
+ // 9.4 The 'ellipse' element.
+ private:
+ double cx; // coordinate x of center of ellipse, default 0
+ double cy; // coordinate y, default 0
+ double rx; // radius x
+ double ry; // radius x
+ public:
+ ellipse_element(double cx, double cy, double rx = 4, double ry = 8)
+ : cx(cx), cy(cy), rx(rx), ry(ry)
+ { // Define all private data.
     }
 
     void write(std::ostream& rhs)
     {
- std::string output;
-
- switch(align)
- {
- case left_align:
- output = "start";
- break;
-
- case right_align:
- output = "end";
- break;
-
- case center_align:
- output = "middle";
- break;
-
- default:
- output = "";
- break;
- }
-
- rhs << "<text x=\"" << x_coord << "\""
- <<" y=\"" << y_coord << "\" ";
-
- if(output != "")
- {
- rhs << "text-anchor=\"" << output << "\" ";
- }
-
- if(rotation != 0)
- {
- rhs << "transform = \"rotate("
- << rotation << " "
- << x_coord << " "
- << y_coord << " )\" ";
- }
-
- rhs << " font-family=\"verdana\"";
-
- if(size == 0)
- {
- rhs << " font-size=\"12\">";
- }
-
- else
- {
- rhs << " font-size=\"" << size << "\">";
- }
-
- rhs << txt
- <<" </text>";
+ rhs << "<ellipse";
+ write_attributes(rhs);
+ rhs << " cx=\"" << cx << "\" cy=\"" << cy << "\""
+ << " rx=\"" << rx << "\" ry=\"" << ry << "\"/>";
+ // Example: <ellipse rx="250" ry="100" fill="red" />
     }
+ }; // class ellipse_element
 
- void font_size(unsigned int _size) { size = _size; }
- void text(const std::string& _txt) { txt = _txt; }
 
- std::string text()
- {
- return txt;
- }
-}; // class text_element
 
-class clip_path_element: public svg_element
-{
-private:
- std::string element_id;
- rect_element rect;
+ // ----------------------------------------------------------------------
+ // text_element Represents a single block of text, with font & alignment.
+ // ----------------------------------------------------------------------
+ enum align_style
+ {
+ left_align, right_align, center_align
+ };
 
-public:
+ enum rotate_style
+ { // Rotation in degrees from horizontal.
+ horizontal = 0, // normal left to right.
+ upward = -90, // vertical writing up.
+ downward = 90, // vertical writing down.
+ upsidedown = 180 //
+ };
 
- clip_path_element(const std::string& _id, const rect_element& _rect):
- element_id(_id), rect(_rect)
- {
- }
+ // text_element::text_element(double x, double y,
+ // const std::string&,
+ // int,
+ // const std::string& font,
+ // const std::string& style, const std::string& weight,
+ // const std::string& stretch, const std::string& decoration,
+ // int align, int rotate);
 
- void write(std::ostream& rhs)
- {
- rhs << "<clipPath id=\"" << element_id << "\">" <<std::endl;
+ class text_element: public svg_element
+ { // Holds text with position, size, font, (& styles) & orientation.
+ // Not necessarily shown correctly by all browsers, alas.
+ private: // Access only via member functions below.
+ double x_coord; // Cartesian units.
+ double y_coord;
+ // http://www.w3.org/TR/SVG/text.html#FontFamilyProperty
+ // 10.10 Font selection properties
+ std::string txt; // Actual text to display
+ // (may contain embedded xml characters for Greek, math etc, for example &#x3A9;).
+ int size; // " font-size = 12"
+ // http://www.w3.org/TR/SVG/text.html#CharactersAndGlyphs
+ std::string font; // font-family: "Arial" | "Times New Roman" | "Verdana" | "Lucida Sans Unicode"
+ std::string style; // font-style: normal | bold | italic | oblique
+ std::string weight; // font-weight: normal | bold | bolder | lighter | 100 | 200 .. 900
+ std::string stretch; // font-stretch: normal | wider | narrower ...
+ std::string decoration; // // "underline" | "overline" | "line-through"
+ align_style align; // left_align, right_align, center_align
+ int rotate; // horizontal, upward, downward, upsidedown
 
- rect.write(rhs);
+ // Example:
+ // <text x="250" y="219.5" text-anchor="middle" font-family="verdana" font-size="12">0 </text>
 
- rhs<<std::endl<<"</clipPath>";
+ public:
+ // Set and get member functions.
+ void font_alignment(align_style a)
+ { // left_align, right_align, center_align
+ align = a;
     }
-}; // class clip_path_element
 
-struct path_point
-{
- bool relative;
+ align_style font_alignment()
+ { // left_align, right_align, center_align
+ return align;
+ }
 
- virtual void write(std::ostream& rhs) = 0;
+ void font_family(const std::string& s)
+ { // Examples: "Arial", "Times New Roman", "Verdana", "Lucida Sans Unicode"
+ font = s;
+ }
 
- virtual ~path_point()
+ const std::string& font_family() const
     {
+ return font;
     }
 
- path_point(bool _rel): relative(_rel)
+ void font_style(const std::string& s)
     {
+ style = s;
     }
-}; // struct path_point
 
+ const std::string& font_style() const
+ {
+ return style;
+ }
 
-struct m_path: public path_point
-{
- double x, y;
+ void font_weight(const std::string& s)
+ { // normal | bold | bolder | lighter | 100 | 200 .. 900
+ weight = s;
+ }
 
- void write(std::ostream& o_str)
+ const std::string& font_weight() const
     {
- if(relative)
- {
- o_str<<"m";
- }
-
- else
- {
- o_str<<"M";
- }
+ return weight;
+ }
 
- o_str<<x<<" "<<y<<" ";
+ void font_stretch(const std::string& s)
+ { // normal | wider | narrower .
+ stretch = s;
     }
 
- m_path(double _x, double _y, bool _rel = false):
- x(_x), y(_y), path_point(_rel)
+ const std::string& font_stretch() const
     {
+ return stretch;
     }
-}; // struct m_path
 
-struct z_path: public path_point
-{
- void write(std::ostream& o_str)
- {
- o_str<<"Z ";
+ void font_decoration(const std::string& s)
+ { // "underline" | "overline" | "line-through"
+ decoration = s;
     }
 
- z_path():path_point(false){}
-}; // struct z_path
+ const std::string& font_decoration() const
+ {
+ return decoration;
+ }
 
-struct l_path: public path_point
-{
- double x, y;
+ void font_size(unsigned int i)
+ { // pixels, default 10.
+ size = i;
+ }
 
- void write(std::ostream& o_str)
+ int font_size() const
     {
- if(relative)
- {
- o_str<<"l";
- }
-
- else
- {
- o_str<<"L";
- }
+ return size;
+ }
 
- o_str << x << " " << y << " ";
+ void font_rotation(int rot)
+ { // Degrees: horizontal = 0, upward = -90, downward, upsidedown
+ rotate = rot;
     }
 
- l_path(double _x, double _y, bool _rel = false):
- x(_x), y(_y), path_point(_rel)
+ int font_rotation() const
     {
+ return rotate;
     }
-}; // struct l_path
 
-struct h_path: public path_point
-{
- double x;
+ void x(double x)
+ { // x coordinate of text to write.
+ x_coord = x;
+ }
 
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str << "h";
- }
+ double x() const
+ { // x coordinate of text to write.
+ return x_coord;
+ }
+
+ void y(double y)
+ { // y coordinate of text to write.
+ y_coord = y;
+ }
 
- else
- {
- o_str << "H";
- }
+ double y() const
+ { // y coordinate of text to write.
+ return y_coord;
+ }
 
- o_str << x << " ";
+ void text(const std::string& t)
+ { // text to write.
+ txt = t;
     }
 
- h_path(double _x, bool _rel = false):
- x(_x), path_point(_rel)
+ std::string text()
     {
+ return txt;
     }
-}; // struct h_path
 
-struct v_path: public path_point
-{
- double y;
+ text_element(double x = 0., double y = 0.,
+ const std::string& text = "",
+ int size = 12,
+ const std::string& font = "Lucida Sans Unicode",
+ const std::string& style = "", const std::string& weight = "",
+ const std::string& stretch = "", const std::string& decoration = "",
+ align_style align = center_align, int rotate = horizontal)
+ :
+ x_coord(x), y_coord(y),
+ txt(text),
+ size(size),
+ font(font),
+ style(style), weight(weight), stretch(stretch), decoration(decoration),
+ align(align), rotate(rotate)
+ { // text_element default constructor, defines defaults for all private members.
+ }
 
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str << "v";
- }
+ void write(std::ostream& rhs)
+ { // text & atributes to stream.
+ // Changed to new convention on spaces:
+ // NO trailing space, but *start* each item with a space.
+ rhs << "<text x=\"" << x_coord << "\" y=\"" << y_coord << "\"";
+ std::string anchor;
+ switch(align)
+ {
+ case left_align:
+ anchor = " start";
+ break;
+ case right_align:
+ anchor = " end";
+ break;
+ case center_align:
+ anchor = " middle";
+ break;
+ default:
+ anchor = "";
+ break;
+ }
+ if(anchor != "")
+ {
+ rhs << " text-anchor=\"" << anchor << "\"";
+ }
+ if(rotate != 0)
+ {
+ rhs << " transform = \"rotate("
+ << rotate << " "
+ << x_coord << " "
+ << y_coord << " )\"";
+ }
+ if (font.size() != 0)
+ {
+ rhs << " font-family=\"" << font << "\"";
+ }
+ if (style.size() != 0)
+ {
+ rhs << " font-style=\"" << style << "\"";
+ }
+ if (weight.size() != 0)
+ {
+ rhs << " font-weight=\"" << weight << "\"";
+ }
+ if (stretch.size() != 0)
+ {
+ rhs << " font-stretch=\"" << stretch << "\"";
+ }
+ if (decoration.size() != 0)
+ {
+ rhs << " font-decoration=\"" << decoration << "\"";
+ }
+ if(size == 0)
+ { // Use a default font size of 12 if none specified.
+ rhs << " font-size=\"12\">";
+ }
+ else
+ {
+ rhs << " font-size=\"" << size << "\">";
+ }
+ rhs << txt << "</text>";
+ // Example: <text x="149" y="207" text-anchor=" middle" font-family="Lucida Sans Unicode" font-size="12">3 </text>
+ } // void write(std::ostream& rhs)
+
+ }; // class text_element
+
+ class clip_path_element: public svg_element
+ { // The clipping path restricts the region to which paint can be applied.
+ // 14.3 Clipping paths http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
+ private:
+ std::string element_id;
+ rect_element rect; // Clipping rectangle.
 
- else
- {
- o_str << "V";
- }
+ public:
 
- o_str << y << " ";
- }
+ clip_path_element(const std::string& id, const rect_element& rect)
+ : element_id(id), rect(rect)
+ { // Constructor defines all member variables.
+ }
+
+ void write(std::ostream& os)
+ {
+ os << "<clipPath id=\"" << element_id << "\">";
+ rect.write(os);
+ os << "</clipPath>" << std::endl;
+ }
+ }; // class clip_path_element
+
+ struct path_point
+ { // Base class for m_path, z_path, q_path, h_path, v_path, c_path, s_path.
+ // Paths represent the outline of a shape which can be
+ // filled, stroked, used as a clipping path, or any combination of the three.
+ bool relative; // or if false then absolute.
 
- v_path(double _y, bool _rel = false):
- y(_y), path_point(_rel)
+ virtual void write(std::ostream& rhs) = 0;
+ virtual ~path_point()
     {
     }
-}; // struct v_path
 
-struct c_path: public path_point
-{
- double x1, y1, x2, y2, x, y;
+ path_point(bool relative) : relative(relative)
+ { // Constructor defines all member variables.
+ }
+ }; // struct path_point
 
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"c";
- }
 
- else
- {
- o_str<<"C";
- }
+ struct m_path: public path_point
+ { // moveto coordinates (x, y)
+ // 8.3.2 The "moveto" commands.
+ double x;
+ double y;
 
- o_str<<x1<<" "<<y1<<" "
- <<x2<<" "<<y2<<" "
- <<x<<" "<<y<<" ";
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str << "m";
+ }
+ else
+ { // absolute
+ o_str << "M";
+ }
+ o_str << x << "," << y << " "; // separator changed to comma for clarity.
+ // Example: "M52.8571 180 "
+ } // void write(std::ostream& o_str)
+
+ m_path(double x, double y, bool relative = false)
+ : x(x), y(y), path_point(relative)
+ {
+ }
+ }; // struct m_path
+
+ struct z_path: public path_point
+ { // http://www.w3.org/TR/SVG/paths.html#PathElement
+ // 8.3.1 General information about path data.
+ // z indicates a closepath.
+ // Close the current subpath by drawing a straight line
+ // from the current point to current subpath's initial point.
+ void write(std::ostream& o_str)
+ {
+ o_str << "Z";
     }
 
- 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)
- {
+ z_path() : path_point(false)
+ { // Constructor defines all member variables.
     }
-}; // struct c_path
+ }; // struct z_path
 
-struct q_path: public path_point
-{
- double x1, y1, x, y;
+ // 8.3.4 The "lineto" commands L, H & V.
+ struct l_path: public path_point
+ {
+ // Draw a line from the current point to the given (x,y) coordinate
+ // which becomes the new current point.
+ double x;
+ double y;
 
     void write(std::ostream& o_str)
     {
- if(relative)
- {
- o_str<<"q";
- }
+ if(relative)
+ {
+ o_str<<"l";
+ }
+ else
+ { // Absolute.
+ o_str << "L";
+ }
+ o_str << x << "," << y << " ";
+ }
+
+ l_path(double x, double y, bool relative = false)
+ : x(x), y(y), path_point(relative)
+ { // Constructor defines all member variables.
+ }
+ }; // struct l_path
 
- else
- {
- o_str<<"Q";
- }
+ struct h_path: public path_point
+ { // Draws a horizontal line from the current point (cpx, cpy) to (x, cpy).
+ double x;
+ // No y needed, start from current point y.
 
- o_str<<x1<<" "<<y1<<" "
- <<x<<" "<<y<<" ";
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str << "h";
+ }
+ else
+ { // Absolute.
+ o_str << "H";
+ }
+ o_str << x << " ";
+ }
+
+ h_path(double x, bool relative = false)
+ : x(x), path_point(relative)
+ { // Constructor defines all member variables.
     }
+ }; // struct h_path
 
- q_path(double _x1, double _y1,
- double _x, double _y, bool _rel = false):
- x1(_x1), y1(_y1), x(_x), y(_y), path_point(_rel)
+ struct v_path: public path_point
+ { // Draws a vertical line from the current point (cpx, cpy) to (cpx, y).
+ double y;
+ // No x coordinate needed - use current point x
+ void write(std::ostream& o_str)
     {
- }
-}; //struct q_path
+ if(relative)
+ {
+ o_str << "v";
+ }
+ else
+ { // Absolute.
+ o_str << "V";
+ }
+ o_str << y << " ";
+ }
+
+ v_path(double y, bool relative = false)
+ : y(y), path_point(relative)
+ { // Constructor defines all member variables.
+ }
+ }; // struct v_path
+
+ // 8.3.5 The curve commands: C, Q & A.
+
+ struct c_path: public path_point
+ { // Draws a cubic Bézier curve from the current point to (x,y) using (x1,y1).
+ double x1;
+ double y1;
+ double x2;
+ double y2;
+ double x;
+ double y;
 
-struct s_path: public path_point
-{
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"c";
+ }
+ else
+ { // Absolute.
+ 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 relative = false)
+ : x1(x1), y1(y1), x2(x2), y2(y2), x(x), y(y), path_point(relative)
+ { // Constructor defines all member variables.
+ }
+ }; // struct c_path
+
+ struct q_path: public path_point
+ { // Draws a quadratic Bézier curve from the current point to (x,y).
+ // using (x1,y1) as the control point.
     double x1, y1, x, y;
 
     void write(std::ostream& o_str)
     {
- if(relative)
- {
- o_str << "s";
- }
-
- else
- {
- o_str << "S";
- }
-
- o_str << x1 << " " << y1 << " "
- << x << " " << y << " ";
+ if(relative)
+ {
+ o_str << "q";
+ }
+ else
+ { // Absolute.
+ o_str << "Q";
+ }
+ o_str << x1 << " " << y1 << " "
+ << x << " " << y << " ";
+ }
+
+ q_path(double x1, double y1, double x, double y, bool relative = false)
+ : x1(x1), y1(y1), x(x), y(y), path_point(relative)
+ { // Constructor.
     }
+ }; //struct q_path
 
- s_path(double _x1, double _y1,
- double _x, double _y, bool _rel = false):
- x1(_x1), y1(_y1), x(_x), y(_y), path_point(_rel)
+ struct s_path : public path_point
+ { // Draws a cubic Bézier curve from the current point to (x,y).
+ double x1, y1, x, y;
+
+ void write(std::ostream& o_str)
     {
+ if(relative)
+ {
+ o_str << "s";
+ }
+ else
+ { // Absolute.
+ o_str << "S";
+ }
+ o_str << x1 << "," << y1 << " "
+ << x << "," << y << " ";
+ }
+
+ s_path(double x1, double y1, double x, double y, bool relative = false)
+ : x1(x1), y1(y1), x(x), y(y), path_point(relative)
+ { // Constructor.
     }
-}; // struct s_path
+ }; // struct s_path
 
-struct t_path: public path_point
-{
- double x, y;
+ struct t_path: public path_point
+ { // Draws a quadratic Bézier curve from the current point to (x,y).
+ double x;
+ double y;
 
     void write(std::ostream& o_str)
     {
- if(relative)
- {
- o_str << "t";
- }
-
- else
- {
- o_str << "T";
- }
+ if(relative)
+ {
+ o_str << "t";
+ }
+ else
+ { // Absolute.
+ o_str << "T";
+ }
+ o_str << x << "," << y << " ";
+ }
+
+ t_path(double x, double y, bool relative = false)
+ : x(x), y(y), path_point(relative)
+ { // Constructor
+ }
+ }; // struct t_path
+
+ struct a_path: public path_point
+ { // Draws a elliptical arc from the current point to (x,y),
+ // using two radii, axis rotation, and control two flags.
+ // See 8.3.8 The elliptical arc curve commands.
+ // Needed for pie charts, etc.
+ double x;
+ double y;
+ double rx;
+ double ry;
+ double x_axis_rotation;
+ bool large_arc; // true if arc >= 180 degrees wanted.
+ bool sweep; // true if to draw in positive-angle direction
 
- o_str << x << " " << y << " ";
- }
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str << "a";
+ }
+ else
+ { // Absolute.
+ o_str << "A";
+ }
+ o_str << rx << "," << ry << " " << x_axis_rotation
+ << ((large_arc) ? 1 : 0) << "," << ((sweep) ? 1 : 0) << " "
+ << x << "," << y << " ";
+ }
+
+ a_path(double x, double y, double rx, double ry, double x_axis_rotation, bool large_arc = false, bool sweep = false, bool relative = false)
+ : x(x), y(y), rx(rx), ry(ry), x_axis_rotation(x_axis_rotation), large_arc(large_arc), sweep(sweep), path_point(relative)
+ { // Constructor
+ }
+ }; // struct a_path
+
+ class path_element: public svg_element
+ { // http://www.w3.org/TR/SVG/paths.html#PathElement
+ // 8.3.1 General information about path data.
+ // A path is defined by including a 'path' element
+ // which contains a d="(path data)" attribute,
+ // where the d attribute contains the moveto, line, curve
+ // (both cubic and quadratic Béziers), arc and closepath instructions.
+ private:
+ ptr_vector<path_point> path; // All the (x, y) coordinate pairs,
+ // filled by calls of m, M, l , L... that push_back.
+ public:
+ bool fill;
 
- t_path(double _x, double _y, bool _rel = false):
- x(_x), y(_y), path_point(_rel)
+ path_element(const path_element& rhs)
     {
+ path = (const_cast<path_element&>(rhs)).path.release();
     }
-}; // struct t_path
-
-class path_element: public svg_element
-{
-private:
- ptr_vector<path_point> path;
-public:
- bool _fill;
 
- path_element(const path_element& rhs)
+ path_element() : fill(true)
     {
- path = (const_cast<path_element&>(rhs)).path.release();
     }
 
- path_element(): _fill(true) { }
+ // Note 1: return of path_element& permits chaining calls like
+ // my_path.M(3, 3).l(150, 150).l(200, 200)...;
+
+ // Note 2: By convention:
+ // lower case (like m call m_path(x, y, true) for relative
+ // but upper case (like M) calls m_path(x, y, false) for absolute.
 
     path_element& m(double x, double y)
- {
- path.push_back(new m_path(x, y, true));
- return *this;
+ { // relative.
+ 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;
+ { // absolute.
+ path.push_back(new m_path(x, y, false));
+ return *this;
     }
 
     path_element& z()
     {
- path.push_back(new z_path());
- return *this;
+ 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.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.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.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.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.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.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.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.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.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;
+ path.push_back(new q_path(x1, y1, x, y, false));
+ return *this;
     }
 
     path_element& s(double x1, double y1, double x, double y)
     {
- path.push_back(new s_path(x1, y1, x, y, true));
- return *this;
+ path.push_back(new s_path(x1, y1, x, y, true));
+ return *this;
     }
 
     path_element& S(double x1, double y1, double x, double y)
- {
- path.push_back(new s_path(x1, y1, x, y, false));
- return *this;
+ { //
+ path.push_back(new s_path(x1, y1, x, y, false));
+ return *this;
     }
 
     path_element& t(double x, double y)
     {
- path.push_back(new t_path(x, y, true));
- return *this;
+ path.push_back(new t_path(x, y, true));
+ return *this;
     }
 
     path_element& T(double x, double y)
     {
- path.push_back(new t_path(x, y, false));
- return *this;
+ path.push_back(new t_path(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<<"\" ";
-
- write_attributes(o_str);
- style_info.write(o_str);
-
- if(!_fill)
- {
- o_str << "fill = \"none\"";
- }
+ o_str << "<path d=\"";
+ for(ptr_vector<path_point>::iterator i = path.begin(); i != path.end(); ++i)
+ {
+ (*i).write(o_str); // M1,2
+ }
+ o_str << "\"";
+ write_attributes(o_str); // id & clip_path
+ style_info.write(o_str); // fill, stroke, width...
+ if(!fill)
+ {
+ o_str << " fill = \"none\"";
+ }
+ o_str<<"/>";
+ // Example: <path d="M5,175 L5,195 M148.571,175" />
+ } // void write(std::ostream& o_str)
+ }; // class path_element
+
+ struct poly_path_point
+ { // polyline or polygon point coordinates (x, y)
+ // 9.6 polyline & 9.7 The 'polygon' element.
+ double x;
+ double y;
+ // Polygon & polyline points are always absolute, never relative,
+ // and values have no preceeding letter like M or L,
+ // So NOT derived from path_point.
 
- o_str<<"/>";
+ void write(std::ostream& o_str)
+ {
+ o_str << " " << x << "," << y; // x, y separator comma for clarity.
+ // Leading space is redundant for 1st after "points= ",
+ // but others are separators, and arkward to know which is 1st.
+ // Example: " 250,180"
+ } // void write(std::ostream& o_str)
+
+ poly_path_point(double x, double y)
+ : x(x), y(y)
+ {
+ }
+
+ poly_path_point()
+ : x(0.), y(0.)
+ { // Default constructor.
+ }
+
+ }; // struct poly_path_point
+
+ std::ostream& operator<< (std::ostream& os, const poly_path_point& p)
+ { // May be needed for Boost.Test.
+ os << "(" << p.x << ", " << p.y << ")" ;
+ // Usage: poly_path_point p0(100, 200);
+ // cout << p0 << endl;
+ // Outputs: (100, 200)
+ return os;
+ } // std::ostream& operator<<
+
+ class polygon_element: public svg_element
+ { // http://www.w3.org/TR/SVG/shapes.html#PolygonElement
+ // 9. 9.7 The 'polygon' element
+ // The 'polygon' element defines a closed shape
+ // consisting of a set of connected straight line segments.
+ // A polygon is defined by including a 'path' element
+ // which contains a points="(path data)" attribute,
+ // where the d attribute contains the x, y coordinate pairs.
+ private:
+ //using boost::ptr_vector;
+ ptr_vector<poly_path_point> poly_points; // All the x, y coordinate pairs,
+ // push_backed by calls of p_path(x, y).
+ public:
+ bool fill; // polygon to have fill color.
+
+ polygon_element(const polygon_element& rhs)
+ { // Copy constructor.
+ poly_points = (const_cast<polygon_element&>(rhs)).poly_points.release();
+ // 'empty' the vector of points.
+ }
+
+ polygon_element() : fill(true)
+ {
+ }
+
+ polygon_element (double x, double y, bool f = true) : fill(f)
+ { // Constructor - One absolute (x, y) point only.
+ // Can add more path points using member function P.
+ poly_points.push_back(new poly_path_point(x, y));
+ }
+
+ polygon_element (double x1, double y1, double x2, double y2, double x3, double y3, bool f = true) : fill(f)
+ { // Constructor - Absolute (x, y) only. Used by triangle.
+ poly_points.push_back(new poly_path_point(x1, y1));
+ poly_points.push_back(new poly_path_point(x2, y2));
+ poly_points.push_back(new poly_path_point(x3, y3));
+ }
+
+ polygon_element (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, bool f = true)
+ :
+ fill(f)
+ { // Constructor - Absolute (x, y) only. Used by rhombus.
+ poly_points.push_back(new poly_path_point(x1, y1));
+ poly_points.push_back(new poly_path_point(x2, y2));
+ poly_points.push_back(new poly_path_point(x3, y3));
+ poly_points.push_back(new poly_path_point(x4, y4));
+ }
+
+ polygon_element (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double x5, double y5, bool f = true)
+ :
+ fill(f)
+ { // Constructor - Absolute (x, y) only. Used by pentagon.
+ poly_points.push_back(new poly_path_point(x1, y1));
+ poly_points.push_back(new poly_path_point(x2, y2));
+ poly_points.push_back(new poly_path_point(x3, y3));
+ poly_points.push_back(new poly_path_point(x4, y4));
+ poly_points.push_back(new poly_path_point(x5, y5));
+ }
+
+ polygon_element (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double x5, double y5, double x6, double y6, bool f = true)
+ :
+ fill(f)
+ { // Constructor - Six absolute (x, y) only. Used by hexagon.
+ // Might be done more efficiently with fixed size boost::array?
+ poly_points.push_back(new poly_path_point(x1, y1));
+ poly_points.push_back(new poly_path_point(x2, y2));
+ poly_points.push_back(new poly_path_point(x3, y3));
+ poly_points.push_back(new poly_path_point(x4, y4));
+ poly_points.push_back(new poly_path_point(x5, y5));
+ poly_points.push_back(new poly_path_point(x6, y6));
+ }
+
+ polygon_element (std::vector<poly_path_point>& points, bool f = true)
+ :
+ fill(f)
+ { // Constructor from vector of path points.
+ poly_points.reserve(points.size()); // Since we know how many will be pushed.
+ for(std::vector<poly_path_point>::iterator i = points.begin(); i != points.end(); ++i)
+ {
+ poly_path_point p = (*i);
+ poly_points.push_back(new poly_path_point(p.x, p.y));
+ }
+ }
+
+ template<int n>
+ polygon_element (boost::array<const poly_path_point, n>& points, bool f = true)
+ :
+ fill(f)
+ { // Constructor from const array of path points.
+ poly_points.reserve(n); // Since we know how many will be pushed.
+ //poly_points.reserve(points.size()); // Since we know how many will be pushed.
+ for(array<const poly_path_point, n>::iterator i = points.begin(); i != points.end(); ++i)
+ {
+ poly_path_point p = (*i);
+ poly_points.push_back(new poly_path_point(p.x, p.y));
+ }
+ }
+
+ // And non-const poly_path_point version, in case needed.
+ template<int n>
+ polygon_element (boost::array<poly_path_point, n>& points, bool f = true)
+ :
+ fill(f)
+ { // Constructor from const array of path points.
+ poly_points.reserve(n); // Since we know how many will be pushed.
+ // == poly_points.reserve(points.size()); // Since we know how many will be pushed.
+ for(array<poly_path_point, n>::iterator i = points.begin(); i != points.end(); ++i)
+ {
+ poly_path_point p = (*i);
+ poly_points.push_back(new poly_path_point(p.x, p.y));
+ }
+ }
+
+ // Member function to add more points to polygon.
+ polygon_element& P(double x, double y)
+ { // Add another (x, y) - absolute only.
+ poly_points.push_back(new poly_path_point(x, y));
+ return *this;
     }
-}; // class path_element
 
+ void write(std::ostream& o_str)
+ {
+ o_str << "<polygon points=\"";
+ for(ptr_vector<poly_path_point>::iterator i = poly_points.begin(); i!=poly_points.end(); ++i)
+ {
+ (*i).write(o_str); // x, y coordinates as " 1,2"
+ }
+ o_str << "\"";
+ write_attributes(o_str);
+ style_info.write(o_str);
+ if(!fill)
+ {
+ o_str << " fill = \"none\"";
+ }
+ o_str<<"/>";
+ // Example: <polygon fill="lime" stroke="blue" stroke-width="10"
+ // points="850,75 958,137.5 958,262.5
+ // 850,325 742,262.6 742,137.5" />
+ } // void write(std::ostream& o_str)
+
+ }; // class polygon_element
+
+ class polyline_element: public svg_element
+ { // http://www.w3.org/TR/SVG/shapes.html#PolylineElement
+ // 9.6 The 'polyline' element: defines a set of connected straight line segments.
+ // Typically, 'polyline' elements define open shapes.
+ // A polyline is defined by including a 'path' element
+ // which contains a points="(path data)" attribute,
+ // where the points attribute contains the x, y coordinate pairs.
+ // * perform an absolute moveto operation
+ // to the first coordinate pair in the list of points
+ // * for each subsequent coordinate pair,
+ // perform an absolute lineto operation to that coordinate pair.
+ // The advantage of polyline is in reducing file size,
+ // avoiding M and repeated L before x & y coordinate pairs.
+
+ private:
+ ptr_vector<poly_path_point> poly_points; // All the (x, y) coordinate pairs,
+ // push_back by calls of p_path(x, y).
+ public:
+ //bool fill; // not needed for polyline, unlike polygon.
+
+ polyline_element(const polyline_element& rhs)
+ { // copy constructor.
+ poly_points = (const_cast<polyline_element&>(rhs)).poly_points.release();
+ }
+
+ polyline_element()
+ { // Construct an 'empty' line.
+ // Can new line path points add using polyline_element member function P.
+ }
+
+ polyline_element (double x1, double y1)
+ { // One (x, y) path point, absolute only.
+ poly_points.push_back(new poly_path_point(x1, y1));
+ }
+
+ polyline_element (double x1, double y1, double x2, double y2)
+ { // Two (x, y) path points, absolute only.
+ poly_points.push_back(new poly_path_point(x1, y1));
+ poly_points.push_back(new poly_path_point(x2, y2));
+ }
+
+ polyline_element (std::vector<poly_path_point>& points)
+ { // Constructor from vector of path points.
+ for(std::vector<poly_path_point>::iterator i = points.begin(); i != points.end(); ++i)
+ {
+ poly_path_point p = (*i);
+ poly_points.push_back(new poly_path_point(p.x, p.y));
+ }
+ }
+
+ // Member function to add new points to existing line.
+ polyline_element& P(double x, double y)
+ { // Absolute (x, y) only, so Capital letter P.
+ poly_points.push_back(new poly_path_point(x, y));
+ return *this;
+ }
 
-// -----------------------------------------------------------------
-// The node element of our document tree.
-// -----------------------------------------------------------------
-class g_element: public svg_element
-{
-private:
- ptr_vector<svg_element> children;
+ void write(std::ostream& o_str)
+ {
+ o_str << "<polyline points=\"";
+ for(ptr_vector<poly_path_point>::iterator i = poly_points.begin(); i!= poly_points.end(); ++i)
+ {
+ (*i).write(o_str); // x, y coordinates as " 1,2"
+ }
+ o_str << "\"";
+ write_attributes(o_str);
+ style_info.write(o_str);
+ o_str<<"/>";
+ // Example: <polyline points=" 100,100 200,100 300,200 400,400"/>
+ } // void write(std::ostream& o_str)
+
+ }; // class polyline_element
+
+ // -------------------------------------------------------------------
+ // g_element (group element) is the node element of our document tree.
+ // 'g' element is a container element for grouping together <g /></g>
+ // related graphics elements, for example:
+ // <g fill="rgb(255,255,255)" id="background"><rect width="500" height="350"/></g>
+ // -------------------------------------------------------------------
+ class g_element: public svg_element
+ {
+ private:
+ ptr_vector<svg_element> children; // of this group element node,
+ // containg graphics elements like text, circle line, polyline...
     std::string clip_name;
-
     bool clip_on;
-
-public:
+ public:
 
     g_element() : clip_on(false)
     {
@@ -684,94 +1290,156 @@
 
     svg_element& operator[](unsigned int i)
     {
- return children[i];
+ return children[i];
     }
 
     size_t size()
     {
- return children.size();
+ return children.size();
     }
 
     void write(std::ostream& rhs)
     {
- rhs << "<g ";
+ rhs << "<g"; // Do NOT need space if convention is to start following with space.
+ write_attributes(rhs); // id="background"
+ style_info.write(rhs); // stroke="rgb(0,0,0)"
+ rhs << ">" ;
+ for(unsigned int i = 0; i < children.size(); ++i)
+ {
+ children[i].write(rhs);
+ }
+ rhs << "</g>" << std::endl;
+ // Example:
+ // <g fill="rgb(255,255,255)" id="background"><rect x="0" y="0" width="500" height="350"/></g>
+ } // void write(std::ostream& rhs)
 
- style_info.write(rhs);
- write_attributes(rhs);
+ g_element& g_tag(int i)
+ { // i is index of children nodes.
+ return *(static_cast<g_element*>(&children[i]));
+ }
 
- rhs<< " >" << std::endl;
+ // Returns a reference to the new child node just created.
+ g_element& add_g_element()
+ {
+ children.push_back(new g_element);
+ return *(static_cast<g_element*>(&children[children.size()-1]));
+ }
 
- for(unsigned int i=0; i<children.size(); ++i)
- {
- children[i].write(rhs);
- }
+ // get ith g_element or child node.
+ g_element& get_g_element(int i)
+ {
+ return *(static_cast<g_element*>(&children[i]));
+ }
 
- rhs << "</g>" << std::endl;
+ void push_back(svg_element* g)
+ {
+ children.push_back(g);
     }
 
- g_element& g_tag(int i)
+ void clear()
     {
- return *(static_cast<g_element*>(&children[i]));
+ children.clear();
     }
 
- // Returns a reference to the node created.
- g_element& add_g_element()
+ // Push_back the several elements:
+ // circle, ellipse, rect, line, path, text, polyline, polygon.
+ g_element& circle(double x, double y, double radius = 5.)
     {
- children.push_back(new g_element);
+ children.push_back(new circle_element(x, y, radius));
+ return *this;
+ }
 
- return *(static_cast<g_element*>(&children[children.size()-1]));
+ g_element& ellipse(double x, double y, double radius_x = 3., double radius_y = 6.)
+ {
+ children.push_back(new ellipse_element(x, y, radius_x, radius_y));
+ return *this;
     }
 
- void push_back(svg_element* _g)
+ g_element& text(double x = 0., double y = 0.,
+ // The order of arguments DOES NOW match svg& text_element!
+ // text_element::text_element(double x, double y,
+ // const std::string&,
+ // int,
+ // const std::string& font,
+ // const std::string& style, const std::string& weight,
+ // const std::string& stretch, const std::string& decoration,
+ // int align, int rotate);
+
+ const std::string& text = "",
+ int text_size = 12,
+ const std::string& font = "Lucida Sans Unicode",
+ const std::string& style = "", const std::string& weight = "",
+ const std::string& stretch = "", const std::string& decoration = "",
+ align_style align = center_align, int rotate = horizontal)
     {
- children.push_back(_g);
+ children.push_back(new text_element(x, y, text, text_size, font, style, weight, stretch, decoration, align, rotate));
+ return *this;
     }
 
- void clear()
+ g_element& rect(double x1, double y1, double x2, double y2)
     {
- children.clear();
+ children.push_back(new rect_element(x1, y1, x2, y2));
+ return *this;
     }
 
- g_element& circle(double x, double y, double radius = 5.)
+ g_element& line(double x1, double y1, double x2, double y2)
     {
- children.push_back(new circle_element(x, y, radius));
- return *this;
+ children.push_back(new line_element(x1, y1, x2, y2));
+ return *this;
     }
 
- g_element& text(double x, double y, const std::string& text,
- int text_size = 12,
- text_style align = center_align, int rotation = 0)
+ g_element& polygon(double x1, double y1, bool f)
     {
- children.push_back(new text_element(x, y, text, text_size,
- align, rotation));
- return *this;
+ children.push_back(new polygon_element(x1, y1, f));
+ return *this;
     }
 
- g_element& get_g_element(int i)
+ g_element& polygon(std::vector<poly_path_point>& points, bool f)
     {
- return *(static_cast<g_element*>(&children[i]));
+ children.push_back(new polygon_element(points, f));
+ return *this;
     }
 
- g_element& rect(double x1, double y1, double x2, double y2)
+ g_element& triangle(double x1, double y1, double x2, double y2, double x3, double y3, bool f)
     {
- children.push_back(new rect_element(x1, y1, x2, y2));
+ children.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, f));
+ return *this;
+ }
 
- return *this;
+ g_element& rhombus(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, bool f)
+ {
+ children.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, x4, y4, f));
+ return *this;
     }
 
- g_element& line(double x1, double y1, double x2, double y2)
+ g_element& polyline(double x1, double y1, bool f)
     {
- children.push_back(new line_element(x1, y1, x2, y2));
+ children.push_back(new polygon_element(x1, y1, f));
+ return *this;
+ }
+
+ // These return a reference to the last child node just pushed.
+ // (Unlike the above functions that return a g_element&).
+ polygon_element& polygon()
+ {
+ children.push_back(new polygon_element()); // Empty polygon,
+ // to which poly_path_points can be added later using member function P.
+ return *(static_cast<polygon_element*>(&(children[(unsigned int)(children.size()-1)])));
+ }
 
- return *this;
+ polyline_element& polyline()
+ {
+ children.push_back(new polyline_element()); // Empty polyline.
+ return *(static_cast<polyline_element*>(&(children[(unsigned int)(children.size()-1)])));
     }
 
     path_element& path()
     {
- children.push_back(new path_element());
- return *(static_cast<path_element*>(&(children[(unsigned int)(children.size()-1)])));
+ children.push_back(new path_element()); // Empty path.
+ return *(static_cast<path_element*>(&(children[(unsigned int)(children.size()-1)])));
     }
-}; // class g_element
+
+ }; // class g_element
 
 } // namespace svg
 } // namespace boost

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/stylesheet.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/stylesheet.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/stylesheet.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,12 +1,15 @@
 // stylesheet.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_STYLESHEET_HPP
-#define _BOOST_SVG_STYLESHEET_HPP
+// Copyright Jacob Voytko 2007
 
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+// -----------------------------------------------------------------
+
+#ifndef BOOST_SVG_STYLESHEET_HPP
+#define BOOST_SVG_STYLESHEET_HPP
 
 #include <boost/spirit/core.hpp>
 #include <boost/spirit/utility/distinct.hpp>
@@ -17,8 +20,10 @@
 #include <ostream>
 #include <iostream>
 
-namespace boost{
-namespace svg{
+namespace boost
+{
+namespace svg
+{
 
 // Note: After GSoC, this will use the suggested CSS parser
 // from the W3C CSS 2.1 Standard
@@ -74,15 +79,16 @@
         ::boost::spirit::rule<ScannerT> const&
         start() const { return expression; }
     };
-};
+}; // struct css_parse
 
 bool validate_stylesheet(std::ifstream& file)
-{
+{ // stream version used by file version below.
     css_parse my_css_parser;
- std::string str, tmp;
+ std::string str;
+ std::string tmp;
 
     while(getline(file, tmp))
- {
+ { // Concatentate all the input lines to a single string.
         str += tmp;
     }
 
@@ -92,13 +98,11 @@
         
     if (!info.full)
     {
- std::cout<<info.stop;
+ std::cout << info.stop;
         return false;
     }
-
-
     return true;
-}
+} // bool validate_stylesheet(std::ifstream& file)
 
 bool validate_stylesheet(const std::string& file)
 {
@@ -108,11 +112,10 @@
     {
         throw std::runtime_error("Failed to open " + file);
     }
-
- return validate_stylesheet(f_str);
+ return validate_stylesheet(f_str); // stream version.
 }
 
-}
-}
+} // namespace svg
+} // namespace boost
 
-#endif
+#endif // BOOST_SVG_STYLESHEET_HPP

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-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,11 +1,12 @@
 // svg.hpp
 
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
+// Copyright Jacob Voytko 2007
+// Copyright Paul A Bristow 2007
 
-// -----------------------------------------------------------------
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_SVG_SVG_HPP
 #define BOOST_SVG_SVG_HPP
@@ -17,216 +18,600 @@
 #include <vector>
 
 #include "stylesheet.hpp" // TODO better to be called svg_stylesheet.hpp?
-#include "detail/svg_tag.hpp"
+#include "detail/svg_tag.hpp" // element class definitions.
 #include "svg_style.hpp"
 
+// SVG stands for Scalable Vector Graphics,
+// an XML grammar for stylable graphics, usable as an XML namespace.
+
 namespace boost
 {
 namespace svg
-{
+{ // Class to output Scalable Vector Graph XML,
+ // graph elements, point, line, circle, rect and, text...
+ // and handle plot stylesheets.
+
+ // Inserted as a SVG comment, for example
+ // "<!-- Demo of 1D plot features. --> \n"
+ // and also as a <desc />
+ // http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements
+ // 5.4 The 'desc' and 'title' elements
+
+ static const std::string package_info =
+ "<!-- SVG plot written using Boost.Plot program (Creator Jacob Voytko) --> \n"
+ "<!-- Use, modification and distribution of Boost.Plot subject to the --> \n"
+ "<!-- Boost Software License, Version 1.0.--> \n"
+ "<!-- (See accompanying file LICENSE_1_0.txt --> \n"
+ "<!-- or copy at http://www.boost.org/LICENSE_1_0.txt) --> \n";
+
+ // Copyright notice to be inserted into plot image produced by this program.
+ // Note: can have more than one copyright date, or a range.
+ // produces a copyright notice as an SVG comment like this:
+ // "<!-- Copyright Paul A. Bristow, 2007 --> \n"
+ // and as a meta item:
+ // <meta name="copyright" content="Paul A. Bristow" />
+
+
+class svg;
+// TODO is it wise to have a class and a namespace with the same name?
+// No problems caused by this noted so far.
+
+// See svg_fwd.hpp for forward declarations.
+// Public member functions:
+// svg() constructor, and copy constructor.
+// Chainable set and get functions for image size, description, title, copyright and date.
+// image size x and y, and both.
+// svg& x_size(unsigned int x)
+// unsigned int x_size()
+// svg& y_size(unsigned int y)
+// unsigned int y_size()
+// svg& image_size(unsigned int x, unsigned int y)
+// information about the image file
+// svg& description(std::string d)
+// std::string& description()
+// svg& document_title(std::string d)
+// std::string document_title()
+// svg& copyright_holder(std::string d)
+// svg& copyright_date(std::string d)
+// const std::string copyright_date()
+
+// Write information about svg shapes:
+// svg& line(double x1, double y1, double x2, double y2)
+// svg& rect(double x1, double y1, double x2, double y2)
+// svg& circle(double x, double y, unsigned int radius = 5)
+// svg& ellipse(double rx, double ry, double cx, double cy)
+
+// svg& text(double x, double y, const std::string& text, int text_size = 12,
+// const std::string& font = "Lucida Sans Unicode",
+// const std::string& style = "", const std::string& weight = "",
+// const std::string& stretch = "", const std::string& decoration = "",
+// align_style align = center_align, int rotate = 0)
+
+// write image out to ostream and file:
+// svg& write(std::ostream& s_out)
+// svg& write(const std::string& file)
+
+// svg& load_stylesheet(const std::string& input) // Load a stylesheet into string css from an input file.
+
+// Possibles for license strings:
+// static const std::string permit("permits");
+// static const std::string require("requires");
+// static const std::string prohibit("prohibits");
 
 class svg
 {
 protected:
- unsigned int x_size;
- unsigned int y_size;
-
- g_element document;
+ unsigned int x_size_; // image size.
+ unsigned int y_size_;
 
- std::vector<clip_path_element> clip_paths;
+ g_element document; // group_element to hold all elements of svg document.
+ std::vector<clip_path_element> clip_paths;
+ std::string title_document_; // SVG document title (for header as <title>).
+ std::string image_desc_; // SVG image description (for header as <desc>).
+ std::string holder_copyright_; // SVG info.
+ std::string date_copyright_; // SVG info.
+ std::string css; // Cascading Style Sheet.
+ std::string filename_; // file written to.
+ std::string author_; // Probably == copyright holder.
+ bool is_license_;
+ std::string reproduction_; // "permits", "requires", or "prohibits"
+ std::string attribution_;
+ std::string commercialuse_;
+ std::string distribution_;
 
- std::string css;
+ int coord_precision_; // decimal digits precision for output of x and y coordinates to svg.
 
 private:
 
- // -----------------------------------------------------------------
- // Internal function to write all of the data to the svg document.
- // -----------------------------------------------------------------
- void _write_document(std::ostream& s_out)
- {
- // Write clip paths.
- for(size_t i=0; i<clip_paths.size(); ++i)
- {
- clip_paths[ (unsigned int)i ].write(s_out);
- }
-
- // Write all visual elements.
- for(size_t i=0; i<document.size(); ++i)
- {
- document[ (unsigned int)i ].write(s_out);
- }
- }
-
- // -----------------------------------------------------------------
- // This prints the svg 1.1 header into the document.
- // -----------------------------------------------------------------
- void _write_header(std::ostream& s_out)
- {
- s_out << "<?xml version=\"1.0\" standalone=\"no\"?>"
- << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
- << "\"http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd\">"<<std::endl;
- }
-
- void _write_css(std::ostream& s_out)
- {
- s_out << "<defs><style type=\"text/css\"><![CDATA[" << css
- << "]]></style></defs>" << std::endl;
+ // ---------------------------------------------------------
+ // Print the svg 1.1 header into the svg g_element document.
+ // ---------------------------------------------------------
+ void write_header(std::ostream& s_out)
+ {
+ s_out << "<?xml version=\"1.0\" standalone=\"no\"?>"
+ << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
+ << "\"http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd\">"
+ << std::endl;
+ // TODO IE6 with updates does not recognise this DOCTYPE, but displays OK.
+ // http://jwatt.org/svg/authoring/#namespace-binding recommends NO DOCTYPE!
+ }
+
+ void write_css(std::ostream& s_out)
+ { // CSS (Cascading Style Sheet)
+ if (css.size() != 0) // css != ""
+ { // TODO confirm that this isn't useful if css is "".
+ s_out << "<defs><style type=\"text/css\"><![CDATA[" << css
+ << "]]></style></defs>" << std::endl;
+ // Example: <defs><style type="text/css"><![CDATA[]]></style></defs>
+ }
+ }
+
+ // ----------------------------------------------------------------
+ // Internal function to write all of the image to the svg document.
+ // ----------------------------------------------------------------
+ void write_document(std::ostream& s_out)
+ {
+ // Write all clip paths that
+ // define a region of the output device
+ // to which paint can be applied.
+ for(size_t i = 0; i < clip_paths.size(); ++i)
+ {
+ clip_paths[ (unsigned int)i ].write(s_out);
+ }
+ // Write all visual elements.
+ for(size_t i = 0; i < document.size(); ++i)
+ { // plot_background, grids, axes ... title
+ document[ (unsigned int)i ].write(s_out);
     }
+ } // write_document
 
 public:
 
- svg() : x_size(400), y_size(400)
- { // Default constructor.
- }
-
- svg(const svg& rhs):x_size(rhs.x_size), y_size(rhs.y_size)
- {
- }
-
- svg& write(const std::string& _file)
+ svg()
+ : x_size_(400), y_size_(400), // of the whole SVG image.
+ title_document_(""), // This is document title, not plot title.
+ image_desc_(""), // Information about the plot, for example the program that created it.
+ author_(""), // Default to copyright holder.
+ holder_copyright_(""), //
+ date_copyright_(""), //
+ css(""), // stylesheet.
+ filename_(""), // If written only to ostream, filename will not appear in comment.
+ is_license_(false), // No default license.
+ reproduction_("permits"), // Set with license
+ distribution_("permits"), // permits, requires, or prohibits.
+ attribution_("requires"),
+ commercialuse_("permits"),
+ coord_precision_(3) // enough for 1 in 1000 resolution to suit
+ { // Default constructor.
+ }
+
+ svg(const svg& rhs) : x_size_(rhs.x_size_), y_size_(rhs.y_size_)
+ { // Defined image size copy constructor.
+ }
+
+ // Set & get functions for x_size_ and y_size_
+ svg& x_size(unsigned int x)
+ {
+ x_size_ = x;
+ return *this;
+ }
+
+ unsigned int x_size()
+ { // x_size_ name is now used in class to permit function called x_size.
+ // TODO Better called image_x_size()?
+ return x_size_;
+ }
+
+ svg& y_size(unsigned int y)
+ {
+ y_size_ = y;
+ return *this;
+ }
+
+ unsigned int y_size()
+ { // y_size_ name is now used in class to permit function called y_size.
+ return y_size_;
+ }
+
+ unsigned int document_size()
+ { // How many elements have been added to document.
+ return static_cast<unsigned int>(document.size());
+ }
+
+ svg& coord_precision(int digits)
+ { // Set decimal digits to be output for output of coordinates.
+ // Default stream precision 6 decimal digits is probably excessive.
+ // 4.1 Basic data types, integer or float in decimal or scientific (using e format).
+ // - probably enough if image size is under 1000 x 1000.
+ // This will reduce .svg file sizes significantly for curves represented with many data points.
+ // For example, if a curve is shown using 100 points,
+ // reducing to precision(3) from 6 will reduce file size by 300 bytes.
+ // So a default of 3 is used in the default constructor above,
+ // but can be changed using this function.
+ // Used in svg.write below and so applies to all the svg document.
+ coord_precision_ = digits;
+ return *this;
+ }
+
+ int coord_precision()
+ { //
+ return coord_precision_;
+ }
+
+ // svg.write() also has two flavors, a file and an ostream.
+ // The file version opens an ostream, and calls the stream version.
+ // The stream version first clears all unnecessary data from the graph,
+ // builds the document tree, and then calls the write function for the root
+ // document node, which calls all other nodes through the Visitor pattern.
+
+ // TODO provide a filtered-stream version that writes in zipped format type .svgz ?
+ // http://lists.w3.org/Archives/Public/www-svg/2005Dec/0308.html
+ // recommends MUST have correct Content-Encoding headers.
+ // --------------------------------------------------------------------------------
+
+ svg& write(const std::string& file)
+ {// Write whole .svg 'file' contents to file.
+ std::ofstream f_out(file.c_str());
+ if(f_out.fail())
+ {
+ filename_ = ""; // Erase any previous filename,
+ // so does not appear in comment if later written just to stream.
+ throw std::runtime_error("Unable to open file " + file);
+ }
+ filename_ = file; // Note so that can embed into file as comment.
+ write(f_out);
+ return *this;
+ }
+
+ svg& write(std::ostream& s_out)
+ { // Write whole .svg 'file' contents to stream (perhaps a file).
+ write_header(s_out); // "<?xml version=...
+ // write svg document, begin <svg tag.
+ s_out << "<svg width=\"" << x_size_ << "\" height =\"" << y_size_
+ << "\" version=\"1.1\"" // http://www.w3.org/TR/SVG11/
+ // 1.2 draft specification at http://www.w3.org/TR/SVG12/
+ << " xmlns=\"http://www.w3.org/2000/svg\"\n"
+ // xml namespace containing svg shapes rect, circle...
+ // so can write rect or circle avoiding need for qualification svg:rect, svg:circle...
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+ " xmlns:ev=\"http://www.w3.org/2001/xml-events\">\n"
+ << std::endl;
+ // Bind the required namespaces, see http://jwatt.org/svg/authoring/#namespace-binding
+ // Added xlink and ev in case needed.
+
+ s_out << package_info << std::endl;
+
+ if (author_ == "")
+ {
+ author_ = holder_copyright_;
+ }
+ else
+ {
+ if (holder_copyright_ == "")
+ {
+ holder_copyright_ = author_;
+ }
+ else
+ { // Copyright has been assigned to another, so list separately.
+ s_out << "<!-- " << author_ << " --> "<< std::endl;
+ }
+ }
+ if (holder_copyright_ != "")
+ { // Output copyright & date as both comment and meta data.
+ s_out << "<!-- SVG Plot Copyright " << holder_copyright_ << " " << date_copyright_ << " --> "<< std::endl;
+ s_out << "<meta name=\"copyright\" content=\"" << holder_copyright_ << "\" />" << std::endl;
+ // Example: <meta name="copyright" content="Paul A. Bristow" />
+ s_out << "<meta name=\"date\" content=\"" << date_copyright_ << "\" />" << std::endl;
+ // Example: <meta name="Date" content="20071101">
+ }
+ if (image_desc_ != "")
+ {
+ s_out << "<!-- " << image_desc_ << " --> "<< std::endl;
+ s_out << "<desc>" << image_desc_ << "</desc>" << std::endl;
+ }
+ if (title_document_ != "")
+ {
+ s_out << "<title>" << title_document_ << "</title>" << std::endl;
+ }
+ if (filename_ != "")
+ { // Example: <!-- File demo_1d_plot.svg -->
+ s_out << "<!-- File " << filename_ << " --> "<< std::endl;
+ }
+ s_out.precision(coord_precision());
+
+ if (is_license_ == true)
+ {
+ s_out <<
+ "<metadata>\n"
+ "<rdf:RDF xmlns:cc=\"http://web.resource.org/cc/\"\n"
+ "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
+ "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n"
+ "<cc:work rdf:about=\" " << filename_ << "\">\n" // Presumably .svg (or svgz?)
+ "<dc:title>" << (title_document_ != "" ? title_document_ : filename_) << "</dc:title>\n"
+ "<dc:creator>Boost.Plot</dc:creator>\n"
+ "<dc:author> " << author_ << "</dc:author>\n"
+ "<dc:rights> " << holder_copyright_ << ", " << date_copyright_ << "</dc:rights>\n"
+ "<dc:format>application/xhtml+xml+svg</dc:format>\n"
+ "<cc:license rdf:about=\"http://creativecommons.org/licenses\">\n"
+ "<cc:requires rdf:resource=\"http://web.resource.org/cc/Notice\"/>\n"
+ "<cc:" << reproduction_ << " rdf:resource=\"http://web.resource.org/cc/Reproduction\"/>\n"
+ "<cc:" << distribution_ << " rdf:resource=\"http://web.resource.org/cc/Distribution\"/>\n"
+ "<cc:" << attribution_ << " rdf:resource=\"http://web.resource.org/cc/Attribution\"/>\n"
+ "<cc:" << commercialuse_ << " rdf:resource=\"http://web.resource.org/cc/CommercialUse\"/>\n"
+ "</cc:license>\n"
+ "</cc:work>\n"
+ "</rdf:RDF>\n"
+ "</metadata>"
+ << std::endl;
+ }
+ write_css(s_out);// stylesheet, if any.
+ write_document(s_out); // write clip paths and all document elements.
+ s_out << std::endl << "</svg>" << std::endl; // close off svg tag (added newline).
+ return *this;
+ }
+
+ svg& license(const std::string repro, const std::string distrib, const std::string attrib, const std::string commercial)
+ { // Might check these are "permits", "requires", or "prohibits"?
+ // Default is permits.
+ reproduction_ = repro;
+ distribution_ = distrib;
+ attribution_ = attrib;
+ commercialuse_ = commercial;
+ is_license_ = true; // Assume want this if set these?
+ return *this;
+ }
+
+ svg& license(bool l)
+ { // Set license using all defaults (permits).
+ is_license_ = l;
+ }
+
+ bool is_license()
+ { // Shows if a license has been requested.
+ return is_license_;
+ }
+
+ // ------------------------------------------------------------------
+ // Writes the information about the image to the document.
+ // TODO: allow other unit identifiers.
+ // ------------------------------------------------------------------
+ svg& image_size(unsigned int x, unsigned int y)
+ {
+ x_size_ = x;
+ y_size_ = y;
+ return *this;
+ }
+
+ svg& description(const std::string d)
+ { // Writes description to the document(for header as <desc>).
+ image_desc_ = d;
+ return *this;
+ }
+
+ const std::string& description()
+ { // Gets description of the document(for header as <desc>).
+ return image_desc_;
+ }
+
+ svg& author(const std::string a)
+ { // Writes author to the document (default is copyright_holder).
+ author_ = a;
+ return *this;
+ }
+
+ const std::string& author()
+ { // Gets description of the document(for header as <desc>).
+ return author_;
+ }
+ svg& document_title(const std::string d)
+ { // Writes document title for the document(for header as <title>)..
+ title_document_ = d;
+ return *this;
+ }
+
+ const std::string document_title()
+ { // Get document title for the document(for header as <title>)..
+ return title_document_;
+ }
+
+ svg& copyright_holder(const std::string d)
+ { // Writes document title for the document(for header as <title>)..
+ holder_copyright_ = d;
+ return *this;
+ }
+
+ const std::string copyright_holder()
+ { // Get document title for the document(for header as <title>)..
+ return holder_copyright_;
+ }
+
+ svg& copyright_date(const std::string d)
+ { // Writes document title for the document(for header as <title>)..
+ date_copyright_ = d;
+ return *this;
+ }
+
+ const std::string copyright_date()
+ { // Get document title for the document(for header as <title>)..
+ return date_copyright_;
+ }
+
+ svg& image_filename(const std::string filename)
+ { // Writes image filename for the document(for header as <title>)..
+ filename_ = filename;
+ return *this;
+ }
+
+ const std::string image_filename()
+ { // Get image filename for the document(for header as <title>)..
+ return filename_;
+ }
+
+ // ----------------------------------------------------------------------------
+ // push_back the information about line, rec, circle & ellipse to the document.
+ // ----------------------------------------------------------------------------
+ svg& line(double x1, double y1, double x2, double y2)
+ { // 'line' element defines a line segment
+ // that starts at one point and ends at another.
+ document.push_back(new line_element(x1, y1, x2, y2));
+ return *this;
+ }
+
+ svg& rect(double x1, double y1, double x2, double y2)
+ {
+ document.push_back(new rect_element(x1, y1, x2, y2));
+
+ return *this;
+ }
+
+ svg& circle(double x, double y, unsigned int radius = 5)
+ {
+ document.push_back(new circle_element(x, y, radius));
+ return *this;
+ }
+
+ svg& ellipse(double rx, double ry, double cx, double cy)
+ { //
+ document.push_back(new ellipse_element(rx, ry, cx, cy));
+ return *this;
+ }
+
+ // -----------------------------------------------------------------
+ // push_back the information about text to the document.
+ // -----------------------------------------------------------------
+ svg& text(double x, double y, const std::string& text, int text_size = 12,
+ const std::string& font = "Lucida Sans Unicode",
+ const std::string& style = "", const std::string& weight = "",
+ const std::string& stretch = "", const std::string& decoration = "",
+ align_style align = center_align, int rotate = 0)
+ {
+ document.push_back(new text_element(x, y,
+ text, text_size, font, style, weight, stretch, decoration, align, rotate)
+ );
+ return *this;
+ }
+
+ // push_back info about polygon shapes:
+ // Polygon for shapes with many vertices.
+
+ svg& polygon(double x, double y, bool f = true) // 1st point only, add others later with .P(x, y).
+ {
+ document.push_back(new polygon_element(x, y, f));
+ return *this;
+ }
+
+ svg& polygon(std::vector<poly_path_point>& v, bool f = true)
+ { // push_back a complete many-sided polygon to the document.
+ document.push_back(new polygon_element(v, f));
+ return *this; // svg&
+ }
+
+ // Specific polygon shapes: triangle, rhombus, pentagon & hexagon.
+
+ svg& triangle(double x1, double y1, double x2, double y2, double x3, double y3, bool f = true)
+ { // push_back a complete triangle to the document.
+ document.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, f));
+ return *this; // svg&
+ }
+
+ svg& rhombus(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, bool f = true)
+ { // push_back a complete rhobus to the document.
+ document.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, x4, y4, f));
+ return *this; // svg&
+ }
+
+ svg& pentagon(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double x5, double y5, bool f = true)
+ { // push_back a complete rhobus to the document.
+ document.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, f));
+ return *this; // svg&
+ }
+
+ svg& hexagon(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double x5, double y5, double x6, double y6, bool f = true)
+ { // push_back a complete 6-sided star to the document.
+ document.push_back(new polygon_element(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, f));
+ return *this; // svg&
+ }
+
+ // push_back info about polylines.
+
+ svg& polyline(double x, double y) // 1st point only, add others later with .P(x, y).
+ {
+ document.push_back(new polyline_element(x, y));
+ return *this;
+ }
+
+ svg& polyline(double x1, double y1, double x2, double y2) // Two points only, add others later with .P(x, y).
+ {
+ document.push_back(new polyline_element(x1, y1));
+ document.push_back(new polyline_element(x2, y2));
+ return *this;
+ }
+
+ svg& polyline(std::vector<poly_path_point>& v, bool f = true)
+ { // push_back a complete many-sided polygon to the document,
+ // from a vector of points.
+ document.push_back(new polygon_element(v, f));
+ return *this; // svg&
+ }
+
+ // --------------------------------------------------------------------------------
+ // Writes the information about path, clip_path to the document.
+ // --------------------------------------------------------------------------------
+
+ path_element& path()
+ {
+ document.push_back(new path_element()); // empty path, ready for additions with M., L. ...
+ return *(static_cast<path_element*>(&(document[(unsigned int)(document.size()-1)])));
+ // reference to the path_element just pushed.
+ }
+
+ svg& clip_path(const rect_element& rect, const std::string& id)
+ {
+ clip_paths.push_back(clip_path_element(id, rect));
+ return *this;
+ }
+
+ // -------------------------------------------------------------
+ // Writes the information about a group element to the document.
+ // -------------------------------------------------------------
+
+ g_element& add_g_element()
+ {
+ return document.add_g_element();
+ }
+
+ g_element& get_g_element(int i)
+ { // Array of g_elements document,
+ // indexed by group type, PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND, ... SVG_PLOT_DOC_CHILDREN
+ return document.g_tag(i);
+ }
+
+ // -------------------------------------------------------------
+ // Load stylesheet
+ // -------------------------------------------------------------
+
+ svg& load_stylesheet(const std::string& input)
+ { // Load a stylesheet into string css from an input file.
+ std::ifstream if_str(input.c_str());
+
+ if(if_str.fail())
+ {
+ throw std::runtime_error("Error opening file " + input);
+ }
+ if(!validate_stylesheet(if_str))
+ {
+ throw std::runtime_error("Error loading stylesheet!");
+ }
+ if_str.clear();
+ if_str.seekg(0);
+ std::string tmp;
+ css = "";
+ while(std::getline(if_str, tmp))
     {
- std::ofstream f_out(_file.c_str());
-
- if(f_out.fail())
- {
- throw std::runtime_error("Unable to open file "+_file);
- }
-
- write(f_out);
-
- return *this;
- }
-
- svg& write(std::ostream& _s_out)
- {
- _write_header(_s_out);
-
- // Begin svg tag.
- _s_out<<"<svg width=\""<<x_size<<"\" height =\""
- <<y_size<<"\" version=\"1.1\""
- <<" xmlns=\"http://www.w3.org/2000/svg\">"<<std::endl;
-
- _write_css(_s_out);
-
- _write_document(_s_out);
-
- //close off svg tag
- _s_out<<"</svg>";
-
- return *this;
- }
-
- // -----------------------------------------------------------------
- // Writes the information about the size of the file to the document.
- // TODO: allow other unit identifiers.
- // -----------------------------------------------------------------
- svg& image_size(unsigned int x, unsigned int y)
- {
- x_size = x;
- y_size = y;
-
- return *this;
- }
- // -----------------------------------------------------------------
- // Writes the information about lcircle to the document.
- // -----------------------------------------------------------------
-
- svg& circle(double x, double y, unsigned int radius = 5)
- {
- document.push_back(new circle_element(x, y, radius));
- return *this;
- }
-
- // -----------------------------------------------------------------
- // Writes the information about a line to the document.
- // -----------------------------------------------------------------
- svg& line(double x1, double y1, double x2, double y2)
- {
- document.push_back(new line_element(x1, y1, x2, y2));
-
- return *this;
- }
-
- // -----------------------------------------------------------------
- // Writes the information about text to the document.
- // -----------------------------------------------------------------
- svg& text(double x, double y, const std::string& text,
- int text_size = 12, text_style align = center_align,
- int rotation = 0)
- {
- document.push_back(new text_element(x, y, text, text_size, align,
- rotation));
-
- return *this;
- }
-
- svg& rect(double x1, double y1, double x2, double y2)
- {
- document.push_back(new rect_element(x1, y1, x2, y2));
-
- 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, const std::string& _id)
- {
- clip_paths.push_back(clip_path_element(_id,_rect));
-
- return *this;
- }
-
- g_element& add_g_element()
- {
- return document.add_g_element();
- }
-
- g_element& get_g_element(int i)
- {
- return document.g_tag(i);
- }
-
- unsigned int get_x_size()
- {
- return x_size;
- }
-
- unsigned int get_y_size()
- {
- return y_size;
- }
-
- svg& load_stylesheet(const std::string& input)
- {
- std::ifstream if_str(input.c_str());
-
- if(if_str.fail())
- {
- throw std::runtime_error("Error opening file " + input);
- }
-
- if(!validate_stylesheet(if_str))
- {
- throw std::runtime_error("Error loading stylesheet");
- }
-
- if_str.clear();
- if_str.seekg(0);
-
- std::string tmp;
-
- css = "";
- while(std::getline(if_str, tmp))
- {
- css += tmp;
- }
-
- return *this;
+ css += tmp;
     }
+ return *this;
+ } // svg& load_stylesheet
 }; // class svg
 
 } // namespace svg

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-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,16 +1,20 @@
 // svg_1d_plot.hpp
 
-// Copyright (C) Jacob Voytko 2007
+// Copyright Jacob Voytko 2007
 // Copyright Paul A. Bristow 2007
-// Added disable warning 4180 in Boost.Parameter Sep 2007.
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
 
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 // -----------------------------------------------------------------
 
-#ifndef _BOOST_SVG_SVG_1D_PLOT_HPP
-#define _BOOST_SVG_SVG_1D_PLOT_HPP
+#ifndef BOOST_SVG_SVG_1D_PLOT_HPP
+#define BOOST_SVG_SVG_1D_PLOT_HPP
+
+//#if defined (BOOST_MSVC)
+//# pragma warning (disable: 4005) // 'BOOST_PARAMETER_MAX_ARITY' : macro redefinition
+//#endif
 
 #define BOOST_PARAMETER_MAX_ARITY 12
 
@@ -22,6 +26,7 @@
 # pragma warning (disable: 4180) // qualifier applied to function type has no meaning; ignored
 #endif
 
+// Added disable warning 4180 in Boost.Parameter Sep 2007.
 // See also pbristow trac ticket #1097 complaining about this ;-)
 // trailing const qualifiers are said to be meaningless.
 
@@ -45,38 +50,34 @@
 #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
+namespace boost
+{
+namespace svg
+{
+ #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
+
+ // -----------------------------------------------------------------
+ // Parameter names for plot() function
+ // -----------------------------------------------------------------
+ #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 allows us to store plot state locally in svg_plot. We don't
@@ -86,370 +87,422 @@
 // -----------------------------------------------------------------
 struct svg_plot_series
 {
- std::vector<double> series;
- std::vector<double> series_limits;
+ std::vector<double> series; // Normal 'OK to plot' data values.
+ std::vector<double> series_limits; // 'limit' values: too big, too small or NaN.
 
- std::string title;
- plot_point_style point_style;
+ std::string title; // title of data series (to show on legend).
+ plot_point_style point_style; // circle, square...
 
-
- // -------------------------------------------------------------
- // Scan each data point between the iterators that are passed,
- // sorting them into the correct std::vector.
- // -------------------------------------------------------------
- template <class T>
- svg_plot_series(T _begin, T _end, const std::string& _title,
- const plot_point_style& _style):
- title(_title), point_style(_style)
+ // -------------------------------------------------------------
+ // Scan each data point between the iterators that are passed,
+ // sorting them into the correct std::vector, normal or not.
+ // -------------------------------------------------------------
+ template <class T>
+ svg_plot_series(T begin, T end, const std::string& title, const plot_point_style& style)
+ :
+ title(title),
+ point_style(style)
+ // No line style for 1-D, only for 2-D.
+ // No defaults for begin and end.
+ {
+ for(T i = begin; i != end; ++i)
     {
- double temp;
-
- for(T i = _begin;
- i != _end;
- ++i)
- {
- temp = *i;
-
- if(detail::is_limit(temp))
- {
- series_limits.push_back(temp);
- }
-
- else
- {
- series.push_back(temp);
- }
- }
+ double temp = *i;
+ if(detail::is_limit(temp))
+ {
+ series_limits.push_back(temp); // 'limit' values: too big, too small or NaN.
+ }
+ else
+ {
+ series.push_back(temp); // Normal 'OK to plot' data values.
+ }
     }
-};
+ } // svg_plot_series
+}; // struct svg_plot_series()
 
-class svg_1d_plot: public detail::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_x1, plot_y1,
- plot_x2, plot_y2;
-
- // axis information.
- unsigned int x_major_length, x_major_width,
- x_minor_length, x_minor_width, x_num_minor,
-
- // misc information.
- legend_title_size;
-
- // 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;
-
- // Yes/no questions
- 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;
+ protected:
+ // Stored so as to avoid rewriting style information constantly.
+ svg image;
+
+ text_element title_info; // Title of whole plot.
+ text_element legend_header; // legend box header (if any).
+ text_element x_label_info; // Example: "length of widget"
+ text_element x_units_info; // For example, to display, "length (meter)"
+ // No Y-axis info for 1D.
+ // Note that text_elements hold font_size.
+
+ // Border information for the plot window (not the full image size).
+ // Allows for title and legend to be separate.
+ // Initially set to the width and height of the image.
+ // TODO Should this be unsigned int??? to be consistent.
+ int plot_x1; // calculate_plot_window() sets these values.
+ int plot_y1;
+ int plot_x2;
+ int plot_y2;
+
+ // X-Axis information.
+ unsigned int x_major_tick_length_; // pixels.
+ unsigned int x_major_tick_width_; // pixels.
+ unsigned int x_minor_tick_length_; // pixels.
+ unsigned int x_minor_tick_width_; // pixels.
+ // Avoid name clash with x_m*_tick_length and width.
+ unsigned int x_num_minor_ticks_; // number of minor ticks, eg 4 gives major 0, minor 1,2,3,4, major 5
+ // grid width is also set in style.stroke_width()
+ // TODO Not sure it is wise to store in two places?
+ unsigned int x_major_grid_width_; // pixels.
+ unsigned int x_minor_grid_width_; // pixels.
+ //unsigned int x_major_label; // pixels. Now in x_units_info font size
+
+ // Other information.
+ double text_margin; // Marginal space around text items like title,
+ // as a fraction of font size, (pixels) (was fixed at 1.5).
+ int border_margin; // Marginal (pixels) space around the plot border.
+
+ // X-Axis information.
+ // (Y_axis stored as one point because this is a 1D graph).
+ double x_min; // minimum x (Cartesian units).
+ double x_max; // maximum x (Cartesian units).
+ double x_axis; // stroke width (pixels). ????
+ double x_major; // Interval (Cartesian units) between major ticks.
+ // set/get by x_major_interval
+ double x_minor; // Interval (Cartesian units) between minor ticks.
+ // because x_num_minor_ticks_ used to determine this instead,
+ // but one could calculate x_minor.
+
+ // Yes/no options.
+ bool use_title; // Show plot title.
+ bool use_legend; // Show legend box.
+ bool use_plot_window; // rather than whole image.
+ bool use_x_axis_lines_; // = x_axis_on()
+ bool use_y_axis_lines_; // Note: is needed in 1D version too in draw_axes.
+ bool use_x_major_labels; // For example, to show value (like 1.2) by ticks.
+ bool use_x_label_units; // For example, to show, "length (meter)"
+ bool use_x_major_grid; // provide major vertical lines.
+ bool use_x_minor_grid;// provide minor vertical lines.
+ bool use_x_label; // Show label text for the axis, like "X-axis"
+ bool use_up_ticks; // ticks only up from Y = 0 horizontal X-axis.
+ bool use_down_ticks;// ticks only down from Y = 0 horizontal X-axis.
+ //bool use_left_ticks; // only for 2D.
+ //bool use_right_ticks;
+ bool use_x_ticks; // = use_up_ticks || use_down_ticks
+ // bool use_y_ticks; // = use_left_ticks || use_right_ticks only for 2-D
+ // Note: can have ticks both up and down (the original style).
+ bool use_x_ticks_on_plot_window_; // rather than on Y = 0 horizontal axis.
+ bool use_line; // set by line_on(bool); // Not really useful for 1-D,
+ // TODO but needs Boost-Parameter removed to do properly.
 
 private:
- friend class detail::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;
-
- double x_scale, x_shift;
- double y_scale, y_shift;
+ // Where we will be storing the data points for transformation.
+ std::vector<svg_plot_series> series;
+ // These are sorted into two vectors for normal and abnormal (max, inf and NaN).
+
+ double x_scale; // Used for transform from Cartesian to SVG coordinates.
+ double x_shift; // SVG origin is top left, Cartesian is bottom right.
+ double y_scale;
+ double y_shift;
+
+ // Public member functions, defined below.
+ // void calculate_transform(); //
+ // void draw_axes();
+ // void calculate_plot_window(); // plot_x, plot_y...
+ // void update_image();
+ // void set_ids();
 
+public:
+ svg_1d_plot() : // Default constructor.
+ // Many ( but not all - see below) default values here.
+ title_info(0, 0, "Plot of data", 20, "Verdana", "", "", "", "", center_align, horizontal),
+ legend_header(0, 0, "Legend", 16, "Arial", "", "", "", "", center_align, horizontal),
+ x_label_info(0, 0, "X Axis", 14, "Lucida Sans Console", "", "", "", "", center_align, horizontal), //
+ x_units_info(0, 0, "(units)", 14, "Lucida Sans Console", "", "", "", "", right_align, horizontal),
+ //x_units_info(0, 0, "(units)", 14, "Times New Roman", "italic", "bold", "wider", "underline", right_align, horizontal),
+ text_margin(2.), // for text was 1.5 // as a fraction of the font size.
+ border_margin(5), // Prevent plot window box begin right on edge.
+ x_min(-10), x_max(10),
+ use_legend(false),
+ use_title(true),
+ use_plot_window(false),
+ use_x_label(false), // Label like "volume".
+ use_x_label_units(false),
+ use_x_major_labels(true), // Values on major ticks.
+ x_major_grid_width_(3),
+ x_minor_grid_width_(1),
+ use_up_ticks(false),
+ use_down_ticks(true),
+ use_x_ticks_on_plot_window_(false), // was external_style
+ // use_y_ticks_on_plot_window_(false), // was external_style
+ use_x_ticks(true), // use_up_ticks || use_down_ticks
+ // 2D has left and right ticks too.
+ use_line(true),
+ use_x_major_grid(false),
+ // x_minor_grid_width(1),
+ use_x_minor_grid(false),
+ use_x_axis_lines_(true),
+ use_y_axis_lines_(false), // Not needed for 1D, but leave at false.
+ x_major(2), // interval between x major ticks
+ x_major_tick_width_(3),
+ x_minor_tick_width_(1),
+ x_major_tick_length_(10), // If both up and down, total is twice this.
+ x_minor_tick_length_(5), // If both up and down, total is twice this.
+ x_num_minor_ticks_(2),
+ // legend_title_size(12), TD remove - now in text_element
+ x_scale(1.), x_shift(0),
+ y_scale(1.), y_shift(0)
+ // See documentation for default settings rationale.
+ {
+ image_size(500, 200); // Default image size.
+ // Only need to be quite shallow (y_size) for a 1-D plot.
+ // 200 barely leaves enough room for five data series in the legend).
+ // (2-D usually needs to be much more rectangular).
+ use_x_ticks = use_up_ticks || use_down_ticks;
+ // Only 2D has left and right ticks.
 
- void _calculate_transform()
+ // Build the document tree & add all the children of the root node.
+ for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
- 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_y1 - (plot_y1-plot_y2)/2.;
+ image.add_g_element();
     }
 
- void _draw_axis()
- {
- double x(0.), y1(0.), y2(image.get_y_size());
-
- _transform_x(x);
-
- y1 = 0.;
-
- //draw origin. Make sure it is in the window
- if(x > plot_x1 && x < plot_x2 && show_y_axis_lines)
- {
- if(!use_plot_window)
- {
- if(use_title)
- {
- y1 += title_info.font_size() * 1.5;
- }
- if(use_x_label)
- {
- y2 -= x_label_info.font_size() * 1.5;
- }
- }
-
- else
- {
- y1 = plot_y1;
- y2 = plot_y2;
- }
-
- image.get_g_element(detail::PLOT_X_AXIS).line(x, y1, x, y2);
+ // Set stroke color & width defaults.
+ image.get_g_element(detail::PLOT_BACKGROUND).style().fill_color(white);
+ //image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color(black); TODO needed? Harmful?
+ image.get_g_element(detail::PLOT_X_AXIS).style().stroke_color(black);
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS).style().stroke_color(black).stroke_width(x_major_tick_width_);
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS).style().stroke_color(black).stroke_width(x_minor_tick_width_);
+ image.get_g_element(detail::PLOT_X_MAJOR_GRID).style().stroke_color(blue); // TODO temporary cyan is good.
+ image.get_g_element(detail::PLOT_X_MAJOR_GRID).style().stroke_width(x_major_grid_width_);
+ image.get_g_element(detail::PLOT_X_MINOR_GRID).style().stroke_color(cyan);
+ image.get_g_element(detail::PLOT_X_MINOR_GRID).style().stroke_width(x_minor_grid_width_);
+ image.get_g_element(detail::PLOT_LIMIT_POINTS).style().stroke_color(lightgray).fill_color(whitesmoke);
+
+ // Font info defaults are set by the constructor above.
+
+ set_ids();
+ } // svg_1d_plot()
+
+ void calculate_transform()
+ { // Calculate scale and shift factors for transform from Cartesian to plot.
+ // SVG image is 0, 0 at top left, Cartesian at bottom left.
+ 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_y1 - (plot_y1 - plot_y2) / 2.;
+ } // void calculate_transform()
+
+ void draw_axes()
+ { // For 1-D, there is, of course, only the X-axis!
+ double x(0.);
+ double y1(0.);
+ double y2(image.y_size());
+ transform_x(x);
+ // Draw origin, making sure it is in the plot window.
+ if(use_x_axis_lines_ && (x > plot_x1) && (x < plot_x2))
+ { // TODO >= and <= ? instead.
+ if(!use_plot_window)
+ { // Use whole image.
+ if(use_title)
+ { // Allow space for title, taking account of font size.
+ y1 += title_info.font_size() * (text_margin +1);
+ }
+ if(use_x_label)
+ {// Allow space for x tick values, taking account of font size.
+ y2 -= x_label_info.font_size() * text_margin;
         }
- _draw_x_axis();
+ }
+ else
+ { // Use plot window.
+ y1 = plot_y1;
+ y2 = plot_y2;
+ }
+ image.get_g_element(detail::PLOT_X_AXIS).line(x, y1, x, y2);
     }
+ draw_x_axis();
+ } // draw_axes()
 
- void _calculate_plot_window()
- {
- x_axis = (plot_y2 + plot_y1)/2.;
-
- plot_x1 = plot_y1 = 0;
- plot_x2 = image.get_x_size();
- plot_y2 = image.get_y_size();
+ void calculate_plot_window()
+ { // For 1-D
+ x_axis = (plot_y2 + plot_y1) / 2.; // Put X-axis halfway up plot window.
+ plot_x1 = 0; // Top left of image.
+ plot_y1 = 0;
+ plot_x2 = image.x_size(); // Bottom right of image.
+ plot_y2 = image.y_size();
 
- if(use_plot_window)
- {
- plot_x1+=5;
- plot_x2-=5;
- plot_y1+=5;
- plot_y2-=5;
-
- if(use_legend)
- {
- plot_x2 -= 155;
- }
-
- if(use_x_label)
- {
- plot_y2 -= 20;
- }
-
- if(use_x_external_style)
- {
- plot_y2 -=
- x_major_length > x_minor_length ?
- x_major_length :
- x_minor_length ;
- }
-
- //for the title. Will take into account font size soon TODO
- 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));
- }
+ if(use_plot_window)
+ {
+ plot_x1 += border_margin; // small margin around border.
+ plot_x2 -= border_margin; //
+ plot_y1 += border_margin; //
+ plot_y2 -= border_margin;
+
+ if(use_title)
+ {
+ // Allow a blank line, title lines and a line space.
+ plot_y1 += title_font_size() * 2;
+ }
+ if(use_legend)
+ { // Allow space for legend at right.
+ plot_x2 -= 150; // This 150 is an arbitrary legend box width.
+ // TODO size could depend on font_size & length of text?
+ }
+ if(use_x_label)
+ {// Allow space for x_label at bottom.
+ plot_y2 -= static_cast<int>(x_label_info.font_size() * text_margin);
+ }
+ if(use_down_ticks)
+ { // Allow space for the downward ticks
+ // (so don't go into/over the border margin).
+ // TODO use std::max here.
+ plot_y2 -=
+ (x_major_tick_length_ > x_minor_tick_length_) ?
+ x_major_tick_length_ : x_minor_tick_length_;
+ }
+ // Draw plot window rect.
+ 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));
+ // <g id="plotBackground" fill="rgb(248,248,255)"><rect x="43" y="53" width="302" height="304"/></g>
+ } // use_plot_window
+ } // void calculate_plot_window()
+
+ void update_image()
+ {
+ // Removes all elements that will show up in a subsequent draw.
+ clear_all();
+
+ // Draw plot background.
+ image.get_g_element(detail::PLOT_BACKGROUND).push_back(
+ new rect_element(0, 0, image.x_size(), image.y_size()));
+
+ calculate_plot_window();
+ calculate_transform();
+ draw_title(); // Call after above to the plot_x and y are defined.
+ if(use_x_axis_lines_)
+ {
+ draw_axes();
     }
-
- void _update_image()
+ if(use_legend)
     {
-
- // removes all elements that will show up in a subsequent draw
- _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(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);
- }
- }
- }
+ draw_legend();
     }
-
- void _set_ids()
+ if(use_x_label)
     {
- for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
+ draw_x_label();
+ }
+ double y(0.); // All 1-D points are plotted are on the y = 0 axis.
+ transform_y(y);
+ for(unsigned int i = 0; i < series.size(); ++i)
+ { // For each of the data series.
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
+
+ g_ptr.style().stroke_color(series[i].point_style.stroke_color);
+ g_ptr.style().fill_color(series[i].point_style.fill_color);
+
+ for(unsigned int j = 0; j < series[i].series.size(); ++j)
+ { // Draw points for jth series.
+ double x = series[i].series[j];
+ transform_x(x);
+ if( // Check point is inside plot_window (otherwise ignore it).
+ (x > plot_x1) // TODO <=?
+ && (x < plot_x2)
+ && (y > plot_y1)
+ && (y < plot_y2) )
         {
- image.get_g_element(i).id(detail::_document_ids[i]);
+ draw_plot_point(x, y, g_ptr, series[i].point_style);
         }
- }
-
-public:
-
-// see documentation for default settings rationale.
-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)
-{
- image_size(500, 350);
-
- //build the document tree.. add children of the root node
- for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
+ } // for j
+ } // for
+ } // void update_image()
+
+ void set_ids()
+ { // document ids for use in <g id = "PLOT_TITLE".../>
+ for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
- image.add_g_element();
+ image.get_g_element(i).id(detail::document_ids[i]);
     }
+ } // void set_ids()
 
- // set color defaults
- 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).stroke_width(2);
-
- image.get_g_element(detail::PLOT_LIMIT_POINTS)
- .style().stroke_color(lightgray).fill_color(whitesmoke);
-
- image.get_g_element(detail::PLOT_X_MINOR_TICKS)
- .style().stroke_width(1);
-
- _set_ids();
-}
-
-// -----------------------------------------------------------------
-// write() has two flavors.. a file and a ostream. The file version
-// opens a stream and calls the stream version. The stream version
-// first clears all unnecessary data from the graph, builds the
-// document tree, and then calls the write function for the root
-// document node, which calls all other nodes through the Visitor
-// pattern.
-// -----------------------------------------------------------------
-svg_1d_plot& write(const std::string& _str)
-{
- std::ofstream fout(_str.c_str());
-
+ // ------------------------------------------------------------------------
+ // write() has two flavors, a file and a ostream.
+ // The file version opens an ostream, and calls the stream version.
+ // The stream version first clears all unnecessary data from the graph,
+ // builds the document tree, and then calls the write function for the root
+ // document node, which calls all other nodes through the Visitor pattern.
+ // ------------------------------------------------------------------------
+
+ svg_1d_plot& write(const std::string& filename)
+ {
+ std::ofstream fout(filename.c_str());
     if(fout.fail())
     {
- throw std::runtime_error("Failed to open "+_str);
+ throw std::runtime_error("Failed to open " + filename);
     }
-
- svg_1d_plot::write(fout);
-
+ image.image_filename(filename);
+ // Note filename for optional output as comment in the .svg file.
+ svg_1d_plot::write(fout); // Use the ostream version.
     return *this;
-}
-
-svg_1d_plot& write(std::ostream& s_out)
-{
- _update_image();
+ }
 
+ svg_1d_plot& write(std::ostream& s_out)
+ {
+ update_image();
+ // Default stream precision 6 decimal digits is probably excessive.
+ // 4.1 Basic data types, integer or float in decimal or scientific (using e format).
+ // - probably enough if image size is under 1000 x 1000.
+ // This will reduce .svg file sizes significantly for curves represented with many data points.
+ // For example, if a curve is shown using 100 points,
+ // reducing to coord_precision(3) from 6 will reduce file size by 300 bytes.
     image.write(s_out);
-
     return (svg_1d_plot&)*this;
-}
+ }
 
-#if defined (BOOST_MSVC)
-# pragma warning(push)
-# pragma warning (disable: 4100) // 'args' : unreferenced formal parameter
-#endif
+ //
+ #if defined (BOOST_MSVC)
+ # pragma warning(push) // disable warnings in Boost.parameter
+ // (delete this and pop below if not used in future.)
+ # pragma warning (disable: 4100) // 'args' : unreferenced formal parameter
+ #endif
 
-BOOST_PARAMETER_MEMBER_FUNCTION
-(
+ BOOST_PARAMETER_MEMBER_FUNCTION
+ (
     (void),
     plot,
     tag,
     (required
- (container, *)
- (title, (const std::string&))
+ (container, *)
+ (title, (const std::string&))
     )
     (optional
- (stroke_color, (const svg_color&), svg_color(white))
- (point_style, (point_shape), circle)
- (size, (int), 10)
- (x_functor, *, detail::boost_default_convert())
+ (stroke_color, (const svg_color&), svg_color(white))
+ (point_style, (point_shape), round)
+ (size, (int), 10)
+ (x_functor, *, detail::boost_default_convert())
     )
     (deduced
- (optional
- (fill_color, (const svg_color&), svg_color(black))
- )
+ (optional
+ (fill_color, (const svg_color&), svg_color(black))
     )
-)
-{
+ )
+ )
+ {
     series.push_back(svg_plot_series(
- boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor),
- title,
- plot_point_style(stroke_color, fill_color, size, point_style)
- ));
-}
-
-#if defined (BOOST_MSVC)
-# pragma warning(pop)
-#endif
+ boost::make_transform_iterator(container.begin(), x_functor),
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
+ plot_point_style(stroke_color, fill_color, size, point_style)
+ ));
+ }
+
+ #if defined (BOOST_MSVC)
+ # pragma warning(pop)
+ #endif
 
 }; // end svg_1d_plot
 
-}
-}
+} // namespace svg
+} // namespace boost
 
 
-#endif
+#endif // BOOST_SVG_SVG_1D_PLOT_HPP

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-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,14 +1,15 @@
 // svg_2d_plot.hpp
 
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
+// Copyright Jacob Voytko 2007
+// Copyright Paul A. Bristow 2007
 
-// -----------------------------------------------------------------
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef _BOOST_SVG_SVG_2D_PLOT_HPP
-#define _BOOST_SVG_SVG_2D_PLOT_HPP
+#ifndef BOOST_SVG_SVG_2D_PLOT_HPP
+#define BOOST_SVG_SVG_2D_PLOT_HPP
 
 #define BOOST_PARAMETER_MAX_ARITY 12
 
@@ -43,921 +44,1166 @@
 #include <iterator>
 #include <exception>
 
-namespace boost {
-namespace svg {
+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)
+ 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(bezier_on)
-BOOST_PARAMETER_NAME(line_on)
-BOOST_PARAMETER_NAME(line_color)
-BOOST_PARAMETER_NAME(area_fill_color)
+ // TODO Why are these outside the #endif? Subset?
+ // Remove when class plot used instead of Boost.Parameter.
+ BOOST_PARAMETER_NAME(bezier_on)
+ BOOST_PARAMETER_NAME(line_on)
+ BOOST_PARAMETER_NAME(line_color)
+ BOOST_PARAMETER_NAME(area_fill_color)
+
+ // -----------------------------------------------------------------
+ // This allows us to store plot state locally in svg_plot. We don't
+ // store it in "svg" because transforming the points after they are
+ // written to the document would be difficult. We store the Cartesian
+ // coordinates locally and transform them before we write them.
+ // -----------------------------------------------------------------
 
 struct svg_2d_plot_series
 {
- std::multimap<double, double> series;
- std::multimap<double, double> series_limits;
-
- std::string title;
- plot_point_style point_style;
- plot_line_style line_style;
-
- template <class T>
- svg_2d_plot_series(T _begin,
- T _end,
- std::string _title,
- const plot_point_style& _point,
- const plot_line_style& _line):
- title(_title),
- point_style(_point),
- line_style(_line)
- {
- for(T i = _begin;
- i != _end;
- ++i)
- {
- if(detail::pair_is_limit(*i))
- {
- series_limits.insert(*i);
- }
-
- else
- {
- series.insert(*i);
- }
- }
+ // 2-D Data series points to plot.
+ std::multimap<double, double> series; // Normal 'OK to plot' data values.
+ std::multimap<double, double> series_limits; // 'limit' values: too big or small, or NaN.
+ // TODO is there a reason why multimap is used rather than vector of pairs?
+ // multimap sorts, which will take time and isn't needed?
+
+ std::string title;
+ plot_point_style point_style;
+ plot_line_style line_style;
+
+ template <class T>
+ svg_2d_plot_series(T begin, T end,
+ std::string title, // of data series.
+ const plot_point_style& point,
+ const plot_line_style& line)
+ :
+ title(title),
+ point_style(point),
+ line_style(line)
+ { // Constructor.
+ for(T i = begin; i != end; ++i)
+ { // Sort into normal and limited series.
+ if(detail::pair_is_limit(*i))
+ { // Either x and/or y is at limit.
+ series_limits.insert(*i);
+ }
+ else
+ { // normal point.
+ series.insert(*i);
+ }
     }
+ } // svg_2d_plot_series
 }; // struct svg_2d_plot_series
 
-class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
-{
-private:
- friend class detail::axis_plot_frame<svg_2d_plot>;
-
- double x_scale, x_shift;
- double y_scale, y_shift;
-
- // Stored so as to avoid rewriting style information constantly.
- svg image;
-
- text_element title_info;
- text_element x_label_info;
- text_element y_label_info;
-
- // Border information for the plot window.
- // Initially will be set to the width and height of the graph.
- int plot_x1;
- int plot_x2;
- int plot_y1;
- int plot_y2;
-
- // X axis information.
- double x_min, x_max;
- double x_axis;
-
- double x_major;
-
- 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 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;
+class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
+{ // See also svg_1d_plot.hpp for 1-D version.
 
- // Where we will be storing the data points for transformation.
- std::vector<svg_2d_plot_series> series;
-
- std::string plot_window_clip;
-
- // Y axis information.
- double y_min, y_max;
-
- double y_major, y_axis;
-
- unsigned int y_major_length, y_minor_length,
- y_num_minor;
-
- bool use_y_label;
- bool use_y_major_labels;
-
- void _draw_y_minor_ticks(double j, path_element& tick_path,
- path_element& grid_path)
- {
- double y1(0.), x1(0.), x2(image.get_y_size());
-
- // Draw the grid if needed.
- if(use_y_minor_grid)
- {
- _transform_y(y1 = j);
-
- if(!use_plot_window && use_y_label)
- {
- x2 -= 12 * 1.5;
- }
-
- else
- {
- x1 = plot_x1 + 1;
- x2 = plot_x2 - 1;
- }
-
- if(y1 > plot_y1)
- {
- grid_path.M(x1, y1).L(x2, y1);
- }
- }
-
- double y_tick_length = y_minor_length / 2.;
-
- if(use_y_external_style)
- {
- x1 = plot_x1;
- x2 = plot_x1 - y_tick_length / 2.;
- }
-
- else
- {
- x1 = y_axis + y_tick_length / 2.;
- x2 = y_axis - y_tick_length / 2.;
- }
- y1=j;
-
- _transform_y(y1);
+private:
+ friend class detail::axis_plot_frame<svg_2d_plot>;
+ // Contains functions common to 1 and 2-D.
 
- // 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);
- }
- } // void _draw_y_minor_ticks
+ double x_scale; // Use by function transform()
+ double x_shift; // to go from Cartesian to svg coordinates.
+ double y_scale;
+ double y_shift;
+
+ // Stored so as to avoid rewriting style information constantly.
+ svg image;
+
+ text_element title_info; // Plot title.
+ text_element legend_header; // legend box header or title (if any).
+ text_element x_label_info; // For example: "length"
+ text_element y_label_info; // For example: "volume"
+ text_element x_units_info; // For example: "mm"
+ text_element y_units_info; // 2-D only.
+
+ double text_margin; // Marginal space around text items like title,
+ // as a fraction of font size, (pixels) (was fixed at 1.5).
+ int border_margin; // Marginal (pixels) space around the plot border.
+
+ // Border information for the plot window (<= image size).
+ // Allows for title and legend to be separate.
+ // Initially will be set to the width and height of the graph image.
+ // calculate_plot_window() sets these values.
+ int plot_x1; // TODO unsigned int? or double?
+ int plot_x2;
+ int plot_y1;
+ int plot_y2;
+
+ // X-Axis information.
+ double x_min; // minimum x value (Cartesian units).
+ double x_max; // maximum x value (Cartesian units).
+ double x_axis; // // x-axis (y = 0) transformed into SVG coordinates.
+ double x_major; // x_major is the stride or interval for major x ticks.
+ // set/get by x_major_interval
+ double x_minor; // Interval (Cartesian units) between minor ticks.
+ // because x_num_minor_ticks_ used to determine this instead,
+ // but one could calculate x_minor.
+
+ unsigned int x_major_tick_length_; // pixels.
+ unsigned int x_major_tick_width_; // pixels.
+ unsigned int x_minor_tick_length_; // pixels.
+ unsigned int x_minor_tick_width_; // pixels.
+ // Avoid name clash with x_m*_tick_length and width.
+ unsigned int x_num_minor_ticks_; // number of minor ticks, eg 4 gives major 0, minor 1,2,3,4, major 5
+ unsigned int x_major_grid_width_; // pixels.
+ unsigned int x_minor_grid_width_; // pixels.
+ // grid width is set in style.stroke_width
+ //unsigned int x_major_label; // pixels. Now in x_units_info font size
+
+ // Y-Axis information.
+ double y_min; // minimum y value (Cartesian units).
+ double y_max; // maximum y value (Cartesian units).
+ double y_major; // y_major is the stride or interval for major y ticks.
+ double y_axis; // Y-axis (x = 0) transformed into SVG coordinates.
+
+ unsigned int y_major_tick_length_; // pixels.
+ unsigned int y_major_tick_width_; // pixels.
+ unsigned int y_minor_tick_length_; // pixels.
+ unsigned int y_minor_tick_width_; // pixels.
+ // Avoid name clash with x_m*_tick_length and width.
+ unsigned int y_num_minor_ticks_; // number of minor ticks, eg 4 gives major 0, minor 1,2,3,4, major 5
+ // grid width is set in style.stroke_width
+ unsigned int y_major_grid_width_; // pixels.
+ unsigned int y_minor_grid_width_; // pixels.
+ //unsigned int y_major_label; // pixels.
+
+ // Yes/no options.
+ bool use_title;
+ bool use_legend;
+ bool use_axis;
+ bool use_plot_window;
+ bool use_x_major_labels; // values for major ticks.
+ bool use_y_major_labels;
+ bool use_x_major_grid;
+ bool use_x_minor_grid;
+ bool use_x_label;
+ bool use_y_label;
+ bool use_x_label_units;
+ bool use_y_label_units;
+
+ // Note: can have ticks both up and/or down, and/or left and right.
+ bool use_up_ticks;
+ bool use_down_ticks;
+ bool use_x_ticks; // = use_up_ticks || use_down_ticks
+ bool use_left_ticks;
+ bool use_right_ticks;
+ bool use_y_ticks; // = use_left_ticks || use_right_ticks
+ bool use_x_ticks_on_plot_window_; // was external style.
+ bool use_y_ticks_on_plot_window_; // rather than on y-axis.
+ bool use_x_axis_lines_; // ??? TODO what does this do?
+ bool use_y_axis_lines_; // ??? TODO what does this do?
+ bool use_y_major_grid;
+ bool use_y_minor_grid;
+ bool use_line; // set by line_on(bool); // Not really useful for 1-D,
+ // TODO but needs Boost-Parameter removed to do properly.
+
+ // Where we will be storing the data points (series) for transformation.
+ std::vector<svg_2d_plot_series> series; // Defined above.
+
+ std::string plot_window_clip; // = "clip_plot_window" id for clippath
+
+ // http://www.w3.org/TR/SVG/masking.html#ClipPathElement 14.1 Introduction
+ // clipping paths, which uses any combination of 'path', 'text' and basic shapes
+ // to serve as the outline where everything on the "inside" of the outline
+ // is allowed to show through but everything on the outside is masked out.
+ // So the plot_window_clip limits display to a plot_window rectangle.
+
+public: // of class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
+
+ svg_2d_plot() // Constructor, including all the very many default plot options.
+ :
+ // TODO check that *all* options are initialized here.
+ // See documentation for default settings rationale.
+
+ title_info(0, 0, "Plot of data", 16, "Verdana", "", "", "", "", center_align, horizontal),
+ x_label_info(0, 0, "X Axis", 14, "verdana", "", "", "", "", center_align, horizontal),
+ y_label_info(0, 0, "Y Axis", 14, "verdana", "", "", "", "", center_align, upward),
+ //x_label_info(0, 0, "X Axis", 12, "Lucida Sans Console", "", "", "", "", center_align, horizontal),
+ //y_label_info(0, 0, "Y Axis", 12, "Lucida Sans Console", "", "", "", "", center_align, upward),
+ x_units_info(0, 0, "(units)", 14, "Lucida Sans Console", "", "", "", "", center_align, horizontal),
+ y_units_info(0, 0, "(units)", 14, "Lucida Sans Console", "", "", "", "", center_align, upward),
+ // Plot may look odd if font and size of label & units are different!
+ // y_units_info(0, 0, "(units)", 11, "Times New Roman", "italic", "bold", "wider", "underline", right_align, upsidedown),
+ // shows some values that might be useful if svg browsers are fully implemented
+ // to support modification to text characters.
+ text_margin(2.), // for text was 1.5 // as a fraction of the font size.
+ border_margin(5), // Prevent plot window box begin right on edge.
+ // plot_x1, x2, y1, 2 are set in calculate_plot_window
+ x_min(-10), x_max(10), // so plots from -10 to +10
+ y_min(-10), y_max(10),
+ x_major(2), // x stride
+ y_major(2), // y stride
+ // Ticks on axes.
+ x_num_minor_ticks_(2),
+ y_num_minor_ticks_(4), // suits: major 0, minor 2, 4, 6, 8, major 10
+ x_major_tick_length_(10), // If both up and down, total is twice this.
+ x_minor_tick_length_(5),
+ x_major_tick_width_(2),
+ x_minor_tick_width_(1),
+ y_major_tick_length_(10), // If both left and right, total is twice this.
+ y_minor_tick_length_(5),
+ y_major_tick_width_(2),
+ y_minor_tick_width_(1),
+ // grids
+ x_major_grid_width_(2),
+ x_minor_grid_width_(1),
+ y_major_grid_width_(2),
+ y_minor_grid_width_(1),
+ x_scale(1.), x_shift(0),
+ y_scale(1.), y_shift(0),
+
+ plot_window_clip("plot_window"), // for <clipPath id="plot_window" ...
+
+ // Boolean options.
+ use_down_ticks(true), // On X-axis.
+ use_up_ticks(false), // external ticks only.
+ use_x_ticks(false), // = use_up_ticks || use_down_ticks
+ use_left_ticks(true), // On y-axis.
+ use_right_ticks(false), //
+ use_y_ticks(false), // = use_left_ticks || use_right_ticks
+ use_x_ticks_on_plot_window_(false), // was external_style
+ use_y_ticks_on_plot_window_(false), // was external_style
+ use_x_label_units(false),
+ use_y_label_units(false),
+ use_x_major_labels(true),
+ use_y_major_labels(false),
+ use_x_label(false),
+ use_y_label(true), // true for 2-D
+ use_title(true),
+ use_legend(false), use_axis(true),
+ use_x_axis_lines_(true),
+ use_y_axis_lines_(true),
+ use_x_major_grid(false),
+ use_x_minor_grid(false),
+ use_y_major_grid(false),
+ use_y_minor_grid(false),
+ use_plot_window(true),
+ use_line(true)
+ // TODO but needs Boost-Parameter removed to do properly.
+
+ {
+ image_size(500, 400); // Default image size for 2-D.
+ // 2-D needs to be squarer than 1-D.
+ use_x_ticks = use_up_ticks || use_down_ticks;
+ use_y_ticks = use_left_ticks || use_right_ticks;
 
- void _draw_y_major_ticks(double i, path_element& tick_path, path_element& grid_path)
+ // Build the document tree by adding all children of the root node.
+ for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
- double y1(i), x1(0.), x2(image.get_y_size());
-
- if(use_y_major_grid)
- {
- _transform_y(y1 = i);
-
- if(!use_plot_window && use_y_label)
- {
- x1 += 12 * 1.5;
- }
-
- else
- {
- x1 = plot_x1 + 1;
- x2 = plot_x2 - 1;
- }
-
- grid_path.M(x1, y1).L(x2, y1);
- }
-
- // Draw major tick.
- y1 = i;
-
- _transform_y(y1);
-
- // Make sure that we are drawing inside the allowed window.
- if(y1 < plot_y2 && y1 > plot_y1)
- {
- double y_tick_length = y_major_length / 2.;
-
- if(use_y_external_style)
- {
- x1 = plot_x1;
- x2 = plot_x1 - y_tick_length/2.;
- }
-
- else
- {
- x1 = y_axis + y_tick_length/2.;
- x2 = y_axis - y_tick_length/2.;
- }
-
- tick_path.M(x1, y1).L(x2, y1);
-
- if(use_y_major_labels)
- {
- std::stringstream fmt;
- fmt<<i;
-
- if(use_y_external_style)
- {
- x1 -= y_major_length;
- }
-
- else
- {
- x1 += (2 + y_major_length/2);
- }
-
- if(!use_y_external_style && i != 0)
- {
- image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
- y1, fmt.str());
- }
+ image.add_g_element();
+ }
 
- if(use_y_external_style)
- {
- image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1 + 12,
- y1, fmt.str(), 12, center_align, -90);
+ // Set other SVG color, stroke & width defaults for various child PLOT nodes.
+ // Tick length etc is now set above in the constructor.
+ image.get_g_element(detail::PLOT_BACKGROUND).style().fill_color(white);
+ image.get_g_element(detail::PLOT_LIMIT_POINTS).style().stroke_color(lightgray).fill_color(whitesmoke);
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color(black);
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(1);
+ 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_LABEL).style().stroke_color(blue); // TODO temp for tests
+ image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color(green); // TODO temp for tests
+ image.get_g_element(detail::PLOT_X_LABEL).style().stroke_width(1);
+ image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_width(1); // TODO control of this?
+ image.get_g_element(detail::PLOT_PLOT_LABELS).style().stroke_color(blue);
+ image.get_g_element(detail::PLOT_PLOT_LABELS).style().stroke_width(1); // 1 is bold blue
+ //image.get_g_element(detail::PLOT_PLOT_LABELS).style().stroke_width(0); // 0 is thin *black* - ignoring color!
+ // control with x_axis_value_color
+
+ // TODO separate control of data series point *values* 1.234 and their colors.
+
+ // Note that widths are stored in member data and copied here.
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS).style().stroke_width(x_major_tick_width_);
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS).style().stroke_width(x_minor_tick_width_);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(black);
+ 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(y_major_tick_width_);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(y_minor_tick_width_);
+ image.get_g_element(detail::PLOT_X_MAJOR_GRID).style().stroke_width(y_major_grid_width_);
+ image.get_g_element(detail::PLOT_X_MAJOR_GRID).style().stroke_color(cyan);
+ image.get_g_element(detail::PLOT_X_MINOR_GRID).style().stroke_width(y_minor_grid_width_);
+ image.get_g_element(detail::PLOT_X_MINOR_GRID).style().stroke_color(cyan);
 
- }
- } // if(use_y_major_labels)
- }
- } // _draw_y_major_ticks
+ set_ids();
+ } // svg_2d_plot() default constructor.
 
- void _draw_y_axis()
+private:
+ // svg_2d_plot Member Functions.
+
+ void set_ids()
+ { // document ids for use in <g id = "PLOT_TITLE".../>
+ for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
- 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();
-
- path_element& major_grid_path =
- image.get_g_element(detail::PLOT_Y_MAJOR_GRID).path();
+ image.get_g_element(i).id(detail::document_ids[i]);
+ }
+ } // void set_ids()
 
- //if(show_y_axis_lines)
- //{
- //image.get_g_element(detail::PLOT_Y_AXIS).
- // line(plot_y1, x_axis, plot_x2, x_axis);
+ void calculate_transform()
+ { // Calculate scale and shift factors for transform from Cartesian to plot.
+ // SVG image is 0, 0 at top left, Cartesian at bottom left.
+ 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_y2-plot_y1) / (y_max-y_min);
+ y_shift = plot_y1 - (y_max * (plot_y1 - plot_y2) / (y_max - y_min));
+ } // void calculate_transform()
+
+ void transform_pair(std::pair<double, double>& pt)
+ { // transform both x and y.
+ transform_point(pt.first, pt.second);
+ }
+
+ void calculate_plot_window()
+ { // The plot window is used to set a clip path.
+ // Start by using all the image.
+ plot_x1 = 0; // left
+ plot_y1 = 0; // top
+ plot_x2 = image.x_size(); // right
+ plot_y2 = image.y_size(); // bottom
+
+ if(use_x_label)
+ { // Leave space at bottom for X axis label.
+ plot_y2 -= (int)(x_label_info.font_size() * text_margin);
+ }
+ if(use_y_label)
+ { // Leave space at left for Y axis label.
+ plot_x1 += (int)(y_label_info.font_size() * text_margin);
+ }
+ if(use_title)
+ { // Leave space at top for title.
+ // TODO what if want to put title at bottom?
+ plot_y1 += (int)(title_font_size() * (text_margin +1));
+ }
+ if(use_plot_window)
+ { // Reduce to allow for legend, axes ticks to be outside plot_window.
+ // Give the plot window a small border.
+ // Needed to allow any window border rectangle to show OK?
+ plot_x1+= border_margin; // pixels.
+ plot_x2-= border_margin;
+ plot_y1+= border_margin;
+ plot_y2-= border_margin;
+
+ if(use_legend)
+ { // Space for legend at right.
+ // TODO what if want legend elsewhere?
+ plot_x2 -= 150; // This 150 is an arbitrary legend box width.
+ // TODO size could depend on font_size & length of text?
+ }
+ if(use_left_ticks)
+ { // Reduce plot to give space for any external left ticks.
+ plot_x1 +=
+ y_major_tick_length_ > y_minor_tick_length_ ? y_major_tick_length_ : y_minor_tick_length_;
+ }
+ if(use_down_ticks)
+ { // Reduce plot to give space for any external down ticks.
+ plot_y2 -=
+ x_major_tick_length_ > x_minor_tick_length_ ? x_major_tick_length_ : x_minor_tick_length_;
+ }
+ // Draw plot window rectangle with background and/or border.
+ 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));
+ } // use_plot_window
+ } // calculate_plot_window
+
+ void draw_y_minor_ticks(double value, path_element& tick_path, path_element& grid_path)
+ {
+ double x1(0.);
+ double y1(value); // for tick position and value label.
+ transform_y(y1);
+ double x2(image.y_size());
+
+ if(use_y_minor_grid)
+ { // Draw the minor grid, if wanted.
+ if(!use_plot_window)
+ { // Use whole image, but make space for title & labels text.
+ //if(use_title)
+ //{ // If title at top, should make no difference, unlike X grid.
+ // x2 -= title_info.font_size() * text_margin;
         //}
+ if(use_y_label)
+ { // TODO ???? Don't draw over the Y axis label?
+ x1 += y_label_info.font_size() * text_margin;
+ //x2 -= y_label_info.font_size() * text_margin;
+ }
+ }
+ else
+ { // Use plot window.
+ x1 = plot_x1 + 1; // TODO what is the +1 for?
+ x2 = plot_x2 - 1; // Ensure *inside* window?
+ }
+ if((y1 > plot_y1) && (x1 > plot_x1) && (x2 < plot_x2) )
+ { // // Make sure that we are drawing inside the allowed window.
+ grid_path.M(x1, y1).L(x2, y1);
+ }
+ // TODO else just ignore outside plot window?
+ }
 
- // 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)
- {
- _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
+ if(use_y_ticks_on_plot_window_)
+ { // Put y minor ticks on the plot window border.
+ // TODO this can be done slicker?
+ x1 = plot_x1; // On the
+ x2 = plot_x1;
+ if(use_left_ticks)
+ {
+ x1 -= y_minor_tick_length_;
+ }
+ if(use_right_ticks)
+ {
+ x2 += y_minor_tick_length_;
+ }
+ }
+ else
+ { // Internal style.
+ x1 = y_axis; // On the Y-axis line.
+ x2 = y_axis;
+ if(use_left_ticks)
+ {
+ x1 -= y_minor_tick_length_;
+ }
+ if(use_right_ticks)
+ { // Right ticks.
+ x2 += y_minor_tick_length_;
+ }
+ }
+ if((x1 > plot_x1) && (x2 < plot_x2) && (y1 < plot_y2) && (y1 > plot_y1))
+ { // Make sure that we are drawing inside of the allowed plot window.
+ tick_path.M(x1, y1).L(x2, y1); // Draw the tick.
+ }
+ else
+ {// Do nothing? warn?
+ }
+ } // void draw_y_minor_ticks
 
- _draw_y_major_ticks(i, major_tick_path, major_grid_path);
+ void draw_y_major_ticks(double value, path_element& tick_path, path_element& grid_path)
+ { // Draw Y axis major ticks.
+ double y1(value);
+ transform_y(y1); // cartesian to SVG coordinates.
+ double x1(0.); // left end of tick.
+ double x2(image.y_size()); // right end of tick.
+
+ if(use_y_major_grid)
+ { // Draw horizontal major grid line.
+ if(!use_plot_window)
+ { // TODO is this right?
+ //if (use_title())
+ //{ // title has no effect if at the top.
+ // y1 += title_info.font_size() * text_margin;
+ //}
+ if(use_y_label)
+ { // Start further right to give space for y axis value label.
+ y1 -= y_label_info.font_size() * text_margin ;
         }
-
- // 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);
+ if(use_left_ticks)
+ { // And similarly for left ticks.
+ y1 -= y_major_tick_length_;
+ }
+ }
+ else
+ { // use_plot_window
+ x1 = plot_x1 + 1;
+ x2 = plot_x2 - 1;
+ }
+ grid_path.M(x1, y1).L(x2, y1);
+ } // use_y_major_grid
+
+ if((y1 < plot_y2) && (y1 > plot_y1))
+ { // Make sure that we are drawing inside the allowed window.
+ double y_tick_length = y_major_tick_length_;
+ if(use_y_ticks_on_plot_window_) // (was external_style)
+ { // Start ticks on the plot window border.
+ x1 = plot_x1; // x1 = left,
+ x2 = plot_x1; // x2 = right.
+ if (use_left_ticks)
+ {
+ x1 -= y_tick_length; // left a tick.
+ }
+ if (use_right_ticks)
+ {
+ x2 += y_tick_length; // right.
+ }
+ }
+ else
+ { // Internal style on Y-axis.
+ x1 = y_axis; // Y-axis line.
+ x2 = y_axis;
+ if(use_left_ticks)
+ {
+ x1 -= y_tick_length; // left
+ }
+ if (use_right_ticks)
+ {
+ x2 += y_tick_length; // right.
+ }
+ }
+ tick_path.M(x1, y1).L(x2, y1); // Draw the major tick.
+
+ if(use_y_major_labels)
+ { // label the tick with value, for example "1.3"
+ std::stringstream fmt;
+ // TODO precision(?) - will be some ugly precision(6) is we do nothing.
+ fmt << value; // fmt.str() == "20"
+ if(use_y_ticks)
+ {
+ x1 -= text_margin; // Or a font height?
+ if(use_left_ticks)
+ {
+ x1 -= y_major_tick_length_; // left, taking account of tick length.
+ }
+ else
+ { // No need to move if right tick, or none?
+ }
+ }
+ if(!use_x_ticks_on_plot_window_ && (value != 0))
+ { // TODO orientation control?
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
+ y1 + y_label_info.font_size() / 2, // shift down to center value digits on tick.
+ fmt.str(), y_label_info.font_size(), "", "", "", "", "", center_align, horizontal);
+ }
+ if(use_y_ticks_on_plot_window_)
+ {
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1 + y_label_info.font_size(),
+ y1 + y_label_info.font_size() /2, // shift down to center digit on tick.
+ fmt.str(), y_label_info.font_size(), "", "", "", "", "", center_align, upward); // -90 degree rotation.
         }
- } // _draw_y_axis
-
- void _draw_axis()
- { // TODO should this be draw axes (plural)
- _draw_y_axis();
- _draw_x_axis();
+ } // if(use_y_major_labels)
     }
+ } // draw_y_major_ticks
 
- void _draw_y_label()
- {
- image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color(black);
+ void draw_y_axis()
+ {
+ double x1(0.);
+ transform_x(x1);
+ // Draw the vertical Y axis line (at cartesian x = 0).
+ image.get_g_element(detail::PLOT_Y_AXIS).line(x1, plot_y1, x1, plot_y2);
+ // <g id="yAxis" stroke="rgb(0,0,0)"><line x1="70.5" y1="53" x2="70.5" y2="357"/>
+ y_axis = x1; // in SVG coordinates.
+ // Access the paths for the ticks & grids, ready for additions.
+ 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();
+ path_element& major_grid_path = image.get_g_element(detail::PLOT_Y_MAJOR_GRID).path();
+
+ if(use_y_axis_lines_)
+ { // TODO what does this do?
+ image.get_g_element(detail::PLOT_Y_AXIS).line(plot_y1, x_axis, plot_x2, x_axis);
+ // <line x1="53" y1="-9.26e+061" x2="345" y2="-9.26e+061"/></g>
+ // So x_axis is undefined!!!
+ }
 
- image.get_g_element(detail::PLOT_Y_LABEL).push_back(new
- text_element(12, (plot_y2 + plot_y1)/2.,
- y_label_info.text(),
- 12, center_align, -90));
- } // _draw_y_label
+ // y_minor_jump is the interval between minor ticks.
+ double y_minor_jump = y_major / ((double)(y_num_minor_ticks_ + 1.) );
+ // TODO Problem here with using floating point?
+ // Was i < y_max; but didn't show the tick and value at y_max so now i <= y_max;
+ // But may still fail if a ls or few bits out? Seems to fail for y = 100, for example.
 
- void _calculate_transform()
+ // Draw the ticks on the positive side.
+ for(double i = 0; i <= y_max; i += y_major)
     {
- 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_y2-plot_y1)/(y_max-y_min);
-
- y_shift = plot_y1 - (y_max *(plot_y1-plot_y2)/(y_max-y_min));
+ for(double j = i + y_minor_jump; j < i + y_major; j += y_minor_jump)
+ { // Draw minor ticks.
+ // This will output 'orphaned' minor ticks that are beyond the plot window,
+ // if the last major tick does not coincide with the plot window.
+ // These are just ignored in draw_x_minor_ticks.
+ // There might be 9 of them,
+ // if you have the common 9 minor tick between major ticks!
+ // TODO this seems ugly - as does the negative ones below.
+ draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+ draw_y_major_ticks(i, major_tick_path, major_grid_path);
     }
 
- void _calculate_plot_window()
+ // Draw the ticks on the negative side.
+ for(double i = 0; i >= y_min; i -= y_major)
     {
- plot_x1 = plot_y1 = 0;
-
- plot_x2 = image.get_x_size();
- plot_y2 = image.get_y_size();
-
-
- if(use_x_label)
- {
- plot_y2 -= (int)(x_label_info.font_size() * 1.5);
- }
-
- if(use_y_label)
- {
- plot_x1 += 20;
- }
-
- if(use_title)
- {
- plot_y1 += (int)(title_info.font_size() * 1.5);
- }
-
- if(use_plot_window)
- {
- // Give the plot window a natural bit of padding.
- plot_x1+=5;
- plot_x2-=5;
- plot_y1+=5;
- plot_y2-=5;
-
-
- if(use_legend)
- {
- plot_x2 -= 155;
- }
-
- if(use_y_external_style)
- {
- plot_x1 +=
- y_major_length > y_minor_length ?
- y_major_length :
- y_minor_length ;
- }
+ for(double j=i; j > i-y_major; j-= y_major / (y_num_minor_ticks_ + 1))
+ { // Draw minor ticks.
+ draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+ draw_y_major_ticks(i, major_tick_path, major_grid_path);
+ }
+ } // draw_y_axis
 
- if(use_x_external_style)
- {
- plot_y2 -=
- x_major_length > x_minor_length ?
- x_major_length :
- x_minor_length ;
- }
+ void draw_y_label()
+ {
+ // image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color(black);
+ // Now set in constructor, and can be changed with member function .
+
+ std::string label = y_label_info.text(); // x_axis label, and optional units.
+ if (use_x_label_units && (y_units_info.text() != ""))
+ { // Append the units, if any, providing brackets ().
+ // TODO Is this the best policy - or should the user provide the ()s????
+ label += " (" + y_units_info.text() + ")";
+ }
 
- 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));
- }
- } // _calculate_plot_window
+ image.get_g_element(detail::PLOT_Y_LABEL).push_back(new
+ text_element(y_label_info.font_size() * text_margin, // shift right
+ (plot_y2 + plot_y1) / 2., // center on the plot window.
+ label, // "Y-Axis" for example.
+ y_label_info.font_size(),
+ y_label_info.font_family(),
+ "", "", "", "", center_align,
+ upward)); // Y label must be drawn vertically.
+ } // draw_y_label
+
+ void draw_bezier_lines(const svg_2d_plot_series& series)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
+ g_ptr.clip_id(plot_window_clip);
+ g_ptr.style().stroke_color(series.line_style.color);
+ path_element& path = g_ptr.path();
+
+ std::pair<double, double> n_minus_2;
+ std::pair<double, double> n_minus_1, n;
+ std::pair<double, double> fwd_vtr;
+ std::pair<double, double> back_vtr;
 
- void _transform_pair(std::pair<double, double>& pt)
+ if(series.line_style.area_fill == blank)
     {
- _transform_point(pt.first, pt.second);
+ path.fill = false;
+ }
+ else
+ { // fill
+ path.style().fill_color(series.line_style.area_fill);
     }
 
- void _draw_bezier_lines(const svg_2d_plot_series& series)
+ if(series.series.size() > 2)
     {
- g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES)
- .add_g_element();
-
- g_ptr.clip_id(plot_window_clip);
-
- g_ptr.style().stroke_color(series.line_style.color);
- path_element& path = g_ptr.path();
-
- std::pair<double, double> n_minus_2, n_minus_1, n;
- std::pair<double, double> fwd_vtr, back_vtr;
-
- if(series.line_style.area_fill == blank)
- {
- path._fill = false;
- }
-
- else
- {
- path.style().fill_color(series.line_style.area_fill);
- }
-
- if(series.series.size() > 2)
- {
- std::multimap<double,double>::const_iterator iter = series.series.begin();
-
- n_minus_1 = *(iter++);
- n = *(iter++);
-
- _transform_pair(n_minus_1);
- _transform_pair(n);
-
- path.M(n_minus_1.first, n_minus_1.second);
-
- for(; iter != series.series.end(); ++iter)
- {
- n_minus_2 = n_minus_1;
- n_minus_1 = n;
- n = *iter;
-
- _transform_pair(n);
-
- back_vtr.first = ((n_minus_1.first - n.first) +
- (n_minus_2.first - n_minus_1.first)) * .2;
-
- back_vtr.second = ((n_minus_1.second - n.second) +
- (n_minus_2.second - n_minus_1.second)) * .2;
-
- path.S(n_minus_1.first + back_vtr.first, n_minus_1.second + back_vtr.second,
- n_minus_1.first, n_minus_1.second);
- }
-
- back_vtr.first = 0;
- back_vtr.second = (n.second - n_minus_1.second)*.2;
+ std::multimap<double, double>::const_iterator iter = series.series.begin();
 
- path.S(n.first + back_vtr.first, n.second + back_vtr.second,
- n.first, n.second);
- }
-
- else
- {
- _draw_straight_lines(series);
- }
-
- } // _draw_bezier_lines
+ n_minus_1 = *(iter++);
+ n = *(iter++);
+ transform_pair(n_minus_1);
+ transform_pair(n);
+ path.M(n_minus_1.first, n_minus_1.second);
+
+ for(; iter != series.series.end(); ++iter)
+ {
+ n_minus_2 = n_minus_1;
+ n_minus_1 = n;
+ n = *iter;
+ transform_pair(n);
+
+ back_vtr.first = ((n_minus_1.first - n.first) +
+ (n_minus_2.first - n_minus_1.first)) * 0.2; // TODO why + 0.2
+
+ back_vtr.second = ((n_minus_1.second - n.second) +
+ (n_minus_2.second - n_minus_1.second)) * 0.2;
+
+ // 8.3.6 The cubic Bézier curve commands path.S(x, y).
+ path.S(n_minus_1.first + back_vtr.first, n_minus_1.second + back_vtr.second,
+ n_minus_1.first, n_minus_1.second);
+ }
+
+ back_vtr.first = 0;
+ back_vtr.second = (n.second - n_minus_1.second)* 0.2;
+ path.S(n.first + back_vtr.first, n.second + back_vtr.second,
+ n.first, n.second);
+ }
+ else
+ { // Only one or two points, so no curving possible!
+ draw_straight_lines(series);
+ }
+ } // draw_bezier_lines
 
- void _draw_straight_lines(const svg_2d_plot_series& series)
+ void draw_straight_lines(const svg_2d_plot_series& series)
+ { // Straight line between data points (rather than a Bezier curve).
+ double prev_x;
+ double prev_y;
+ double temp_x(0.);
+ double temp_y;
+
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
+ g_ptr.clip_id(plot_window_clip);
+ g_ptr.style().stroke_color(series.line_style.color);
+ path_element& path = g_ptr.path();
+ if(series.series.size() > 1)
     {
- double prev_x, prev_y, temp_x(0.), temp_y;
-
- g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
-
- g_ptr.clip_id(plot_window_clip);
-
- g_ptr.style().stroke_color(series.line_style.color);
-
- path_element& path = g_ptr.path();
-
- if(series.series.size() > 1)
- {
- std::multimap<double, double>::const_iterator j = series.series.begin();
- prev_x = (*j).first;
- 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_point(prev_x, prev_y);
-
- if(series.line_style.area_fill != blank)
- {
- path.style().fill_color(series.line_style.area_fill);
- path.M(prev_x, prev_y);
- }
-
- _transform_y(prev_y = (*j).second);
-
- if(series.line_style.area_fill != blank)
- {
- path.style().fill_color(series.line_style.area_fill);
- path.L(prev_x, prev_y);
- }
-
- else
- {
- path.M(prev_x, prev_y);
- }
- ++j;
-
- for(; j != series.series.end(); ++j)
- {
- temp_x = (*j).first;
- temp_y = (*j).second;
-
- _transform_point(temp_x, temp_y);
-
- path.L(temp_x, temp_y);
-
- if(series.line_style.area_fill == blank)
- {
- path.M(temp_x, temp_y);
- }
-
- prev_x = temp_x;
- prev_y = temp_y;
- }
-
- if(series.line_style.area_fill != blank)
- {
- _transform_y(temp_y = 0.);
- path.L(temp_x, temp_y).z();
- }
- }
- } // _draw_straight_lines
+ std::multimap<double, double>::const_iterator j = series.series.begin();
+ prev_x = (*j).first;
+ prev_y = 0.;
+
+ // If we have to fill the area under the plot,
+ // we first have to move from the X-axis (y = 0) to the first point,
+ // and again at the end after the last point.
+ transform_point(prev_x, prev_y); // TODO 0. clearer here.
+ if(series.line_style.area_fill != blank)
+ { // Move to 1st point.
+ path.style().fill_color(series.line_style.area_fill);
+ path.M(prev_x, prev_y);
+ }
+
+ transform_y(prev_y = (*j).second);
+ if(series.line_style.area_fill != blank)
+ { // fill wanted.
+ path.style().fill_color(series.line_style.area_fill);
+ path.L(prev_x, prev_y); // Line from X-axis to 1st point.
+ }
+ else
+ { // fill == blank
+ path.M(prev_x, prev_y);
+ }
+ ++j; // refers to 2nd point to plot.
+
+ for(; j != series.series.end(); ++j)
+ {
+ temp_x = (*j).first;
+ temp_y = (*j).second;
+ transform_point(temp_x, temp_y);
+ path.L(temp_x, temp_y); // line to next point.
+
+ if(series.line_style.area_fill == blank)
+ {
+ path.M(temp_x, temp_y);
+ }
+ prev_x = temp_x;
+ prev_y = temp_y;
+ } // for j
+
+ if(series.line_style.area_fill != blank)
+ { // fill wanted.
+ transform_y(temp_y = 0.); // X-axis
+ path.L(temp_x, temp_y).z(); // terminate line.
+ }
+ }
+ } // draw_straight_lines
 
- void _draw_plot_lines()
+ void draw_plot_lines()
+ { // Draw line through data series, curved or straight.
+ for(unsigned int i = 0; i < series.size(); ++i)
     {
- for(unsigned int i = 0; i < series.size(); ++i)
- {
- if(series[i].line_style.bezier_on)
- {
- _draw_bezier_lines(series[i]);
- }
- else
- {
- _draw_straight_lines(series[i]);
- }
- }
- } // _draw_plot_lines
+ if(series[i].line_style.bezier_on)
+ { // curved.
+ draw_bezier_lines(series[i]);
+ }
+ else
+ {
+ draw_straight_lines(series[i]);
+ }
+ }
+ } // draw_plot_lines
 
- void _update_image()
+ void update_image()
+ {
+ clear_all();
+
+ // Draw imagebackground (perhaps with border and/or fill color).
+ image.get_g_element(detail::PLOT_BACKGROUND).push_back(
+ new rect_element(0, 0, image.x_size(), image.y_size()));
+
+ calculate_plot_window();
+ calculate_transform();
+ draw_title(); // Moved to ensure plot_X and Y are valid.
+
+ // Define the clip path for the plot window.
+ // We don't want to allow overlap of the plot window border lines,
+ // thus the minor adjustments.
+ // TODO should this be border thickness?
+
+ image.clip_path(rect_element(plot_x1 + 1, plot_y1 + 1,
+ plot_x2 - plot_x1 - 2, plot_y2 - plot_y1 - 2),
+ plot_window_clip);
+ // <clipPath id="plot_window"><rect x="35" y="38" width="309" height="322"/></clipPath>
+
+ image.get_g_element(detail::PLOT_PLOT_POINTS).clip_id(plot_window_clip);
+ // Draw axes, labels & legend, as required.
+ if(use_axis)
     {
- _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();
-
- // Define the clip path for the plot window.
- // We don't want to allow overlap of the plot window lines,
- // thus the minor adjustments.
-
- image.clip_path(rect_element(plot_x1 + 1, plot_y1 + 1,
- plot_x2 - plot_x1 - 2, plot_y2 - plot_y1 - 2),
- plot_window_clip);
-
- image.get_g_element(detail::PLOT_PLOT_POINTS).clip_id(plot_window_clip);
-
- if(use_axis)
- {
- _draw_y_axis();
- _draw_x_axis();
- }
-
- if(use_legend)
- {
- _draw_legend();
- }
-
- if(use_x_label)
- {
- _draw_x_label();
- }
-
- if(use_y_label)
- {
- _draw_y_label();
- }
-
- // Draw lines between non-limit points.
-
- _draw_plot_lines();
-
- // Draw non-limit 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);
- }
- }
- }
-
- // Draw limit points.
- for(unsigned int i=0; i<series.size(); ++i)
- {
- g_element& g_ptr = image.get_g_element(detail::PLOT_LIMIT_POINTS);
-
- for(std::multimap<double,double>::const_iterator j = series[i].series_limits.begin();
- j!=series[i].series_limits.end(); ++j)
- {
- x = j->first;
- y = j->second;
-
- _transform_point(x, y);
-
- _draw_plot_point(x, y, g_ptr, plot_point_style(blank, blank, 10, circle));
- }
- }
+ draw_y_axis(); // TODO is draw_axes used?
+ draw_x_axis();
     }
-
-public:
-
-svg_2d_plot() : // Construct with all the default plot options.
- title_info(0, 0, "Plot of data", 30),
- x_label_info(0, 0, "X Axis", 12),
- y_label_info(0, 0, "Y Axis", 12),
- x_min(-10), x_max(10),
- y_min(-10), y_max(10),
- 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),
- plot_window_clip("__clip_window"),
- 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)
-
-{
- image_size(500, 350); // Default image size.
-
- // Build the document tree.. add children of the root node.
- for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
+ if(use_legend)
     {
- image.add_g_element();
+ draw_legend();
+ }
+ if(use_x_label)
+ {
+ draw_x_label();
+ }
+ if(use_y_label)
+ {
+ draw_y_label();
     }
 
- // Set color defaults.
- image.get_g_element(detail::PLOT_BACKGROUND)
- .style().fill_color(white);
-
- image.get_g_element(detail::PLOT_LIMIT_POINTS)
- .style().stroke_color(lightgray).fill_color(whitesmoke);
-
- 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(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);
+ draw_plot_lines(); // Draw lines between points.
 
- 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);
-} // svg_2d_plot()
+ // Draw normal 'good' non-limit points.
+ double x(0.);
+ double 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))
+ { // Onside plot window, so draw a point.
+ draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
+ } // for
+ } // for normal points
 
-svg_2d_plot& write(const std::string& _str)
-{
- std::ofstream fout(_str.c_str());
+ // Draw all the 'bad' at_limit points.
+ for(unsigned int i = 0; i < series.size(); ++i)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_LIMIT_POINTS);
 
+ for(std::multimap<double,double>::const_iterator j = series[i].series_limits.begin();
+ j!=series[i].series_limits.end(); ++j)
+ {
+ x = j->first;
+ y = j->second;
+ transform_point(x, y);
+ draw_plot_point(x, y, g_ptr, plot_point_style(blank, blank, series[i].point_style.size, cone));
+ // TODO why are fill and stroke blank? How is point style for 'bad' values determined?
+ }
+ } // limits point
+ } // void update_image()
+
+
+public: // Member functions
+ // -----------------------------------------------------------------
+ // write() has two flavors, a file and a ostream.
+ // The file version opens an ostream, and calls the stream version.
+ // The stream version first clears all unnecessary data from the graph,
+ // builds the document tree, and then calls the write function for the root
+ // document node, which calls all other nodes through the Visitor pattern.
+ // -----------------------------------------------------------------
+
+ svg_2d_plot& write(const std::string& filename)
+ { // Write the plot image to a named file.
+ std::ofstream fout(filename.c_str());
     if(fout.fail())
     {
- throw std::runtime_error("Unable to open "+_str);
+ throw std::runtime_error("Unable to open " + filename);
     }
+ write(fout); // Using the ostream version.
+ return *this;
+ }
 
- write(fout);
-
+ svg_2d_plot& write(std::ostream& s_out)
+ { // Write the image to an ostream.
+ update_image();
+ image.write(s_out); // Use the ostream version of write.
     return *this;
-}
+ }
 
-svg_2d_plot& write(std::ostream& s_out)
-{
- _update_image();
+ // Member functions to set plot options.
+ // All return *this to permit chaining.
 
- image.write(s_out);
+ // These below only refer to 2D plot.
+ // See axis_plot_label.hpp for all the many 1D functions X-Axis.
 
+ svg_2d_plot& y_name_on(bool cmd)
+ {
+ use_y_label = cmd;
     return *this;
-}
+ }
 
-svg_2d_plot& y_name_on(bool _cmd)
-{
- use_y_label = _cmd;
+ svg_2d_plot& y_major_labels_on(bool cmd)
+ {
+ use_y_major_labels = cmd;
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_labels_on(bool _cmd)
-{
- use_y_major_labels = _cmd;
+ svg_2d_plot& y_axis_color(const svg_color& col)
+ { // Set BOTH stroke and fill to the same color.
+ image.get_g_element(detail::PLOT_Y_AXIS).style().fill_color(col);
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color(col);
     return *this;
-}
-
-svg_2d_plot& y_axis_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_AXIS)
- .style().fill_color(_col);
+ }
 
- image.get_g_element(detail::PLOT_Y_AXIS)
- .style().stroke_color(_col);
+ svg_color y_axis_color()
+ { // But only return the stroke color.
+ return image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color();
+ }
 
+ svg_2d_plot& y_axis_label_color(const svg_color& col)
+ { // Set BOTH stroke and fill to the same color.
+ image.get_g_element(detail::PLOT_Y_LABEL).style().fill_color(col);
+ image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color(col);
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_grid_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MAJOR_GRID).style().stroke_color(_col);
+ svg_color y_axis_label_color()
+ { // But only return the stroke color.
+ return image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color();
+ }
+
+ svg_2d_plot& y_major_grid_color(const svg_color& col)
+ {
+ image.get_g_element(detail::PLOT_Y_MAJOR_GRID).style().stroke_color(col);
     return *this;
-}
+ }
 
-svg_2d_plot& y_minor_grid_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MINOR_GRID).style().stroke_color(_col);
+ svg_2d_plot& y_minor_grid_color(const svg_color& col)
+ {
+ image.get_g_element(detail::PLOT_Y_MINOR_GRID).style().stroke_color(col);
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_tick_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(_col);
+ svg_2d_plot& y_major_tick_color(const svg_color& col)
+ {
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(col);
     return *this;
-}
+ }
 
-svg_2d_plot& y_minor_tick_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(_col);
+ svg_2d_plot& y_minor_tick_color(const svg_color& col)
+ {
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(col);
     return *this;
-}
+ }
 
-svg_2d_plot& y_range(double y1, double y2)
-{
+ svg_2d_plot& y_range(double y1, double y2)
+ {
     y_min = y1;
     y_max = y2;
-
     if(y2 <= y1)
     {
- throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
+ throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
     }
+ return *this;
+ }
 
+ svg_2d_plot& y_axis_width(unsigned int width)
+ {
+ // TODO should be stored elsewhere too?
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(width);
     return *this;
-}
+ }
 
-svg_2d_plot& y_axis_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(_width);
+ svg_2d_plot& y_major_interval(double inter)
+ {
+ y_major = inter;
+ return *this;
+ }
+
+ double y_major_interval()
+ {
+ return y_major;
+ }
 
+ svg_2d_plot& y_major_tick_length(unsigned int length)
+ {
+ y_major_tick_length_ = length;
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_interval(double _inter)
-{
- y_major = _inter;
+ unsigned int y_major_tick_length()
+ {
+ return y_major_tick_length_;
+ }
 
+ svg_2d_plot& y_minor_tick_length(unsigned int length)
+ {
+ y_minor_tick_length_ = length;
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_tick_length(unsigned int _length)
-{
- y_major_length = _length;
+ unsigned int y_minor_tick_length()
+ {
+ return y_minor_tick_length_;
+ }
+
+ svg_2d_plot& y_num_minor_ticks(unsigned int num)
+ {
+ y_num_minor_ticks_ = num;
     return *this;
-}
+ }
+
+ unsigned int y_num_minor_ticks()
+ {
+ return y_num_minor_ticks_;
+ }
 
-svg_2d_plot& y_minor_tick_length(unsigned int _length)
-{
- y_minor_length = _length;
+ svg_2d_plot& y_name(const std::string& str)
+ { // Label for Y-axis.
+ y_label_info.text(str);
     return *this;
-}
+ }
 
-svg_2d_plot& y_num_minor_ticks(unsigned int _num)
-{
- y_num_minor = _num;
+ const std::string& y_name()
+ {
+ return y_label_info.text();
+ }
+
+ svg_2d_plot& y_major_tick_width(unsigned int width)
+ {
+ y_major_tick_width_ = width;
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(width);
     return *this;
-}
+ }
 
-svg_2d_plot& y_name(const std::string& _str)
-{
- y_label_info.text(_str);
+ unsigned int y_major_tick_width()
+ {
+ return y_major_tick_width_;
+ }
+
+ svg_2d_plot& y_minor_tick_width(unsigned int width)
+ {
+ y_minor_tick_width_ = width;
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(width);
     return *this;
-}
+ }
+
+ unsigned int y_minor_tick_width()
+ {
+ return y_minor_tick_width_;
+ }
 
-svg_2d_plot& y_major_tick_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(_width);
 
+ svg_2d_plot& x_ticks_on_plot_window_on(bool is)
+ {
+ use_x_ticks_on_plot_window_ = is;
     return *this;
-}
+ }
 
-svg_2d_plot& y_minor_tick_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(_width);
+ bool x_ticks_on_plot_window_on()
+ {
+ return use_x_ticks_on_plot_window_;
+ }
 
+ svg_2d_plot& y_ticks_on_plot_window_on(bool is)
+ {
+ use_y_ticks_on_plot_window_ = is;
     return *this;
-}
+ }
 
-svg_2d_plot& y_label_on(bool _cmd)
-{
- use_y_label = _cmd;
+ bool y_ticks_on_plot_window_on()
+ {
+ return use_y_ticks_on_plot_window_;
+ }
+
+
+ svg_2d_plot& y_ticks_left_on(bool cmd)
+ {
+ use_left_ticks = cmd;
     return *this;
-}
+ }
 
-svg_2d_plot& axis_external_style(bool _is)
-{
- use_x_external_style = _is;
- use_y_external_style = _is;
+ bool y_ticks_left_on()
+ {
+ return use_left_ticks;
+ }
+
+ svg_2d_plot& y_ticks_right_on(bool cmd)
+ {
+ use_right_ticks = cmd;
     return *this;
-}
+ }
+
+ bool y_ticks_right_on()
+ {
+ return use_right_ticks;
+ }
+ // Only need y_ticks_left_on & y_ticks_right_on in 2D
 
-svg_2d_plot& x_external_style_on(bool _is)
-{
- use_x_external_style = _is;
 
+ svg_2d_plot& y_major_grid_on(bool is)
+ {
+ use_y_major_grid = is;
     return *this;
-}
+ }
 
-svg_2d_plot& y_external_style_on(bool _is)
-{
- use_y_external_style = _is;
+ bool y_major_grid_on()
+ {
+ return use_y_major_grid;
+ }
+
+ svg_2d_plot& y_minor_grid_on(bool is)
+ {
+ use_y_minor_grid = is;
     return *this;
-}
+ }
 
-svg_2d_plot& y_major_grid_on(bool _is)
-{
- use_y_major_grid = _is;
+ bool y_minor_grid_on()
+ {
+ return use_y_minor_grid;
+ }
+
+ svg_2d_plot& y_label_on(bool cmd)
+ {
+ use_y_label = cmd;
     return *this;
-}
+ }
 
-svg_2d_plot& y_minor_grid_on(bool _is)
-{
- use_y_minor_grid = _is;
+ svg_2d_plot& y_label_font_size(unsigned int i)
+ { // TODO May be best to tie these two font sizes together?
+ y_label_info.font_size(i);
+ // y_units_info.font_size(i);
+ return *this;
+ }
+
+ unsigned int y_label_font_size()
+ {
+ return y_label_info.font_size();
+ }
+
+ svg_2d_plot& y_label_font_family(const std::string& family)
+ {
+ y_label_info.font_family(family);
     return *this;
-}
+ }
+
+ const std::string& y_label_font_family()
+ {
+ return y_label_info.font_family();
+ }
+
+ // plot member function, with several parameters, using Boost.Parameter,
+ // to add data series to the plot window.
+ // TODO replace this with chainable member functions.
 
 #if defined (BOOST_MSVC)
 # pragma warning(push)
 # pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
 #endif
 
-BOOST_PARAMETER_MEMBER_FUNCTION
-(
+ BOOST_PARAMETER_MEMBER_FUNCTION
+ (
     (void),
     plot,
     tag,
     (required
- (container, *)
- (title, (const std::string&))
+ (container, *)
+ (title, (const std::string&))
     )
     (optional
- (fill_color, (const svg_color&), white)
- (stroke_color, (const svg_color&), black)
- (line_color, (const svg_color&), black)
- (area_fill_color, (svg_color_constant), blank)
- (point_style, (point_shape), circle)
- (size, (int), 10)
- (line_on, (bool), true)
- (bezier_on, (bool), false)
- (x_functor, *, detail::boost_default_2d_convert())
+ (fill_color, (const svg_color&), white)
+ (stroke_color, (const svg_color&), black)
+ (line_color, (const svg_color&), black)
+ (area_fill_color, (svg_color_constant), blank)
+ (point_style, (point_shape), round)
+ (size, (int), 10)
+ (line_on, (bool), true)
+ (bezier_on, (bool), false)
+ (x_functor, *, detail::boost_default_2d_convert())
     )
-)
-{
+ )
+ {
     // This line has the error in GCC. Also, operator() in boost_default_2d_convert
     // has been changed so that the value of i is not updated. I would like
     // the start to be set, as well as i to update in operator().
@@ -968,22 +1214,21 @@
     line_style.area_fill=area_fill_color;
 
     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),
- line_style
- ));
-}
-};
+ 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),
+ line_style
+ ));
+ }
+}; // class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
 
 #if defined (BOOST_MSVC)
 # pragma warning(pop)
 #endif
 
+ } // namespace svg
+} // namespace boost
 
-}
-}
-
-#endif
+#endif // BOOST_SVG_SVG_2D_PLOT_HPP

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,8 +1,11 @@
 // svg_boxplot.hpp
-// Copyright (C) Jacob Voytko 2007
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-// -----------------------------------------------------------------
+
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #ifndef BOOST_SVG_SVG_BOXPLOT_HPP
 #define BOOST_SVG_SVG_BOXPLOT_HPP
@@ -58,37 +61,52 @@
 
 struct svg_boxplot_series
 {
- double whisker_min, whisker_max, q1, q3, median;
- std::vector<double> outliers, extreme_outliers;
+ double whisker_min;
+ double whisker_max;
+ double q1; // 1st lower quartile.
+ double q3;// 3rd upper quartile. TODO 4th?
+ double median;
+ std::vector<double> outliers;
+ std::vector<double> extreme_outliers;
     std::string title;
 
- unsigned int whisker_length, box_width;
+ unsigned int whisker_length;
+ unsigned int box_width;
 
- svg_style box_style, median_style, axis_style,
- min_whisker_style, max_whisker_style;
+ svg_style box_style;
+ svg_style median_style;
+ svg_style axis_style;
+ svg_style min_whisker_style;
+ svg_style max_whisker_style;
 
- plot_point_style mild_outlier, ext_outlier;
+ plot_point_style mild_outlier;
+ plot_point_style ext_outlier;
 
     template <class T>
- svg_boxplot_series(T _begin, T _end, const std::string& _title,
- unsigned int _whisk_length, unsigned int _box_width,
- svg_style _box_style, svg_style _median_style, svg_style _axis_style,
- svg_style _min_whisker, svg_style _max_whisker,
- plot_point_style _mild_outlier, plot_point_style _ext_outlier):
- title(_title),
- whisker_length(_whisk_length),
- box_width(_box_width), box_style(_box_style),
- median_style(_median_style), axis_style(_axis_style),
- min_whisker_style(_min_whisker),
- max_whisker_style(_max_whisker),
- mild_outlier(_mild_outlier), ext_outlier(_ext_outlier)
+ svg_boxplot_series(T begin, T end, const std::string& title,
+ unsigned int whisk_length,
+ unsigned int box_width,
+ svg_style box_style,
+ svg_style median_style,
+ svg_style axis_style,
+ svg_style min_whisker,
+ svg_style max_whisker,
+ plot_point_style mild_outlier,
+ plot_point_style ext_outlier) :
+ title(title),
+ whisker_length(whisk_length),
+ box_width(box_width), box_style(box_style),
+ median_style(median_style), axis_style(axis_style),
+ min_whisker_style(min_whisker),
+ max_whisker_style(max_whisker),
+ mild_outlier(mild_outlier), ext_outlier(ext_outlier)
     {
         //std::vector used for fast lookups of quartile values.
- std::vector<double> data(_begin, _end);
+ std::vector<double> data(begin, end);
 
         if(data.empty())
         {
- throw std::runtime_error("Empty dataset");
+ throw std::runtime_error("Empty dataset!");
         }
 
         std::sort(data.begin(), data.end());
@@ -104,9 +122,9 @@
         double iqr(q3-q1);
 
         double min_ext_cutoff = q1 - 3. * iqr;
- double min_cutoff = q1 - 1.5 * iqr;
+ double min_cutoff = q1 - text_margin * iqr;
         double max_ext_cutoff = q3 + 3. * iqr;
- double max_cutoff = q3 + 1.5 * iqr;
+ double max_cutoff = q3 + text_margin * iqr;
 
         std::vector<double>::const_iterator i;
 
@@ -116,7 +134,6 @@
             {
                 extreme_outliers.push_back(*i);
             }
-
             else if(*i < min_cutoff)
             {
                 outliers.push_back(*i);
@@ -124,24 +141,20 @@
         }
 
         whisker_min = *i;
-
         std::vector<double>::const_reverse_iterator j;
-
         for(j = data.rbegin(); *j > max_cutoff; ++j)
         {
             if(*j > max_ext_cutoff)
             {
                 extreme_outliers.push_back(*j);
             }
-
             else if(*j > max_cutoff)
             {
                 outliers.push_back(*j);
             }
         }
-
         whisker_max = *j;
- }
+ } //
 }; // struct svg_boxplot_series
 
 class svg_boxplot
@@ -150,7 +163,8 @@
     // Stored so as to avoid rewriting style information constantly.
     svg image;
 
- double y_scale, y_shift;
+ double y_scale;
+ double y_shift;
 
     text_element title_info;
     text_element x_label_info;
@@ -162,97 +176,103 @@
     int plot_y1;
     int plot_y2;
 
-
     // Yes/no questions.
- bool use_x_label;
+ bool use_x_label; // // Show X-axis label text.
     bool use_x_major_labels;
     bool use_y_major_labels;
     bool use_y_label;
     bool use_title;
 
- // where we will be storing the data points for transformation.
+ // Where we will be storing the data points for transformation.
     std::vector<svg_boxplot_series> series;
     std::string plot_window_clip;
 
- // axis information
- double y_min, y_max;
- double y_major, y_axis, x_axis;
- unsigned int x_major_length, y_major_length, y_minor_length,
- y_num_minor;
+ // Axes information.
+ double y_min;
+ double y_max;
+ double y_major;
+ double y_axis;
+ double x_axis;
+ unsigned int x_major_tick_length_;
+ unsigned int x_major_tick_width_; // pixels.
+
+ unsigned int y_major_tick_length_;
+ unsigned int y_major_tick_width_;
+ unsigned int y_minor_tick_length_;
+ unsigned int y_minor_tick_width_;
+ unsigned int y_num_minor_ticks_;
 
- void _clear_all()
+ void clear_all()
     {
         // TODO, fill
     }
 
- void _transform_y(double& y)
+ void transform_y(double& y)
     {
         y = y * y_scale + y_shift;
     }
 
- void _draw_y_minor_ticks(double j, path_element& tick_path)
+ void draw_y_minor_ticks(double j, path_element& tick_path)
     {
         double y1(j), x1(plot_x1);
- double y_tick_length = y_minor_length / 2.;
+ double y_tick_length = y_minor_tick_length_ / 2.;
         double x2(plot_x1 - y_tick_length / 2.);
 
- _transform_y(y1);
+ transform_y(y1);
 
         tick_path.M(x1, y1).L(x2, y1);
     }
 
 
- void _draw_x_major_ticks(double i, path_element& tick_path,
+ void draw_x_major_ticks(double i, path_element& tick_path,
         const std::string& str)
     {
- double x1(i), y1(0.), y2(image.get_x_size());
+ double x1(i), y1(0.), y2(image.x_size());
 
         // Draw major tick.
         x1=i;
 
         y1 = plot_y2;
- y2 = plot_y2 + x_major_length;
+ y2 = plot_y2 + x_major_tick_length_;
 
         tick_path.M(x1, y1).L(x1, y2);
 
         if(use_x_major_labels)
         {
- y1 += x_major_length;
-
- image.get_g_element(boxplot::PLOT_LABELS).text(x1,
- y1 + 12, str);
+ y1 += x_major_tick_length_;
+ image.get_g_element(boxplot::PLOT_LABELS).text(x1, y1 + 12, str);
         }
     }
 
- void _draw_y_major_ticks(double i, path_element& tick_path)
+ void draw_y_major_ticks(double i, path_element& tick_path)
     {
- double y1(i), x1(0.), x2(image.get_y_size());
+ double y1(i), x1(0.), x2(image.y_size());
 
- // Draw major tick.
- y1=i;
+ // Draw ith major tick.
+ y1 = i;
 
- _transform_y(y1);
+ transform_y(y1);
 
- double y_tick_length = y_major_length / 2.;
+ double y_tick_length = y_minor_tick_length_ / 2.;
 
         x1 = plot_x1;
- x2 = plot_x1 - y_tick_length/2.;
+ x2 = plot_x1 - y_tick_length / 2.;
 
         tick_path.M(x1, y1).L(x2, y1);
 
         if(use_y_major_labels)
         {
             std::stringstream fmt;
- fmt<<i;
+ fmt << i; // So fmt.str() has the value to label the tick.
 
- x1 -= y_major_length;
+ x1 -= y_minor_tick_length_;
 
             image.get_g_element(boxplot::PLOT_LABELS).text(x1 + 12,
- y1, fmt.str(), 12, center_align, -90);
+ y1, fmt.str(), 12, "", "", "", "", "", center_align, upward);
         }
     }
 
- void _draw_y_axis()
+ void draw_y_axis()
     {
         path_element& minor_tick_path =
             image.get_g_element(boxplot::Y_MINOR_TICKS).path();
@@ -261,7 +281,7 @@
             image.get_g_element(boxplot::Y_MAJOR_TICKS).path();
 
         // y_minor_jump is the interval between minor ticks.
- double y_minor_jump = y_major/((double)(y_num_minor + 1.) );
+ double y_minor_jump = y_major/((double)(y_num_minor_ticks_ + 1.) );
 
         // Draw the ticks on the positive side.
         for(double i = 0; i < y_max; i += y_major)
@@ -270,31 +290,31 @@
                        j < i + y_major;
                        j += y_minor_jump)
             {
- _draw_y_minor_ticks(j, minor_tick_path);
+ draw_y_minor_ticks(j, minor_tick_path);
             }
 
- _draw_y_major_ticks(i, major_tick_path);
+ draw_y_major_ticks(i, major_tick_path);
         }
 
         // 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))
+ for(double j=i; j>i-y_major; j-=y_major / (y_num_minor_ticks_+1))
             {
- _draw_y_minor_ticks(j, minor_tick_path);
+ draw_y_minor_ticks(j, minor_tick_path);
             }
 
- _draw_y_major_ticks(i, major_tick_path);
+ draw_y_major_ticks(i, major_tick_path);
         }
     }
 
- void _draw_x_axis()
+ void draw_x_axis()
     {
         double y1(0.);
 
         // Draw the axis line.
- _transform_y(y1);
+ transform_y(y1);
 
         x_axis = y1;
 
@@ -304,64 +324,62 @@
         // Draw the ticks on the positive side.
         for(size_t i = 0; i < series.size(); ++i)
         {
- _draw_x_major_ticks(
+ draw_x_major_ticks(
                 plot_x1 + (plot_x2-plot_x1)*((double)(i + 1)) /
                     (double)(series.size() + 1),
                 major_tick_path, series[i].title);
         }
     }
 
- void _draw_axis()
+ void draw_axes()
     {
- _draw_y_axis();
- _draw_x_axis();
+ draw_y_axis();
+ draw_x_axis();
     }
 
- void _draw_title()
+ void draw_title()
     {
- text_element title(image.get_x_size()/2.,
+ text_element title(image.x_size()/2.,
                            title_info.font_size(),
                            title_info.text());
 
- title.alignment(center_align);
+ title.font_alignment(center_align);
         title.font_size(title_info.font_size());
         image.get_g_element(boxplot::TITLE).push_back(new text_element(title));
     }
 
- void _draw_x_label()
+ void draw_x_label()
     {
         text_element to_use((plot_x2 + plot_x1) / 2.,
- image.get_y_size() - 8, x_label_info.text());
+ image.y_size() - 8, x_label_info.text());
 
         to_use.font_size(12);
- to_use.alignment(center_align);
+ to_use.font_alignment(center_align);
 
         image.get_g_element(boxplot::X_LABEL).push_back(new text_element(to_use));
     }
 
- void _draw_y_label()
+ void draw_y_label()
     {
         image.get_g_element(boxplot::Y_LABEL).style().stroke_color(black);
-
         image.get_g_element(boxplot::Y_LABEL).push_back(new
- text_element(12, (plot_y2 + plot_y1)/2.,
- y_label_info.text(),
- 12, center_align, -90));
+ text_element(12, (plot_y2 + plot_y1) /2.,
+ y_label_info.text(), 12, "", "", "", "", "",center_align, upward));
     }
 
 
- void _calculate_transform()
+ void calculate_transform()
     {
         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()
+ void calculate_plot_window()
     {
         plot_x1 = plot_y1 = 0;
 
- plot_x2 = image.get_x_size();
- plot_y2 = image.get_y_size();
+ plot_x2 = image.x_size();
+ plot_y2 = image.y_size();
 
         if(use_x_label)
         {
@@ -370,12 +388,12 @@
 
         if(use_y_label)
         {
- plot_x1 += (int)(y_label_info.font_size() * 1.5);
+ plot_x1 += (int)(y_label_info.font_size() * text_margin);
         }
 
         if(use_title)
         {
- plot_y1 += (int)(title_info.font_size() * 1.5);
+ plot_y1 += (int)(title_info.font_size() * text_margin);
         }
 
         // Give the plot window a natural bit of padding.
@@ -385,11 +403,10 @@
         plot_y2-=5;
 
         plot_x1 +=
- y_major_length > y_minor_length ?
- y_major_length :
- y_minor_length ;
+ y_minor_tick_length_ > y_minor_tick_length_ ?
+ y_minor_tick_length_ : y_minor_tick_length_ ;
 
- plot_y2 -= x_major_length + 10;
+ plot_y2 -= x_major_tick_length_ + 10;
 
         image.get_g_element(boxplot::PLOT_BACKGROUND).push_back(
                 new rect_element(plot_x1, plot_y1,
@@ -397,13 +414,12 @@
 
     }
 
- void _draw_whiskers(double min, double max, double length, double x,
+ void draw_whiskers(double min, double max, double length, double x,
         const svg_style& min_whisker, const svg_style& max_whisker,
         const svg_style& axis_whisker)
     {
         // Set up document structure for whiskers.
- g_element& g_whisk_ptr = image.get_g_element(boxplot::WHISKER)
- .add_g_element();
+ g_element& g_whisk_ptr = image.get_g_element(boxplot::WHISKER).add_g_element();
 
         // Set colors for whiskers.
         g_whisk_ptr.add_g_element().style()
@@ -425,8 +441,8 @@
             .fill_color(axis_whisker.fill_color())
             .stroke_width(axis_whisker.stroke_width());
 
- _transform_y(min);
- _transform_y(max);
+ transform_y(min);
+ transform_y(max);
 
         double half_length = length / 2.;
 
@@ -443,7 +459,7 @@
         g_whisk_ptr.clip_id(plot_window_clip);
     }
 
- void _draw_box(double q1, double q3, double x, double width,
+ void draw_box(double q1, double q3, double x, double width,
         const svg_style& box_style)
     {
         g_element& g_ptr = image.get_g_element(boxplot::MEDIAN)
@@ -453,7 +469,7 @@
                      .stroke_width(box_style.stroke_width())
                      .fill_color(box_style.fill_color());
 
- _transform_y(q1); _transform_y(q3);
+ transform_y(q1); transform_y(q3);
 
         double half_width = width/2;
 
@@ -463,10 +479,10 @@
         g_ptr.clip_id(plot_window_clip);
     }
 
- void _draw_median(double median, double x_offset, double box_width,
+ void draw_median(double median, double x_offset, double box_width,
         const svg_style& median_style)
     {
- _transform_y(median);
+ transform_y(median);
 
         g_element& g_ptr = image.get_g_element(boxplot::MEDIAN)
             .add_g_element();
@@ -483,7 +499,7 @@
         g_ptr.clip_id(plot_window_clip);
     }
 
- void _draw_outliers(double x, const std::vector<double>& outliers,
+ void draw_outliers(double x, const std::vector<double>& outliers,
         const std::vector<double>& extreme_outliers,
         const plot_point_style& mild_style, const plot_point_style& extreme_style)
     {
@@ -503,13 +519,13 @@
 
         for(i = outliers.begin(); i != outliers.end(); ++i)
         {
- _transform_y(temp = *i);
+ transform_y(temp = *i);
             g_mild_ptr.circle(x, temp, 2);
         }
 
         for(i = extreme_outliers.begin(); i != extreme_outliers.end(); ++i)
         {
- _transform_y(temp = *i);
+ transform_y(temp = *i);
             g_ext_ptr.circle(x, temp, 2);
         }
 
@@ -518,36 +534,35 @@
         g_ext_ptr.clip_id(plot_window_clip);
     }
 
- void _draw_boxplot(const svg_boxplot_series& series, double x_offset)
+ void draw_boxplot(const svg_boxplot_series& series, double x_offset)
     {
- _draw_whiskers(series.whisker_min, series.whisker_max,
+ draw_whiskers(series.whisker_min, series.whisker_max,
                        series.whisker_length, x_offset,
                        series.min_whisker_style, series.max_whisker_style,
                        series.axis_style);
 
- _draw_box(series.q1, series.q3, x_offset, series.box_width,
+ draw_box(series.q1, series.q3, x_offset, series.box_width,
             series.box_style);
 
- _draw_median(series.median, x_offset,
+ draw_median(series.median, x_offset,
             series.box_width - series.box_style.stroke_width(),
             series.median_style);
 
- _draw_outliers(x_offset, series.outliers, series.extreme_outliers,
+ draw_outliers(x_offset, series.outliers, series.extreme_outliers,
             series.mild_outlier, series.ext_outlier);
     }
 
- void _update_image()
+ void update_image()
     {
- _clear_all();
+ clear_all();
 
         // Draw background.
         image.get_g_element(boxplot::BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
- image.get_y_size()));
+ new rect_element(0, 0, image.x_size(), image.y_size()) );
 
- _draw_title();
- _calculate_plot_window();
- _calculate_transform();
+ draw_title();
+ calculate_plot_window();
+ calculate_transform();
 
         // Define the clip path for the plot window.
         // We don't want to allow overlap of the plot window lines,
@@ -557,39 +572,47 @@
                                      plot_x2 - plot_x1 - 2, plot_y2 - plot_y1 - 2),
                                      plot_window_clip);
 
- _draw_y_axis();
- _draw_x_axis();
+ draw_y_axis();
+ draw_x_axis();
 
         if(use_x_label)
         {
- _draw_x_label();
+ draw_x_label();
         }
 
         if(use_y_label)
         {
- _draw_y_label();
+ draw_y_label();
         }
 
         for(unsigned int i=0; i<series.size(); ++i)
         {
- _draw_boxplot(series[i],
+ draw_boxplot(series[i],
                 plot_x1 + (plot_x2-plot_x1)*((double)(i + 1)) / (double)(series.size() + 1));
         }
     }
 
 public:
 
-svg_boxplot(): title_info(0, 0, "Plot of data", 30),
- x_label_info(0, 0, "X Axis", 12),
- y_label_info(0, 0, "Y Axis", 12),
+svg_boxplot()
+:
+ title_info(0, 0, "Plot of data", 30),
+ x_label_info(0, 0, "X Axis", 12,"Lucida Sans Console", "", "", "", "", center_align, horizontal),
+ y_label_info(0, 0, "Y Axis", 12, "Lucida Sans Console", "", "", "", "", center_align, upward),
+ // x_units_info(0, 0, "(units)", 12, "Lucida Sans Console", "", "", "", "", center_align, horizontal),
+ // y_units_info(0, 0, "(units)", 12, "Lucida Sans Console", "", "", "", "", center_align, upward),
+
                       y_min(0), y_max(100),
- y_major(10), use_y_label(true),
- use_x_label(true), x_major_length(10),
- y_minor_length(5), y_num_minor(1),
- y_major_length(20),
- plot_window_clip("__clip_window"),
+ y_major(10),
+ use_y_label(true),
+ use_x_label(true),
+ x_major_tick_length_(10),
+ y_num_minor_ticks_(1),
+ y_minor_tick_length_(20),
+ plot_window_clip("__clip_window"), // TODO Why the __???
                       use_x_major_labels(true),
- use_title(true), use_y_major_labels(true)
+ use_title(true),
+ use_y_major_labels(true)
 
 {
     image.image_size(500, 350);
@@ -601,21 +624,11 @@
     }
 
     // Set boxplot color defaults.
- image.get_g_element(boxplot::BACKGROUND)
- .style().fill_color(white);
-
- image.get_g_element(boxplot::PLOT_BACKGROUND)
- .style().fill_color(white).stroke_color(black);
-
- image.get_g_element(boxplot::X_TICKS)
- .style().stroke_color(black).stroke_width(2);
-
- image.get_g_element(boxplot::Y_MINOR_TICKS)
- .style().stroke_color(black).stroke_width(1);
-
- image.get_g_element(boxplot::Y_MAJOR_TICKS)
- .style().stroke_color(black).stroke_width(2);
-
+ image.get_g_element(boxplot::BACKGROUND).style().fill_color(white);
+ image.get_g_element(boxplot::PLOT_BACKGROUND).style().fill_color(white).stroke_color(black);
+ image.get_g_element(boxplot::X_TICKS).style().stroke_color(black).stroke_width(2);
+ image.get_g_element(boxplot::Y_MINOR_TICKS).style().stroke_color(black).stroke_width(1);
+ image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_color(black).stroke_width(2);
     image.get_g_element(boxplot::X_LABEL).style().stroke_color(black);
     image.get_g_element(boxplot::Y_LABEL).style().stroke_color(black);
     image.get_g_element(boxplot::TITLE).style().stroke_color(black);
@@ -633,13 +646,13 @@
     return *this;
 }
 
-svg_boxplot& write(const std::string& _str)
+svg_boxplot& write(const std::string& str)
 {
- std::ofstream fout(_str.c_str());
+ std::ofstream fout(str.c_str());
 
     if(fout.fail())
     {
- throw std::runtime_error("Unable to open "+_str);
+ throw std::runtime_error("Unable to open "+str);
     }
 
     write(fout);
@@ -649,88 +662,88 @@
 
 svg_boxplot& write(std::ostream& s_out)
 {
- _update_image();
+ update_image();
 
     image.write(s_out);
 
     return *this;
 }
 
-svg_boxplot& title_on(bool _cmd)
+svg_boxplot& title_on(bool cmd)
 {
- use_title = _cmd;
+ use_title = cmd;
     return *this;
 }
 
-svg_boxplot& y_label_on(bool _cmd)
+svg_boxplot& y_label_on(bool cmd)
 {
- use_y_label = _cmd;
+ use_y_label = cmd;
     return *this;
 }
 
-svg_boxplot& x_label_on(bool _cmd)
+svg_boxplot& x_label_on(bool cmd)
 {
- use_x_label = _cmd;
+ use_x_label = cmd;
     return *this;
 }
 
-svg_boxplot& y_major_labels_on(bool _cmd)
+svg_boxplot& y_major_labels_on(bool cmd)
 {
- use_y_major_labels = _cmd;
+ use_y_major_labels = cmd;
     return *this;
 }
 
-svg_boxplot& x_labels_on(bool _cmd)
+svg_boxplot& x_labels_on(bool cmd)
 {
- use_x_major_labels = _cmd;
+ use_x_major_labels = cmd;
     return *this;
 }
 
-svg_boxplot& y_major_tick_color(const svg_color& _col)
+svg_boxplot& y_major_tick_color(const svg_color& col)
 {
- image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_color(_col);
+ image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& x_tick_color(const svg_color& _col)
+svg_boxplot& x_tick_color(const svg_color& col)
 {
- image.get_g_element(boxplot::X_TICKS).style().stroke_color(_col);
+ image.get_g_element(boxplot::X_TICKS).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& y_minor_tick_color(const svg_color& _col)
+svg_boxplot& y_minor_tick_color(const svg_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().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& title_color(const svg_color& _col)
+svg_boxplot& title_color(const svg_color& col)
 {
- image.get_g_element(boxplot::TITLE).style().stroke_color(_col);
+ image.get_g_element(boxplot::TITLE).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& background_color(const svg_color& _col)
+svg_boxplot& background_color(const svg_color& col)
 {
- image.get_g_element(boxplot::BACKGROUND).style().fill_color(_col);
+ image.get_g_element(boxplot::BACKGROUND).style().fill_color(col);
     return *this;
 }
 
-svg_boxplot& background_border_color(const svg_color& _col)
+svg_boxplot& background_border_color(const svg_color& col)
 {
- image.get_g_element(boxplot::BACKGROUND).style().stroke_color(_col);
+ image.get_g_element(boxplot::BACKGROUND).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& plot_background_color(const svg_color& _col)
+svg_boxplot& plot_background_color(const svg_color& col)
 {
- image.get_g_element(boxplot::PLOT_BACKGROUND).style().fill_color(_col);
+ image.get_g_element(boxplot::PLOT_BACKGROUND).style().fill_color(col);
     return *this;
 }
 
-svg_boxplot& plot_background_border_color(const svg_color& _col)
+svg_boxplot& plot_background_border_color(const svg_color& col)
 {
- image.get_g_element(boxplot::PLOT_BACKGROUND).style().stroke_color(_col);
+ image.get_g_element(boxplot::PLOT_BACKGROUND).style().stroke_color(col);
     return *this;
 }
 
@@ -747,9 +760,9 @@
     return *this;
 }
 
-svg_boxplot& y_label(const std::string& _str)
+svg_boxplot& y_label(const std::string& str)
 {
- y_label_info.text(_str);
+ y_label_info.text(str);
     return *this;
 }
 
@@ -759,175 +772,171 @@
     return *this;
 }
 
-svg_boxplot& y_label_size(unsigned int _size)
+svg_boxplot& y_label_size(unsigned int size)
 {
- y_label_info.font_size(_size);
+ y_label_info.font_size(size);
     return *this;
 }
 
-svg_boxplot& y_label_color(const svg_color& _col)
+svg_boxplot& y_label_color(const svg_color& col)
 {
- image.get_g_element(boxplot::Y_LABEL).style().stroke_color(_col);
+ image.get_g_element(boxplot::Y_LABEL).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& title(const std::string& _str)
+svg_boxplot& title(const std::string& str)
 {
- y_label_info.text(_str);
+ y_label_info.text(str);
     return *this;
 }
 
-svg_boxplot& title_size(unsigned int _size)
+svg_boxplot& title_size(unsigned int size)
 {
- y_label_info.font_size(_size);
+ y_label_info.font_size(size);
     return *this;
 }
 
-svg_boxplot& x_label(const std::string& _str)
+svg_boxplot& x_label(const std::string& str)
 {
- x_label_info.text(_str);
+ x_label_info.text(str);
     return *this;
 }
 
-svg_boxplot& x_label_size(unsigned int _size)
+svg_boxplot& x_label_size(unsigned int size)
 {
- x_label_info.font_size(_size);
+ x_label_info.font_size(size);
     return *this;
 }
 
-svg_boxplot& x_label_color(const svg_color& _col)
+svg_boxplot& x_label_color(const svg_color& col)
 {
- image.get_g_element(boxplot::X_LABEL).style().stroke_color(_col);
+ image.get_g_element(boxplot::X_LABEL).style().stroke_color(col);
     return *this;
 }
 
-svg_boxplot& y_major_interval(double _inter)
+svg_boxplot& y_major_interval(double inter)
 {
- y_major = _inter;
+ y_major = inter;
 
     return *this;
 }
 
-svg_boxplot& x_tick_length(unsigned int _length)
+svg_boxplot& x_tick_length(unsigned int length)
 {
- x_major_length = _length;
+ x_major_tick_length_ = length;
     return *this;
 }
 
-svg_boxplot& y_major_tick_length(unsigned int _length)
+svg_boxplot& y_major_tick_length(unsigned int length)
 {
- y_major_length = _length;
+ y_major_tick_length_ = length;
     return *this;
 }
 
-svg_boxplot& y_minor_tick_length(unsigned int _length)
+svg_boxplot& y_minor_tick_length(unsigned int length)
 {
- y_minor_length = _length;
+ y_minor_tick_length_ = length;
     return *this;
 }
 
-svg_boxplot& y_num_minor_ticks(unsigned int _num)
+svg_boxplot& y_num_minor_ticks(unsigned int num)
 {
- y_num_minor = _num;
+ y_num_minor_ticks_ = num;
     return *this;
 }
 
-svg_boxplot& x_tick_width(unsigned int _width)
+svg_boxplot& x_tick_wide(unsigned int width)
 {
- image.get_g_element(boxplot::X_TICKS).style().stroke_width(_width);
-
+ image.get_g_element(boxplot::X_TICKS).style().stroke_width(width);
     return *this;
 }
 
-svg_boxplot& y_major_tick_width(unsigned int _width)
+svg_boxplot& y_major_tick_width(unsigned int width)
 {
- image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_width(_width);
-
+ image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_width(width);
     return *this;
 }
 
-svg_boxplot& y_minor_tick_width(unsigned int _width)
+svg_boxplot& y_minor_tick_width(unsigned int width)
 {
- image.get_g_element(boxplot::Y_MINOR_TICKS).style().stroke_width(_width);
-
+ image.get_g_element(boxplot::Y_MINOR_TICKS).style().stroke_width(width);
     return *this;
 }
 
-
-unsigned int get_image_x_size()
-{
- return image.get_x_size();
+unsigned int image_x_size()
+{ // TODO is this needed?
+ return image.x_size();
 }
 
-unsigned int get_image_y_size()
+unsigned int image_y_size()
 {
- return image.get_x_size();
+ return image.x_size();
 }
 
-std::string get_title()
+std::string title()
 {
     return title_info.text();
 }
 
-bool get_x_label()
+bool x_label()
 {
     return use_x_label;
 }
 
-bool get_x_major_labels()
+bool x_major_labels()
 {
     return use_x_major_labels;
 }
 
 // color information
-svg_color get_title_color()
+svg_color title_color()
 {
     return image.get_g_element(boxplot::TITLE).style().stroke_color();
 }
 
-svg_color get_background_color()
+svg_color background_color()
 {
     return image.get_g_element(boxplot::BACKGROUND).style().fill_color();
 }
 
-svg_color get_background_border_color()
+svg_color background_border_color()
 {
     return image.get_g_element(boxplot::BACKGROUND).style().stroke_color();
 }
 
-svg_color get_plot_background_color()
+svg_color plot_background_color()
 {
     return image.get_g_element(boxplot::PLOT_BACKGROUND).style().fill_color();
 }
 
-svg_color get_x_label_color()
+svg_color x_label_color()
 {
     return image.get_g_element(boxplot::X_LABEL).style().stroke_color();
 }
 
-svg_color get_x_tick_color()
+svg_color x_tick_color()
 {
     return image.get_g_element(boxplot::X_TICKS).style().stroke_color();
 }
 
-unsigned int get_x_tick_length()
+unsigned int x_tick_length()
 {
- return x_major_length;
+ return x_major_tick_length_;
 }
 
-unsigned int get_x_major_tick_width()
+unsigned int x_major_tick_width()
 {
     return image.get_g_element(boxplot::X_TICKS).style().stroke_width();
 }
 
-std::string get_x_label_text()
+std::string x_label_text()
 {
     return x_label_info.text();
 }
 
 svg& get_svg()
 {
- _update_image();
+ update_image();
 
     return image;
 }
@@ -977,5 +986,3 @@
 } // namespace svg
 } // namespace boost
 #endif // BOOST_SVG_SVG_BOXPLOT_HPP
-
-

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -54,56 +54,58 @@
     salmon, sandybrown, seagreen, seashell, sienna, silver,
     skyblue, slateblue, slategray, slategrey, snow, springgreen,
     steelblue, tan, teal, thistle, tomato, turquoise, violet,
- // Forward declarations.
- wheat, white, whitesmoke, yellow, yellowgreen, blank
+ wheat, white, whitesmoke, yellow, yellowgreen,
+ blank // 'NotAColor'
 };
 
-// Forward declarations:
+// Forward declarations in this module (see svg_fwd):
 struct svg_color;
-void constant_to_rgb(svg_color_constant _c, unsigned char &r,
- unsigned char &g, unsigned char &b);
+void constant_to_rgb(svg_color_constant c,
+ unsigned char& r, unsigned char& g, unsigned char& b);
 std::ostream& operator<< (std::ostream&, const svg_color&);
 
-// -----------------------------------------------------------------
+// --------------------------------------------------------------------
 // svg_color is the struct that contains information about RGB 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 [0, 255].
-// -----------------------------------------------------------------
+// outside the normal rgb range are to be accepted,
+// but are constrained to acceptable range of integer values [0, 255].
+// --------------------------------------------------------------------
 
 struct svg_color
 {
     friend std::ostream& operator<< (std::ostream& os, const svg_color& rhs);
 
- unsigned char r, g, b;
+ unsigned char r; // unsigned char provides range [0 to 255].
+ unsigned char g;
+ unsigned char b;
     bool blank; // true means "Not to be displayed" 'pseudo-color'.
     // TODO seems to display as black? - Need a check if is_blank == true?
 
- svg_color(int _r, int _g, int _b) : blank(false)
+ svg_color(int red, int green, int blue) : blank(false)
     { // Constrain rgb to [0 .. 255]
- _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);
+ red = ( red < 0 ) ? 0 : red;
+ green = ( green < 0 ) ? 0 : green;
+ blue = ( blue < 0 ) ? 0 : blue;
+ r = (unsigned char)(( red > 255 ) ? 255 : red);
+ g = (unsigned char)(( green > 255 ) ? 255 : green);
+ b = (unsigned char)(( blue > 255 ) ? 255 : blue);
     }
 
- svg_color(bool _is) : blank(_is)
- {
+ svg_color(bool is) : blank(is)
+ { // Permits blank as a (non-)color.
       r = 0; // Safer to assign *some* value to rgb? zero, or 255?
- g = 0; // rather than leaving random?
+ g = 0; // rather than leaving them random?
       b = 0;
     }
 
- svg_color(svg_color_constant _col) : blank(false)
+ svg_color(svg_color_constant col) : blank(false)
     {
- constant_to_rgb(_col, r, g, b);
+ constant_to_rgb(col, r, g, b);
     }
 
     void write(std::ostream& rhs)
- {
+ { // Write color in svg format, for example, rgb(127,255,212).
         if(!blank)
         {
             rhs << "rgb(" << (unsigned int)r << "," << (unsigned int) g << ","
@@ -114,7 +116,7 @@
             rhs << "blank";
         }
          // Usage: my_color.write(cout); cout << endl; outputs: rgb(127,255,212)
- } // void write(std::ostream& rhs)
+ } // void write(std::ostream& rhs)
 
     bool operator== (const svg_color& rhs)
     {
@@ -125,10 +127,22 @@
       }
       return (r == rhs.r) && (g == rhs.g) && (b == rhs.b);
     }
+
+ bool operator!= (const svg_color& rhs)
+ {
+ if ((blank) || (rhs.blank == true))
+ { // Make blank a sort of NaN, that never compares true?
+ // not even if both rhs and lhs are blank.
+ return true;
+ }
+ return (r != rhs.r) || (g != rhs.g) || (b != rhs.b);
+ }
 }; // struct svg_color
 
+// Note operator== and operator<< are both needed to use Boost.Test.
+
 bool operator== (const svg_color& lhs, const svg_color& rhs)
-{
+{ // Note operator== and operator << both needed to use Boost.Test.
   if ((rhs.blank == true) || (rhs.blank == true))
   { // Make blank a sort of NaN, that never compares true?
     // not even if both rhs and lhs are blank.
@@ -137,8 +151,18 @@
   return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
 }
 
+bool operator!= (const svg_color& lhs, const svg_color& rhs)
+{ // Note operator== and operator << both needed to use Boost.Test.
+ if ((rhs.blank == true) || (rhs.blank == true))
+ { // Make blank a sort of NaN, that never compares true?
+ // not even if both rhs and lhs are blank.
+ return true;
+ }
+ return (lhs.r == rhs.r) || (lhs.g == rhs.g) || (lhs.b == rhs.b);
+}
+
 std::ostream& operator<< (std::ostream& os, const svg_color& color)
-{
+{ //
     if(!color.blank)
     {
         os << "RGB("
@@ -153,7 +177,7 @@
     // Usage: svg_color my_color(127, 255, 212); cout << "my_color " << my_color << endl;
     // Outputs: my_color RGB(127,255,212)
     // cout << "magenta " << svg_color(magenta) << endl;
- // but caution cout << magenta << endl; outputs 85 because magenta is an enum!
+ // but caution! cout << magenta << endl; outputs 85 because magenta is an enum!
     return os;
 } // std::ostream& operator<<
 
@@ -309,10 +333,10 @@
     svg_color(false) // blank - "Not to be displayed" pseudo-color.
 }; // svg_color color_array[]
 
-void constant_to_rgb(svg_color_constant _c,
- unsigned char &r, unsigned char &g, unsigned char &b)
-{ // Convert a named SVG standard color to rgb.
- svg_color color(color_array[_c]);
+void constant_to_rgb(svg_color_constant c,
+ unsigned char& r, unsigned char& g, unsigned char& b)
+{ // Convert a named SVG standard color to update three rgb variables.
+ svg_color color(color_array[c]);
     if(!color.blank)
     {
         r = color.r;
@@ -321,15 +345,15 @@
     }
     else
     { // Unwise to leave r, g, & b unchanged?
- r = 255; // Set all to white?
+ r = 255; // Set all to white (255) or 0?
       g = 255;
       b = 255;
     }
-}
+} // void constant_to_rgb
 
-svg_color constant_to_rgb(svg_color_constant _c)
+svg_color constant_to_rgb(svg_color_constant c)
 {
- return color_array[_c];
+ return color_array[c];
 }
 
 } // svg

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,139 +1,215 @@
 // 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
 
-// -----------------------------------------------------------------
+// Copyright Jacob Voytko 2007
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_SVG_SVG_STYLE_HPP
+#define BOOST_SVG_SVG_STYLE_HPP
+
+// svg style information is fill, stroke, width, line & bezier curve.
+// This module provides struct plot_point_style & struct plot_line_style
+// and class svg_style holding the styles.
 
-#ifndef _BOOST_SVG_SVG_STYLE_HPP
-#define _BOOST_SVG_SVG_STYLE_HPP
+// http://www.w3.org/TR/SVG11/styling.html
 
-#include <ostream>
 #include "svg_color.hpp"
 #include "detail/svg_style_detail.hpp"
 
-namespace boost {
-namespace svg {
-
-enum point_shape{none, circle, square, point};
+#include <ostream>
+// using std::ostream;
 
-struct plot_point_style
+namespace boost
+{
+namespace svg
 {
- 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)
- {
+enum point_shape
+{ // Marking a data point.
+ // Used in draw_plot_point in axis_plot_frame.hpp
+ none = 0,
+ round, square, point, egg, // ellipse
+ vertical_line, // line up & down from axis.
+ horizontal_line, // line left & right from axis.
+ vertical_tick, // tick up from axis.
+ horizontal_tick, // line left & right from axis.
+ // Note horizontal will not be useful for 1D plot - will be on the axis.
+ cone, // pointing up - 'rightwayup'.
+ triangle, // pointing down 'upsidedown'.
+ star, // using polygon.
+ lozenge,
+ diamond,
+ heart,
+ club,
+ spade,
+ asterisk, // *
+ x, // x
+ cross,
+ symbol // Unicode symbol including letters, digits, greek & 'squiggles'.
+ // &#x3A9; = greek omega
+ // TODO add other shapes?
+// name circle changed to round to avoid clash with function named circle.
+};
 
+struct plot_point_style
+{
+ svg_color fill_color; // Color of the centre of the shape.
+ svg_color stroke_color; // Color of circumference of shape.
+ int size; // diameter of circle, height of square, font_size ...
+ point_shape shape; // round, square, point...
+ std::string symbols; // Unicode symbol (letters, digits, squiggles etc)
+ // Caution: not all Unicode symbols are output by all browsers!
+ // const std::string font = "Lucida Sans Unicode";
+ // TODO? devise way of setting this font?
+
+ plot_point_style(const svg_color& fill, const svg_color& stroke,
+ int size = 10, point_shape shape = round, const std::string& symbols = "X")
+ :
+ fill_color(fill), stroke_color(stroke), size(size), shape(shape), symbols(symbols)
+ { // TODO Should these be default colors?
     }
-};
+}; // struct plot_point_style
 
 struct plot_line_style
-{
+{ // TODO dotted and dashed line style? Useful for B&W?
     svg_color color;
- svg_color_constant area_fill;
-
+ svg_color area_fill; // Fill color from line to axis.
     bool line_on;
     bool bezier_on;
 
- plot_line_style(const svg_color& _col, bool _on, bool _bezier_on = false):
- color(_col), line_on(_on), area_fill(blank), bezier_on(_bezier_on)
+ plot_line_style(const svg_color& col, const svg_color& acol = blank, bool on = true, bool bezier_on = false)
+ :
+ color(col), line_on(on), area_fill(acol), bezier_on(bezier_on)
     {
     }
-};
+}; // struct plot_line_style
 
 // -----------------------------------------------------------------
-// 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.
+// This is the style information for any <g> tag.
+// This may be expanded to include more data from the SVG standard.
 // -----------------------------------------------------------------
 class svg_style
 {
-private:
- svg_color fill;
- svg_color stroke;
-
- unsigned int width;
-
- bool fill_on;
- bool stroke_on;
- bool width_on;
+private: // Accesses only by set and get member functions below.
+ // Names changed so private data member variables end with _,
+ // to permit use of names for set & get member functions.
+ svg_color fill_;
+ svg_color stroke_;
+ unsigned int width_;
+ bool fill_on_; // true means there is fill info.
+ 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() :
+ fill_(svg_color(0, 0, 0)), // == black
+ stroke_(svg_color(0, 0, 0)),
+ width_(0),
+ fill_on_(false), stroke_on_(false), width_on_(false)
+ { // Default constructor initialises all private data.
+ }
+
+ 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)
+ { // Construct with specified fill and stroke colors, and width.
+ }
+
+ // Set & get svg_style member functions
+ // to return fill color and stroke color & width.
+ svg_color fill_color() const
     {
+ return svg_color(fill_);
+ }
 
+ svg_color stroke_color() const
+ {
+ return svg_color(stroke_);
     }
 
- // getters
- svg_color fill_color() const { return svg_color(fill); }
- svg_color stroke_color() const { return svg_color(stroke); }
- unsigned int stroke_width() const { return width; }
+ unsigned int stroke_width() const
+ { // TODO probably should be double???
+ return width_;
+ }
 
- 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)
+ bool fill_on() const
     {
+ return fill_on_;
+ }
 
+ void fill_on(bool is)
+ {
+ fill_on_ = is;
     }
-
- // setters
- svg_style& fill_color(const svg_color& _col)
+
+ bool stroke_on() const
+ {
+ return stroke_on_;
+ }
+
+ void stroke_on(bool is)
+ {
+ stroke_on_ = is;
+ }
+
+ bool width_on() const
+ {
+ return width_on_;
+ }
+
+ void width_on(bool is)
+ {
+ width_on_ = is;
+ }
+
+ // Set svg_style member functions to set fill, stroke & width.
+ svg_style& fill_color(const svg_color& col)
     {
- fill = _col;
- fill_on = true;
+ fill_ = col;
+ fill_on_ = true;
         return *this;
     }
 
- svg_style& stroke_color(const svg_color& _col)
+ svg_style& stroke_color(const svg_color& col)
     {
- stroke = _col;
- stroke_on = true;
+ stroke_ = col;
+ stroke_on_ = true;
         return *this;
     }
 
- svg_style& stroke_width(unsigned int _width)
+ svg_style& stroke_width(unsigned int width)
     {
- width = _width;
- width_on = true;
+ width_ = width;
+ width_on_ = true;
         return *this;
     }
     
     void write(std::ostream& rhs)
- {
- if(stroke_on)
+ { // Write any stroke, fill colors and/or width info (start with space).
+ if(stroke_on_)
         {
- rhs << "stroke=\"";
- stroke.write(rhs);
- rhs << "\" ";
+ rhs << " stroke=\"";
+ stroke_.write(rhs);
+ rhs << "\"";
         }
-
- if(fill_on)
+ if(fill_on_)
         {
- rhs << "fill=\"";
- fill.write(rhs);
- rhs<<"\" ";
+ rhs << " fill=\"";
+ fill_.write(rhs);
+ rhs<<"\"";
         }
- if(width_on)
+ if(width_on_)
         {
- rhs << "stroke-width=\""
- << width
- << "\" ";
+ rhs << " stroke-width=\""
+ << width_
+ << "\"";
         }
- }
-};
+ } // void write
+}; // class svg_style
 
 }//svg
 }//boost
 
-
-#endif
+#endif // BOOST_SVG_SVG_STYLE_HPP

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,14 +1,16 @@
-# Copyright Paul A. Bristow 2007
 # Copyright Jake Voytko 2007
+# Copyright Paul A. Bristow 2007
   
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt
 # or copy at http://www.boost.org/LICENSE_1_0.txt)
 
+# Reminder: whitespace MUST terminate variable name!
+# so space BEFORE ; and :
+
 # SVG plot documentation as html and pdf from Quickbook.
 
 # project boost/doc ;
-# import boostbook : boostbook ;
 
 using quickbook ;
 
@@ -21,6 +23,8 @@
   :
 ;
 
+# import boostbook : boostbook ;
+
 boostbook standalone
   :
     svg_plot

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -28,7 +28,7 @@
 </h3></div></div></div>
 <div><p class="copyright">Copyright © 2007 Jake Voytko</p></div>
 <div><div class="legalnotice">
-<a name="id623758"></a><p>
+<a name="id623859"></a><p>
         Distributed under the Boost Software License, Version 1.0. (See accompanying
         file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       </p>
@@ -88,13 +88,14 @@
 <dt><span class="section"> svg_2d_plot Public Interface</span></dt>
 <dt><span class="section"> svg_boxplot Public Interface</span></dt>
 </dl></dd>
+<dt><span class="section"> Implementation & Rationale</span></dt>
 <dt><span class="section"> Acknowledgements</span></dt>
 </dl>
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: October 17, 2007 at 10:32:28 GMT</small></p></td>
-<td align="right"><small></small></td>
+<td align="left"><p><small>Last revised: November 13, 2007 at 12:10:52 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav"><a accesskey="n" href="svg_plot/howtouse.html"><img src="../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a></div>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/acknowledgements.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/acknowledgements.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/acknowledgements.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -6,7 +6,7 @@
 <meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
 <link rel="start" href="../index.html" title="SVG_Plot">
 <link rel="up" href="../index.html" title="SVG_Plot">
-<link rel="prev" href="interface/svg_boxplot_interface.html" title=" svg_boxplot Public Interface">
+<link rel="prev" href="implementation.html" title=" Implementation &amp; Rationale">
 </head>
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 <table cellpadding="2" width="100%"><tr>
@@ -19,7 +19,7 @@
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="interface/svg_boxplot_interface.html"><img src="../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a>
+<a accesskey="p" href="implementation.html"><img src="../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a>
 </div>
 <div class="section" lang="en">
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -59,11 +59,15 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="interface/svg_boxplot_interface.html"><img src="../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a>
+<a accesskey="p" href="implementation.html"><img src="../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a>
 </div>
 </body>
 </html>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -33,7 +33,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_limits.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_limits.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_limits.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -43,7 +43,7 @@
         <span class="identifier">whitesmoke</span></code>. This will become customizable.
       </p>
 <a name="svg_plot.behavior.behavior_limits.nan"></a><h5>
-<a name="id689092"></a>
+<a name="id689250"></a>
         <a href="behavior_limits.html#svg_plot.behavior.behavior_limits.nan">NaN</a>
       </h5>
 <p>
@@ -53,7 +53,7 @@
         user-defined coordinates as 0.
       </p>
 <a name="svg_plot.behavior.behavior_limits.infinity"></a><h5>
-<a name="id689152"></a>
+<a name="id689309"></a>
         <a href="behavior_limits.html#svg_plot.behavior.behavior_limits.infinity">Infinity</a>
       </h5>
 <p>
@@ -70,7 +70,7 @@
         appear at the top of the graph.
       </p>
 <a name="svg_plot.behavior.behavior_limits.negative_infinity"></a><h5>
-<a name="id689288"></a>
+<a name="id689445"></a>
         <a href="behavior_limits.html#svg_plot.behavior.behavior_limits.negative_infinity">Negative
         Infinity</a>
       </h5>
@@ -97,7 +97,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_stylesheets.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_stylesheets.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/behavior/behavior_stylesheets.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -74,14 +74,12 @@
 </tr>
 <tr><td align="left" valign="top">
 <p>
- </p>
-<p>
- Please note that the language that is accepted by the parser is actually
- stricter than the real CSS standard allows for. Following GSoC, the parser
- will be reimplemented to reflect the parser suggested by the CSS standard.
- All identifiers (class, ID, or otherwise), must be the <span class="bold"><strong>one
- and only</strong></span> identifier on the line. The following is not accepted:
-
+ Please note that the language that is accepted by the parser is actually
+ stricter than the real CSS standard allows for. Following GSoC, the parser
+ will be reimplemented to reflect the parser suggested by the CSS standard.
+ All identifiers (class, ID, or otherwise), must be the <span class="bold"><strong>one
+ and only</strong></span> identifier on the line. The following is not accepted:
+
 </p>
 <pre class="programlisting">
 <span class="identifier">rect</span><span class="special">,</span> <span class="identifier">circle</span>
@@ -91,16 +89,12 @@
 <span class="special">}</span>
 </pre>
 <p>
- </p>
-<p>
- </p>
-<p>
- But the following is:
- </p>
+ </p>
 <p>
- </p>
+ But the following is:
+ </p>
 <p>
-
+
 </p>
 <pre class="programlisting">
 <span class="identifier">rect</span>
@@ -116,21 +110,21 @@
 <span class="special">}</span>
 </pre>
 <p>
- </p>
-<p>
- </p>
-<p>
- None of the power of CSS is compromised (I believe), but it becomes more
- verbose.
- </p>
+ </p>
 <p>
+ None of the power of CSS is compromised (I believe), but it becomes more
+ verbose.
         </p>
 </td></tr>
 </table></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/color.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/color.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/color.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -32,7 +32,7 @@
       by the SVG standard</a>.
     </p>
 <a name="svg_plot.color._code__phrase_role__identifier__svg_color_constant__phrase___code_"></a><h4>
-<a name="id622075"></a>
+<a name="id622212"></a>
       <a href="color.html#svg_plot.color._code__phrase_role__identifier__svg_color_constant__phrase___code_"><code class="computeroutput"><span class="identifier">svg_color_constant</span></code></a>
     </h4>
 <p>
@@ -40,7 +40,10 @@
       an enumerated list.
     </p>
 <p>
- The constants are defined at svg_color.hpp.
+ The constants are defined at svg_color.hpp.
+ </p>
+<p>
+ Examples of colors are at svg_colors.cpp.
     </p>
 <p>
       The <a href="http://www.w3.org/TR/SVG/types.html#ColorKeywords" target="_top">colors are
@@ -54,7 +57,7 @@
       for defining defaults for functions, for example.
     </p>
 <a name="svg_plot.color.example_of_using__code__phrase_role__identifier__svg_color_constant__phrase___code_"></a><h5>
-<a name="id622187"></a>
+<a name="id622335"></a>
       <a href="color.html#svg_plot.color.example_of_using__code__phrase_role__identifier__svg_color_constant__phrase___code_">Example
       of using <code class="computeroutput"><span class="identifier">svg_color_constant</span></code></a>
     </h5>
@@ -75,28 +78,27 @@
 </tr>
 <tr><td align="left" valign="top">
 <p>
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">svg_color</span></code> has a constructor
- for <code class="computeroutput"><span class="identifier">svg_color_constant</span></code>,
- so you can use a <code class="computeroutput"><span class="identifier">svg_color_constant</span></code>
- in place of a <code class="computeroutput"><span class="identifier">svg_color</span></code>
- and it will be implicitly converted. However, there is not currently an
- <code class="computeroutput"><span class="identifier">svg_color</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="identifier">svg_color_constant</span><span class="special">)</span></code>
- overload, so
+ <code class="computeroutput"><span class="identifier">svg_color</span></code> has a constructor
+ for <code class="computeroutput"><span class="identifier">svg_color_constant</span></code>, so
+ you can use a <code class="computeroutput"><span class="identifier">svg_color_constant</span></code>
+ in place of a <code class="computeroutput"><span class="identifier">svg_color</span></code> and
+ it will be implicitly converted. However, there is <span class="bold"><strong>not</strong></span>
+ currently an <code class="computeroutput"><span class="identifier">svg_color</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="identifier">svg_color_constant</span><span class="special">)</span></code>
+ overload, so
 </p>
 <pre class="programlisting">
 <span class="identifier">svg_color</span> <span class="identifier">my_color</span> <span class="special">=</span> <span class="identifier">red</span><span class="special">;</span>
 </pre>
 <p>
- does not work.
- </p>
-<p>
+ does not have the desired effect, and nor does <code class="computeroutput"><span class="identifier">cout</span>
+ <span class="special">&lt;&lt;</span> <span class="identifier">red</span>
+ <span class="special">&lt;&lt;</span> <span class="identifier">endl</span><span class="special">;</span></code> output the expected RGB(255,0,0) but instead
+ 119 the value of the enum!
       </p>
 </td></tr>
 </table></div>
 <a name="svg_plot.color._code__phrase_role__identifier__svg_color__phrase___code__interface"></a><h5>
-<a name="id678177"></a>
+<a name="id678342"></a>
       <a href="color.html#svg_plot.color._code__phrase_role__identifier__svg_color__phrase___code__interface"><code class="computeroutput"><span class="identifier">svg_color</span></code> interface</a>
     </h5>
 <p>
@@ -115,19 +117,13 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../../../trunk/doc/html/images/important.png"></td>
 <th align="left">Important</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- Any integer value is accepted but negative values are contrained 0, and
- positive values &gt; 255 are constrained to 255.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ Any integer value is accepted but negative values are contrained 0, and positive
+ values &gt; 255 are constrained to 255.
+ </p></td></tr>
 </table></div>
 <a name="svg_plot.color.example_of_using__code__phrase_role__identifier__svg_color__phrase___code_"></a><h5>
-<a name="id678332"></a>
+<a name="id678494"></a>
       <a href="color.html#svg_plot.color.example_of_using__code__phrase_role__identifier__svg_color__phrase___code_">Example
       of using <code class="computeroutput"><span class="identifier">svg_color</span></code></a>
     </h5>
@@ -144,22 +140,16 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../../trunk/doc/html/images/note.png"></td>
 <th align="left">Note</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">svg_color</span></code>'s constructor
- takes in three integer values. The <a href="http://www.w3.org/TR/SVG11/types.html" target="_top">SVG
- 1.1 standard</a> allows any integer to represent an RGB value, with
- values less than 0 and greater than 255 being constrained to their respective
- min and max.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ <code class="computeroutput"><span class="identifier">svg_color</span></code>'s constructor takes
+ in three integer values. The <a href="http://www.w3.org/TR/SVG11/types.html" target="_top">SVG
+ 1.1 standard</a> allows any integer to represent an RGB value, with values
+ less than 0 and greater than 255 being constrained to their respective min
+ and max.
+ </p></td></tr>
 </table></div>
 <a name="svg_plot.color.colors_internals_and_rationale"></a><h4>
-<a name="id678572"></a>
+<a name="id678730"></a>
       <a href="color.html#svg_plot.color.colors_internals_and_rationale">Colors Internals
       and Rationale</a>
     </h4>
@@ -175,13 +165,17 @@
       All color information is stored in RGB format as three 'unsigned char' in a
       <code class="computeroutput"><span class="identifier">svg_color</span></code> struct. The rationale
       for storing information in RGB format is because it is precise, and is always
- representable the exact same way. Storing a floating-point percentage would
- introduce the possibility of undesirable rounding error.
+ representable the exact same way. Storing a floating-point percent or fraction
+ would introduce the possibility of undesirable rounding error.
     </p>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/howtouse.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/howtouse.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/howtouse.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -58,7 +58,7 @@
       </li>
 </ul></div>
 <a name="svg_plot.howtouse.admonishments"></a><h4>
-<a name="id623856"></a>
+<a name="id667019"></a>
       <a href="howtouse.html#svg_plot.howtouse.admonishments">Admonishments</a>
     </h4>
 <div class="note"><table border="0" summary="Note">
@@ -66,63 +66,39 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../../trunk/doc/html/images/note.png"></td>
 <th align="left">Note</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- These blocks typically go into more detail about an explanation given above.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ These blocks typically go into more detail about an explanation given above.
+ </p></td></tr>
 </table></div>
 <div class="tip"><table border="0" summary="Tip">
 <tr>
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../../../trunk/doc/html/images/tip.png"></td>
 <th align="left">Tip</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- These blocks contain information that you may find helpful while coding.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ These blocks contain information that you may find helpful while coding.
+ </p></td></tr>
 </table></div>
 <div class="important"><table border="0" summary="Important">
 <tr>
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../../../trunk/doc/html/images/important.png"></td>
 <th align="left">Important</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- These contain information that is imperative to understanding a concept.
- Failure to follow these blocks will likely result in undesired behavior.
- Read all of these you find.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ These contain information that is imperative to understanding a concept.
+ Failure to follow suggestions in these blocks will probably result in undesired
+ behavior. Read all of these you find.
+ </p></td></tr>
 </table></div>
 <div class="warning"><table border="0" summary="Warning">
 <tr>
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../../../trunk/doc/html/images/warning.png"></td>
 <th align="left">Warning</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- It is imperative that you follow these. Failure to do so will lead to incorrect,
- and likely undesired, results in the plot
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ It is imperative that you follow these. Failure to do so will lead to incorrect,
+ and likely undesired, results in the plot.
+ </p></td></tr>
 </table></div>
 <p>
       And the first admonishment I will use is as follows:
@@ -132,19 +108,13 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../../../trunk/doc/html/images/important.png"></td>
 <th align="left">Important</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- This is not currently a Boost library. It is a <a href="http://code.google.com/soc/2007/boost/about.html" target="_top">GSoC
- project</a> whose mentor organization is Boost.
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ This is not (yet) a Boost library. It is a <a href="http://code.google.com/soc/2007/boost/about.html" target="_top">GSoC
+ project</a> whose mentor organization is Boost.
+ </p></td></tr>
 </table></div>
 <a name="svg_plot.howtouse.preface"></a><h4>
-<a name="id667008"></a>
+<a name="id667101"></a>
       <a href="howtouse.html#svg_plot.howtouse.preface">Preface</a>
     </h4>
 <p>
@@ -168,9 +138,10 @@
     </p>
 <p>
       SVG files (.svg) can be viewed with a browser like Mozilla Firefox (newer version),
- Adobe Acrobat Reader, many other graphics program, and by Microsoft Internet
- Explorer, provided a suitable <a href="http://www.adobe.com/svg/" target="_top">Adobe
- SVG Veiwer plug-in for SVG files</a> is installed.
+ <a href="http://www.adobe.com/products/acrobat/readstep2.htmlAdobe" target="_top">Acrobat
+ Reader</a>, many other graphics program, and by Microsoft Internet Explorer,
+ provided a suitable <a href="http://www.adobe.com/svg/" target="_top">Adobe SVG Veiwer
+ plug-in for SVG files</a> is installed.
     </p>
 <p>
       The goals of the project are:
@@ -201,21 +172,18 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../../trunk/doc/html/images/note.png"></td>
 <th align="left">Note</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- Comments and suggestions to Jake Voytko at jakevoytko (at) gmail (dot)
- com
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ Comments and suggestions to Jake Voytko at jakevoytko (at) gmail (dot) com
+ </p></td></tr>
 </table></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -38,7 +38,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_1d_plot_interface.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_1d_plot_interface.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_1d_plot_interface.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -28,7 +28,7 @@
 <a name="svg_plot.interface.svg_1d_plot_interface"></a> svg_1d_plot Public Interface
 </h3></div></div></div>
 <div class="table">
-<a name="id693577"></a><p class="title"><b>Table 4. 1D_plot Miscellaneous Functions</b></p>
+<a name="id694572"></a><p class="title"><b>Table 4. 1D_plot Miscellaneous Functions</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Miscellaneous Functions">
 <colgroup>
 <col>
@@ -77,6 +77,49 @@
 <td>
             <p>
               <code class="computeroutput"><span class="identifier">svg_1d_plot</span><span class="special">&amp;</span>
+ <span class="identifier">coord_precision</span><span class="special">(</span><span class="keyword">int</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets the precision output for coordinates (decimal digits, default
+ 3).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg_1d_plot</span><span class="special">&amp;</span>
+ <span class="identifier">document_title</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets title for the SVG XML document (not the plot). &lt;title&gt;My
+ Document title&lt;/title&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg_1d_plot</span><span class="special">&amp;</span>
+ <span class="identifier">description</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets description for the SVG XML document, as comment and XML, for
+ example: &lt;!-- My Document description --&gt; &lt;desc&gt;My Document
+ description&lt;/desc&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg_1d_plot</span><span class="special">&amp;</span>
               <span class="identifier">legend_title_font_size</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">)</span></code>
             </p>
             </td>
@@ -142,7 +185,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id694068"></a><p class="title"><b>Table 5. 1D_plot Commands</b></p>
+<a name="id695258"></a><p class="title"><b>Table 5. 1D_plot Commands</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Commands">
 <colgroup>
 <col>
@@ -310,7 +353,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id694757"></a><p class="title"><b>Table 6. 1D_plot Colors</b></p>
+<a name="id695947"></a><p class="title"><b>Table 6. 1D_plot Colors</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Colors">
 <colgroup>
 <col>
@@ -505,7 +548,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id695744"></a><p class="title"><b>Table 7. 1D_plot X-Axis Definition</b></p>
+<a name="id696934"></a><p class="title"><b>Table 7. 1D_plot X-Axis Definition</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot X-Axis Definition">
 <colgroup>
 <col>
@@ -647,7 +690,7 @@
 </table></div>
 </div>
 <br class="table-break"><a name="svg_plot.interface.svg_1d_plot_interface.the_1d_plot__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method"></a><h5>
-<a name="id696407"></a>
+<a name="id697597"></a>
         <a href="svg_1d_plot_interface.html#svg_plot.interface.svg_1d_plot_interface.the_1d_plot__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method">The
         1D_plot <code class="computeroutput"><span class="identifier">plot</span><span class="special">()</span></code>
         Method</a>
@@ -658,7 +701,7 @@
         named parameters, as well as a deduced parameter.
       </p>
 <div class="table">
-<a name="id696465"></a><p class="title"><b>Table 8. 1D_plot Required parameter</b></p>
+<a name="id697655"></a><p class="title"><b>Table 8. 1D_plot Required parameter</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Required parameter">
 <colgroup>
 <col>
@@ -721,7 +764,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id696587"></a><p class="title"><b>Table 9. 1D_plot Deduced parameter</b></p>
+<a name="id697777"></a><p class="title"><b>Table 9. 1D_plot Deduced parameter</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Deduced parameter">
 <colgroup>
 <col>
@@ -777,7 +820,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id696693"></a><p class="title"><b>Table 10. 1D_plot Optional Parameters</b></p>
+<a name="id697883"></a><p class="title"><b>Table 10. 1D_plot Optional Parameters</b></p>
 <div class="table-contents"><table class="table" summary="1D_plot Optional Parameters">
 <colgroup>
 <col>
@@ -928,7 +971,7 @@
         method:
       </p>
 <a name="svg_plot.interface.svg_1d_plot_interface.using_1d_plot_fill_and_stroke_colors"></a><h5>
-<a name="id697246"></a>
+<a name="id698436"></a>
         <a href="svg_1d_plot_interface.html#svg_plot.interface.svg_1d_plot_interface.using_1d_plot_fill_and_stroke_colors">Using
         1D_plot fill and stroke colors</a>
       </h5>
@@ -960,7 +1003,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_2d_plot_interface.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_2d_plot_interface.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_2d_plot_interface.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -27,7 +27,7 @@
 <a name="svg_plot.interface.svg_2d_plot_interface"></a> svg_2d_plot Public Interface
 </h3></div></div></div>
 <div class="table">
-<a name="id697596"></a><p class="title"><b>Table 11. 2D_plot Miscellaneous</b></p>
+<a name="id698786"></a><p class="title"><b>Table 11. 2D_plot Miscellaneous</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Miscellaneous">
 <colgroup>
 <col>
@@ -115,7 +115,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id697954"></a><p class="title"><b>Table 12. 2D_plot Commands</b></p>
+<a name="id699143"></a><p class="title"><b>Table 12. 2D_plot Commands</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Commands">
 <colgroup>
 <col>
@@ -295,7 +295,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id698688"></a><p class="title"><b>Table 13. 2D_plot Colors</b></p>
+<a name="id699878"></a><p class="title"><b>Table 13. 2D_plot Colors</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Colors">
 <colgroup>
 <col>
@@ -546,7 +546,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id699977"></a><p class="title"><b>Table 14. 2D_plot Axis Information</b></p>
+<a name="id701166"></a><p class="title"><b>Table 14. 2D_plot Axis Information</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Axis Information">
 <colgroup>
 <col>
@@ -834,7 +834,7 @@
         (Note: Getters omitted for now. TODO)
       </p>
 <a name="svg_plot.interface.svg_2d_plot_interface.the__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method"></a><h5>
-<a name="id701376"></a>
+<a name="id702566"></a>
         <a href="svg_2d_plot_interface.html#svg_plot.interface.svg_2d_plot_interface.the__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method">The
         <code class="computeroutput"><span class="identifier">plot</span><span class="special">()</span></code>
         Method</a>
@@ -845,7 +845,7 @@
         named parameters, as well as a deduced parameter.
       </p>
 <div class="table">
-<a name="id701436"></a><p class="title"><b>Table 15. 2D_plot Required parameter</b></p>
+<a name="id702627"></a><p class="title"><b>Table 15. 2D_plot Required parameter</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Required parameter">
 <colgroup>
 <col>
@@ -908,7 +908,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id701558"></a><p class="title"><b>Table 16. 2D_plot Deduced parameter</b></p>
+<a name="id702748"></a><p class="title"><b>Table 16. 2D_plot Deduced parameter</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Deduced parameter">
 <colgroup>
 <col>
@@ -964,7 +964,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id701658"></a><p class="title"><b>Table 17. 2D_plot Optional Parameters</b></p>
+<a name="id702848"></a><p class="title"><b>Table 17. 2D_plot Optional Parameters</b></p>
 <div class="table-contents"><table class="table" summary="2D_plot Optional Parameters">
 <colgroup>
 <col>
@@ -1199,7 +1199,7 @@
         Here are some examples of correct uses:
       </p>
 <a name="svg_plot.interface.svg_2d_plot_interface.using_fill_and_stroke_colors"></a><h4>
-<a name="id702463"></a>
+<a name="id703643"></a>
         <a href="svg_2d_plot_interface.html#svg_plot.interface.svg_2d_plot_interface.using_fill_and_stroke_colors">Using
         fill and stroke colors</a>
       </h4>
@@ -1230,7 +1230,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_boxplot_interface.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_boxplot_interface.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_boxplot_interface.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -7,7 +7,7 @@
 <link rel="start" href="../../index.html" title="SVG_Plot">
 <link rel="up" href="../interface.html" title=" Public Interfaces">
 <link rel="prev" href="svg_2d_plot_interface.html" title=" svg_2d_plot Public Interface">
-<link rel="next" href="../acknowledgements.html" title=" Acknowledgements">
+<link rel="next" href="../implementation.html" title=" Implementation &amp; Rationale">
 </head>
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 <table cellpadding="2" width="100%"><tr>
@@ -20,14 +20,14 @@
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="svg_2d_plot_interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../acknowledgements.html"><img src="../../../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a>
+<a accesskey="p" href="svg_2d_plot_interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../implementation.html"><img src="../../../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a>
 </div>
 <div class="section" lang="en">
 <div class="titlepage"><div><div><h3 class="title">
 <a name="svg_plot.interface.svg_boxplot_interface"></a> svg_boxplot Public Interface
 </h3></div></div></div>
 <div class="table">
-<a name="id702792"></a><p class="title"><b>Table 18. Boxplot Miscellaneous</b></p>
+<a name="id703972"></a><p class="title"><b>Table 18. Boxplot Miscellaneous</b></p>
 <div class="table-contents"><table class="table" summary="Boxplot Miscellaneous">
 <colgroup>
 <col>
@@ -102,7 +102,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id703086"></a><p class="title"><b>Table 19. Boxplot Commands</b></p>
+<a name="id704266"></a><p class="title"><b>Table 19. Boxplot Commands</b></p>
 <div class="table-contents"><table class="table" summary="Boxplot Commands">
 <colgroup>
 <col>
@@ -190,7 +190,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id703415"></a><p class="title"><b>Table 20. Boxplot Colors</b></p>
+<a name="id704595"></a><p class="title"><b>Table 20. Boxplot Colors</b></p>
 <div class="table-contents"><table class="table" summary="Boxplot Colors">
 <colgroup>
 <col>
@@ -341,7 +341,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id704147"></a><p class="title"><b>Table 21. Boxplot Axis Information</b></p>
+<a name="id705328"></a><p class="title"><b>Table 21. Boxplot Axis Information</b></p>
 <div class="table-contents"><table class="table" summary="Boxplot Axis Information">
 <colgroup>
 <col>
@@ -526,7 +526,7 @@
         (Note: Getters omitted for now - TODO)
       </p>
 <a name="svg_plot.interface.svg_boxplot_interface.the__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method"></a><h5>
-<a name="id705049"></a>
+<a name="id706229"></a>
         <a href="svg_boxplot_interface.html#svg_plot.interface.svg_boxplot_interface.the__code__phrase_role__identifier__plot__phrase__phrase_role__special______phrase___code__method">The
         <code class="computeroutput"><span class="identifier">plot</span><span class="special">()</span></code>
         Method</a>
@@ -537,7 +537,7 @@
         named parameters, as well as a deduced parameter.
       </p>
 <div class="table">
-<a name="id705110"></a><p class="title"><b>Table 22. Required parameter</b></p>
+<a name="id706290"></a><p class="title"><b>Table 22. Required parameter</b></p>
 <div class="table-contents"><table class="table" summary="Required parameter">
 <colgroup>
 <col>
@@ -600,7 +600,7 @@
 </table></div>
 </div>
 <br class="table-break"><div class="table">
-<a name="id705231"></a><p class="title"><b>Table 23. Optional Parameters</b></p>
+<a name="id706411"></a><p class="title"><b>Table 23. Optional Parameters</b></p>
 <div class="table-contents"><table class="table" summary="Optional Parameters">
 <colgroup>
 <col>
@@ -860,21 +860,21 @@
             <p>
               A class or that contains a conversion function. You will not have to
               worry about this, unless you are trying to accomplish stuff like plotting
- a container of a user-defined class that does not have a conversion
- to double. For example:
+ a container of a user-defined class, for example human, that does not
+ have a conversion to double. For example:
 </p>
 <pre class="programlisting">
 <span class="keyword">class</span> <span class="identifier">my_functor</span>
 <span class="special">{</span>
   <span class="identifier">typdef</span> <span class="keyword">double</span> <span class="identifier">result_type</span><span class="special">;</span>
 
- <span class="keyword">double</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">human</span><span class="special">&amp;</span> <span class="identifier">_hum</span><span class="special">)</span> <span class="keyword">const</span>
+ <span class="keyword">double</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">human</span><span class="special">&amp;</span> <span class="identifier">body</span><span class="special">)</span> <span class="keyword">const</span>
   <span class="special">{</span>
- <span class="keyword">return</span> <span class="keyword">double</span><span class="special">(</span><span class="identifier">_hum</span><span class="special">.</span><span class="identifier">age</span><span class="special">());</span>
+ <span class="keyword">return</span> <span class="keyword">double</span><span class="special">(</span><span class="identifier">body</span><span class="special">.</span><span class="identifier">age</span><span class="special">());</span>
   <span class="special">}</span>
 <span class="special">}</span>
 
-<span class="comment">// snip
+<span class="comment">// ...
 </span>
 <span class="identifier">plot</span><span class="special">(</span><span class="identifier">my_data</span><span class="special">,</span> <span class="string">"People"</span><span class="special">,</span> <span class="identifier">functor</span> <span class="special">=</span> <span class="identifier">my_functor</span><span class="special">());</span>
 </pre>
@@ -884,8 +884,8 @@
 <td>
             <p>
               <code class="computeroutput"><span class="identifier">boost_default_convert</span></code>
- (the default) is sufficient in all cases where the data stored in the
- container can be directly cast to a double.
+ (default) is sufficient in all cases where the data stored in the container
+ can be directly cast to a double.
             </p>
             </td>
 </tr>
@@ -896,11 +896,15 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">
-<a accesskey="p" href="svg_2d_plot_interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../acknowledgements.html"><img src="../../../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a>
+<a accesskey="p" href="svg_2d_plot_interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../interface.html"><img src="../../../../../../../../../../trunk/doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../../../../../trunk/doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="../implementation.html"><img src="../../../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a>
 </div>
 </body>
 </html>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_interface.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_interface.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_interface.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -30,7 +30,7 @@
       Public Interface</a>
 </h3></div></div></div>
 <div class="table">
-<a name="id692102"></a><p class="title"><b>Table 3. class svg</b></p>
+<a name="id692282"></a><p class="title"><b>Table 3. class svg</b></p>
 <div class="table-contents"><table class="table" summary="class svg">
 <colgroup>
 <col>
@@ -50,7 +50,7 @@
             </th>
 <th>
             <p>
- Notes
+ Notes &amp; Examples
             </p>
             </th>
 </tr></thead>
@@ -68,13 +68,177 @@
             </td>
 <td>
             <p>
- The default image size is (400, 400).
+ Default image size (pixels) is (400, 400).
             </p>
             </td>
 </tr>
 <tr>
 <td>
             <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">coord_precision</span><span class="special">(</span><span class="keyword">int</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets the precision output for coordinates (decimal digits)
+ </p>
+ </td>
+<td>
+ <p>
+ default 3, but for mobiles, 2 might suffice.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">()</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Constructor
+ </p>
+ </td>
+<td>
+ <p>
+ Default image size (pixels) is (400, 400).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">copyright_holder</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Set copyright holder for the SVG XML document, as comment and XML.
+ </p>
+ </td>
+<td>
+ <p>
+ &lt;!-- SVG Plot Copyright Paul A. Bristow 2007 --&gt; &lt;meta name<code class="literal">"copyright"
+ content</code>"Paul A. Bristow" /&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">copyright_date</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Set copyright date for the SVG XML document, as comment and XML.
+ </p>
+ </td>
+<td>
+ <p>
+ &lt;!-- SVG Plot Copyright Paul A. Bristow 2007 --&gt; &lt;meta name<code class="literal">"date"
+ content</code>"2007" /&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">description</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets description for the SVG XML document, as comment and XML.
+ </p>
+ </td>
+<td>
+ <p>
+ &lt;!-- My Document description --&gt; &lt;desc&gt;My Document description&lt;/desc&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">document_title</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets title for the SVG XML document (not the plot)
+ </p>
+ </td>
+<td>
+ <p>
+ &lt;title&gt;My Document title&lt;/title&gt;
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">license</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Set license terms (if any): reproduction, distribution, attribution,
+ commercialuse
+ </p>
+ </td>
+<td>
+ <p>
+ "permits" (default), "requires", or "prohibits".
+ </p>
+ </td>
+<td>
+ <p>
+ [1is_license(bool)
+ </p>
+ </td>
+<td>
+ <p>
+ Adds a typical permissive Boost-like license.
+ </p>
+ </td>
+<td>
+ <p>
+ permits reproduction &amp; distribution but requires atribution.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">get_g_element</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Class derived from svg_element.
+ </p>
+ </td>
+<td>
+ <p>
+ Graph element: line, circle, rect... Node element of document tree.
+ </p>
+ </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+</tr>
+<tr>
+<td>
+ <p>
               <code class="computeroutput"><span class="identifier">g_element</span><span class="special">&amp;</span>
               <span class="identifier">add_g_element</span><span class="special">()</span></code>
             </p>
@@ -93,6 +257,9 @@
               was just created.
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -116,6 +283,9 @@
               are making this call.
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -136,12 +306,55 @@
               interface to access these elements might be useful.
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">x_size</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets the width of the image (pixels).
+ </p>
+ </td>
+<td>
+ <p>
+ </p>
+ </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">svg</span><span class="special">&amp;</span>
+ <span class="identifier">y_size</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">)</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Sets the height of the image (pixels).
+ </p>
+ </td>
+<td>
+ <p>
+ </p>
+ </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
             <p>
               <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">get_x_size</span><span class="special">()</span></code>
+ <span class="identifier">x_size</span><span class="special">()</span></code>
             </p>
             </td>
 <td>
@@ -153,12 +366,15 @@
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
             <p>
               <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">get_y_size</span><span class="special">()</span></code>
+ <span class="identifier">y_size</span><span class="special">()</span></code>
             </p>
             </td>
 <td>
@@ -170,6 +386,9 @@
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -188,6 +407,9 @@
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -205,6 +427,9 @@
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -217,7 +442,7 @@
             <p>
               Pushes a <code class="computeroutput"><span class="identifier">path_element</span></code>
               to the back of the tree and returns a reference to it. This allows
- you to do the following:
+ chaining, for example:
 </p>
 <pre class="programlisting">
 <span class="identifier">path_element</span><span class="special">&amp;</span> <span class="identifier">my_path</span> <span class="special">=</span> <span class="identifier">image</span><span class="special">.</span><span class="identifier">path</span><span class="special">();</span>
@@ -225,10 +450,12 @@
 <span class="identifier">my_path</span><span class="special">.</span><span class="identifier">M</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="number">3</span><span class="special">).</span><span class="identifier">l</span><span class="special">(</span><span class="number">150</span><span class="special">,</span> <span class="number">150</span><span class="special">);</span>
 </pre>
 <p>
- I'm open to suggestions for how to improve this process.
             </p>
             </td>
 <td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -239,14 +466,17 @@
             </td>
 <td>
             <p>
- Adds a rectangle at point (x1, y1) that has width <code class="computeroutput"><span class="identifier">width</span></code>
- and height <code class="computeroutput"><span class="identifier">height</span></code>
+ Adds a rectangle at point (x1, y1) that has <code class="computeroutput"><span class="identifier">width</span></code>
+ wide and <code class="computeroutput"><span class="identifier">height</span></code> high.
             </p>
             </td>
 <td>
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -257,14 +487,17 @@
             </td>
 <td>
             <p>
- Adds text <code class="computeroutput"><span class="identifier">text</span></code> at (x,y)
- in the root level of the document
+ Adds string <code class="computeroutput"><span class="identifier">text</span></code> at
+ (x,y) in the root level of the document
             </p>
             </td>
 <td>
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -284,6 +517,9 @@
               if it can not open the file.
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 <tr>
 <td>
@@ -301,6 +537,9 @@
             <p>
             </p>
             </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
+<td class="auto-generated"> </td>
 </tr>
 </tbody>
 </table></div>
@@ -309,7 +548,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -36,7 +36,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/1d_defaults.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/1d_defaults.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/1d_defaults.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -31,11 +31,11 @@
       Defaults</a>
 </h3></div></div></div>
 <p>
- You may have noticed that there are certain defaults that are true at the
- beginning of the plotting. Here is a table of the defaults:
+ There are certain defaults, tabulated below, that are true at the beginning
+ of the plotting.
       </p>
 <div class="table">
-<a name="id690092"></a><p class="title"><b>Table 1. Default Values</b></p>
+<a name="id690244"></a><p class="title"><b>Table 1. Default Values</b></p>
 <div class="table-contents"><table class="table" summary="Default Values">
 <colgroup>
 <col>
@@ -99,6 +99,24 @@
 <tr>
 <td>
             <p>
+ Coordinate precision
+ </p>
+ </td>
+<td>
+ <p>
+ 3 decimal digits
+ </p>
+ </td>
+<td>
+ <p>
+ Sufficient 1 in 1000 precision for typical small plots. (Higher precision
+ will increase svg file size).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
               Distance between major X ticks
             </p>
             </td>
@@ -488,7 +506,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/2d_defaults.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/2d_defaults.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/plot_defaults/2d_defaults.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -35,7 +35,7 @@
         beginning of the plotting. Here is a table of the defaults:
       </p>
 <div class="table">
-<a name="id691008"></a><p class="title"><b>Table 2. Default Values</b></p>
+<a name="id691188"></a><p class="title"><b>Table 2. Default Values</b></p>
 <div class="table-contents"><table class="table" summary="Default Values">
 <colgroup>
 <col>
@@ -557,7 +557,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -37,7 +37,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial/svg_boxplot_tutorial_simple.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial/svg_boxplot_tutorial_simple.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_boxplot_tutorial/svg_boxplot_tutorial_simple.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -83,7 +83,7 @@
 <span class="special">}</span>
 </pre>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.image_boxplot_simple_svg"></a><h5>
-<a name="id688242"></a>
+<a name="id688405"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.image_boxplot_simple_svg">Image
         boxplot_simple.svg</a>
       </h5>
@@ -91,7 +91,7 @@
         <span class="inlinemediaobject"><img src="../../images/boxplot_simple.png" alt="boxplot_simple"></span>
       </p>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.basic_example_breakdown"></a><h5>
-<a name="id688290"></a>
+<a name="id688452"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.basic_example_breakdown">Basic
         Example Breakdown</a>
       </h5>
@@ -99,7 +99,7 @@
         Let's examine what this does.
       </p>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.initializing_a_new_boxplot"></a><h5>
-<a name="id688321"></a>
+<a name="id688484"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.initializing_a_new_boxplot">Initializing
         a new boxplot</a>
       </h5>
@@ -108,7 +108,7 @@
         svg_boxplot my_plot;
       </p>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_a_color"></a><h5>
-<a name="id688355"></a>
+<a name="id688518"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_a_color">Setting
         a color</a>
       </h5>
@@ -120,7 +120,7 @@
 <span class="identifier">my_plot</span><span class="special">.</span><span class="identifier">background_border_color</span><span class="special">(</span><span class="identifier">black</span><span class="special">);</span>
 </pre>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_strings_in_the_plot"></a><h5>
-<a name="id688428"></a>
+<a name="id688591"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_strings_in_the_plot">Setting
         strings in the plot</a>
       </h5>
@@ -135,7 +135,7 @@
       <span class="special">.</span><span class="identifier">y_label</span><span class="special">(</span><span class="string">"Population Size"</span><span class="special">);</span>
 </pre>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_axis_information"></a><h4>
-<a name="id688557"></a>
+<a name="id688720"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.setting_axis_information">Setting
         axis information</a>
       </h4>
@@ -151,7 +151,7 @@
         .y_major_interval(20);
       </p>
 <a name="svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.writing_to_a_file"></a><h5>
-<a name="id688596"></a>
+<a name="id688763"></a>
         <a href="svg_boxplot_tutorial_simple.html#svg_plot.svg_boxplot_tutorial.svg_boxplot_tutorial_simple.writing_to_a_file">Writing
         to a file</a>
       </h5>
@@ -167,7 +167,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/todo.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/todo.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/todo.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -90,7 +90,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -39,7 +39,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_simple_code_example.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_simple_code_example.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_simple_code_example.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -65,7 +65,7 @@
 <span class="special">}</span>
 </pre>
 <a name="svg_plot.tutorial_2d_code_simple.2d_simple_code_example.resulting_simple_2d_example_image"></a><h5>
-<a name="id683557"></a>
+<a name="id683728"></a>
         <a href="2d_simple_code_example.html#svg_plot.tutorial_2d_code_simple.2d_simple_code_example.resulting_simple_2d_example_image">Resulting
         Simple_2D Example Image</a>
       </h5>
@@ -73,7 +73,7 @@
         <span class="inlinemediaobject"><img src="../../images/2d_simple.png" alt="2d_simple"></span>
       </p>
 <a name="svg_plot.tutorial_2d_code_simple.2d_simple_code_example.simple_2d_example_breakdown"></a><h5>
-<a name="id683604"></a>
+<a name="id683775"></a>
         <a href="2d_simple_code_example.html#svg_plot.tutorial_2d_code_simple.2d_simple_code_example.simple_2d_example_breakdown">Simple_2D
         Example Breakdown</a>
       </h5>
@@ -142,7 +142,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_special.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_special.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/2d_special.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -31,7 +31,7 @@
       2D Special Features</a>
 </h3></div></div></div>
 <a name="svg_plot.tutorial_2d_code_simple.2d_special.y_axis_grid_lines"></a><h5>
-<a name="id686272"></a>
+<a name="id686443"></a>
         <a href="2d_special.html#svg_plot.tutorial_2d_code_simple.2d_special.y_axis_grid_lines">Y-Axis
         Grid Lines</a>
       </h5>
@@ -71,7 +71,7 @@
 </span> <span class="special">.</span><span class="identifier">y_minor_grid_color</span><span class="special">(</span><span class="identifier">azure</span><span class="special">);</span> <span class="comment">// lighter color for minor grid.
 </span></pre>
 <a name="svg_plot.tutorial_2d_code_simple.2d_special.external_y_axis_style"></a><h5>
-<a name="id686650"></a>
+<a name="id686821"></a>
         <a href="2d_special.html#svg_plot.tutorial_2d_code_simple.2d_special.external_y_axis_style">External
         Y Axis Style</a>
       </h5>
@@ -86,19 +86,13 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../../../../trunk/doc/html/images/important.png"></td>
 <th align="left">Important</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- If the axis is turned off, <code class="computeroutput"><span class="identifier">y_external_style_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code> will not turn the axis back on. To do
- that, you must call <code class="computeroutput"><span class="identifier">axis_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ If the axis is turned off, <code class="computeroutput"><span class="identifier">y_external_style_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
+ will not turn the axis back on. To do that, you must call <code class="computeroutput"><span class="identifier">axis_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
+ </p></td></tr>
 </table></div>
 <a name="svg_plot.tutorial_2d_code_simple.2d_special.fill_the_area_between_the_plot_and_the_axis"></a><h5>
-<a name="id686788"></a>
+<a name="id686955"></a>
         <a href="2d_special.html#svg_plot.tutorial_2d_code_simple.2d_special.fill_the_area_between_the_plot_and_the_axis">Fill
         the area between the plot and the axis</a>
       </h5>
@@ -118,7 +112,7 @@
         <span class="inlinemediaobject"><img src="../../images/2d_area_fill.png" alt="2d_area_fill"></span>
       </p>
 <a name="svg_plot.tutorial_2d_code_simple.2d_special.curve_interpolation"></a><h5>
-<a name="id686993"></a>
+<a name="id687160"></a>
         <a href="2d_special.html#svg_plot.tutorial_2d_code_simple.2d_special.curve_interpolation">Curve
         Interpolation</a>
       </h5>
@@ -141,25 +135,23 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../../../../trunk/doc/html/images/warning.png"></td>
 <th align="left">Warning</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- The <code class="computeroutput"><span class="identifier">_bezier_curve</span></code> feature
- still displays undesired behavior in extreme circumstances. Do not use
- this feature with curves that have a numeric_limit value (<code class="computeroutput"><span class="special">-</span><span class="identifier">NaN</span></code>,
- for example), or with data that has high irregularity in X-Axis spacing
- (for example, a clump of points between (0, 1) on the X axis, with the
- next one at 100 on the X axis.)
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ The <code class="computeroutput"><span class="identifier">_bezier_curve</span></code> feature
+ still displays undesired behavior in extreme circumstances. Do not use
+ this feature with curves that have a numeric_limit value (<code class="computeroutput"><span class="special">-</span><span class="identifier">NaN</span></code>,
+ for example), or with data that has high irregularity in X-Axis spacing
+ (for example, a clump of points between (0, 1) on the X axis, with the
+ next one at 100 on the X axis.)
+ </p></td></tr>
 </table></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/full_2d_layout.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/full_2d_layout.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_2d_code_simple/full_2d_layout.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -133,7 +133,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -38,7 +38,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/1d_special.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/1d_special.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/1d_special.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -31,7 +31,7 @@
       1D Special Features</a>
 </h3></div></div></div>
 <a name="svg_plot.tutorial_code_1d_simple.1d_special.x_axis_grid_lines"></a><h5>
-<a name="id682313"></a>
+<a name="id682487"></a>
         <a href="1d_special.html#svg_plot.tutorial_code_1d_simple.1d_special.x_axis_grid_lines">X-Axis
         Grid Lines</a>
       </h5>
@@ -57,7 +57,7 @@
         <span class="inlinemediaobject"><img src="../../images/1d_x_grid.png" alt="1d_x_grid"></span>
       </p>
 <a name="svg_plot.tutorial_code_1d_simple.1d_special.x_axis_external_style"></a><h5>
-<a name="id682535"></a>
+<a name="id682709"></a>
         <a href="1d_special.html#svg_plot.tutorial_code_1d_simple.1d_special.x_axis_external_style">X-Axis
         External Style</a>
       </h5>
@@ -81,21 +81,19 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../../../../trunk/doc/html/images/important.png"></td>
 <th align="left">Important</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- If the axis is turned off, <code class="computeroutput"><span class="identifier">x_external_style_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code> will not turn the axis back on. To do
- that, you must call <code class="computeroutput"><span class="identifier">axis_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ If the axis is turned off, <code class="computeroutput"><span class="identifier">x_external_style_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
+ will not turn the axis back on. To do that, you must call <code class="computeroutput"><span class="identifier">axis_on</span><span class="special">(</span><span class="keyword">true</span><span class="special">)</span></code>
+ </p></td></tr>
 </table></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/full_1d_layout.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/full_1d_layout.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/full_1d_layout.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -134,7 +134,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/tutorial_code_1d_example.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/tutorial_code_1d_example.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_code_1d_simple/tutorial_code_1d_example.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -66,7 +66,7 @@
         <span class="inlinemediaobject"><img src="../../images/1d_simple.png" alt="1d_simple"></span>
       </p>
 <a name="svg_plot.tutorial_code_1d_simple.tutorial_code_1d_example.a_note_on_syntax"></a><h5>
-<a name="id679420"></a>
+<a name="id679578"></a>
         <a href="tutorial_code_1d_example.html#svg_plot.tutorial_code_1d_simple.tutorial_code_1d_example.a_note_on_syntax">A
         Note On Syntax</a>
       </h5>
@@ -83,7 +83,7 @@
 </span></pre>
 <p>
         Within all of the plot classes, 'chaining' works the same way. Equivalent
- code for the example is as follows:
+ tradional code for the example is as follows:
       </p>
 <pre class="programlisting">
 <span class="identifier">my_plot</span><span class="special">.</span><span class="identifier">title</span><span class="special">(</span><span class="string">"Race Times"</span><span class="special">);</span>
@@ -91,17 +91,17 @@
 <span class="identifier">my_plot</span><span class="special">.</span><span class="identifier">x_range</span><span class="special">(-</span><span class="number">1</span><span class="special">,</span> <span class="number">11</span><span class="special">);</span>
 </pre>
 <p>
- Chaining allows you to group related settings together, and avoids relying
- on the order of arguments in ordinary function calls that would clearly become
- impracticable with dozens of arguments required to set all the myriad of
- plot options.
+ Chaining allows you to avoid repeatedly typing <code class="computeroutput"><span class="identifier">myplot</span><span class="special">.</span></code> and to easily group related settings like
+ plot window, axes, ... together, and avoids relying on the order of arguments
+ in ordinary function calls. Order would clearly become impracticable with
+ dozens of arguments required to set all the myriad plot options.
       </p>
 <p>
         In the long run, I think you will find that chaining helps organize your
         code to read more clearly!
       </p>
 <a name="svg_plot.tutorial_code_1d_simple.tutorial_code_1d_example.simple_1d_example_breakdown"></a><h5>
-<a name="id679813"></a>
+<a name="id679988"></a>
         <a href="tutorial_code_1d_example.html#svg_plot.tutorial_code_1d_simple.tutorial_code_1d_example.simple_1d_example_breakdown">Simple
         1D Example Breakdown</a>
       </h5>
@@ -163,7 +163,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_stylesheet.html
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_stylesheet.html (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial_stylesheet.html 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -47,7 +47,7 @@
       </li>
 </ul></div>
 <a name="svg_plot.tutorial_stylesheet.using_the_stylesheet"></a><h5>
-<a name="id688849"></a>
+<a name="id689017"></a>
       <a href="tutorial_stylesheet.html#svg_plot.tutorial_stylesheet.using_the_stylesheet">Using the
       stylesheet</a>
     </h5>
@@ -65,19 +65,13 @@
 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../../../trunk/doc/html/images/caution.png"></td>
 <th align="left">Caution</th>
 </tr>
-<tr><td align="left" valign="top">
-<p>
- </p>
-<p>
- When the user will have the option to convert the graph to another image
- format, the stylesheets will be ignored. These would provide the user with
- an even more complex function object that they would need to implement.
- If you provide a stylesheet, make sure you know what will not be converted.
- (Currently, that is everything in the stylesheets.)
- </p>
-<p>
- </p>
-</td></tr>
+<tr><td align="left" valign="top"><p>
+ When the user will have the option to convert the graph to another image
+ format, the stylesheets will be ignored. These would provide the user with
+ an even more complex function object that they would need to implement. If
+ you provide a stylesheet, make sure you know what will not be converted.
+ (Currently, that is everything in the stylesheets.)
+ </p></td></tr>
 </table></div>
 <p>
       <span class="inlinemediaobject"><img src="../images/1d_simple_style.png" alt="1d_simple_style"></span>
@@ -85,7 +79,11 @@
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>
-<td align="right"><small>Copyright © 2007 Jake Voytko</small></td>
+<td align="right"><div class="copyright-footer">Copyright © 2007 Jake Voytko<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
 </tr></table>
 <hr>
 <div class="spirit-nav">

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -36,14 +36,15 @@
 above.]
 [tip These blocks contain information that you may find helpful while coding.]
 [important These contain information that is imperative to understanding a
-concept. Failure to follow these blocks will likely result in undesired behavior.
+concept.
+Failure to follow suggestions in these blocks will probably result in undesired behavior.
 Read all of these you find.]
 [warning It is imperative that you follow these. Failure to do so will lead to
-incorrect, and likely undesired, results in the plot]
+incorrect, and likely undesired, results in the plot.]
 
 And the first admonishment I will use is as follows:
 
-[important This is not currently a Boost library. It is a
+[important This is not (yet) a Boost library. It is a
 [@http://code.google.com/soc/2007/boost/about.html GSoC project]
 whose mentor organization is Boost.]
 
@@ -65,7 +66,10 @@
 [@http://www.w3.org/TR/REC-xml/#sec-comments XML specification]
 and file format for describing two-dimensional vector graphics.
 
-SVG files (.svg) can be viewed with a browser like Mozilla Firefox (newer version), Adobe Acrobat Reader, many other graphics program, and by Microsoft Internet Explorer, provided a suitable
+SVG files (.svg) can be viewed with a browser like Mozilla Firefox (newer version),
+[@http://www.adobe.com/products/acrobat/readstep2.htmlAdobe Acrobat Reader],
+many other graphics program, and by Microsoft Internet Explorer,
+provided a suitable
 [@http://www.adobe.com/svg/ Adobe SVG Veiwer plug-in for SVG files] is installed.
 
 The goals of the project are:
@@ -130,7 +134,9 @@
 `svg_color_constant` is simply an enumerated list.
 
 The constants are defined at
-[@..\..\..\..\visualization\boost\svg_plot\svg_color.hpp svg_color.hpp].
+[@../../../../boost/svg_plot/svg_color.hpp svg_color.hpp].
+
+Examples of colors are at [@../../../svg_plot/example/svg_colors.cpp svg_colors.cpp].
 
 The
 [@http://www.w3.org/TR/SVG/types.html#ColorKeywords colors are defined by the SVG standard here].
@@ -153,12 +159,14 @@
   
 [note `svg_color` has a constructor for `svg_color_constant`, so you can use
 a `svg_color_constant` in place of a `svg_color` and it will be implicitly
-converted. However, there is not currently an
+converted. However, there is *not* currently an
 `svg_color::operator=(svg_color_constant)` overload, so
 ``
 svg_color my_color = red;
 ``
-does not work.]
+does not have the desired effect, and nor does
+`cout << red << endl;`
+output the expected RGB(255,0,0) but instead 119 the value of the enum!]
 
 [h4 `svg_color` interface]
 
@@ -197,7 +205,8 @@
 
 All color information is stored in RGB format as three 'unsigned char' in a `svg_color` struct.
 The rationale for storing information in RGB format is because it is precise,
-and is always representable the exact same way. Storing a floating-point percentage
+and is always representable the exact same way.
+Storing a floating-point percent or fraction
 would introduce the possibility of undesirable rounding error.
 
 [endsect] [/section:color Color]
@@ -246,14 +255,18 @@
 
   std::cout << a + b + c + d << std::endl; // prints 12
 
-Within all of the plot classes, 'chaining' works the same way. Equivalent
-code for the example is as follows:
+Within all of the plot classes, 'chaining' works the same way.
+Equivalent tradional code for the example is as follows:
 
   my_plot.title("Race Times");
   my_plot.legend_on(true);
   my_plot.x_range(-1, 11);
   
-Chaining allows you to group related settings together, and avoids relying on the order of arguments in ordinary function calls that would clearly become impracticable with dozens of arguments required to set all the myriad of plot options.
+Chaining allows you to avoid repeatedly typing `myplot.`
+and to easily group related settings like plot window, axes, ... together,
+and avoids relying on the order of arguments in ordinary function calls.
+Order would clearly become impracticable with dozens of arguments required
+to set all the myriad plot options.
 
 In the long run, I think you will find that chaining helps organize your code
 to read more clearly!
@@ -414,6 +427,8 @@
 
 [h4 X-Axis External Style]
 
+TODO this has ben changed to x_up_ticks and x_down_ticks and y_left_ticks and y_right_ticks.
+
 By default the 'ticks' face into the plot area.
 Alternatively, you can use an 'external' style,
 so that the ticks face out from the X- and/or Y-axes.
@@ -852,7 +867,7 @@
 Here is an example of numeric limits handling in action:
 
 [$images/2d_limit.png] [\TODO this file is missing!]
-[endsect][/section:numerical_limits]
+[endsect] [/section:numerical_limits]
 
 [section:behavior_stylesheets Stylesheets]
 Stylesheets currently have only a single way of being used with the program: they are parsed by the `svg` class, and if the stylesheet parses correctly, they are loaded directly into the SVG file. I recognize that it may also be desired to link to an external stylesheet, but this presents a few problems.
@@ -903,19 +918,20 @@
 None of the power of CSS is compromised (I believe), but it becomes more verbose.
 ] [/caution]
 
-[endsect][/section:behavior_stylesheets]
-[endsect][/section:behavior Behavior]
+[endsect] [/section:behavior_stylesheets]
+[endsect] [/section:behavior Behavior]
 
 [section:plot_defaults Plot Defaults]
 
 [section:1d_defaults `svg_1d_plot` Defaults]
-You may have noticed that there are certain defaults that are true at the
-beginning of the plotting. Here is a table of the defaults:
+There are certain defaults, tabulated below, that are true at the beginning of the plotting.
 
 [table Default Values
   [[object] [Default value] [Rationale]]
   [[All colors not defined in this table] [black] [Coloring, if any, will be highly dependent on user needs.]]
   [[Axis] [On, internal style] [Most graphs include an axis of some kind. The internal axis style is used because this seems to be the default behavior in many textbooks I have owned.]]
+ [[Coordinate precision] [3 decimal digits] [Sufficient 1 in 1000 precision for typical small plots. (Higher precision will increase svg file size).]]
+
   [[Distance between major X ticks] [`3 units`] [Reasonably fits into a plot window.]]
   [[Font size of the legend title] [12] [Reasonable when paired with the image size.]]
   [[Font size of the X Label] [12] [Reasonable when paired with the image size.]]
@@ -986,28 +1002,43 @@
 [section:interface Public Interfaces]
 [section:svg_interface `svg` Public Interface]
 [table class svg
- [[Signature] [Description] [Notes]]
- [[`svg()`] [Constructor] [The default image size is (400, 400).]]
+ [[Signature] [Description] [Notes & Examples]]
+ [[`svg()`] [Constructor] [Default image size (pixels) is (400, 400).]]
+
+ [[`svg& coord_precision(int)`] [Sets the precision output for coordinates (decimal digits)][default 3, but for mobiles, 2 might suffice.]]
+ [[`svg()`] [Constructor] [Default image size (pixels) is (400, 400).]]
+ [[`svg& copyright_holder(const std::string)`] [Set copyright holder for the SVG XML document, as comment and XML.][<!-- SVG Plot Copyright Paul A. Bristow 2007 -->
+<meta name="copyright" content="Paul A. Bristow" />]]
+ [[`svg& copyright_date(const std::string)`] [Set copyright date for the SVG XML document, as comment and XML.][<!-- SVG Plot Copyright Paul A. Bristow 2007 -->
+<meta name="date" content="2007" />]]
+ [[`svg& description(const std::string)`] [Sets description for the SVG XML document, as comment and XML.][<!-- My Document description --> <desc>My Document description</desc>]]
+ [[`svg& document_title(const std::string)`] [Sets title for the SVG XML document (not the plot)][<title>My Document title</title>]]
+ [[`svg& license(const std::string, const std::string, const std::string, const std::string)`][Set license terms (if any): reproduction, distribution, attribution, commercialuse]["permits" (default), "requires", or "prohibits".]
+ [[1is_license(bool)][Adds a typical permissive Boost-like license.][permits reproduction & distribution but requires atribution.]]
+ [[`get_g_element`] [Class derived from svg_element.] [Graph element: line, circle, rect... Node element of document tree.]]
   [[`g_element& add_g_element()`] [Adds a g_element at the root of the document tree. Acts as a `push_back()`] [Returns the `g_element` that is pushed back. This allows you to do something like the following: `image.add_g_element().line(/**/).line(/**/).rect(/**/); `
   which adds two lines and a rectangle to the g_element that was just created.]]
   [[`svg& circle(double x, double y, unsigned int radius = 5)`] [Adds a point at (x,y) in the root level of the document][If the user is calling the circle method, odds are they would prefer a real circle instead of a degenerate circle (a point). 5 is as good a default as any other, and the user is unlikely want a point if they are making this call.]]
   [[`g_element& get_g_element(int)`] [Gets the g_element at the index specified.] [Gives a runtime error if you specify an index that does not contain a `g_element`. An iterator interface to access these elements might be useful.]]
- [[`unsigned int get_x_size()`] [Returns the width of the image (pixels).] []]
- [[`unsigned int get_y_size()`] [Returns the height of the image (pixels).] []]
+ [[`svg& x_size(unsigned int)`] [Sets the width of the image (pixels).] []]
+ [[`svg& y_size(unsigned int)`] [Sets the height of the image (pixels).] []]
+ [[`unsigned int x_size()`] [Returns the width of the image (pixels).] []]
+ [[`unsigned int y_size()`] [Returns the height of the image (pixels).] []]
   [[`svg& image_size(unsigned int, unsigned int)`] [Sets the size of the image produced,
   (pixels).][]]
   [[`svg& line(double x1, double y1, double x2, double y2)`] [Adds a line from (x1,y1) to (x2,y2) in the root level of the document.][]]
- [[`path_element& path()`] [Pushes a `path_element` to the back of the tree and returns a reference to it. This allows you to do the following:
+ [[`path_element& path()`]
+ [Pushes a `path_element` to the back of the tree and returns a reference to it.
+ This allows chaining, for example:
 ``
 path_element& my_path = image.path();
 
 my_path.M(3, 3).l(150, 150);
 ``
-I'm open to suggestions for how to improve this process.
 ]]
   [[`svg& rect(double x1, double y1,
- double width, double height)`] [Adds a rectangle at point (x1, y1) that has width `width` and height `height`][]]
- [[`svg& text(double x, double y, std::string text)`] [Adds text `text` at (x,y) in the root level of the document][]]
+ double width, double height)`] [Adds a rectangle at point (x1, y1) that has `width` wide and `height` high.][]]
+ [[`svg& text(double x, double y, std::string text)`] [Adds string `text` at (x,y) in the root level of the document][]]
   [[`svg& write(const std::string&)`] [Writes the document to the file represented by the argument.][Opens the file stream itself and tries to call `write(std::ostream&)`. Throws `std::runtime_exception` if it can not open the file.]]
   [[`svg& write(std::ostream&)`] [Writes the document to the stream represented by the argument.][]]
 ]
@@ -1018,6 +1049,11 @@
   [[Signature] [Description]]
   [[`svg_1d_plot()`] [See the defaults section for further details]]
   [[`svg_1d_plot& image_size(unsigned int, unsigned int)`] [Sets the size of the image produced (pixels)]]
+ [[`svg_1d_plot& coord_precision(int)`] [Sets the precision output for coordinates (decimal digits, default 3).]]
+ [[`svg_1d_plot& document_title(std::string)`] [Sets title for the SVG XML document (not the plot). <title>My Document title</title>]]
+ [[`svg_1d_plot& description(std::string)`] [Sets description for the SVG XML document, as comment and XML, for example: <!-- My Document description -->
+<desc>My Document description</desc>]]
+
   [[`svg_1d_plot& legend_title_font_size(unsigned int)`] [Sets the font size for the legend title.]]
   [[`svg_1d_plot& title(const std::string&)`] [Sets the string to be used for the title.]]
   [[`svg_1d_plot& title_font_size(unsigned int)`] [Sets the font size for the title.]]
@@ -1330,25 +1366,322 @@
 [[ext_outlier_style] [`const plot_point_style&`] [Styles outliers more than 3 IQRs away from the box.] [`plot_point_style(white, black, 1)`]]
 [[whisker_length] [unsigned int] [Determines how long the whiskers at the end of the data range line will be] [30]]
 [[box_width] [unsigned int] [Determines the width of the box.] [60]]
-[[functor] [*] [A class or that contains a conversion function. You will not have to worry about this, unless you are trying to accomplish stuff like plotting a container of a user-defined class that does not have a conversion to double. For example:
+
+[[functor] [*] [A class or that contains a conversion function. You will not have to worry about this, unless you are trying to accomplish stuff like plotting a container of a user-defined class, for example human, that does not have a conversion to double. For example:
 ``
 class my_functor
 {
   typdef double result_type;
 
- double operator()(const human& _hum) const
+ double operator()(const human& body) const
   {
- return double(_hum.age());
+ return double(body.age());
   }
 }
 
-// snip
+// ...
 
 plot(my_data, "People", functor = my_functor());
-``
-][`boost_default_convert` (the default) is sufficient in all cases where the data stored in the container can be directly cast to a double.]]]
-[endsect][/section:svg_2d_plot_interface]
-[endsect][/section:interface]
+``]
+[`boost_default_convert` (default) is sufficient in all cases where the data stored in the container can be directly cast to a double.]]
+] [/ table Required parameter]
+[endsect] [/section:svg_2d_plot_interface]
+[endsect] [/section:interface]
+
+[section:implementation Implementation & Rationale]
+
+This section provide more information about this implementation
+and some of the rationale for desing decisions.
+
+[h4 SVG Specification]
+
+[@http://www.w3.org/TR/SVG/ SVG version 1.1]
+was used in the design of this version but
+[@http://www.w3.org/TR/SVG12/ SVG 1.2 draft specification]
+is also available and appears to be final and designed to be backward compatible.
+No changes that affect the code produced
+have been detected from a quick perusal of this document.
+It is probable but untested that the svg files produced will also comply
+with the [@http://www.w3.org/TR/SVGMobile12/ Tiny svg for mobiles specification].
+
+[h4 Design]
+
+SVG would be a flat format if it weren't for
+the <g> elements: these make it parse into a tree.
+
+If each element has its own style (fill, stroke etc)
+then the .svg file size would be increased.
+(This style is used by other packages that output svg).
+
+So the [@http://www.w3.org/TR/SVG/struct.html#GElement group element]
+is used with each type given an id to allow reference back to it.
+
+svg_style_details.hpp contains a list of these groups,
+for example: PLOT_X_AXIS, PLOT_TITLE... indexing an array of string
+document id "yAxis", "title"...
+
+and these can be seen, with style information in the output, for example:
+
+ <g id="yAxis" stroke="rgb(0,0,0)"></g>
+
+ <g id="title">
+ <text x="250" y="20" text-anchor=" middle" font-size="20">Demo 1D plot</text></g>
+
+In the general case, the most that occurs grouped together is the
+style information: axis lines all share the same style information,
+points in a series all share the same color information, and this is
+also a logical grouping. One can can add a series, and then come back later
+and change the <g> element above the points, which is a single change,
+and have the change reflected on every point in the series. It seems
+this is the most logical way to represent the data in memory.
+
+
+
+
+
+[h4 Economising on .svg File Size]
+
+Some of the factors affecting the file size are:
+
+# Excessive precision of data points.
+
+If plots are to be viewed only at a modest size,
+then the precision of x and y coordinates
+does not need to be higher than about 1 in 1000,
+so a precision of about 3 decimal digits will suffice.
+
+A default of 3 decimal digits has been chosen,
+but the precision can be controlled to permit a higher resolution,
+for example on a map that is printed at 2000 dpi.
+or even only 2 decimal digits for a display on a mobile,
+where file transfer speed may make reducing file size important.
+
+# Excessive data points.
+When plotting functions, it is sensible to avoid using more data points
+than are justified by the resolution. Again 1 in 1000 is a typical number,
+and by using bezier curve fitting, as few as 100 points should be sufficient
+to produce a visibly perfectly smooth curve for 'well-behaved' functions.
+
+Plotting extremely large datasets from files may cause memory overflow,
+as with any STL container held in memory.
+It may be necessary to perform some averaging or smoothing,
+or just using a 'stride' to select, for example, every 100th value
+to be plotted.
+
+# Redundant style specifications.
+
+The use of the g or group element has been used to try to reduce
+repeated (and thus redundant) style specifications.
+More efficient use of groups may be possible.
+
+# Not using default style and attributes where possible.
+
+Some effort has been made to use defaults, but more may be possible.
+
+[h4 Adding document information to the svg Image files]
+
+Several ways of adding useful information to the svg document are provided.
+If the strings are null (the default) nothing is output.
+
+Member function svg& description(const std::string) allows output like:
+
+ <desc>My Document description</desc>
+
+ svg& document_title(const std::string)
+
+ <title>My Document title</title>
+
+(Note that this is *not* the same as the title of the plot.)
+
+
+[h4 Adding Copyright and License conditions for the SVG Image files]
+
+In general, setting values for items like copyright_holder will ensure that
+they appear in the SVG document both as XML and as XML comment.
+If none are set, nothing will be output, to minimize file size.
+
+[@http://www.w3.org/TR/2004/WD-SVG12-20041027/nonvisual.html www.w3.org/TR/2004/WD-SVG12-20041027]
+discusses primary documents, of type .svg in section 17.3
+Adding Copyright information to an SVG document:
+SVG encourages the use of a common metadata format for inclusion of copyright information.
+Metadata relevant to the data copyright of the entire document
+should be added to metadata element of the topmost svg element.
+This allows the author to unambiguously state the licensing terms for the entire document.
+The scheme may also be used elsewhere in the document,
+for pieces that have different licensing. For example,
+an SVG font may have specific licensing details expressed in its own metadata element.
+
+Note that inclusion of this metadata does not provide the author with a method
+in which to protect or enforce their copyright,
+it simply bundles the copyright information with the content in a defined manner.
+Providing methods, technical or non-technical, for data protection
+is currently beyond the scope of the SVG specification.
+
+This does not exclude the use of other metadata schemes.
+
+A simple way of adding metadata for copyright is provided by functions to set
+
+ copyright_holder(std::string);
+ copyright_date(std::string);
+
+(as well as description and document_title, and .svg filename if any).
+
+For example, setting these will incorporate an XML comment
+
+ <!-- SVG Plot Copyright Paul A. Bristow 2007 -->
+
+and also as meta data:
+
+ <meta name="copyright" content="Paul A. Bristow" />
+ <meta name="date" content="2007" />
+
+The Creative Commons Metadata Set is also provided as an option in this implementation,
+following [@http://www.ibm.com/developerworks/xml/library/x-think18.html this example.]
+
+The [@http://creativecommons.org/about/licenses Creative Commons License] is one method
+of providing license terms in a machine-readable format.
+
+Typical data added to the file would be XML like this:
+
+ <metadata>
+ <rdf:RDF xmlns:cc="http://web.resource.org/cc/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <cc:work rdf:about="filename.svg">
+ <!-- insert filename or title here -->
+ <dc:title>Plot title</dc:title>
+ <dc:creator>Boost.Plot</dc:creator>
+ <dc:author>Paul A. Bristow</dc:author>
+ <dc:format>application/xhtml+xml+svg</dc:format>
+ <cc:license rdf:about="http://creativecommons.org/licenses/by-sa/.0/">
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/CommercialUse"/>
+ </cc:license>
+ </cc:work>
+ </rdf:RDF>
+ </metadata>
+
+cc:permits can also be cc:requires or cc:prohibits, as required.
+
+A license that permits reproduction, distribution and commercial use,
+but requires both notice & attribution
+is probably most suitable for Boost documents as is therefore chosen as the default.
+
+This license can be included by calling svg member function is_license(true).
+
+[@http://web.resource.org/rss/1.0/modules/cc/ RDF] is the metadata format chosen by
+[@http://creativecommons.org Creative Commons].
+
+and references the resource (cc) at
+[@http://web.resource.org/cc/] using the definition of its XML namespace:
+
+ rdf:RDF xmlns:cc="http://web.resource.org/cc/"
+
+Options are [@http://web.resource.org/rss/1.0/modules/cc/ summarized].
+
+A way of seting the author is also provided, in case the copyright has been assigned to someone else,
+for example a publisher. svg set and get member functions:
+
+ author(const std::string);
+ const std::string author();
+
+[h4 Using Unicode Symbols (usually Math Sumbols and Greek letters)]
+
+Unicode symbols that work on most browsers in html are listed at:
+
+[@boost\math_toolkit\libs\math\doc\sf_and_dist\html4_symbols.qbk html4_symbols],
+[@http://www.htmlhelp.com/reference/html40/entities/symbols.html reference/html40/entities/symbols],
+and [@http://www.alanwood.net/demos/ent4_frame.html demos].
+
+However support for Unicode in SVG is much less fully implemented and displayed results are variable.
+
+The Unicode value in decimal 9830 or hex x2666 must be prefixed with `& `and terminated with `;`
+for example, `&x2666`; for xml
+and then enveloped with "" to convert to a const std::string, for example: "&#x2666;" for diamond.
+
+Thus diamond can be used a point marker.
+
+Similarly for greek in title, legend and axes:
+
+ .legend_title("My Legend &#956;") // generates <em>&#956;</em> greek mu
+
+
+[h4 Subscript and superscript in title, legend and labels]
+
+It is very common need to show superscript, in units for example, area (m[super 2]),
+and subscript for a[sub 0, a[sub 2]...
+
+Sadly, although these needs are both OK with html,
+showing sub and superscripts in svg doesn't work well as yet
+because browsers don't handle <sub> or <sup>, nor baseline-shift.
+
+The only reasonably widely supported feature is
+Unicode symbols for superscript 1, 2 and 3 (only).
+For example, Latin1_symbols: sup1 &185; sup2 &178; sup3 &179; work on Firefox & IE6/7.
+
+But&#2071; &#2075; &#2090; - show just square boxes.
+
+The SVG specification covers <sub, <super>, and the general baseline-shift,
+but these are just not implemented yet.
+
+[@http://unicode.org/reports/tr25/#_Toc28 2.8 Superscripts and Subscripts]
+[@http://www.unicode.org/charts/symbols.html symbols]
+
+At Nov 2007, the following commands don't have very useful coverage.
+<tspan baseline-shift = \"50%\" font-stretch = \"wider\" font-variant = \"small-caps\" > 3 </tspan>
+baseline-shift = \"50%\" & super and subscript down't work on Firefox 2.
+but DO on IE6 (and probably 7)
+font-stretch = \"wider\" No effect Firefox or IE6.
+font-variant = \"small-caps\" No effect Firefox or IE6.
+<tspan baseline-shift = \"50%\" >3/4 </tspan>
+
+This has been reported as a bug to Mozilla,
+and is regarded a duplicate of other reports on sub and super
+https://bugzilla.mozilla.org/show_bug.cgi?id=401102
+
+but baseline-shift has no effect on Firefox 2. See
+http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=7410&view=previous
+
+The use of <tspan to shift characters *is* feasible, as shown
+[@http://www.w3.org/TR/SVG/images/text/tspan02.svg in this example],
+which displays correctly in all browsers,
+
+and it is also possible to use
+
+ <svg:g transform="translate(5.062500, -5.367188)">
+
+to shift the next letter up, but these parameters are font-size related,*
+and the svg most verbose.
+
+None of these method provides a *convenient* method of creating the right string
+for titles, legends, or axis labels, but it may be possible to devise code that does.
+
+[h4 Coding style]
+
+In general [@http://www.boost.org/libs/spirit/doc/style_guide.html Boost coding style guide]
+and [@http://groups.yahoo.com/group/boost/files/coding_guidelines.html Boost coding guidelines]
+has been used.
+
+But some work is needed to rename arguments named with lading underscores in violation of
+guidance 2.14:
+
+Names containing double underscores (``__'') or beginning with single underscores (``_'')
+are entirely forbidden. These are reserved to the C++ implementation in various contexts.
+
+and also
+
+2.10. Data members should have a ``m_'' prefix, to distinguish them
+from an otherwise-identical member function name
+and to clarify their provenance in code which uses them.
+Non-member names must not have an ``m_'' prefix.
+
+Some data members end with _ to avoid name clashes, another widely used convention.
+
+[endsect] [/section:implementation Implementation & Rationale]
+
 
 [section:acknowledgements Acknowledgements]
 I would like to thank the following people:

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_full_layout.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,17 +1,23 @@
 // 1d_full_layout.cpp
-// Copyright (C) Jacob Voytko 2007
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-// -----------------------------------------------------------------
+
+// Copyright Jacob Voytko 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
 #include <boost/svg_plot/svg_1d_plot.hpp>
+using namespace boost::svg;
+
+#include <boost/array.hpp>
+ using boost::array;
 #include <vector>
+ using std::vector;
 #include <deque>
+ using std::deque;
 #include <cmath>
-#include <boost/array.hpp>
-
-using std::vector;
-using std::deque;
-using namespace boost::svg;
+ using std::sqrt;
 
 double f(double x)
 {
@@ -59,29 +65,30 @@
                .x_label_on(true)
                .x_major_labels_on(true);
         
- // color settings
+ // Color settings.
         my_plot.background_color(svg_color(67, 111, 69))
                .legend_background_color(svg_color(207, 202,167))
                .legend_border_color(svg_color(102, 102, 84))
                .plot_background_color(svg_color(136, 188, 126))
                .title_color(white);
 
- //axis settings
+ // Axis settings.
         my_plot.x_major_interval(2)
                .x_major_tick_length(14)
                .x_major_tick_width(1)
                .x_minor_tick_length(7)
                .x_minor_tick_width(1)
- .x_num_minor_ticks(3);
+ .x_num_minor__ticks(3);
         
- //legend settings
+ // Legend settings.
         my_plot.legend_title_font_size(15);
         
         my_plot.plot(data1, "Lions", blue);
         my_plot.plot(data2, "Tigers", orange);
         my_plot.plot(data3, "Bears", red);
 
- my_plot.write("./1d_complex.svg");
+ my_plot.write("./1d_complex.svg");
 
         return 0;
 }
+// 1d_full_layout.cpp

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/1d_x_external.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -38,7 +38,8 @@
     my_plot.x_major_grid_color(black)
            .x_minor_grid_color(lightgray);
 
- my_plot.x_external_style_on(true);
+ my_plot.x_ticks_down(true); // external.
+ my_plot.y_ticks_left(true); // external.
 
     // Write to plot.
         my_plot.plot(dan_times, "Dan", blue);

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_area_fill.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -61,7 +61,7 @@
                .x_major_tick_width(1)
                .x_minor_tick_length(7)
                .x_minor_tick_width(1)
- .x_num_minor_ticks(3)
+ .x_num_minor__ticks(3)
         
         //Y axis settings.
                .y_major_interval(25)
@@ -70,8 +70,8 @@
         //legend settings
         my_plot.legend_title_font_size(15);
         
- my_plot.plot(data1, "Sqrt(x)", _point_style = none,
- _area_fill_color = red);
+ my_plot.plot(data1, "Sqrt(x)", point_style = none,
+ area_fill_color = red);
 
     my_plot.write("./2d_area_fill.svg");
 

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_bezier.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_bezier.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_bezier.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -68,7 +68,7 @@
                .x_major_tick_width(1)
                .x_minor_tick_length(7)
                .x_minor_tick_width(1)
- .x_num_minor_ticks(3)
+ .x_num_minor__ticks(3)
         
         //Y axis settings.
                .y_major_interval(25)
@@ -77,11 +77,11 @@
         //legend settings
         my_plot.legend_title_font_size(15);
         
- my_plot.plot(data1, "Sin(x)", _point_style = circle,
- _bezier_on = true, _size = 5, _fill_color = yellow);
+ my_plot.plot(data1, "Sin(x)", point_style = circle,
+ bezier_on = true, size = 5, fill_color = yellow);
 
- my_plot.plot(data2, "Cos(x)", _point_style = square,
- _bezier_on = true, _size = 5, _fill_color = red);
+ my_plot.plot(data2, "Cos(x)", point_style = square,
+ bezier_on = true, size = 5, fill_color = red);
 
     my_plot.write("D:\\2d_bezier.svg");
 

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_full.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -68,7 +68,7 @@
                .x_major_tick_width(1)
                .x_minor_tick_length(7)
                .x_minor_tick_width(1)
- .x_num_minor_ticks(3)
+ .x_num_minor__ticks(3)
         
         //Y axis settings.
                .y_major_interval(10)
@@ -80,7 +80,7 @@
         my_plot.plot(data1, "Sqrt(x)", red);
         my_plot.plot(data2, "-2 + x^2", orange);
         my_plot.plot(data3, "-1 + 2x", yellow,
- _point_style = square, _size = 5);
+ point_style = square, size = 5);
 
     my_plot.write("./2d_full.svg");
 

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -51,7 +51,7 @@
                .x_major_tick_width(1)
                .x_minor_tick_length(7)
                .x_minor_tick_width(1)
- .x_num_minor_ticks(3)
+ .x_num_minor__ticks(3)
         
         //Y axis settings.
                .y_major_interval(25)
@@ -60,8 +60,8 @@
         //legend settings
         my_plot.legend_title_font_size(15);
         
- my_plot.plot(data1, "1 / x", _point_style = square,
- _size = 5, _line_on = false);
+ my_plot.plot(data1, "1 / x", point_style = square,
+ size = 5, line_on = false);
 
     my_plot.write("D:\\2d_limit.svg");
 

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_color_consistency.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_color_consistency.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/1d_color_consistency.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -8,18 +8,365 @@
 // (See accompanying file LICENSE_1_0.txt
 // or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#pragma warning(disable : 4267) // '=' : conversion from 'size_t' to 'unsigned int'
+//#if defined (BOOST_MSVC) // requires a prior Boost include, so use MSC_VER instead.
+
+#if defined (_MSC_VER)
+# pragma warning(disable : 4267) // '=' : conversion from 'size_t' to 'unsigned int'
 // in spirit
+# pragma warning(disable : 4310) // cast truncates constant value
+# pragma warning(disable : 4512) // assignment operator could not be generated
+# pragma warning(disable : 4702) // unreachable code
+# pragma warning(disable : 4701) // potentially uninitialized local variable 'old_iph' used
+#endif
 
 #include <boost/test/included/test_exec_monitor.hpp>
 #include <boost/svg_plot/svg_1d_plot.hpp>
-using namespace boost::svg;
+ using namespace boost::svg;
+#include <boost/svg_plot/svg_fwd.hpp> // forward declarations.
+// Included to check its validity.
+
+#include <iostream>
+ using std::cout;
+ using std::endl;
+#include <string>
+ using std::string;
 
 int test_main(int, char*[])
 {
+ // Check on default values and all set and get functions.
+ // (Note: changes to default will mean tests must change too!)
+ // Note that constants for comparison must be exactly the right type.
+ // to avoid a warning from within Boost.Test.
+ // use of unsigned int means that test value must also be unsigned,
+ // for example 12U rather 12,
+ // double must be 1. rather than 1...
+
+ // Test the text_element class.
+ // text_element::text_element(double x, double y,
+ // const std::string&,
+ // int,
+ // const std::string& font,
+ // const std::string& style, const std::string& weight,
+ // const std::string& stretch, const std::string& decoration,
+ // int align, int rotate);
+
+
+ text_element text;
+ BOOST_CHECK_EQUAL(text.x(), 0);
+ text.x(10);
+ BOOST_CHECK_EQUAL(text.x(), 10);
+ BOOST_CHECK_EQUAL(text.y(), 0);
+ text.y(20);
+ BOOST_CHECK_EQUAL(text.y(), 20);
+
+ BOOST_CHECK_EQUAL(text.text(), "");
+ text.text("X");
+ BOOST_CHECK_EQUAL(text.text(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_size(), 12);
+ text.font_size(10);
+ BOOST_CHECK_EQUAL(text.font_size(), 10);
+
+ BOOST_CHECK_EQUAL(text.font_family(), "Lucida Sans Unicode");
+ text.font_family("X");
+ BOOST_CHECK_EQUAL(text.font_family(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_style(), "");
+ text.font_style("X");
+ BOOST_CHECK_EQUAL(text.font_style(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_weight(), "");
+ text.font_weight("X");
+ BOOST_CHECK_EQUAL(text.font_weight(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_stretch(), "");
+ text.font_stretch("X");
+ BOOST_CHECK_EQUAL(text.font_stretch(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_decoration(), "");
+ text.font_decoration("X");
+ BOOST_CHECK_EQUAL(text.font_decoration(), "X");
+
+ BOOST_CHECK_EQUAL(text.font_rotation(), horizontal);
+ text.font_rotation(upward);
+ BOOST_CHECK_EQUAL(text.font_rotation(), upward);
+
+ BOOST_CHECK_EQUAL(text.font_alignment(), center_align);
+ text.font_alignment(left_align);
+ BOOST_CHECK_EQUAL(text.font_alignment(), left_align);
+
+ // Test the svg_element class.
+
         svg_1d_plot my_plot;
+ // Check the default image sizes:
+ BOOST_CHECK_EQUAL(my_plot.image_x_size(), 500U);
+ BOOST_CHECK_EQUAL(my_plot.image_y_size(), 200U);
+
+ my_plot.image_size(200U, 100U);
+ BOOST_CHECK_EQUAL(my_plot.image_x_size(), 200U);
+ my_plot.image_size(500U, 100U); // update x
+ BOOST_CHECK_EQUAL(my_plot.image_x_size(), 500U); // & check
+ my_plot.image_size(500U, 300U); // update y
+ BOOST_CHECK_EQUAL(my_plot.image_y_size(), 300U); // & check
+
+ // cout << my_plot.image_x_size() << endl; // 500
+ BOOST_CHECK_EQUAL(my_plot.image_x_size(), 500U);
+ // Check that test really works by checking the wrong answer!
+ //BOOST_CHECK_EQUAL(my_plot.image_x_size(), 400U);
+ // check my_plot.image_x_size() == 400U failed [500 != 400]
+
+ BOOST_CHECK_EQUAL(my_plot.title(), "Plot of data"); // Title of plot.
+ my_plot.title("test");
+ BOOST_CHECK_EQUAL(my_plot.title(), "test");
+
+ BOOST_CHECK_EQUAL(my_plot.legend_title(), "Legend"); // Default no legend title.
+ my_plot.legend_title("");
+ BOOST_CHECK_EQUAL(my_plot.legend_title(), "");
+
+ BOOST_CHECK_EQUAL(my_plot.document_title(), ""); // Default no document title
+ my_plot.document_title("Document Title");
+ BOOST_CHECK_EQUAL(my_plot.document_title(), "Document Title");
+
+ BOOST_CHECK_EQUAL(my_plot.description(), ""); // Default no document description.
+ my_plot.description("Document Description");
+ BOOST_CHECK_EQUAL(my_plot.description(), "Document Description");
+
+ BOOST_CHECK_EQUAL(my_plot.copyright_holder(), ""); // Default no copyright_holder.
+ my_plot.copyright_holder("Jake Voytko");
+ BOOST_CHECK_EQUAL(my_plot.copyright_holder(), "Jake Voytko");
+
+ BOOST_CHECK_EQUAL(my_plot.copyright_date(), ""); // Default no copyright_date.
+ my_plot.copyright_date("2007");
+ BOOST_CHECK_EQUAL(my_plot.copyright_date(), "2007");
+
+ // Plot Title & font.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_family(), "Lucida Sans Console");// Check default.
+ my_plot.title_font_family("Times New Roman"); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_family(),"Times New Roman"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_style(), ""); // Check default.
+ my_plot.title_font_style("bold"); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_style(), "bold"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_weight(), ""); // Check default.
+ my_plot.title_font_weight("400"); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_weight(), "400"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_stretch(), ""); // Check default.
+ my_plot.title_font_stretch("wider"); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_stretch(), "wider"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_decoration(), ""); // Check default.
+ my_plot.title_font_decoration("underline"); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_decoration(), "underline"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_rotation(), 0);// Check default.
+ my_plot.title_font_rotation(180); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_rotation(), 180); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_font_alignment(), center_align);// Check default.
+ my_plot.title_font_alignment(left_align); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_font_alignment(), left_align); // & check.
+
+ // legend title & font
+
+ BOOST_CHECK_EQUAL(my_plot.legend_on(), false); // Check default.
+ my_plot.legend_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.legend_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.legend_title_font_size(), 16U);// Check default.
+ my_plot.legend_title_font_size(15); // Set
+ BOOST_CHECK_EQUAL(my_plot.legend_title_font_size(), 15U); // & check.
+
+
+ BOOST_CHECK_EQUAL(my_plot.plot_window_on(), false); // Check default.
+ my_plot.plot_window_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.plot_window_on(), true); // & check.
+ BOOST_CHECK_EQUAL(my_plot.plot_window_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_up_on(), false); // Check default.
+ my_plot.x_ticks_up_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_up_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_down_on(), true); // Check default.
+ my_plot.x_ticks_down_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_down_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_label_on(), false); // Check default.
+ my_plot.x_label_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_label_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_label_units_on(), false); // Check default.
+ my_plot.x_label_units_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_label_units_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_labels_on(), true); // Check default.
+ my_plot.x_major_labels_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_major_labels_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.title_on(), true); // Check default.
+ my_plot.title_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.title_on(), false); // & check.
+ BOOST_CHECK_EQUAL(my_plot.title_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_on(), false); // Check default.
+ my_plot.x_major_grid_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_on(), false); // Check default.
+ my_plot.x_minor_grid_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.axes_on(), false); // Check default (both axes on).
+ my_plot.axes_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.axes_on(), true); // & check.
+ my_plot.axes_on(false); // Set false revert to default (both axes on).
+
+ BOOST_CHECK_EQUAL(my_plot.x_axis_on(), false); // & check.
+ my_plot.x_axis_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_axis_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.y_axis_on(), true); // Check default.
+ my_plot.y_axis_on(false); // But leave false - as always should be for 1D?
+ BOOST_CHECK_EQUAL(my_plot.y_axis_on(), false); // & check.
+ my_plot.y_axis_on(true); // Set
+ BOOST_CHECK_EQUAL(my_plot.y_axis_on(), true); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.axes_on(), false); //
+ my_plot.axes_on(true); //
+ BOOST_CHECK_EQUAL(my_plot.axes_on(), true); // Only x axis on
+ my_plot.axes_on(true); // Both on
+ BOOST_CHECK_EQUAL(my_plot.axes_on(), true); //
+
+ // ticks left and right only for 2-D
+
+
+ my_plot.y_axis_on(false); // But leave false - as always should be for 1D?
+
+ BOOST_CHECK_EQUAL(my_plot.title_color(), svg_color(0, 0, 0)); // Check default color.
+ my_plot.title_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.title_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.background_color(), svg_color(255, 255, 255)); // Check default color.
+ my_plot.background_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.background_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.legend_background_color(), svg_color(255, 255, 255)); // Check default color.
+ my_plot.legend_background_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.legend_background_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.legend_border_color(), svg_color(0, 0, 0)); // Check default color.
+ my_plot.legend_border_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.legend_border_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.background_border_color(), svg_color(0, 0, 0)); // Check default color.
+ my_plot.background_border_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.background_border_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.plot_background_color(), svg_color(255, 255, 255)); // Check default color.
+ my_plot.plot_background_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.plot_background_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_axis_color(), svg_color(black)); // Check default color.
+ my_plot.x_axis_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_axis_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.y_axis_color(), svg_color(black)); // Check default color.
+ my_plot.y_axis_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.y_axis_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_label_color(), svg_color(black)); // Check default color.
+ my_plot.x_label_color( svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_label_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.y_label_color(), svg_color(black)); // Check default color.
+ my_plot.y_label_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.y_label_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_color(), svg_color(black)); // Check default color.
+ my_plot.x_major_tick_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_minor_tick_color(), svg_color(black)); // Check default color.
+ my_plot.x_minor_tick_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_minor_tick_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_color(), svg_color(blue)); // Check default color.
+ my_plot.x_major_grid_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_color(), svg_color(red)); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_width(), 3U); // Check default width.
+ my_plot.x_major_grid_width(10U); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_grid_width(), 10U); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_width(), 1U); // Check default width.
+ my_plot.x_minor_grid_width(10U); //
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_width(), 10U); // & check.
+
+ my_plot.x_minor_grid_color(svg_color(red)); //
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_color(), svg_color(red)); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_minor_grid_color(), svg_color(red)); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_axis_width(), 0U); // Check default width.
+ my_plot.x_axis_width(0); //
+ BOOST_CHECK_EQUAL(my_plot.x_axis_width(), 0U); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_axis_width(), 0U); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_label(), "X Axis"); // Check default label.
+ my_plot.x_label("X"); //
+ BOOST_CHECK_EQUAL(my_plot.x_label(), "X"); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_label(), "X"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_label_units(), "(units)"); // Check default label.
+ my_plot.x_label_units("(meter)"); //
+ BOOST_CHECK_EQUAL(my_plot.x_label_units(),"(meter)"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_interval(), 2.); // Check default.
+ my_plot.x_major_interval(1.); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_interval(), 1.); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_length(), 10U);
+ my_plot.x_major_tick_length(5U); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_length(), 5U);
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_width(), 3U);
+ my_plot.x_major_tick_width(5U); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_tick_width(), 5U);
+
+ BOOST_CHECK_EQUAL(my_plot.x_minor_tick_width(), 1U);
+ my_plot.x_minor_tick_width(5U); //
+ BOOST_CHECK_EQUAL(my_plot.x_minor_tick_width(), 5U);
+
+ BOOST_CHECK_EQUAL(my_plot.x_num_minor_ticks(), 2U);
+ my_plot.x_num_minor_ticks(9U); //
+ BOOST_CHECK_EQUAL(my_plot.x_num_minor_ticks(), 9U);
+
+ BOOST_CHECK_EQUAL(my_plot.x_major_interval(), 1.);
+ my_plot.x_major_interval(2.); //
+ BOOST_CHECK_EQUAL(my_plot.x_major_interval(), 2.);
+
+ BOOST_CHECK_EQUAL(my_plot.x_minimum(), -10.); // Check default xmin.
+ BOOST_CHECK_EQUAL(my_plot.x_maximum(), +10.); // Check default xmax.
+ my_plot.x_range(-1., +1.); //
+ BOOST_CHECK_EQUAL(my_plot.x_minimum(), -1.); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_maximum(), +1.); // & check.
+
+ std::pair<double, double> r = my_plot.x_range();
+ BOOST_CHECK_EQUAL(r.first, -1.); // & check.
+ BOOST_CHECK_EQUAL(r.second, +1.); // & check.
+
+ std::pair<double, double> xr = my_plot.x_range();
+ BOOST_CHECK_EQUAL(xr.first, -1.); // & check.
+ BOOST_CHECK_EQUAL(xr.second, +1.); // & check.
+
+ const string style = "test_style.css";
+ //my_plot.load_stylesheet(style); // TODO - Error opening file test_style.css
+ //BOOST_CHECK(validate_stylesheet(style));
+
 
- my_plot
+ my_plot
         .background_border_color(svg_color(0, 0, 1))
         .background_color(svg_color(0, 0, 2))
         .legend_background_color(svg_color(0, 0, 3))
@@ -33,14 +380,14 @@
         .x_minor_grid_color(svg_color(0, 0, 11))
         .x_minor_tick_color(svg_color(0, 0, 12));
 
- BOOST_CHECK(my_plot.get_background_border_color() == svg_color(0, 0, 1));
- BOOST_CHECK(my_plot.get_background_color() == svg_color(0, 0, 2));
- BOOST_CHECK(my_plot.get_legend_background_color() == svg_color(0, 0, 3));
- BOOST_CHECK(my_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(my_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(my_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(my_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(my_plot.get_x_label_color() == svg_color(0, 0, 8));
+ BOOST_CHECK(my_plot.background_border_color() == svg_color(0, 0, 1));
+ BOOST_CHECK(my_plot.background_color() == svg_color(0, 0, 2));
+ BOOST_CHECK(my_plot.legend_background_color() == svg_color(0, 0, 3));
+ BOOST_CHECK(my_plot.legend_border_color() == svg_color(0, 0, 4));
+ BOOST_CHECK(my_plot.plot_background_color() == svg_color(0, 0, 5));
+ BOOST_CHECK(my_plot.title_color() == svg_color(0, 0, 6));
+ BOOST_CHECK(my_plot.x_axis_color() == svg_color(0, 0, 7));
+ BOOST_CHECK(my_plot.x_label_color() == svg_color(0, 0, 8));
         //BOOST_CHECK_EQUAL(svg_color(1, 1, 1), svg_color(0, 0, 0));
   // check svg_color(1, 1, 1) == svg_color(0, 0, 0) failed [RGB(1,1,1) != RGB(0,0,0)]
 
@@ -50,14 +397,14 @@
   // Note that named colors are enums!
 
         BOOST_CHECK_EQUAL(svg_color(0, 0, 8), svg_color(0, 0, 8));
- BOOST_CHECK_EQUAL(my_plot.get_x_label_color(), svg_color(0, 0, 8));
+ BOOST_CHECK_EQUAL(my_plot.x_label_color(), svg_color(0, 0, 8));
   // using BOOST_CHECK_EQUAL is more convenient because it shows the difference!
   // provided operator== and operator >> is provided.
 
- BOOST_CHECK(my_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(my_plot.get_x_major_tick_color() == svg_color(0, 0, 10));
- BOOST_CHECK(my_plot.get_x_minor_grid_color() == svg_color(0, 0, 11));
- BOOST_CHECK(my_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
+ BOOST_CHECK(my_plot.x_major_grid_color() == svg_color(0, 0, 9));
+ BOOST_CHECK(my_plot.x_major_tick_color() == svg_color(0, 0, 10));
+ BOOST_CHECK(my_plot.x_minor_grid_color() == svg_color(0, 0, 11));
+ BOOST_CHECK(my_plot.x_minor_tick_color() == svg_color(0, 0, 12));
 
   // Repeat - intentional? - would different values be a better test?
         my_plot
@@ -74,31 +421,39 @@
         .background_color(svg_color(0, 0, 2))
         .background_border_color(svg_color(0, 0, 1));
 
- BOOST_CHECK(my_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
- BOOST_CHECK(my_plot.get_x_minor_grid_color() == svg_color(0, 0, 11));
- BOOST_CHECK(my_plot.get_x_major_tick_color() == svg_color(0, 0, 10));
- BOOST_CHECK(my_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(my_plot.get_x_label_color() == svg_color(0, 0, 8));
- BOOST_CHECK(my_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(my_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(my_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(my_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(my_plot.get_legend_background_color() == svg_color(0, 0, 3));
- BOOST_CHECK(my_plot.get_background_color() == svg_color(0, 0, 2));
- BOOST_CHECK(my_plot.get_background_border_color() == svg_color(0, 0, 1));
+ BOOST_CHECK(my_plot.x_minor_tick_color() == svg_color(0, 0, 12));
+ BOOST_CHECK(my_plot.x_minor_grid_color() == svg_color(0, 0, 11));
+ BOOST_CHECK(my_plot.x_major_tick_color() == svg_color(0, 0, 10));
+ BOOST_CHECK(my_plot.x_major_grid_color() == svg_color(0, 0, 9));
+ BOOST_CHECK(my_plot.x_label_color() == svg_color(0, 0, 8));
+ BOOST_CHECK(my_plot.x_axis_color() == svg_color(0, 0, 7));
+ BOOST_CHECK(my_plot.title_color() == svg_color(0, 0, 6));
+ BOOST_CHECK(my_plot.plot_background_color() == svg_color(0, 0, 5));
+ BOOST_CHECK(my_plot.legend_border_color() == svg_color(0, 0, 4));
+ BOOST_CHECK(my_plot.legend_background_color() == svg_color(0, 0, 3));
+ BOOST_CHECK(my_plot.background_color() == svg_color(0, 0, 2));
+ BOOST_CHECK(my_plot.background_border_color() == svg_color(0, 0, 1));
+
+
+
+
+
+
         return 0;
 } // int test_main(int, char*[])
 
 
-//**passed** ../../../bin.v2/libs/svg_plot/test/1d_color_consistency.test/gcc-4.1.2/debug/1d_color_consistency.test
 /*
-
-Compiling...
-1d_color_consistency.cpp
+demo_1d_plot.cpp
 Linking...
 Embedding manifest...
-Autorun "j:\Cpp\SVG\debug\test_1d_color_consistency.exe"
-Running 1 test case...
-*** No errors detected
+Autorun "j:\Cpp\SVG\debug\demo_1d_plot.exe"
+font-family was Lucida Sans Console
+font-family is Times New Roman
+Plot window x 5 to 340, y 45 to 315
+Build Time 0:11
+Build log was saved at "file://j:\Cpp\SVG\demo_1d_plot\Debug\BuildLog.htm"
+demo_1d_plot - 0 error(s), 0 warning(s)
+
 
 */
\ No newline at end of file

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/2d_color_consistency.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/2d_color_consistency.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/2d_color_consistency.cpp 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,17 +1,70 @@
 // 2d_color_consistency.cpp
-// Copyright (C) Jacob Voytko 2007
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-// -----------------------------------------------------------------
-#include <boost/svg_plot/svg_2d_plot.hpp>
-#include <boost/test/included/test_exec_monitor.hpp>
 
+// Copyright Jacob Voytko 2007
+// Copyright Paul A. Bristow 2007
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifdef _MSC_VER
+# pragma warning(disable : 4267) // '=' : conversion from 'size_t' to 'unsigned int' in spirit
+# pragma warning(disable : 4180) // warning C4180: qualifier applied to function type has no meaning; ignored
+# pragma warning(disable : 4172) // warning C4180: qualifier applied to function type has no meaning; ignored
+
+# pragma warning(disable : 4310) // cast truncates constant value
+# pragma warning(disable : 4512) // assignment operator could not be generated
+# pragma warning(disable : 4702) // unreachable code
+#endif
+
+#include <boost/test/included/test_exec_monitor.hpp>
+#include <boost/svg_plot/svg_2d_plot.hpp>
 using namespace boost::svg;
 
+#include <iostream>
+using std::cout;
+using std::endl;
+
 int test_main(int, char*[])
 {
         svg_2d_plot my_plot;
 
+ BOOST_CHECK_EQUAL(my_plot.title(), "Plot of data");
+ my_plot.title("Plot of my data");
+ cout << my_plot.title() << endl;
+ BOOST_CHECK_EQUAL(my_plot.title(), "Plot of my data");
+
+ my_plot.x_range(-1., 1.);
+ cout << "x max " << my_plot.x_minimum() << endl;
+ cout << "x min " << my_plot.x_maximum() << endl;
+
+ // Tests that do NOT apply to 1D.
+
+ BOOST_CHECK_EQUAL(my_plot.y_label(), "Y Axis"); // Check default label.
+ my_plot.y_label("Y"); //
+ BOOST_CHECK_EQUAL(my_plot.y_label(), "Y"); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_up_on(), true); // Check default.
+ my_plot.x_ticks_up_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_up_on(), false); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_up_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_down_on(), true); // Check default.
+ my_plot.x_ticks_down_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_down_on(), false); // & check.
+ BOOST_CHECK_EQUAL(my_plot.x_ticks_down_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_right_on(), true); // Check default.
+ my_plot.y_ticks_right_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_right_on(), false); // & check.
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_right_on(), false); // & check.
+
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_left_on(), true); // Check default.
+ my_plot.y_ticks_left_on(false); // Set
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_left_on(), false); // & check.
+ BOOST_CHECK_EQUAL(my_plot.y_ticks_left_on(), false); // & check.
+
         my_plot
         .background_border_color(svg_color(0, 0, 1))
         .background_color(svg_color(0, 0, 2))
@@ -26,30 +79,36 @@
         .x_minor_grid_color(svg_color(0, 0, 11))
         .x_minor_tick_color(svg_color(0, 0, 12))
         .y_axis_color(svg_color(0, 0, 13))
-// .y_label_color(svg_color(0, 0, 14))
+ .y_label_color(svg_color(0, 0, 14))
         .y_major_grid_color(svg_color(0, 0, 15))
         .y_major_tick_color(svg_color(0, 0, 16))
         .y_minor_grid_color(svg_color(0, 0, 17))
         .y_minor_tick_color(svg_color(0, 0, 18));
 
- BOOST_CHECK(my_plot.get_background_border_color()==svg_color(0, 0, 1));
- BOOST_CHECK(my_plot.get_background_color()==svg_color(0, 0, 2));
- BOOST_CHECK(my_plot.get_legend_background_color()==svg_color(0, 0, 3));
- BOOST_CHECK(my_plot.get_legend_border_color()==svg_color(0, 0, 4));
- BOOST_CHECK(my_plot.get_plot_background_color()==svg_color(0, 0, 5));
- BOOST_CHECK(my_plot.get_title_color()==svg_color(0, 0, 6));
- BOOST_CHECK(my_plot.get_x_axis_color()==svg_color(0, 0, 7));
- BOOST_CHECK(my_plot.get_x_label_color()==svg_color(0, 0, 8));
- BOOST_CHECK(my_plot.get_x_major_grid_color()==svg_color(0, 0, 9));
- BOOST_CHECK(my_plot.get_x_major_tick_color()==svg_color(0, 0, 10));
- BOOST_CHECK(my_plot.get_x_minor_grid_color()==svg_color(0, 0, 11));
- BOOST_CHECK(my_plot.get_x_minor_tick_color()==svg_color(0, 0, 12));
- BOOST_CHECK(my_plot.get_y_axis_color()==svg_color(0, 0, 13));
-// BOOST_CHECK(my_plot.get_y_label_color()==svg_color(0, 0, 14));
- BOOST_CHECK(my_plot.get_y_major_grid_color()==svg_color(0, 0, 15));
- BOOST_CHECK(my_plot.get_y_major_tick_color()==svg_color(0, 0, 16));
- BOOST_CHECK(my_plot.get_y_minor_grid_color()==svg_color(0, 0, 17));
- BOOST_CHECK(my_plot.get_y_minor_tick_color()==svg_color(0, 0, 18));
+ BOOST_CHECK(my_plot.background_border_color() == svg_color(0, 0, 1));
+ BOOST_CHECK(my_plot.background_color() == svg_color(0, 0, 2));
+ BOOST_CHECK(my_plot.legend_background_color() == svg_color(0, 0, 3));
+ BOOST_CHECK(my_plot.legend_border_color() == svg_color(0, 0, 4));
+ BOOST_CHECK(my_plot.plot_background_color() == svg_color(0, 0, 5));
+ BOOST_CHECK(my_plot.title_color() == svg_color(0, 0, 6));
+ BOOST_CHECK(my_plot.x_axis_color() == svg_color(0, 0, 7));
+ BOOST_CHECK(my_plot.x_label_color() == svg_color(0, 0, 8));
+ BOOST_CHECK(my_plot.x_major_grid_color() == svg_color(0, 0, 9));
+ BOOST_CHECK(my_plot.x_major_tick_color() == svg_color(0, 0, 10));
+ BOOST_CHECK(my_plot.x_minor_grid_color() == svg_color(0, 0, 11));
+ BOOST_CHECK(my_plot.x_minor_tick_color() == svg_color(0, 0, 12));
+ //BOOST_CHECK(my_plot.x_axis_color() == svg_color(0, 0, 7)); // Seems to work???
+ cout << svg_color(red) << endl;
+ cout << my_plot.y_axis_color() << endl;
+ BOOST_CHECK(my_plot.y_axis_color() == svg_color(0, 0, 13));
+ //cout << my_plot.y_axis_color() << endl;
+ //BOOST_CHECK(my_plot.y_axis_color() == svg_color(0, 0, 13)); // fails " does not expect 0 arguments"
+ BOOST_CHECK(my_plot.y_label_color() == svg_color(0, 0, 14));
+ BOOST_CHECK_EQUAL(my_plot.y_label_color(), svg_color(0, 0, 14));
+ //BOOST_CHECK(my_plot.y_major_grid_color() == svg_color(0, 0, 15));
+ //BOOST_CHECK(my_plot.y_major_tick_color() == svg_color(0, 0, 16));
+ //BOOST_CHECK(my_plot.y_minor_grid_color() == svg_color(0, 0, 17));
+ //BOOST_CHECK(my_plot.y_minor_tick_color() == svg_color(0, 0, 18));
 
         my_plot
         .y_minor_tick_color(svg_color(0, 0, 18))
@@ -71,25 +130,32 @@
         .background_color(svg_color(0, 0, 2))
         .background_border_color(svg_color(0, 0, 1));
 
- BOOST_CHECK(my_plot.get_y_minor_tick_color()==svg_color(0, 0, 18));
- BOOST_CHECK(my_plot.get_y_minor_grid_color()==svg_color(0, 0, 17));
- BOOST_CHECK(my_plot.get_y_major_tick_color()==svg_color(0, 0, 16));
- BOOST_CHECK(my_plot.get_y_major_grid_color()==svg_color(0, 0, 15));
-// BOOST_CHECK(my_plot.get_y_label_color()==svg_color(0, 0, 14));
- BOOST_CHECK(my_plot.get_y_axis_color()==svg_color(0, 0, 13));
- BOOST_CHECK(my_plot.get_x_minor_tick_color()==svg_color(0, 0, 12));
- BOOST_CHECK(my_plot.get_x_minor_grid_color()==svg_color(0, 0, 11));
- BOOST_CHECK(my_plot.get_x_major_tick_color()==svg_color(0, 0, 10));
- BOOST_CHECK(my_plot.get_x_major_grid_color()==svg_color(0, 0, 9));
- BOOST_CHECK(my_plot.get_x_label_color()==svg_color(0, 0, 8));
- BOOST_CHECK(my_plot.get_x_axis_color()==svg_color(0, 0, 7));
- BOOST_CHECK(my_plot.get_title_color()==svg_color(0, 0, 6));
- BOOST_CHECK(my_plot.get_plot_background_color()==svg_color(0, 0, 5));
- BOOST_CHECK(my_plot.get_legend_border_color()==svg_color(0, 0, 4));
- BOOST_CHECK(my_plot.get_legend_background_color()==svg_color(0, 0, 3));
- BOOST_CHECK(my_plot.get_background_color()==svg_color(0, 0, 2));
- BOOST_CHECK(my_plot.get_background_border_color()==svg_color(0, 0, 1));
+// BOOST_CHECK(my_plot.y_minor_tick_color() == svg_color(0, 0, 18));
+// BOOST_CHECK(my_plot.y_minor_grid_color() == svg_color(0, 0, 17));
+// BOOST_CHECK(my_plot.y_major_tick_color() == svg_color(0, 0, 16));
+// BOOST_CHECK(my_plot.y_major_grid_color() == svg_color(0, 0, 15));
+//// BOOST_CHECK(my_plot.y_label_color() == svg_color(0, 0, 14));
+// BOOST_CHECK(my_plot.y_axis_color() == svg_color(0, 0, 13));
+ BOOST_CHECK(my_plot.x_minor_tick_color() == svg_color(0, 0, 12));
+ BOOST_CHECK(my_plot.x_minor_grid_color() == svg_color(0, 0, 11));
+ BOOST_CHECK(my_plot.x_major_tick_color() == svg_color(0, 0, 10));
+ BOOST_CHECK(my_plot.x_major_grid_color() == svg_color(0, 0, 9));
+ BOOST_CHECK(my_plot.x_label_color() == svg_color(0, 0, 8));
+ BOOST_CHECK(my_plot.x_axis_color() == svg_color(0, 0, 7));
+ BOOST_CHECK(my_plot.title_color() == svg_color(0, 0, 6));
+ BOOST_CHECK(my_plot.plot_background_color() == svg_color(0, 0, 5));
+ BOOST_CHECK(my_plot.legend_border_color() == svg_color(0, 0, 4));
+ BOOST_CHECK(my_plot.legend_background_color() == svg_color(0, 0, 3));
+ BOOST_CHECK(my_plot.background_color() == svg_color(0, 0, 2));
+ BOOST_CHECK(my_plot.background_border_color() == svg_color(0, 0, 1));
         return 0;
 }
 
-//**passed** ../../../bin.v2/libs/svg_plot/test/2d_color_consistency.test/gcc-4.1.2/debug/2d_color_consistency.test
+/*
+
+Autorun "j:\Cpp\SVG\debug\test_2d_color_persistence.exe
+Running 1 test case...
+*** No errors detected
+
+
+*/

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 2007-11-22 16:53:43 EST (Thu, 22 Nov 2007)
@@ -1,4 +1,4 @@
-# Copyright 2007 Stjepan Rajko.
+# Copyright 2007 Jake Voytko
 # Distributed under the Boost Software License, Version 1.0. (See
 # accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)


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