Boost logo

Boost-Commit :

From: JakeVoytko_at_[hidden]
Date: 2007-08-12 17:12:44


Author: jakevoytko
Date: 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
New Revision: 38612
URL: http://svn.boost.org/trac/boost/changeset/38612

Log:
Added Boost.SVG_Plot.Boxplot
Added:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp (contents, props changed)
Removed:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 22 +++-----
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 33 ++++++++++++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp | 7 ++
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 16 ------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 77 ++++-----------------------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp | 31 ++++++++++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 11 ++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 92 +++++----------------------------------
   8 files changed, 95 insertions(+), 194 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -388,16 +388,13 @@
 
     void _draw_title()
     {
- if(derived().use_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));
- }
+ 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()
@@ -455,7 +452,6 @@
             case square:
                 g_ptr.rect(_x - half_size, _y - half_size, size, size);
                 break;
- default: break;
         }
     }
 
@@ -777,7 +773,7 @@
     // color information
     svg_color get_title_color()
     {
- return derived().image.get_g_element(PLOT_TITLE).style().fill_color();
+ return derived().image.get_g_element(PLOT_TITLE).style().stroke_color();
     }
 
     svg_color get_background_color()
@@ -812,7 +808,7 @@
 
     svg_color get_x_label_color()
     {
- return derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color();
+ return derived().image.get_g_element(PLOT_X_LABEL).style().fill_color();
     }
 
     svg_color get_x_major_tick_color()

Added: sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -0,0 +1,62 @@
+// 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
+
+namespace boost {
+namespace svg {
+namespace detail {
+
+// -----------------------------------------------------------------
+// This functor allows any data convertible to doubles to be plotted
+// -----------------------------------------------------------------
+class boost_default_convert
+{
+public:
+ typedef double result_type;
+
+ template <class T>
+ double operator()(T val) const
+ {
+ return (double)val;
+ }
+};
+
+// -----------------------------------------------------------------
+// This functor allows any data convertible to type
+// std::pair<double, double> to be plot
+// -----------------------------------------------------------------
+class boost_default_2d_convert
+{
+public:
+ typedef std::pair<double, double> result_type;
+
+ double i;
+
+ void start(double _i)
+ {
+ i = _i;
+ }
+
+ template <class T, class U>
+ std::pair<double, double> operator()(const std::pair<T, U>& a) const
+ {
+ return std::pair<double, double>((double)(a.first), (double)(a.second));
+ }
+
+ template <class T>
+ std::pair<double, double> operator()(T a)
+ {
+ return std::pair<double, double>(i++, (double)a);
+ }
+};
+
+}
+}
+}
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_boxplot_detail.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -0,0 +1,24 @@
+// 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
+// -----------------------------------------------------------------
+
+#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,
+ 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};
+
+}
+}
+}
+
+#endif

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

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -168,6 +168,7 @@
     int size;
     std::string txt;
     text_style align;
+ int rotation;
 
 public:
     void alignment(text_style _a)
@@ -175,11 +176,21 @@
         align = _a;
     }
 
- int font_size()
+ int font_size() const
     {
         return size;
     }
 
+ void rotate(int val)
+ {
+ rotation = val;
+ }
+
+ int rotate() const
+ {
+ return rotation;
+ }
+
     double x(double _x)
     {
         x_coord = _x;
@@ -191,8 +202,9 @@
     }
 
     text_element(double _x, double _y, std::string _text, int _size = 12,
- text_style _align = center_align)
+ text_style _align = center_align, int _rotation = 0)
                  :x_coord(_x), y_coord(_y), txt(_text), size(_size), align(_align)
+ , rotation(_rotation)
     {
         
     }
@@ -228,6 +240,14 @@
             rhs << "text-anchor=\"" << output << "\" ";
         }
 
+ if(rotation != 0)
+ {
+ rhs << "transform = \"rotate("
+ << rotation << " "
+ << x_coord << " "
+ << y_coord << " )\" ";
+ }
+
         rhs << " font-family=\"verdana\"";
 
         if(size == 0)
@@ -244,7 +264,7 @@
             <<" </text>";
     }
 
- void font_size(unsigned int _size){ size = _size; }
+ void font_size(unsigned int _size) { size = _size; }
     void text(const std::string& _txt) { txt = _txt; }
 
     std::string text()
@@ -731,9 +751,12 @@
         return *this;
     }
 
- g_element& text(double x, double y, std::string text)
+ g_element& text(double x, double y, const std::string& text,
+ int text_size = 12,
+ text_style align = center_align, int rotation = 0)
     {
- children.push_back(new text_element(x, y, text));
+ children.push_back(new text_element(x, y, text, text_size,
+ align, rotation));
         return *this;
     }
 

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-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -136,9 +136,12 @@
     // -----------------------------------------------------------------
     // Writes the information about text to the document
     // -----------------------------------------------------------------
- svg& text(double x, double y, std::string text)
+ 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));
+ document.push_back(new text_element(x, y, text, text_size, align,
+ rotation));
 
         return *this;
     }

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -32,6 +32,7 @@
 #include "svg.hpp"
 #include "svg_style.hpp"
 #include "detail/axis_plot_frame.hpp"
+#include "detail/functors.hpp"
 
 #if defined (BOOST_MSVC)
 # pragma warning(pop)
@@ -77,20 +78,7 @@
 # pragma warning(pop)
 #endif
 
-// -----------------------------------------------------------------
-// This functor allows any data convertible to doubles to be plotted
-// -----------------------------------------------------------------
-class boost_default_convert
-{
-public:
- typedef double result_type;
 
- template <class T>
- double operator()(T val) const
- {
- return (double)val;
- }
-};
 
 // -----------------------------------------------------------------
 // This allows us to store plot state locally in svg_plot. We don't
@@ -429,7 +417,7 @@
         (stroke_color, (const svg_color&), svg_color(white))
         (point_style, (point_shape), circle)
         (size, (int), 10)
- (x_functor, *, boost_default_convert())
+ (x_functor, *, detail::boost_default_convert())
     )
     (deduced
         (optional

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-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -28,6 +28,7 @@
 #include "svg_style.hpp"
 #include "detail/axis_plot_frame.hpp"
 #include "detail/numeric_limits_handling.hpp"
+#include "detail/functors.hpp"
 #include "svg.hpp"
 
 #if defined (BOOST_MSVC)
@@ -65,31 +66,6 @@
 BOOST_PARAMETER_NAME(line_color)
 BOOST_PARAMETER_NAME(area_fill_color)
 
-class boost_default_2d_convert
-{
-public:
- typedef std::pair<double, double> result_type;
-
- double i;
-
- void start(double _i)
- {
- i = _i;
- }
-
- template <class T, class U>
- std::pair<double, double> operator()(const std::pair<T, U>& a) const
- {
- return std::pair<double, double>((double)(a.first), (double)(a.second));
- }
-
- template <class T>
- std::pair<double, double> operator()(T a)
- {
- return std::pair<double, double>(i++, (double)a);
- }
-};
-
 struct svg_2d_plot_series
 {
     std::multimap<double, double> series;
@@ -604,22 +580,18 @@
 
     void _draw_plot_lines()
     {
-
         for(unsigned int i = 0; i < series.size(); ++i)
- {
- if(series[i].line_style.line_on)
+ {
+ if(series[i].line_style.bezier_on)
             {
- if(series[i].line_style.bezier_on)
- {
- _draw_bezier_lines(series[i]);
- }
+ _draw_bezier_lines(series[i]);
+ }
 
- else
- {
- _draw_straight_lines(series[i]);
- }
+ else
+ {
+ _draw_straight_lines(series[i]);
             }
- }
+ }
     }
 
     void _update_image()
@@ -946,35 +918,6 @@
     return *this;
 }
 
-svg_color get_y_axis_color()
-{
- return image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_color();
-}
-
-svg_color get_y_label_color()
-{
- return image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color();
-}
-
-svg_color get_y_major_tick_color()
-{
- return image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color();
-}
-
-svg_color get_y_minor_tick_color()
-{
- return image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color();
-}
-
-svg_color get_y_major_grid_color()
-{
- return image.get_g_element(detail::PLOT_Y_MAJOR_GRID).style().stroke_color();
-}
-
-svg_color get_y_minor_grid_color()
-{
- return image.get_g_element(detail::PLOT_Y_MINOR_GRID).style().stroke_color();
-}
 #if defined (BOOST_MSVC)
 # pragma warning(push)
 # pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
@@ -998,7 +941,7 @@
         (size, (int), 10)
         (line_on, (bool), true)
         (bezier_on, (bool), false)
- (x_functor, *, boost_default_2d_convert())
+ (x_functor, *, detail::boost_default_2d_convert())
     )
 )
 {

Added: sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -0,0 +1,951 @@
+// 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
+// -----------------------------------------------------------------
+
+#ifndef _BOOST_SVG_SVG_BOXPLOT_HPP
+#define _BOOST_SVG_SVG_BOXPLOT_HPP
+
+#define BOOST_PARAMETER_MAX_ARITY 12
+
+#include <boost/iterator/transform_iterator.hpp>
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4512) // "assignment operator could not be generated."
+# pragma warning(disable: 4127) // "conditional expression is constant."
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+#include <boost/parameter/preprocessor.hpp>
+#include <boost/parameter/name.hpp>
+
+#include "svg_style.hpp"
+#include "detail/numeric_limits_handling.hpp"
+#include "detail/svg_boxplot_detail.hpp"
+#include "detail/functors.hpp"
+#include "svg.hpp"
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+#include <vector>
+#include <string>
+#include <ostream>
+#include <algorithm>
+#include <iterator>
+#include <exception>
+
+
+namespace boost {
+namespace svg {
+
+BOOST_PARAMETER_NAME((box_style, keyword) box);
+BOOST_PARAMETER_NAME((median_style, keyword) median);
+BOOST_PARAMETER_NAME((axis_style, keyword) axis);
+BOOST_PARAMETER_NAME((min_whisker_style, keyword) min_whisker);
+BOOST_PARAMETER_NAME((max_whisker_style, keyword) max_whisker);
+BOOST_PARAMETER_NAME((mild_outlier_style, keyword) mild_outlier);
+BOOST_PARAMETER_NAME((ext_outlier_style, keyword) ext_outlier);
+BOOST_PARAMETER_NAME((whisker_length, keyword) whisker);
+BOOST_PARAMETER_NAME((box_width, keyword) width);
+BOOST_PARAMETER_NAME((functor, keyword) fnctr);
+BOOST_PARAMETER_NAME((ctr, keyword) container);
+BOOST_PARAMETER_NAME((name, keyword) title);
+
+struct svg_boxplot_series
+{
+ double whisker_min, whisker_max, q1, q3, median;
+ std::vector<double> outliers, extreme_outliers;
+ std::string title;
+
+ unsigned int whisker_length, box_width;
+
+ svg_style box_style, median_style, axis_style,
+ min_whisker_style, max_whisker_style;
+
+ plot_point_style mild_outlier, 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)
+ {
+ //std::vector used for fast lookups of quartile values.
+ std::vector<double> data(_begin, _end);
+
+ if(data.empty())
+ {
+ throw std::runtime_error("Empty dataset");
+ }
+
+ std::sort(data.begin(), data.end());
+
+ size_t data_size = data.size();
+
+ // Pth quartile in n numbers is P(n+1)/100, rounded
+ // to the nearest integer.
+ q1 = data[(unsigned int)((data_size + 1) / 4. + 1)];
+ median = data[(unsigned int)((data_size + 1) / 2. + 1)];
+ q3 = data[(unsigned int)(3*(data_size + 1) / 4. + 1)];
+
+ double iqr(q3-q1);
+
+ double min_ext_cutoff = q1 - 3. * iqr;
+ double min_cutoff = q1 - 1.5 * iqr;
+ double max_ext_cutoff = q3 + 3. * iqr;
+ double max_cutoff = q3 + 1.5 * iqr;
+
+ std::vector<double>::const_iterator i;
+
+ for(i = data.begin(); *i < min_cutoff; ++i)
+ {
+ if(*i < min_ext_cutoff)
+ {
+ extreme_outliers.push_back(*i);
+ }
+
+ else if(*i < min_cutoff)
+ {
+ outliers.push_back(*i);
+ }
+ }
+
+ 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;
+ }
+};
+
+class svg_boxplot
+{
+private:
+ // Stored so as to avoid rewriting style information constantly.
+ svg image;
+
+ double y_scale, y_shift;
+
+ text_element title_info;
+ text_element x_label_info;
+ text_element y_label_info;
+
+ // Border information for the plot window.
+ int plot_x1;
+ int plot_x2;
+ int plot_y1;
+ int plot_y2;
+
+
+ // Yes/no questions
+ bool use_x_label;
+ 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
+ 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;
+
+ void _clear_all()
+ {
+ // TODO, fill
+ }
+
+ void _transform_y(double& y)
+ {
+ y = y * y_scale + y_shift;
+ }
+
+ 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 x2(plot_x1 - y_tick_length / 2.);
+
+ _transform_y(y1);
+
+ tick_path.M(x1, y1).L(x2, y1);
+ }
+
+
+ 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());
+
+ //draw major tick
+ x1=i;
+
+ y1 = plot_y2;
+ y2 = plot_y2 + x_major_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);
+ }
+ }
+
+ void _draw_y_major_ticks(double i, path_element& tick_path)
+ {
+ double y1(i), x1(0.), x2(image.get_y_size());
+
+ //draw major tick
+ y1=i;
+
+ _transform_y(y1);
+
+ double y_tick_length = y_major_length / 2.;
+
+ x1 = plot_x1;
+ 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;
+
+ x1 -= y_major_length;
+
+ image.get_g_element(boxplot::PLOT_LABELS).text(x1 + 12,
+ y1, fmt.str(), 12, center_align, -90);
+ }
+ }
+
+ void _draw_y_axis()
+ {
+ path_element& minor_tick_path =
+ image.get_g_element(boxplot::Y_MINOR_TICKS).path();
+
+ path_element& major_tick_path =
+ 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.) );
+
+ // 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);
+ }
+
+ _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))
+ {
+ _draw_y_minor_ticks(j, minor_tick_path);
+ }
+
+ _draw_y_major_ticks(i, major_tick_path);
+ }
+ }
+
+ void _draw_x_axis()
+ {
+ double y1(0.);
+
+ // draw the axis line
+ _transform_y(y1);
+
+ x_axis = y1;
+
+ path_element& major_tick_path =
+ image.get_g_element(boxplot::X_TICKS).path();
+
+ // draw the ticks on the positive side
+ for(size_t i = 0; i < series.size(); ++i)
+ {
+ _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()
+ {
+ _draw_y_axis();
+ _draw_x_axis();
+ }
+
+ void _draw_title()
+ {
+ text_element title(image.get_x_size()/2.,
+ title_info.font_size(),
+ title_info.text());
+
+ title.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()
+ {
+ text_element to_use((plot_x2 + plot_x1) / 2.,
+ image.get_y_size() - 8, x_label_info.text());
+
+ to_use.font_size(12);
+ to_use.alignment(center_align);
+
+ image.get_g_element(boxplot::X_LABEL).push_back(new text_element(to_use));
+ }
+
+ 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));
+ }
+
+
+ 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()
+ {
+ 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() * 2);
+ }
+
+ if(use_y_label)
+ {
+ plot_x1 += (int)(y_label_info.font_size() * 1.5);
+ }
+
+ if(use_title)
+ {
+ plot_y1 += (int)(title_info.font_size() * 1.5);
+ }
+
+ // give the plot window a natural bit of padding
+ plot_x1+=5;
+ plot_x2-=5;
+ plot_y1+=5;
+ plot_y2-=5;
+
+ plot_x1 +=
+ y_major_length > y_minor_length ?
+ y_major_length :
+ y_minor_length ;
+
+ plot_y2 -= x_major_length + 10;
+
+ image.get_g_element(boxplot::PLOT_BACKGROUND).push_back(
+ new rect_element(plot_x1, plot_y1,
+ (plot_x2-plot_x1), plot_y2-plot_y1));
+
+ }
+
+ 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();
+
+ // Set colors for whiskers.
+ g_whisk_ptr.add_g_element().style()
+ .stroke_color(min_whisker.stroke_color())
+ .fill_color(min_whisker.fill_color())
+ .stroke_width(min_whisker.stroke_width());
+
+ g_whisk_ptr.add_g_element().style()
+ .stroke_color(max_whisker.stroke_color())
+ .fill_color(max_whisker.fill_color())
+ .stroke_width(max_whisker.stroke_width());
+
+ // Set axis structure and colors.
+ g_element& g_axis_ptr = image.get_g_element(boxplot::BOX_AXIS)
+ .add_g_element();
+
+ g_axis_ptr.style()
+ .stroke_color(axis_whisker.stroke_color())
+ .fill_color(axis_whisker.fill_color())
+ .stroke_width(axis_whisker.stroke_width());
+
+ _transform_y(min);
+ _transform_y(max);
+
+ double half_length = length / 2.;
+
+ g_whisk_ptr.get_g_element(0)
+ .line(x-half_length, min, x+half_length, min);
+
+ g_whisk_ptr.get_g_element(1)
+ .line(x-half_length, max, x+half_length, max);
+
+ g_axis_ptr.line(x, min, x, max);
+
+ // Clip elements.
+ g_axis_ptr.clip_id(plot_window_clip);
+ g_whisk_ptr.clip_id(plot_window_clip);
+ }
+
+ 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)
+ .add_g_element();
+
+ g_ptr.style().stroke_color(box_style.stroke_color())
+ .stroke_width(box_style.stroke_width())
+ .fill_color(box_style.fill_color());
+
+ _transform_y(q1); _transform_y(q3);
+
+ double half_width = width/2;
+
+ g_ptr.rect(x - half_width, q3, width, q1 - q3);
+
+ // Clip elements.
+ g_ptr.clip_id(plot_window_clip);
+ }
+
+ void _draw_median(double median, double x_offset, double box_width,
+ const svg_style& median_style)
+ {
+ _transform_y(median);
+
+ g_element& g_ptr = image.get_g_element(boxplot::MEDIAN)
+ .add_g_element();
+
+ g_ptr.style().stroke_color(median_style.stroke_color())
+ .stroke_width(median_style.stroke_width());
+
+ double half_width = box_width / 2.;
+
+ g_ptr.line(x_offset - half_width, median,
+ x_offset + half_width, median);
+
+ // Clip elements.
+ g_ptr.clip_id(plot_window_clip);
+ }
+
+ 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)
+ {
+ std::vector<double>::const_iterator i;
+ double temp;
+
+ g_element& g_mild_ptr = image.get_g_element(boxplot::MILD_OUTLIERS)
+ .add_g_element();
+ g_element& g_ext_ptr = image.get_g_element(boxplot::EXTREME_OUTLIERS)
+ .add_g_element();
+
+ g_mild_ptr.style().fill_color(mild_style.fill_color)
+ .stroke_color(mild_style.stroke_color);
+
+ g_ext_ptr.style().fill_color(extreme_style.fill_color)
+ .stroke_color(extreme_style.stroke_color);
+
+ for(i = outliers.begin(); i != outliers.end(); ++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);
+ g_ext_ptr.circle(x, temp, 2);
+ }
+
+ // Clip elements.
+ g_mild_ptr.clip_id(plot_window_clip);
+ g_ext_ptr.clip_id(plot_window_clip);
+ }
+
+ void _draw_boxplot(const svg_boxplot_series& series, double x_offset)
+ {
+ _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,
+ series.box_style);
+
+ _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,
+ series.mild_outlier, series.ext_outlier);
+ }
+
+ void _update_image()
+ {
+ _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()));
+
+ _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);
+
+ _draw_y_axis();
+ _draw_x_axis();
+
+ if(use_x_label)
+ {
+ _draw_x_label();
+ }
+
+ if(use_y_label)
+ {
+ _draw_y_label();
+ }
+
+ for(unsigned int i=0; i<series.size(); ++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),
+ 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"),
+ use_x_major_labels(true),
+ use_title(true), use_y_major_labels(true)
+
+{
+ image.image_size(500, 350);
+
+ //Build the document tree.. add children of the root node
+ for(int i=0; i<boxplot::BOXPLOT_DOC_CHILDREN; ++i)
+ {
+ image.add_g_element();
+ }
+
+ // set 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::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);
+ image.get_g_element(boxplot::WHISKER).style().stroke_color(black);
+ image.get_g_element(boxplot::BOX_AXIS).style().stroke_color(black);
+ image.get_g_element(boxplot::BOX).style().stroke_color(black).fill_color(white);
+ image.get_g_element(boxplot::MEDIAN).style().stroke_color(black).stroke_width(2);
+ image.get_g_element(boxplot::EXTREME_OUTLIERS).style().stroke_color(black).fill_color(white);
+ image.get_g_element(boxplot::MILD_OUTLIERS).style().stroke_color(black).fill_color(black);
+}
+
+
+svg_boxplot& write(const std::string& _str)
+{
+ std::ofstream fout(_str.c_str());
+
+ if(fout.fail())
+ {
+ throw std::runtime_error("Unable to open "+_str);
+ }
+
+ write(fout);
+
+ return *this;
+}
+
+svg_boxplot& write(std::ostream& s_out)
+{
+ _update_image();
+
+ image.write(s_out);
+
+ return *this;
+}
+
+svg_boxplot& y_label_on(bool _cmd)
+{
+ use_y_label = _cmd;
+ return *this;
+}
+
+svg_boxplot& y_major_labels_on(bool _cmd)
+{
+ use_y_major_labels = _cmd;
+ return *this;
+}
+
+svg_boxplot& y_major_tick_color(const svg_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)
+{
+ image.get_g_element(boxplot::X_TICKS).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& y_minor_tick_color(const svg_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)
+{
+ image.get_g_element(boxplot::TITLE).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& background_color(const svg_color& _col)
+{
+ image.get_g_element(boxplot::BACKGROUND).style().fill_color(_col);
+ return *this;
+}
+
+svg_boxplot& background_border_color(const svg_color& _col)
+{
+ image.get_g_element(boxplot::BACKGROUND).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& plot_background_color(const svg_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)
+{
+ image.get_g_element(boxplot::PLOT_BACKGROUND).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& 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");
+ }
+
+ return *this;
+}
+
+svg_boxplot& y_label(const std::string& _str)
+{
+ y_label_info.text(_str);
+ return *this;
+}
+
+svg_boxplot& y_label_size(unsigned int _size)
+{
+ y_label_info.font_size(_size);
+ return *this;
+}
+
+svg_boxplot& y_label_color(const svg_color& _col)
+{
+ image.get_g_element(boxplot::Y_LABEL).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& title(const std::string& _str)
+{
+ y_label_info.text(_str);
+ return *this;
+}
+
+svg_boxplot& title_size(unsigned int _size)
+{
+ y_label_info.font_size(_size);
+ return *this;
+}
+
+svg_boxplot& x_label(const std::string& _str)
+{
+ x_label_info.text(_str);
+ return *this;
+}
+
+svg_boxplot& x_label_size(unsigned int _size)
+{
+ x_label_info.font_size(_size);
+ return *this;
+}
+
+svg_boxplot& x_label_color(const svg_color& _col)
+{
+ image.get_g_element(boxplot::X_LABEL).style().stroke_color(_col);
+ return *this;
+}
+
+svg_boxplot& y_major_interval(double _inter)
+{
+ y_major = _inter;
+
+ return *this;
+}
+
+svg_boxplot& x_tick_length(unsigned int _length)
+{
+ x_major_length = _length;
+ return *this;
+}
+
+svg_boxplot& y_major_tick_length(unsigned int _length)
+{
+ y_major_length = _length;
+ return *this;
+}
+
+svg_boxplot& y_minor_tick_length(unsigned int _length)
+{
+ y_minor_length = _length;
+ return *this;
+}
+
+svg_boxplot& y_num_minor_ticks(unsigned int _num)
+{
+ y_num_minor = _num;
+ return *this;
+}
+
+svg_boxplot& x_tick_width(unsigned int _width)
+{
+ image.get_g_element(boxplot::X_TICKS).style().stroke_width(_width);
+
+ return *this;
+}
+
+svg_boxplot& y_major_tick_width(unsigned int _width)
+{
+ image.get_g_element(boxplot::Y_MAJOR_TICKS).style().stroke_width(_width);
+
+ return *this;
+}
+
+svg_boxplot& y_minor_tick_width(unsigned int _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 get_image_y_size()
+{
+ return image.get_x_size();
+}
+
+std::string get_title()
+{
+ return title_info.text();
+}
+
+bool get_x_label()
+{
+ return use_x_label;
+}
+
+bool get_x_major_labels()
+{
+ return use_x_major_labels;
+}
+
+// color information
+svg_color get_title_color()
+{
+ return image.get_g_element(boxplot::TITLE).style().stroke_color();
+}
+
+svg_color get_background_color()
+{
+ return image.get_g_element(boxplot::BACKGROUND).style().fill_color();
+}
+
+svg_color get_background_border_color()
+{
+ return image.get_g_element(boxplot::BACKGROUND).style().stroke_color();
+}
+
+svg_color get_plot_background_color()
+{
+ return image.get_g_element(boxplot::PLOT_BACKGROUND).style().fill_color();
+}
+
+svg_color get_x_label_color()
+{
+ return image.get_g_element(boxplot::X_LABEL).style().stroke_color();
+}
+
+svg_color get_x_tick_color()
+{
+ return image.get_g_element(boxplot::X_TICKS).style().stroke_color();
+}
+
+unsigned int get_x_tick_length()
+{
+ return x_major_length;
+}
+
+unsigned int get_x_major_tick_width()
+{
+ return image.get_g_element(boxplot::X_TICKS).style().stroke_width();
+}
+
+std::string get_x_label_text()
+{
+ return x_label_info.text();
+}
+
+svg& get_svg()
+{
+ _update_image();
+
+ return image;
+}
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+BOOST_PARAMETER_MEMBER_FUNCTION
+(
+ (void),
+ plot,
+ keyword,
+ (required
+ (container, *)
+ (title, (const std::string&))
+ )
+ (optional
+ (box, (const svg_style&), svg_style(white, black, 1))
+ (median, (const svg_style&), svg_style(white, black, 1))
+ (axis, (const svg_style&), svg_style(white, black, 1))
+ (min_whisker, (const svg_style&), svg_style(white, black, 1))
+ (max_whisker, (const svg_style&), svg_style(white, black, 1))
+ (mild_outlier, (const plot_point_style&), plot_point_style(black, black, 0))
+ (ext_outlier, (const plot_point_style&), plot_point_style(white, black, 1))
+ (whisker, (unsigned int), 30)
+ (width, (unsigned int), 60)
+ (fnctr, *, detail::boost_default_convert())
+ )
+)
+{
+ series.push_back(
+ svg_boxplot_series(
+ boost::make_transform_iterator(container.begin(), fnctr),
+ boost::make_transform_iterator(container.end(), fnctr), title,
+ whisker, width, box, median, axis, min_whisker, max_whisker, mild_outlier,
+ ext_outlier
+ ));
+}
+};
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+
+}
+}
+
+#endif

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-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -68,8 +68,9 @@
 struct svg_color
 {
     unsigned char r, g, b;
+ bool blank;
 
- svg_color(int _r, int _g, int _b)
+ svg_color(int _r, int _g, int _b): blank(false)
     {
         _r = ( _r < 0 ) ? 0 : _r;
         _g = ( _g < 0 ) ? 0 : _g;
@@ -80,15 +81,27 @@
         b = (unsigned char)(( _b > 255 ) ? 255 : _b);
     }
 
- svg_color(svg_color_constant _col)
+ svg_color(bool _is):blank(_is)
+ {
+ }
+
+ svg_color(svg_color_constant _col):blank(false)
     {
         constant_to_rgb(_col, r, g, b);
     }
 
     void write(std::ostream& rhs)
     {
- rhs << "rgb(" << (unsigned int)r << "," << (unsigned int) g << ","
- << (unsigned int)b << ")" ;
+ if(!blank)
+ {
+ rhs << "rgb(" << (unsigned int)r << "," << (unsigned int) g << ","
+ << (unsigned int)b << ")" ;
+ }
+
+ else
+ {
+ rhs <<"none";
+ }
     }
 
     bool operator==(const svg_color& rhs)
@@ -247,6 +260,7 @@
     svg_color(245, 245, 245), // whitesmoke
     svg_color(255, 255, 0 ), // yellow
     svg_color(154, 205, 50 ), // yellowgreen
+ svg_color(false) // blank
 };
 
 void constant_to_rgb(svg_color_constant _c, unsigned char &r,
@@ -254,9 +268,12 @@
 {
     svg_color temp(color_array[_c]);
 
- r = temp.r;
- g = temp.g;
- b = temp.b;
+ if(!temp.blank)
+ {
+ r = temp.r;
+ g = temp.g;
+ b = temp.b;
+ }
 }
 
 svg_color constant_to_rgb(svg_color_constant _c)

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-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -72,6 +72,11 @@
 
     }
 
+ // 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; }
+
     svg_style(const svg_color& _fill, const svg_color& _stroke,
                      unsigned int _width = 0):
                      fill(_fill), stroke(_stroke),
@@ -102,12 +107,6 @@
         width_on = true;
         return *this;
     }
-
- // getters
- svg_color fill_color() { return svg_color(fill); }
- svg_color stroke_color() { return svg_color(stroke); }
- unsigned int stroke_width() { return width; }
-
     
     void write(std::ostream& rhs)
     {

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp 2007-08-12 17:12:05 EDT (Sun, 12 Aug 2007)
@@ -1,103 +1,35 @@
-#include "svg_1d_plot.hpp"
-#include "svg_2d_plot.hpp"
+#include "svg_boxplot.hpp"
 
 #include <vector>
 #include <cmath>
-#include <map>
-#include <limits>
 
 using std::multimap;
 using std::vector;
 
-double f(double x)
-{
- return sin(x);
-}
-
-double g(double x)
-{
- return 2*cos(x);
-}
-
 double h(double x)
 {
- return tan(x);
+ return 50 / (x);
 }
 
-class dConvert
-{
-public:
- typedef double result_type;
-
- double operator()(int a) const
- {
- return (double)a;
- }
-};
-
 int main()
 {
     using namespace boost::svg;
- std::map<double, double> data1;
- std::map<double, double> data2;
- std::vector<double> data3;
-
- svg_2d_plot my_2d_plot;
- svg_1d_plot my_1d_plot;
-
- double pi = 3.1415926535;
+ std::vector<double> data;
 
- data2[.5] = std::numeric_limits<double>::max();
- data2[1.3] = std::numeric_limits<double>::infinity();
- data2[2] = std::numeric_limits<double>::quiet_NaN();
+ svg_boxplot my_plot;
 
- for(double i=0; i<10; i+=pi/8.)
+ my_plot.background_border_color(black)
+ .y_range(0, 150)
+ .y_major_interval(20);
+
+ for(double i=.1; i < 10; i+=.1)
     {
- data2[i] = g(i);
+ data.push_back(h(i));
     }
 
- // size/scale settings
- my_2d_plot.image_size(500, 350);
-
- my_2d_plot.title("Hello, operator")
- .plot_window_on(true);
-
- my_2d_plot.title_on(true)
- .x_label_on(true)
- .y_major_labels_on(true)
- .x_label("sqrt(x)")
- .x_major_grid_on(false)
- .y_range(-1.1, 1.1)
- .x_range(-.5, 10.5)
- .y_major_interval(1)
- .x_major_interval(pi/2.);
-// .y_external_style_on(true)
-// .x_external_style_on(true);
-
- my_1d_plot.image_size(500, 350);
-
- my_1d_plot.title("Hello, operator")
- .plot_window_on(true)
- .legend_on(true);
-
- my_1d_plot.title_on(true)
- .x_label_on(true)
- .x_label("sqrt(x)");
-
- //my_2d_plot.plot(data1, "sqrt(x)", _bezier_on = true, _size = 5);
-
- my_2d_plot.plot(data2, "Not sqrt(x)",
- _area_fill_color = orange,
- _size = 6,
- _point_style = square,
- _stroke_color = hotpink,
- _line_color = black,
- _fill_color = yellow);
-
-// my_2d_plot.plot(data3, "1D Plot", _bezier_on = true, _size = 5);
+ my_plot.plot(data, "50 / (x)");
 
- my_1d_plot.write("./test1d.svg");
- my_2d_plot.write("./test2d.svg");
+ my_plot.write("D:\\test2d.svg");
 
     return 0;
 }


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