Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2008-01-18 11:09:58


Author: pbristow
Date: 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
New Revision: 42846
URL: http://svn.boost.org/trac/boost/changeset/42846

Log:
Minor work but re-commit to ensure latest version is up.
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 48 +-
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp | 4
   sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp | 2
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 658 +++++++++++++++++++++++----------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 93 +++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 64 +++
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html | 3
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface.html | 1
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/interface/svg_boxplot_interface.html | 6
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/interface.qbk | 3
   10 files changed, 536 insertions(+), 346 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -523,7 +523,8 @@
           if(derived().legend_on_) // Legend box required.
           {
             derived().outside_legend_on_ = true; // Unless proves to be inside.
- double spacing = derived().y_label_font_size() * 1.; // Around any legend box - beyond any border.
+ //double spacing = derived().y_label_font_size() * 1.; // Around any legend box - beyond any border.
+ double spacing = derived().y_axis_label_style_.font_size() * 1.; // Around any legend box - beyond any border.
             switch (derived().legend_place_)
             {
             case nowhere:
@@ -1279,6 +1280,28 @@
             return derived().x_ticks_.value_precision_;
           }
 
+ Derived& x_value_ioflags(int flags)
+ { // IO flags of X tick label values (default 0X201).
+ derived().x_ticks_.value_ioflags_ = flags;
+ return derived();
+ }
+
+ int x_value_ioflags()
+ { // ALL stream ioflags for control of format of X value labels.
+ return derived().x_ticks_.value_ioflags_;
+ }
+
+ Derived& x_labels_strip_e0s(bool cmd)
+ {
+ derived().x_ticks_.strip_e0s_ = cmd;
+ return *this;
+ }
+
+ bool y_labels_strip_e0s()
+ {
+ return derived().x_ticks_.strip_e0s_;
+ }
+
           const std::string title()
           {
             return derived().title_info_.text();
@@ -1704,16 +1727,6 @@
             return derived().x_label_info_.style().font_family();
           }
 
- Derived& x_value_ioflags(int flags)
- { // IO flags of X tick label values (default 0X201).
- derived().x_ticks_.value_ioflags_ = flags;
- return derived();
- }
-
- int x_value_ioflags()
- { // ALL stream ioflags for control of format of X value labels.
- return derived().x_ticks_.value_ioflags_;
- }
 
           Derived& title(const std::string title)
           { // Plot title.
@@ -1873,7 +1886,9 @@
           }
 
           Derived& title_font_width(double width)
- { // width of text is effectively the boldness
+ { // width of text is effectively the boldness.
+ // Not useful with current browsers, setting this may cause lower quality graphic fonts
+ // perhaps because the font is created using graphics rather than a built-in font.
             derived().image.get_g_element(PLOT_TITLE).style().stroke_width(width);
             return derived();
           }
@@ -1885,14 +1900,13 @@
 
           Derived& legend_color(const svg_color& col)
           {
- derived().image.get_g_element(PLOT_LEGEND_TEXT).style().fill_color(col);
             derived().image.get_g_element(PLOT_LEGEND_TEXT).style().stroke_color(col);
             return derived();
           }
 
           svg_color legend_color()
- { // Function legend_color sets both fill and stroke,
- // but stroke (outside) is considered 'more important'.
+ { // Function legend_color sets only stroke, assuming that 'filled' text is not being used.
+ // (It produces much lower quality fonts on some browsers).
             return derived().image.get_g_element(PLOT_LEGEND_TEXT).style().stroke_color();
           }
 
@@ -1903,12 +1917,12 @@
           }
 
           double legend_font_width()
- {
+ { // Probably not useful at present (se above).
             return derived().image.get_g_element(PLOT_LEGEND_TEXT).style().stroke_width();
           }
 
           Derived& background_color(const svg_color& col)
- {
+ { //
             derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(col);
             return derived();
           }

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -28,10 +28,10 @@
 
 // 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()
+// 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
-{
+{ // Order control the painting order, later ones overwriting earlier layers.
   PLOT_BACKGROUND = 0, // Must be zero to index array document_ids[]
     PLOT_WINDOW_BACKGROUND, // the smaller plot window (if used).
     PLOT_Y_MINOR_GRID, PLOT_Y_MAJOR_GRID, // 2, 3

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -158,11 +158,11 @@
   // doesn't work - no filename is shown.
   
   cout << "axes_on " << plot.axes_on() << endl;
+ cout << "background_border_width " << plot.background_border_width() << endl;
   cout << "background_border_color " << plot.background_border_color() << endl;
   cout << "background_color " << plot.background_color() << endl;
   cout << "image_border_margin() " << plot.image_border_margin() << endl;
   cout << "image_border_width() " << plot.image_border_width() << endl;
- cout << "background_border_width " << plot.background_border_width() << endl;
   cout << "coord_precision " << plot.coord_precision() << endl;
   cout << "copyright_date " << plot.copyright_date() << endl;
   cout << "copyright_holder " << plot.copyright_holder() << endl;

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -12,21 +12,12 @@
 #ifndef BOOST_SVG_SVG_1D_PLOT_HPP
 #define BOOST_SVG_SVG_1D_PLOT_HPP
 
-
-#include <boost/bind.hpp>
-
 #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
 
-// 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.
-
-#include <boost/parameter/preprocessor.hpp>
-#include <boost/parameter/name.hpp>
 #include <boost/iterator/transform_iterator.hpp>
 
 #include "svg.hpp"
@@ -34,10 +25,6 @@
 #include "detail/axis_plot_frame.hpp"
 #include "detail/functors.hpp"
 
-#if defined (BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
 #include <vector>
 #include <ostream>
 #include <sstream>
@@ -49,59 +36,59 @@
 {
 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
+ // Forward declarations.
+ const std::string strip_e0s(std::string s); // Strip unncessary zeros and e and sign.
+ class svg_1d_plot; // Plot.
+ class svg_1d_plot_series; // plot data series.
+
+ static const double wh = 0.7; // font text width/height ratio.
+ // Even after reading http://www.w3.org/TR/SVG/fonts.html, unclear how to
+ // determine the exact width of digits, so an
+ // arbitrary average width height ratio wh = 0.7 is used as a good approximation.
+
+ static const double sin45 = 0.707; // Use if axis value labels are sloping.
+
+ // x_axis_position_ and y_axis_position_ use these.
+ enum x_axis_intersect {bottom = -1, x_intersects_y = 0, top = +1};
+ // bottom = X-axis free below bottom of end of Y-axis (case of all Y definitely < 0).
+ // top = X-axis free above top of X-axis (case of all Y definitely > 0).
+ // x_intersects_y when Y values include zero, so X intersects the Y axis.
+
+ enum y_axis_intersect {left = -1, y_intersects_x = 0, right = +1};
+ // left = Y-axis free to left of end of X-axis (case of all X definitely < 0).
+ // right = Y-axis free to left of end of X-axis (case of all X definitely > 0).
+ // y_intersects_x when X values include zero, so intersects the X axis.
 
-// -----------------------------------------------------------------
+ // -----------------------------------------------------------------
 // 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_plot_series
+class svg_1d_plot_series
 {
+public:
   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; // title of data series (to show on legend).
- plot_point_style point_style; // circle, square...
+ std::string title_; // title of data series (to show on legend).
+ plot_point_style point_style_; // circle, square...
+ plot_point_style limit_point_style_;
+ plot_line_style line_style_; // No line style for 1-D, only for 2-D.
 
   // -------------------------------------------------------------
   // 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)
+ template <class T> // T an STL container: array, vector ...
+ svg_1d_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.
+ title_(title),
+ point_style_(style),
+ line_style_ // Meaning of line style for 1-D as yet undefined?
   {
     for(T i = begin; i != end; ++i)
- {
+ { // No defaults for begin and end.
       double temp = *i;
       if(detail::is_limit(temp))
       {
@@ -113,106 +100,149 @@
       }
     }
   } // svg_plot_series
+
+ // Set functions for the plot series.
+ svg_1d_plot_series& fill_color(const svg_color& col_)
+ {
+ point_style_.fill_color_ = col_;
+ return *this;
+ }
+
+ svg_1d_plot_series& stroke_color(const svg_color& col_)
+ {
+ point_style_.stroke_color_ = col_;
+ return *this;
+ }
+
+ svg_1d_plot_series& shape(point_shape shape_)
+ {
+ point_style_.shape_ = shape_;
+ return *this;
+ }
+
+ svg_1d_plot_series& size(int size_)
+ {
+ point_style_.size_ = size_;
+ return *this;
+ }
+
+ svg_1d_plot_series& line_color(const svg_color& col_)
+ {
+ line_style_.color_ = col_;
+ return *this;
+ }
+
+ svg_1d_plot_series& line_width(double wid_)
+ { // Doesn't have desired effect yet.
+ line_style_.width_ = wid_;
+ return *this;
+ }
+
+ // Get functions for the plot series.
+ double line_width()
+ {
+ return line_style_.width_;
+ }
+
+ svg_1d_plot_series& line_on(bool on_)
+ {
+ line_style_.line_on_ = on_;
+ return *this;
+ }
+
+ svg_1d_plot_series& bezier_on(bool on_)
+ {
+ line_style_.bezier_on_ = on_;
+ return *this;
+ }
+
+ bool bezier_on()
+ {
+ return line_style_.bezier_on_;
+ }
 }; // struct svg_plot_series()
 
 class svg_1d_plot : public detail::axis_plot_frame<svg_1d_plot>
-{
+{ // See also svg_2d_plot.hpp for 2-D version.
+ friend void show_plot_settings(svg_1d_plot&);
+ friend class detail::axis_plot_frame<svg_1d_plot>;
+
  protected:
- // Stored so as to avoid rewriting style information constantly.
- svg image;
+ // Where we will be storing the data points for transformation.
+ std::vector<svg_1d_plot_series> series;
+ // These are sorted into two vectors for normal and abnormal (max, inf and NaN).
+
+ svg image; // Stored so as to avoid rewriting style information constantly.
+
+ // Member data names conventionally end with _.
+
+ 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_;
+
+ double text_margin_; // Marginal space around text items like title,
+ // text_margin_ * font_size to get distance in svg units
+
+ text_style a_style_; // Defaults.
+ // text_style contains font size & type etc.
+ text_style title_style_;
+ text_style legend_style_;
+ text_style x_axis_label_style_;
+ text_style y_axis_label_style_;
+ text_style x_value_label_style_;
+ text_style y_value_label_style_; // Not used?
+ text_style point_symbols_style_; // Used for data point marking.
 
   text_element title_info_; // Title of whole plot.
- text_element legend_header; // legend box header (if any).
+ text_element legend_header_; // legend box header or title (if any).
   text_element x_label_info_; // Example: "length of widget"
+ text_element x_label_value_; // For example: "1.2" or "1.2e+001"
   text_element x_units_info_; // For example, to display, "length (meter)"
   // No Y-axis info for 1D.
- // Note that text_elements hold font_size.
+ // Note that text_elements hold font_size, bold, italic...
 
   // 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_left_; // calculate_plot_window() sets these values.
- int plot_top_;
- int plot_right_;
- int plot_bottom_;
-
- // 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
+ box_style image_border_; // rectangular border of all image width, color...
+ box_style plot_window_border_; // rectangular border of plot window width, color...
 
- // 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.
- // text width is effectively the boldness of the font.
- // 0 is default, 1 is bolder, 2 very bold...
- // TODO SVG has also a not yet implemented boldness.
- double title_width_;
- double legend_width_;
- double legend_left_; // Left of legend box. (Optionally set by legend_position).
- double legend_top_; // Top of legend box.
+ double plot_left_; // calculate_plot_window() sets these values.
+ double plot_top_;
+ double plot_right_;
+ double plot_bottom_;
+
+ // enum legend_places{ nowhere, inside...}
+ legend_places legend_place_; // Place for any legend box.
+ double legend_width_; // Width of legend box (pixels).
+ double legend_height_; // Height of legend box (in pixels).
   // Size of legend box is controlled by its contents,
- // but may be helpful to store bottom right coordinates.
- // legend_bottom_right() gives access.
- double legend_right_; // right of legend box.
+ // but helpful to store computed coordinates.
+ double legend_left_; // Left of legend box.
+ double legend_top_; // Top of legend box.
+ // Both optionally set by legend_top_left.
+ double legend_right_; // SVG Coordinates of right of legend box,
   double legend_bottom_; // bottom of legend box.
+ size_t legend_longest_; // longest (both header & data) string in legend box,
 
- // 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_; // Interval (Cartesian units) between major ticks.
- // set/get by x_major_interval
- double x_minor_interval_; // Interval (Cartesian units) between minor ticks.
- // because x_num_minor_ticks_ used to determine this instead,
- // but one could calculate x_minor_interval_.
-
- // Yes/no options.
- bool title_on_; // Show plot title.
- bool legend_on_; // Show legend box.
- bool use_plot_window; // rather than whole image.
- bool use_x_axis_line_; // = x_axis_on()
- bool use_y_axis_line_; // Note: is needed in 1D version too in draw_axes.
- bool use_x_major_labels; // For example, to show value (like 1.2) by major ticks.
- //bool use_x_minor_labels; // For example, to show value (like 1.2) by minor ticks.
- // Not yet implemented (doubt if needed).
- 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 up_ticks_on_; // ticks only up from Y = 0 horizontal X-axis.
- bool down_ticks_on_;// ticks only down from Y = 0 horizontal X-axis.
- //bool left_ticks_on_; // only for 2D.
- //bool right_ticks_on_;
- bool x_ticks_on_; // = up_ticks_on_ || down_ticks_on_
- // bool y_ticks_on_; // = left_ticks_on_ || right_ticks_on_ 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 legend_lines_; // set by legend_lines(bool); // Not really useful for 1-D,
- // TODO but needs Boost-Parameter removed to do properly.
+ axis_line_style x_axis_;
+ axis_line_style y_axis_;
 
-private:
- friend class detail::axis_plot_frame<svg_1d_plot>;
+ ticks_labels_style x_ticks_;
+ ticks_labels_style y_ticks_; // Added to permit shared code!
 
- // 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_;
+ bool title_on_; // Provide a title for the whole plot.
+ bool legend_on_; // Provide a legend box.
+ bool outside_legend_on_; // legend box outside the plot window.
+ bool legend_lines_; // get/set by legend_lines(bool); data colored line type in legend box.
+ bool plot_window_on_; // Use a separate plot window (not whole image).
+ bool x_ticks_on_; // TODO check these are really useful.
+ int x_axis_position_; // TODO should these be in axis_style?
+ 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 member functions, defined below.
   // void calculate_transform(); //
@@ -222,55 +252,51 @@
   // void set_ids();
 
 public:
- svg_1d_plot() : // Default constructor.
+ 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.
- legend_left_(-1), legend_right_(-1),legend_top_(-1),legend_bottom_(-1), // Indicates not yet set.
+ text_margin_(2.), // for text was 1.5 // as a multiplier of the font size.
 
- x_min_(-10), x_max_(10),
+ title_style_(16, "Verdana", "", ""), // last "bold" ?
+ legend_style_(14, "Verdana", "", ""), // 2nd "italic"?
+ x_axis_label_style_(14, "Verdana", "", ""),
+ x_value_label_style_(12, "Verdana", "", ""),
+ point_symbols_style_(12, "Lucida Sans Unicode"), // Used for data point marking.
+
+ title_info_(0, 0, "Plot of data", title_style_, center_align, horizontal),
+ x_label_info_(0, 0, "X Axis", x_axis_label_style_, center_align, horizontal),
+ x_units_info_(0, 0, " (units)", x_value_label_style_, center_align, horizontal),
+ x_label_value_(0, 0, "", x_value_label_style_, center_align, horizontal),
+ x_axis_(X, -10., +10., black, 1, 0, true, false, true),
+ // Might fill in all values, but there are rather many for ticks_labels_style,
+ x_ticks_(X),// so for defaults see ticks_labels_style.
+ image_border_(yellow, white, 2, 10, true, true), // margin should be about axis label font size.
+ plot_window_border_(yellow, svg_color(255, 255, 255), 2, 3, true, false),
+ legend_header_(0, 0, "", legend_style_, center_align, horizontal),
+ legend_width_(200), // width of legend box (pixels) // TODO isn't this calculated?
+ legend_height_(0), // height of legend box (pixels)
+ legend_left_(-1), legend_right_(-1),legend_top_(-1),legend_bottom_(-1), // Default top left of plot window.
+ legend_place_(outside_right), // default but interacts with using plot_window.
     legend_on_(false),
+ legend_longest_(0),
+ outside_legend_on_(true),
+ plot_window_clip_("plot_window"), // for <clipPath id="plot_window" ...
     title_on_(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),
- up_ticks_on_(false),
- down_ticks_on_(true),
- use_x_ticks_on_plot_window_(false), // was external_style
- // use_y_ticks_on_plot_window_(false), // was external_style
- x_ticks_on_(true), // up_ticks_on_ || down_ticks_on_
- // 2D has left and right ticks too.
- legend_lines_(true),
- use_x_major_grid(false),
- // x_minor_grid_width(1),
- use_x_minor_grid(false),
- use_x_axis_line_(true),
- use_y_axis_line_(false), // Not needed for 1D, but leave at false.
- x_major_interval_(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)
+ plot_window_on_(true),
+ // Used to transform Cartesian to SVG.
+ x_scale_(1.), x_shift_(0.),
+ y_scale_(1.), y_shift_(0.),
+ x_axis_position_(0) // Move into axis_style?
+
   // 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).
- x_ticks_on_ = up_ticks_on_ || down_ticks_on_;
- // Only 2D has left and right ticks.
+
+
+ using namespace boost::svg::detail; // avoid detail::
 
     // Build the document tree & add all the children of the root node.
     for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
@@ -278,22 +304,154 @@
       image.add_g_element();
     }
 
- // 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);
+ // Set other SVG color, stroke & width defaults for various child PLOT nodes.
+ image.get_g_element(PLOT_BACKGROUND).style().fill_color(image_border_.fill_);
+ image.get_g_element(PLOT_BACKGROUND).style().stroke_color(image_border_.stroke_);
+ image.get_g_element(PLOT_BACKGROUND).style().stroke_width(image_border_.width_); //
+ image.get_g_element(PLOT_WINDOW_BACKGROUND).style().fill_color(plot_window_border_.fill_);
+ image.get_g_element(PLOT_WINDOW_BACKGROUND).style().stroke_width(plot_window_border_.width_).stroke_color(plot_window_border_.stroke_);
+ image.get_g_element(PLOT_LIMIT_POINTS).style().stroke_color(lightslategray).fill_color(antiquewhite);
+ image.get_g_element(PLOT_X_AXIS).style().stroke_color(black).stroke_width(x_axis_.width());
+ image.get_g_element(PLOT_X_LABEL).style().fill_color(black);
+ image.get_g_element(PLOT_VALUE_LABELS).style().fill_color(black);
+ image.get_g_element(PLOT_LEGEND_TEXT).style().fill_color(black);
+ image.get_g_element(PLOT_TITLE).style().fill_color(black).stroke_on(false);
 
+ // Note that widths are stored in member data *and* copied here.
+ // Not sure if this is wise but ...
     // Font info defaults are set by the constructor above.
+ // Ticks
+ if(x_ticks_.use_up_ticks() || x_ticks_.use_down_ticks())
+ {
+ image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(x_ticks_.major_tick_width_).stroke_color(black);
+ image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(x_ticks_.minor_tick_width_).stroke_color(black);
+ }
+ // Grids.
+ // Default color & width for grid, used or not.
+ image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_width(x_ticks_.major_grid_width_).stroke_color(svg_color(200, 220, 255));
+ BOOST_ASSERT(image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color() == svg_color(200, 220, 255));
+ image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_width(x_ticks_.minor_grid_width_).stroke_color(svg_color(200, 220, 255));
+ //image.get_g_element(PLOT_DATA_LINES).style().stroke_width(2); // default width.
+ // Alter with plot.data_lines_width(4);
+
+ legend_place_ = (plot_window_on_) ? outside_right : inside; // Defaults.
+ // Note if set plot_window_on() then also need to set legend_place.
+ // (if set a default in plot_window then call to set legend place must to come *after* it.
+ // So not set a default? But leaving it as inside is worse?)
 
+ x_ticks_on_ = x_ticks_.up_ticks_on_ || x_ticks_.down_ticks_on_;
+ // Only 2D has left and right ticks.
     set_ids();
- } // svg_1d_plot()
+ } // svg_1d_plot() Default constructor.
+
+
+ void calculate_plot_window()
+ { // For 1-D
+ // All calculation use svg units, pixels by default.
+
+ // Start by assuming we can use all the svg image,
+ // but reduce by the width of any image border.
+ plot_left_ = 0 + image_border_width(); // Top left of image.
+ plot_top_ = 0 + image_border_width();
+ plot_right_ = image.x_size() - image_border_width(); // Bottom right of image.
+ plot_bottom_ = image.y_size() - image_border_width();
+
+ if(title_on_)
+ { // Leave space at top for title.
+ // TODO what if want to put title at bottom?
+ plot_top_ += title_font_size() * (text_margin_ + 0.5);
+ }
+
+ size_legend_box(); // depending on its contents.
+ place_legend_box();
+ // Assume that axis labels are always at bottom and left.
+ if(x_axis_.label_on_)
+ { // Leave space at bottom for X axis label.
+ plot_bottom_ -= x_axis_label_style_.font_size() * (text_margin_);
+ }
+
+ x_axis_.axis_ = (plot_bottom_ + plot_top_) / 2.; // Put X-axis halfway up plot window.
+
+ if(plot_window_on_)
+ { // Needed to allow any plot window border rectangle to show OK.
+ // A small margin is to prevent it overlapping the image border.
+ // Also allows for axis value labels that mark the min and max
+ // that must extend half a font width beyond the plot window border.
+ plot_left_ += image_border_.margin_;
+ plot_right_ -= image_border_.margin_;
+ plot_top_ += image_border_.margin_;
+ plot_bottom_ -= image_border_.margin_;
+
+ // Calculate the number of chars of the longest value label.
+ x_ticks_.longest_label();
+ double x_label_length_ = 0; // Work out the longest value label for X-Axis.
+ if (x_ticks_.label_rotation_ == horizontal)
+ { // Only 1 char height & 1 space needed if labels are horizontal.
+ x_label_length_ = 2 * x_value_label_style_.font_size() * wh; // SVG chars
+ }
+ else if ((x_ticks_.label_rotation_ == upward) || (x_ticks_.label_rotation_ == downward))
+ { // ! horizontal so will need more than 2 chars worth.
+ x_label_length_+= x_ticks_.label_max_chars_ * x_value_label_style_.font_size() * wh; // SVG chars.
+ }
+ else
+ { // Assume label is sloping, say 45, so * sin(45) = 0.707.
+ x_label_length_+= x_ticks_.label_max_chars_ * x_value_label_style_.font_size() * wh * sin45; // SVG 'chars'.
+ }
+
+ if (x_ticks_.major_value_labels_on_ != 0)
+ { // Some value labels.
+ if ((x_ticks_.ticks_on_plot_window_on_ < 0) // on bottom of plot window.
+ && (x_ticks_.major_value_labels_on_ < 0) ) // & labels on bottom.
+ { // Contract plot window bottom edge up to make space for x value labels on bottom.
+ plot_bottom_ -= x_label_length_; // Move up.
+ }
+ else if ((x_ticks_.ticks_on_plot_window_on_ > 0) //
+ && (x_ticks_.major_value_labels_on_ > 0) ) // & x labels to top.
+ { // Move top of plot window down to give space for x value labels.
+ plot_top_ += x_label_length_; // Move down.
+ }
+ else
+ { // no labels on plot window (may be on mid-plot X-axis).
+ }
+ } // x_ticks_. major_value_labels_on
+
+ // Make space for any ticks.
+ if(x_ticks_.down_ticks_on_)
+ { // Start bottom of plot higher to give space for any external down ticks.
+ plot_bottom_ -= (std::max)(x_ticks_.major_tick_length_, x_ticks_.minor_tick_length_);// Avoid macro max trap!
+ }
+ if (x_axis_.axis_line_on_)
+ { // Want a X-axis line, so check if range includes zero, so axes intersect,
+ // and x_axis_ is svg coordinate of Y-axis (usually y = 0).
+ // If not fix axis to bottom of the plot window.
+ if ((x_axis_position_ == bottom) // All definitely > zero.
+ && !(x_ticks_.ticks_on_plot_window_on_ < 0) ) // & not already at bottom.
+ { // y_min_ > 0 so X-axis will not intersect Y-axis, so use plot window.
+ plot_bottom_ -= x_label_length_; // Move up for the value labels.
+ x_axis_.axis_ = plot_bottom_; // Put X-axis on bottom.
+ }
+ else if ((x_axis_position_ == top) // definitely < zero.
+ && !(x_ticks_.ticks_on_plot_window_on_ > 0) ) // & not already at top.
+ { // // y_max_ < 0 so X-axis will not intersect Y-axis, so use plot window.
+ plot_top_ += x_label_length_; // Move down for labels.
+ x_axis_.axis_ = plot_top_; // Put X-axis on top.
+ }
+ else
+ { // y_axis_position_ == y_intersects_x
+ // Calculate below after transform is calculated.
+ }
+ } // if (use_x_axis_line_)
+
+ } // plot_window_on_
+
+ if(plot_window_on_)
+ {
+ // Draw plot window rect.
+ image.get_g_element(detail::PLOT_WINDOW_BACKGROUND).push_back(
+ new rect_element(plot_left_, plot_top_, (plot_right_ - plot_left_), plot_bottom_ - plot_top_));
+ } // plot_window_on_
+ } // void calculate_plot_window()
+
 
   //void calculate_transform()
   //{ // Calculate scale and shift factors for transform from Cartesian to plot.
@@ -311,17 +469,17 @@
     double y2(image.y_size());
     transform_x(x);
     // Draw origin, making sure it is in the plot window.
- if(use_x_axis_line_ && (x > plot_left_) && (x < plot_right_))
- { // TODO >= and <= ? instead.
- if(!use_plot_window)
+ if(x_axis_.axis_line_on_ && (x >= plot_left_) && (x <= plot_right_))
+ {
+ if(!plot_window_on_)
       { // Use whole image.
         if(title_on_)
         { // Allow space for title, taking account of font size.
- y1 += title_info_.font_size() * (text_margin_ +1);
+ y1 += title_info_.style().font_size() * text_margin_;
         }
- if(use_x_label)
+ if(x_axis_.label_on_)
         {// Allow space for x tick values, taking account of font size.
- y2 -= x_label_info_.font_size() * text_margin_;
+ y2 -= x_label_info_.style().font_size() * text_margin_;
         }
       }
       else
@@ -334,46 +492,6 @@
     draw_x_axis();
   } // draw_axes()
 
- void calculate_plot_window()
- { // For 1-D
- x_axis_ = (plot_bottom_ + plot_top_) / 2.; // Put X-axis halfway up plot window.
- plot_left_ = 0; // Top left of image.
- plot_top_ = 0;
- plot_right_ = image.x_size(); // Bottom right of image.
- plot_bottom_ = image.y_size();
-
- if(use_plot_window)
- {
- plot_left_ += border_margin_; // small margin around border.
- plot_right_ -= border_margin_; //
- plot_top_ += border_margin_; //
- plot_bottom_ -= border_margin_;
-
- if(title_on_)
- { // Allow a blank line, title lines and a line space.
- plot_top_ += title_font_size() * 2;
- }
- if(legend_on_)
- { // Allow space for legend at right.
- plot_right_ -= 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_bottom_ -= static_cast<int>(x_label_info_.font_size() * text_margin_);
- }
- if(down_ticks_on_)
- { // Allow space for the downward ticks
- // (so don't go into/over the border margin).
- plot_bottom_ -= (std::max)(x_major_tick_length_, x_minor_tick_length_)
- }
- // Draw plot window rect.
- image.get_g_element(detail::PLOT_WINDOW_BACKGROUND).push_back(
- new rect_element(plot_left_, plot_top_, (plot_right_ - plot_left_), plot_bottom_ - plot_top_));
- // <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.
@@ -386,7 +504,7 @@
     calculate_plot_window();
     //calculate_transform();
     draw_title(); // Call after above to the plot_x and y are defined.
- if(use_x_axis_line_)
+ if(x_axis_.axis_line_on_)
     {
       draw_axes();
     }
@@ -394,7 +512,7 @@
     {
       draw_legend();
     }
- if(use_x_label)
+ if(x_axis_.label_on_)
     {
       draw_x_label();
     }
@@ -404,18 +522,18 @@
     { // For each of the data series.
       g_element& g_ptr = image.get_g_element(detail::PLOT_DATA_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);
+ 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_left_) // TODO <=?
- && (x < plot_right_)
- && (y > plot_top_)
- && (y < plot_bottom_) )
+ (x >= plot_left_)
+ && (x <= plot_right_)
+ && (y >= plot_top_)
+ && (y <= plot_bottom_) )
         {
           draw_plot_point(x, y, g_ptr, series[i].point_style_);
         }
@@ -464,50 +582,38 @@
     image.write(s_out);
     return (svg_1d_plot&)*this;
   }
+
+ template <class T>
+ svg_1d_plot_series& plot(const T& container, const std::string& title)
+ {
+ series.push_back(
+ svg_1d_plot_series(
+ boost::make_transform_iterator(container.begin(), detail::boost_default_convert()),
+ boost::make_transform_iterator(container.end(), detail::boost_default_convert()),
+ title)
+ );
+ return series[series.size()-1];
+ }
 
- //
- #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
- (
- (void),
- plot,
- tag,
- (required
- (container, *)
- (title, (const std::string&))
- )
- (optional
- (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))
- )
- )
- )
- {
- 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
+ template <class T, class U>
+ svg_1d_plot_series& plot(const T& container, const std::string& title, U functor)
+ { // Version with functor.
+ series.push_back(
+ svg_1d_plot_series(
+ boost::make_transform_iterator(container.begin(), functor),
+ boost::make_transform_iterator(container.end(), functor),
+ title)
+ );
+ return series[series.size()-1];
+ }
 
 }; // end svg_1d_plot
 
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+
 } // namespace svg
 } // namespace boost
 

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -44,7 +44,7 @@
 
     static const double wh = 0.7; // font text width/height ratio.
     // Even after reading http://www.w3.org/TR/SVG/fonts.html, unclear how to
- // determine the exact width of digits, so an
+ // determine the exact width of digits, so an
     // arbitrary average width height ratio wh = 0.7 is used as a good approximation.
 
     static const double sin45 = 0.707; // Use if axis value labels are sloping.
@@ -106,7 +106,6 @@
       } // svg_2d_plot_series
 
       // Set functions for the plot series.
- // TODO get functions for completeness?
       svg_2d_plot_series& fill_color(const svg_color& col_)
       {
         point_style_.fill_color_ = col_;
@@ -143,6 +142,7 @@
         return *this;
       }
 
+ // Get functions for the plot series.
       double line_width()
       {
         return line_style_.width_;
@@ -166,7 +166,7 @@
       }
 
     }; // struct svg_2d_plot_series
-
+
     class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
     { // See also svg_1d_plot.hpp for 1-D version.
      friend void show_plot_settings(svg_2d_plot&);
@@ -238,7 +238,7 @@
       ticks_labels_style y_ticks_;
 
       bool title_on_; // Provide a title for the whole plot.
- bool legend_on_; // Provide a legend box.
+ bool legend_on_; // Provide a legend box.
       bool outside_legend_on_; // legend box outside the plot window.
       bool legend_lines_; // get/set by legend_lines(bool); data colored line type in legend box.
       bool plot_window_on_; // Use a separate plot window (not whole image).
@@ -294,7 +294,7 @@
         legend_width_(200), // width of legend box (pixels) // TODO isn't this calculated?
         legend_height_(0), // height of legend box (pixels)
         legend_left_(-1), legend_right_(-1),legend_top_(-1),legend_bottom_(-1), // Default top left of plot window.
- legend_place_(outside_right), // default but interacts with using plot_window
+ legend_place_(outside_right), // default but interacts with using plot_window.
         legend_on_(false),
         legend_longest_(0),
         outside_legend_on_(true),
@@ -304,7 +304,7 @@
         // Used to transform Cartesian to SVG.
         x_scale_(1.), x_shift_(0.),
         y_scale_(1.), y_shift_(0.),
- x_axis_position_(0), // TODO move into axis_style?
+ x_axis_position_(0), // TODO move into axis_style?
         y_axis_position_(0) // But some problems with this.
       {
         image_size(500, 400); // Default image size for 2-D.
@@ -357,7 +357,7 @@
         image.get_g_element(PLOT_Y_MAJOR_GRID).style().stroke_width(y_ticks_.major_grid_width_).stroke_color(svg_color(200, 220, 255));
         image.get_g_element(PLOT_Y_MINOR_GRID).style().stroke_width(y_ticks_.minor_grid_width_).stroke_color(svg_color(200, 220, 255));
         image.get_g_element(PLOT_DATA_LINES).style().stroke_width(2); // default width.
- // Alter with plot.data_lines_width(4);
+ // Alter with plot.data_lines_width(4);
 
         legend_place_ = (plot_window_on_) ? outside_right : inside; // Defaults.
         // Note if set plot_window_on() then also need to set legend_place.
@@ -367,16 +367,15 @@
         x_ticks_on_ = x_ticks_.up_ticks_on_ || x_ticks_.down_ticks_on_;
         y_ticks_on_ = y_ticks_.left_ticks_on_ || y_ticks_.right_ticks_on_;
 
- // title_info_.style().font_size(20);
       } // svg_2d_plot() default constructor.
 
     private:
       // svg_2d_plot Member Functions.
 
- void set_ids() // TODO is this only used once in constructor and should be inline?
+ void set_ids() // This only used once in constructor and should be inlined.
       { // document ids for use in <g id = "PLOT_TITLE".../>
         for(int i = 0; i < detail::SVG_PLOT_DOC_CHILDREN; ++i)
- {
+ { // Order determines the painting order.
           image.get_g_element(i).id(detail::document_ids[i]);
         }
       } // void set_ids()
@@ -406,8 +405,8 @@
           plot_top_ += title_font_size() * (text_margin_ + 0.5);
         }
 
- size_legend_box(); // depending on its contents.
- place_legend_box();
+ size_legend_box(); // Size depends on its contents.
+ place_legend_box(); // according to options chosen.
        // Assume that axis labels are always at bottom and left.
        if(x_axis_.label_on_)
        { // Leave space at bottom for X axis label.
@@ -438,7 +437,7 @@
         else if(y_axis_.max_ < -std::numeric_limits<double>::min()) // all Y values definitely < zero.
         { // // y_max_ < 0, so X-axis will not intersect Y-axis, so use top plot window.
           x_axis_position_ = top; // X-axis to top of plot window.
- x_ticks_.ticks_on_plot_window_on_ = +1; // top = true;
+ x_ticks_.ticks_on_plot_window_on_ = +1; // top = true;
         }
         // Y axis position is determined by the range of X values.
         y_axis_position_ = y_intersects_x; // Assume Y-axis will intersect X-axis (X range includes zero).
@@ -454,7 +453,7 @@
           y_ticks_.ticks_on_plot_window_on_ = +1; // right = true;
         }
 
- // Calculate the lengths of the longest value labels.
+ // Calculate the number of chars of the longest value labels.
         x_ticks_.longest_label();
         y_ticks_.longest_label();
 
@@ -493,7 +492,7 @@
           // In this case the value labels may overflow the plot window
           // and collide with the axis label!
           // User must change to put value label downward, or on other side of the axis line.
- // using major_value_labels_on(int d)
+ // using major_value_labels_on(int d)
           // to set tick value labels to left (<0), none (==0) or right (>0).
           else
           { // no labels on plot window (may be on mid-plot Y-axis).
@@ -504,7 +503,7 @@
         if (x_ticks_.label_rotation_ == horizontal)
         { // Only 1 char height & 1 space needed if labels are horizontal.
           x_label_length_ = 2 * x_value_label_style_.font_size() * wh; // SVG chars
- }
+ }
         else if ((x_ticks_.label_rotation_ == upward) || (x_ticks_.label_rotation_ == downward))
         { // ! horizontal so will need more than 2 chars worth.
             x_label_length_+= x_ticks_.label_max_chars_ * x_value_label_style_.font_size() * wh; // SVG chars.
@@ -521,7 +520,7 @@
           { // Contract plot window bottom edge up to make space for x value labels on bottom.
             plot_bottom_ -= x_label_length_; // Move up.
           }
- else if ((x_ticks_.ticks_on_plot_window_on_ > 0) //
+ else if ((x_ticks_.ticks_on_plot_window_on_ > 0) //
              && (x_ticks_.major_value_labels_on_ > 0) ) // & x labels to top.
           { // Move top of plot window down to give space for x value labels.
             plot_top_ += x_label_length_; // Move down.
@@ -541,7 +540,7 @@
           plot_bottom_ -= (std::max)(x_ticks_.major_tick_length_, x_ticks_.minor_tick_length_);// Avoid macro max trap!
         }
 
- if (x_axis_.axis_line_on_)
+ if (x_axis_.axis_line_on_)
         { // Want a X-axis line, so check if range includes zero, so axes intersect,
           // and x_axis_ is svg coordinate of Y-axis (usually y = 0).
           // If not fix axis to bottom of the plot window.
@@ -555,15 +554,15 @@
             && !(x_ticks_.ticks_on_plot_window_on_ > 0) ) // & not already at top.
           { // // y_max_ < 0 so X-axis will not intersect Y-axis, so use plot window.
              plot_top_ += x_label_length_; // Move down for labels.
- x_axis_.axis_ = plot_top_; // Put X-axis on top.
+ x_axis_.axis_ = plot_top_; // Put X-axis on top.
           }
           else
           { // y_axis_position_ == y_intersects_x
             // Calculate below after transform is calculated.
           }
- } // if (use_x_axis_line_)
+ } // if (use_x_axis_line_)
 
- if (y_axis_.axis_line_on_)
+ if (y_axis_.axis_line_on_)
         { // Want a Y-axis line, so check if range includes zero, so axes intersect,
           // and y_axis_ is svg coordinate of X-axis (usually x = 0).
           // If not fix axis to left of the plot window
@@ -573,8 +572,8 @@
             y_axis_.axis_ = plot_left_; // Y-axis to left,
             //plot_left_ += 2 * y_label_info_.font_size(); // with a space.
           }
- else if(y_axis_position_ == right)
- {
+ else if(y_axis_position_ == right)
+ {
             y_axis_.axis_ = plot_right_; // Y-axis to right of plot window,
             //plot_right_ -= 2 * y_label_info_.font_size(); // with a space.
           }
@@ -582,7 +581,7 @@
           { // x_axis_position_ == x_intersects_y
             // Calculate below after transform is calculated.
           }
- } // if (use_y_axis_line_)
+ } // if (use_y_axis_line_)
 
         // TODO this can move up to after last change to plot_left ...???
         // Calculate scale and shift factors for transform from Cartesian to plot.
@@ -640,7 +639,7 @@
             { // Draw vertical line holding the ticks on the left of plot window.
               image.get_g_element(detail::PLOT_Y_AXIS).line(plot_left_, plot_top_, plot_left_, plot_bottom_);
             }
- else
+ else
             {// Draw vertical line holding the ticks on the right of plot window.
               image.get_g_element(detail::PLOT_Y_AXIS).line(plot_right_, plot_top_, plot_right_, plot_bottom_);
             }
@@ -747,7 +746,7 @@
         if(y_ticks_.major_grid_on_)
         { // Draw horizontal major grid line.
           if(!plot_window_on_ != 0)
- {
+ {
             if(y_ticks_.major_value_labels_on_ < 0)
             { // Start further right to give space for y axis value label.
               y -= y_value_label_style_.font_size() * text_margin_;
@@ -817,9 +816,9 @@
           if(y_ticks_.ticks_on_plot_window_on_ != 0)
           { // External to plot window style left or right.
             if(y_ticks_.label_rotation_ == horizontal)
- { // Just shift down half a digit to center value digits on tick.
+ { // Just shift down third a digit to center value digits on tick.
               alignment = right_align;
- y += y_value_label_style_.font_size() / 2;
+ y += y_value_label_style_.font_size() * 0.3;
             }
             else if ((y_ticks_.label_rotation_ == upward) || (y_ticks_.label_rotation_ == downward))
             {// Tick value label straight up or down vertically on y axis.
@@ -847,7 +846,7 @@
               image.get_g_element(detail::PLOT_VALUE_LABELS).text(
                 x_left ,
                 y, // Just shift down half a digit to center value digits on tick.
- label.str(),
+ label.str(),
                 y_value_label_style_,
                 alignment, // on the tick ???
                 y_ticks_.label_rotation_);
@@ -866,7 +865,7 @@
         if(y_ticks_.minor_grid_on_)
         { // Draw the minor grid, if wanted.
           if(!plot_window_on_)
- {
+ {
             if(x_axis_.label_on_)
             {
               x_left += y_value_label_style_.font_size() * text_margin_;
@@ -888,12 +887,12 @@
 
         if(y_ticks_.ticks_on_plot_window_on_ < 0)
         { // Put y minor ticks on the plot window border left.
- x_left = plot_left_;
+ x_left = plot_left_;
           x_right = plot_left_;
         }
         else if (y_ticks_.ticks_on_plot_window_on_ > 0)
         { // Put y minor ticks on the plot window border left.
- x_left = plot_right_;
+ x_left = plot_right_;
           x_right = plot_right_;
         }
         else
@@ -1014,13 +1013,13 @@
         if(series.series.size() > 2)
         { // Need >= 3 for a cubic curve (start point, 2 control points, and end point).
           std::multimap<double, double>::const_iterator iter = series.series.begin();
- n_minus_1 = *(iter++); // begin()
+ n_minus_1 = *(iter++); // begin()
           transform_pair(n_minus_1);
           n = *(iter++); // middle
           transform_pair(n);
           path.M(n_minus_1.first, n_minus_1.second); // move m_minus_1, the 1st data point.
 
- double control = 0.1;
+ double control = 0.1;
           //0.2 is a scaling factor that Jake used to define the magnitude of the
           //vector of the current control point to be placed. I was basically
           //taking advantage of the auto-drawing of Bezier curves that exists in
@@ -1032,13 +1031,13 @@
 
           for(; iter != series.series.end(); ++iter)
           {
- n_minus_2 = n_minus_1;
+ n_minus_2 = n_minus_1;
             n_minus_1 = n;
             n = *iter;
             transform_pair(n);
 
             back_vtr.first = ((n_minus_1.first - n.first) + // (x diff - x previous diff) * control
- (n_minus_2.first - n_minus_1.first)) * control;
+ (n_minus_2.first - n_minus_1.first)) * control;
             back_vtr.second = ((n_minus_1.second - n.second) + // y
               (n_minus_2.second - n_minus_1.second)) * control;
 
@@ -1052,7 +1051,7 @@
               n_minus_1.first, n_minus_1.second); // x, y - end point.
           } // for
           // Last point.
- back_vtr.first = 0.;
+ back_vtr.first = 0.;
           back_vtr.second = (n.second - n_minus_1.second) * control;
           path.S(n.first + back_vtr.first, // x
             n.second + back_vtr.second, // y
@@ -1244,7 +1243,7 @@
       }
 
       svg_2d_plot& y_major_labels_on(int cmd)
- {
+ { //< 0 means to left or down (default), 0 (false) means none, > 0 means to right (or top).
         y_ticks_.major_value_labels_on_ = cmd;
         return *this;
       }
@@ -1298,6 +1297,17 @@
         return y_ticks_.value_ioflags_;
       }
 
+ svg_2d_plot& y_labels_strip_e0s(bool cmd)
+ {
+ y_ticks_.strip_e0s_ = cmd;
+ return *this;
+ }
+
+ bool y_labels_strip_e0s()
+ {
+ return y_ticks_.strip_e0s_;
+ }
+
       svg_2d_plot& y_axis_color(const svg_color& col)
       { // Set only stroke color.
         image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color(col);
@@ -1332,7 +1342,7 @@
       }
 
       svg_2d_plot& y_axis_value_color(const svg_color& col)
- {
+ {
         image.get_g_element(detail::PLOT_VALUE_LABELS).style().stroke_color(col);
         return *this;
       }
@@ -1343,7 +1353,7 @@
       }
 
       svg_2d_plot& y_label_width(double width)
- {
+ {
         image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_width(width);
         return *this;
       }
@@ -1547,7 +1557,6 @@
         return y_ticks_.ticks_on_plot_window_on_;
       }
 
-
       svg_2d_plot& y_ticks_left_on(bool cmd)
       {
         y_ticks_.left_ticks_on_ = cmd;
@@ -1627,7 +1636,7 @@
 
       unsigned int y_label_font_size()
       {
- return x_axis_label_style_.font_size();
+ return y_axis_label_style_.font_size();
       }
 
       svg_2d_plot& y_label_weight(std::string s)

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -518,11 +518,67 @@
     bool line_on_;
     bool bezier_on_;
 
- plot_line_style(const svg_color& col = black, const svg_color& acol = true, double width = 2, bool on = true, bool bezier_on = false)
+ plot_line_style(const svg_color& col = black, const svg_color& acol = true, double width = 2, bool line_on = true, bool bezier_on = false)
       :
- color_(col), area_fill_(acol), width_(width), line_on_(on), bezier_on_(bezier_on)
+ color_(col), area_fill_(acol), width_(width), line_on_(line_on), bezier_on_(bezier_on)
     { // Defaults for all private data.
     }
+
+ plot_line_style& width(double w)
+ {
+ width_ = w;
+ return *this;
+ }
+
+ double width()
+ {
+ return width_;
+ }
+
+ plot_line_style& color(const svg_color& f)
+ {
+ color_ = f;
+ return *this;
+ }
+
+ svg_color& color()
+ {
+ return color_;
+ }
+
+ plot_line_style& area_fill(const svg_color& f)
+ {
+ area_fill_ = f;
+ return *this;
+ }
+
+ svg_color& area_fill()
+ {
+ return area_fill_;
+ }
+
+ bool line_on() const
+ {
+ return line_on_;
+ }
+
+ plot_line_style& line_on(bool is)
+ {
+ line_on_ = is;
+ return *this; // Make chainable.
+ }
+
+ bool bezier_on() const
+ {
+ return bezier_on_;
+ }
+
+ plot_line_style& bezier_on(bool is)
+ {
+ bezier_on_ = is;
+ return *this; // Make chainable.
+ }
+
 }; // class plot_line_style
 
 std::ostream& operator<< (std::ostream& os, plot_line_style p)
@@ -680,7 +736,7 @@
     bool major_grid_on_; // Draw X grid at major ticks.
     bool minor_grid_on_;// Draw X grid at minor ticks.
     int value_precision_; // precision for tick value labels, usually 3 will suffice.
- int value_ioflags_; // IO formatting flags for the axis.
+ int value_ioflags_; // IO formatting flags for the axis default std::ios::dec.
     bool strip_e0s_; // If redundant zero, + and e are to be stripped.
     size_t label_max_chars_; // width (in SVG units) of longest label on axis.
     int ticks_on_plot_window_on_; // Value labels & ticks on the plot window border
@@ -871,7 +927,7 @@
     fill_on_(fill_on)
     { // Initializes all private data.
     }
-}; // class axis_line_style
+}; // class box_style
 
 const std::string strip_e0s(std::string s)
 { // Ugly hack to remove unwanted sign and leading zero(s) in exponent.

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -88,6 +88,7 @@
 <dt><span class="section"> svg_1d_plot Public Interface</span></dt>
 <dt><span class="section"> svg_2d_plot Public Interface</span></dt>
 <dt><span class="section"> svg_boxplot Public Interface</span></dt>
+<dt><span class="section"> Show settings Public Interface</span></dt>
 </dl></dd>
 <dt><span class="section"> Implementation & Rationale</span></dt>
 <dt><span class="section"> Acknowledgements</span></dt>
@@ -95,7 +96,7 @@
 </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: January 17, 2008 at 18:41:35 GMT</small></p></td>
+<td align="left"><p><small>Last revised: January 18, 2008 at 09:53:10 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -34,6 +34,7 @@
 <dt><span class="section"> svg_1d_plot Public Interface</span></dt>
 <dt><span class="section"> svg_2d_plot Public Interface</span></dt>
 <dt><span class="section"> svg_boxplot Public Interface</span></dt>
+<dt><span class="section"> Show settings Public Interface</span></dt>
 </dl></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

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 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -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="../implementation.html" title=" Implementation &amp; Rationale">
+<link rel="next" href="settings.html" title=" Show settings Public Interface">
 </head>
 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 <table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
 </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="../implementation.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="settings.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">
@@ -906,7 +906,7 @@
 </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="../implementation.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="settings.html"><img src="../../../../../../../../../../trunk/doc/html/images/next.png" alt="Next"></a>
 </div>
 </body>
 </html>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/interface.qbk
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/interface.qbk (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/interface.qbk 2008-01-18 11:09:57 EST (Fri, 18 Jan 2008)
@@ -357,6 +357,9 @@
 [`boost_default_convert` (default) is sufficient in all cases where the data stored in the container can be directly cast to a double.]]
 ] [/ table Optional Functions]
 [endsect] [/section:svg_2d_plot_interface]
+
+[include settings.qbk]
+
 [endsect] [/section:interface]
 
 [/ interface.qbk


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