Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51936 - in sandbox/SOC/2007/visualization: boost/svg_plot boost/svg_plot/detail libs/svg_plot/doc libs/svg_plot/doc/html libs/svg_plot/example
From: pbristow_at_[hidden]
Date: 2009-03-23 11:07:53


Author: pbristow
Date: 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
New Revision: 51936
URL: http://svn.boost.org/trac/boost/changeset/51936

Log:
Unc now working with autoscale, but does not allow room on axes for 3 sd ellipse.
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/auto_axes.hpp | 48 +++---
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 89 +++++++++++--
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp | 9 +
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp | 8
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 14 +
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 12 +
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp | 262 +++++++++++++++++++++++----------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_fwd.hpp | 2
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 4
   sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp | 248 +++++++++++++++++++++++++------------
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 | 12 +
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/doxywarn.log | 2
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html | 4
   sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp | 58 +++++---
   sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_color.cpp | 29 +--
   sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_svg.cpp | 7
   16 files changed, 518 insertions(+), 290 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/auto_axes.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/auto_axes.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/auto_axes.hpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -108,6 +108,7 @@
     Similar to boost::minmax_element, but ignoring at 'limit': non-finite, +-infinity, max & min, & NaN).
     If can't find a max and a min, then throw a runtime_error exception.
     \tparam iter STL container iterator.
+ \return number of normal values (not NaN nor infinite).
   */
   *max = std::numeric_limits<double>::quiet_NaN();
   *min = std::numeric_limits<double>::quiet_NaN();
@@ -115,8 +116,8 @@
   int goods = 0; // Count of values within limits.
   int limits = 0;
   iter pos = begin;
- while(pos != end && is_limit(*pos))
- { // Count any limits before the first good.
+ while(pos != end && is_limit(value_of(*pos)))
+ { // Count any limits before the first 'good' (FP normal) value.
     limits++;
     pos++;
   }
@@ -128,7 +129,7 @@
   }
   else
   {
- double x = *pos;
+ double x = value_of(*pos);
     *max = x;
     *min = x;
     //cout << "Initial min & max " << x << endl;
@@ -136,9 +137,9 @@
     goods++;
     while(pos != end)
     {
- if (!is_limit(*pos))
+ if (!is_limit(value_of(*pos)))
       { // x is finite.
- x = *pos;
+ x = value_of(*pos);
         if (x > *max)
         {
           *max = x;
@@ -172,7 +173,7 @@
 void scale_axis(
    double min_value, //! Minimum value.
    double max_value, //! Maximum value.
- double* axis_min_value, double* axis_max_value, double* axis_tick_increment, int* auto_ticks, // All 4 updated.
+ double* axis_min_value, double* axis_max_value, double* axis_tick_increment, int* auto_ticks, //! All 4 updated.
    bool check_limits, //! Whether to check all values for infinity, NaN etc.
    bool origin, //! If true, ensures that zero is a tick value.
    double tight, //! Allows user to avoid a small fraction over a tick using another tick.
@@ -200,7 +201,7 @@
    int min_ticks = 6, // Minimum number of major ticks.
    int steps = 0) // 0, or 2 for 2, 4, 6, 8, 10, 5 for 1, 5, 10, or 10 (2, 5, 10).
 {
- void scale_axis(double min_value, double max_value, // Input range.
+ void scale_axis(double min_value, double max_value, // Input range.
                double* axis_min_value, double* axis_max_value, double* axis_tick_increment, int* auto_ticks, // All 4 updated.
                bool origin, // If true, ensures that zero is a tick value.
                double tight, // Allows user to avoid a small fraction over a tick using another tick.
@@ -253,8 +254,8 @@
     // minmax_element is efficient because can use knowledge of being sorted,
     // BUT only if it can be assumed that no values are 'at limits',
     // infinity, NaN, max_value, min_value, denorm_min.
- x_min = *(result.first);
- x_max = *(result.second);
+ x_min = value_of(*(result.first));
+ x_max = value_of(*(result.second));
   }
   else
   { // It is necessary to inspect all values individually.
@@ -277,7 +278,8 @@
 template <class T>
 void scale_axis( //! Scale X and Y axis using T a 2D STL container: array, vector ...
   const T& container, //! Container Data series to plot - entire 2D container.
- // (not necessarily ordered, so will find min and max).
+ //! (not necessarily ordered, so will find min and max).
+ //! \tparam T STL container of pairs of X and Y.
   double* x_axis_min_value, double* x_axis_max_value, double* x_axis_tick_increment, int* x_auto_ticks,
   double* y_axis_min_value, double* y_axis_max_value, double* y_axis_tick_increment, int* y_auto_ticks,
   // All 8 updated.
@@ -288,7 +290,6 @@
   // allowing values just 1 pixel over the tick to be shown.
   int x_min_ticks = 6, // Minimum number of major ticks.
   int x_steps = 0, // 0, or 2 for 2, 4, 6, 8, 10, 5 for 1, 5, 10, or 10 (2, 5, 10).
-
   bool y_origin = false, // do not include the origin unless the range min_value <= 0 <= max_value.
   double y_tight = 0., // tightest - fraction of 'overrun' allowed before another tick used.
   // for visual effect up to about 0.001 might suit a 1000 pixel wide image,
@@ -296,7 +297,6 @@
   int y_min_ticks = 6, // Minimum number of major ticks.
   int y_steps = 0) // 0, or 2 for 2, 4, 6, 8, 10, 5 for 1, 5, 10, or 10 (2, 5, 10).
 {
- typedef T::const_iterator iter;
   double x_max = std::numeric_limits<double>::quiet_NaN();
   double x_min = std::numeric_limits<double>::quiet_NaN();
   double y_max = std::numeric_limits<double>::quiet_NaN();
@@ -305,10 +305,12 @@
   if (!check_limits)
   { // BUT only if it can be assumed that no values are 'at limits',
     // infinity, NaN, max_value, min_value, denorm_min.
- // minmax_element is efficient for maps because can use knowledge of being sorted,
- std::pair<iter, iter> result = boost::minmax_element(container.begin(), container.end());
- pair<const double, double> px = *result.first; // x min & max
- pair<const double, double> py = *result.second; // y min & max
+ // minmax_element is efficient for maps because it can use knowledge of all maps being sorted,
+ std::pair<T::const_iterator, T::const_iterator> result = boost::minmax_element(container.begin(), container.end());
+ //std::pair<const double, double> px = *result.first; // x min & max
+ std::pair<const double, double> px = values_of(*result.first); // x min & max
+ //std::pair<const double, double> py = *result.second; // y min & max
+ std::pair<const double, double> py = values_of(*result.second); // y min & max
     x_min = px.first;
     x_max = py.first;
     y_min = px.second;
@@ -322,10 +324,10 @@
     // int good_y = mnmx(container.begin(), container.end(), &y_min, &y_max);
 
     // Work out min and max, ignoring non-finite (+-infinity & NaNs).
- using boost::svg::detail::pair_is_limit; // either x and/or y not a proper data value.
+ using boost::svg::detail::pair_is_limit; // Either x and/or y is not a proper data value.
 
- int goods = 0; // count of values where both X and Y are within limits.
- int limits = 0;
+ int goods = 0; // Count of values where both X and Y are normal (within limits).
+ int limits = 0;// Count of values where both X and Y are at limits (not normal).
     T::const_iterator pos = container.begin();
     while(pos != container.end() && pair_is_limit(*pos))
     { // Count any limits before the first good.
@@ -339,10 +341,10 @@
     }
     else
     {
- double x = pos->first;
+ double x = value_of(pos->first);
       x_max = x;
       x_min = x;
- double y = pos->second;
+ double y = value_of(pos->second);
       y_max = y;
       y_min = y;
       //cout << "Initial min & max " << x << ' ' << y << endl;
@@ -352,7 +354,7 @@
       {
         if (!pair_is_limit(*pos))
         { // Either x and/or y are finite.
- x = pos->first;
+ x = value_of(pos->first);
           if (x > x_max)
           {
             x_max = x;
@@ -361,7 +363,7 @@
           {
             x_min = x;
           }
- y = pos->second;
+ y = value_of(pos->second);
           if (y > y_max)
           {
             y_max = y;

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -50,6 +50,7 @@
     static const double sin45 = 0.707; //!< Use to calculate 'length' if axis value labels are sloping.
     static const double reducer = 0.9; //!< To make uncertainty and degrees of freedom testimates a bit smaller to distinguish from value.
     // (0.8 reduced from value 12, to 9 which is a bit too small).
+ //static const double plusminus = 2.; //! Number of standard deviations used for plusminus display. Nominal factor of 2 (strictly 1.96) corresponds to 95% confidence limit.
 
     // x_axis_position_ and y_axis_position_ use x_axis_intersect & y_axis_intersect
     enum x_axis_intersect
@@ -87,12 +88,11 @@
          class svg_1d_plot : public detail::axis_plot_frame<svg_1d_plot>\n
          class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
         */
- //protected:
- public:
+ protected:
         // We don't use the SVG coordinate transform because then text would
         // be flipped. Might use it to scale the image for resizes.
 
- // protected member functions (defined below):
+ // Protected Member Functions Declarations (defined below):
 
         // void transform_point(double &x, double &y);
         // void transform_x(double &x);
@@ -107,7 +107,6 @@
         // void draw_plot_point_value(double x, double y, g_element& g_ptr, value_style& val_style, plot_point_style& point_style, unc uvalue);
         // void draw_plot_point_values(double x, double y, g_element& x_g_ptr, g_element& y_g_ptr, const value_style& x_sty, const value_style& y_sty, unc uncx, unc uncy);
 
-
         // Clear functions.
         // void clear_all(); // Calls all the other clear_* functions.
         // void clear_legend();
@@ -118,6 +117,9 @@
         // void clear_points();
         // void clear_plot_background();
         // void clear_grids();
+
+ // Protected Member Functions Definitions:
+
         void transform_point(double& x, double& y)
         { //! Scale & shift both X & Y to graph Cartesian coordinates.
           x = derived().x_scale_ * x + derived().x_shift_;
@@ -956,7 +958,7 @@
               break;
 
             case unc_ellipse:
- {
+ { // Uncertainty ellipses for one, two and three standard deviations.
                 double xu = ux.uncertainty() + ux.value(); //
                 transform_x(xu);
                 double x_radius = abs(xu - x);
@@ -972,10 +974,15 @@
                 {
                   y_radius = 1.;
                 }
- g_ptr.ellipse(x, y, x_radius, y_radius); // Radii are uncertainty.
- // g_ptr.style().stroke_color(blue); would need a new group element to hold a different color.
- // stroke color of outer and center X Y marker must be same stroke_color at present.
- g_ptr.circle(x, y, 1); // Show x and y values at center.
+ //image.g(PLOT_DATA_UNC).style().stroke_color(magenta).fill_color(pink).stroke_width(1);
+ // color set in svg_1d_plot data at present.
+ g_element* gu3_ptr = &(derived().image.g(PLOT_DATA_UNC3));
+ g_element* gu2_ptr = &(derived().image.g(PLOT_DATA_UNC2));
+ g_element* gu1_ptr = &(derived().image.g(PLOT_DATA_UNC1));
+ gu1_ptr->ellipse(x, y, x_radius, y_radius); // Radii are one standard deviation.
+ gu2_ptr->ellipse(x, y, x_radius * 2, y_radius * 2); // Radii are two standard deviation..
+ gu3_ptr->ellipse(x, y, x_radius * 3, y_radius * 3); // Radii are three standard deviation..
+ g_ptr.circle(x, y, 1); // Show x and y values at center using stroke and fill color of data point marker.
               }
               break;
 
@@ -1056,13 +1063,13 @@
           void draw_plot_point_value(double x, double y, g_element& g_ptr, value_style& val_style, plot_point_style& point_style, unc uvalue)
           { /*! Write one data point (X or Y) value as a string, for example "1.23e-2", near the data point marker.
              Unecessary e, +, \& leading exponent zeros may optionally be stripped, and the position and rotation controlled.
- Uncertainty estimate ('plus or minus') may be optionally be appended.
+ Uncertainty estimate, typically standard deviation (half conventional 95% confidence 'plus or minus') may be optionally be appended.
              Degrees of freedom estimate (number of replicates) may optionally be appended.
              For example: "3.45 +-0.1(10)"\n
              The precision and format (scientific, fixed), and color and font type and size can be controlled too.
              */
             double value = uvalue.value(); // Most likely value.
- double u = uvalue.uncertainty(); // Uncertainty or plusminus for value.
+ double u = uvalue.uncertainty(); // Uncertainty standard devision or 1/2 plusminus for value.
             double df = uvalue.deg_free(); // Degrees of freedom estimate for value.
 
             std::stringstream label;
@@ -1169,7 +1176,8 @@
             if ((val_style.plusminus_on_ == true) // Is wanted.
                 && (u > 0.) // Is a valid uncertainty estimate.
               )
- { // Uncertainty estimate usually 95% confidence interval + or - 2 standard deviation.
+ { // Uncertainty estimate usually expressed 95% confidence interval + or - 2 standard deviation.
+ u = u * plusminus; // typically + or - 2 standard deviations.
               label_u = sv(u, val_style, true); // stripped.
               t.tspan(pm).fill_color(val_style.plusminus_color_);
               t.tspan(label_u).fill_color(val_style.plusminus_color_).font_size(udf_font);
@@ -1334,6 +1342,7 @@
                   && (ux > 0.)
                 )
             { // Uncertainty estimate usually 95% confidence interval + or - 2 standard deviation.
+ ux *= plusminus; // typically + or - 2 standard deviations.
               label_xu = sv(ux, x_sty, true);
               //t.tspan(pm).fill_color(darkcyan);
               // Should this be stroke_color?
@@ -1371,8 +1380,9 @@
                    (y_sty.plusminus_on_) // Is wanted.
                    && (uy > 0.) // Is valid uncertainty estimate.
                  )
- { // Uncertainty estimate usually 95% confidence interval + or - 2 standard deviation.
+ { // Uncertainty estimate (usually 95% confidence interval + or - 2 standard deviation).
                  // Precision of uncertainty is usually less than value,
+ uy *=plusminus; // Tylically + or - 2 standard deviations.
                 label_yu = "&#x00A0;" + sv(uy, y_sty, true);
                 t.tspan(pm).font_family("arial").font_size(fy).fill_color(green);
                 t.tspan(label_yu).fill_color(y_sty.plusminus_color_).font_size(fy);
@@ -1787,8 +1797,14 @@
           Derived& draw_note(double x, double y, std::string note, rotate_style rot = horizontal, align_style al = center_align, const svg_color& = black, text_style& tsty = no_style);
           Derived& draw_line(double x1, double y1, double x2, double y2, const svg_color& col = black);
           Derived& draw_plot_line(double x1, double y1, double x2, double y2, const svg_color& col = black);
- Derived& draw_plot_curve(double x1, double y1, double x2, double y2, double x3, double y3,const svg_color& col = black);
+ Derived& draw_plot_curve(double x1, double y1, double x2, double y2, double x3, double y3,const svg_color& col = black);
 
+ Derived& one_sd_color(const svg_color&);
+ svg_color one_sd_color();
+ Derived& two_sd_color(const svg_color&);
+ svg_color two_sd_color();
+ Derived& three_sd_color(const svg_color&);
+ svg_color three_sd_color();
 
           //// Stylesheet.
           // Removed for now to avoid compile warning in spirit.
@@ -3785,6 +3801,51 @@
         }
 
         template <class Derived>
+ Derived& axis_plot_frame<Derived>::one_sd_color(const svg_color& col)
+ { //! Set the color for the one standard deviation (~67% confidence) ellipse fill.
+ derived().image.g(detail::PLOT_DATA_UNC1).style().fill_on(true);
+ derived().image.g(detail::PLOT_DATA_UNC1).style().fill_color(col);
+ derived().image.g(detail::PLOT_DATA_UNC1).style().stroke_color(blank);
+ return derived();
+ }
+
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::one_sd_color()
+ { //! \return Color for the one standard deviation (~67% confidence) ellipse fill.
+ return derived().image.g(detail::PLOT_DATA_UNC1).style().fill_color();
+ }
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::two_sd_color(const svg_color& col)
+ { //! Set the color for two standard deviation (~95% confidence) ellipse fill.
+ derived().image.g(detail::PLOT_DATA_UNC2).style().fill_on(true);
+ derived().image.g(detail::PLOT_DATA_UNC2).style().fill_color(col);
+ derived().image.g(detail::PLOT_DATA_UNC2).style().stroke_color(blank);
+ return derived();
+ }
+
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::two_sd_color()
+ { //! \return Color for two standard deviation (~95% confidence) ellipse fill.
+ return derived().image.g(detail::PLOT_DATA_UNC2).style().fill_color();
+ }
+
+ template <class Derived>
+ Derived& axis_plot_frame<Derived>::three_sd_color(const svg_color& col)
+ { //! Set the color for three standard deviation (~99% confidence) ellipse fill.
+ derived().image.g(detail::PLOT_DATA_UNC3).style().fill_on(true);
+ derived().image.g(detail::PLOT_DATA_UNC3).style().fill_color(col);
+ derived().image.g(detail::PLOT_DATA_UNC3).style().stroke_color(blank);
+ return derived();
+ }
+
+ template <class Derived>
+ svg_color axis_plot_frame<Derived>::three_sd_color()
+ { //! \return Color for three standard deviation (~99% confidence) ellipse fill.
+ return derived().image.g(detail::PLOT_DATA_UNC3).style().fill_color();
+ }
+
+ template <class Derived>
         Derived& axis_plot_frame<Derived>::draw_note(double x, double y, std::string note, rotate_style rot /*= horizontal*/, align_style al/* = center_align*/, const svg_color& col /* black */, text_style& tsty/* = no_style*/)
         { /*! \brief Annotate plot with a text string (perhaps including Unicode), putting note at SVG Coordinates X, Y.
             \details Defaults color black, rotation horizontal and align = center_align

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -78,11 +78,18 @@
 }
 
 inline bool pair_is_limit(std::pair<double, double> a)
-{ //! Check on both x and y data points. Return false if either or both are at limit.
+{ //! Check on both x and y double data points. Return false if either or both are at limit.
   return limit_max(a.first) || limit_min(a.first) || limit_NaN(a.first)
     || limit_max(a.second) || limit_min(a.second) || limit_NaN(a.second);
 }
 
+inline bool pair_is_limit(std::pair<const unc, unc> a)
+{ //! Check on values of both x and y unc data points.
+ // \return false if either or both are at limit.
+ return limit_max(value_of(a.first)) || limit_min(value_of(a.first)) || limit_NaN(value_of(a.first))
+ || limit_max(value_of(a.second)) || limit_min(value_of(a.second)) || limit_NaN(value_of(a.second));
+}
+
 } // namespace detail
 } // namespace svg
 } // namespace boost

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -52,7 +52,9 @@
     PLOT_Y_LABEL, //! Y axis text labels "length (cm)".
     PLOT_X_LABEL, //! X axis text labels "height (m)".
     PLOT_DATA_LINES, //! Lines joining data points.
- PLOT_DATA_UNC, //! Uncertainty zone of data points.
+ PLOT_DATA_UNC3, //! Uncertainty zone of 3 sd from data points.
+ PLOT_DATA_UNC2, //! Uncertainty zone of 2 sd from data points.
+ PLOT_DATA_UNC1, //! Uncertainty zone of 1 sd from data points.
     PLOT_DATA_POINTS, //! Normal data point markers.
     PLOT_LIMIT_POINTS, //! 'At limit or NaN' data point markers.
     PLOT_LEGEND_BACKGROUND, //! Legend box.
@@ -84,7 +86,9 @@
     "yLabel",
     "xLabel", // axis text labels "length (cm)"
     "plotLines", // normal data point markers.
- "plotUnc", // uncertainty zone of data points.
+ "plotUnc3", // Uncertainty zone of 3 sd from data points.
+ "plotUnc2", // Uncertainty zone of 2 sd from data points.
+ "plotUnc1", // Uncertainty zone of 2 sd from data points.
     "plotPoints", // normal data point markers.
     "limitPoints", // at limit or NaN data point markers
     "legendBackground", // legend box.

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -438,6 +438,9 @@
     image.g(PLOT_WINDOW_BACKGROUND).style().stroke_width(plot_window_border_.width_).stroke_color(plot_window_border_.stroke_);
     image.g(PLOT_LIMIT_POINTS).style().stroke_color(lightslategray).fill_color(antiquewhite);
     image.g(PLOT_X_AXIS).style().stroke_color(black).stroke_width(x_axis_.width());
+ image.g(PLOT_DATA_UNC3).style().stroke_color(lightgoldenrodyellow).fill_color(lightgoldenrodyellow).stroke_width(1);
+ image.g(PLOT_DATA_UNC2).style().stroke_color(peachpuff).fill_color(peachpuff).stroke_width(1);
+ image.g(PLOT_DATA_UNC1).style().stroke_color(magenta).fill_color(pink).stroke_width(1);
 
     // Note that widths are stored in member data *and* copied here.
     // Not sure if this is wise but ...
@@ -466,6 +469,7 @@
 
     x_ticks_on_ = x_ticks_.up_ticks_on_ || x_ticks_.down_ticks_on_;
     // Only 2D has left and right y ticks.
+ x_ticks_.ticks_on_window_or_axis_ = 0; // Make ticks (and value labels) on axis the default.
   } // svg_1d_plot() Default constructor.
 
   void set_ids()
@@ -495,7 +499,7 @@
       plot_top_ += title_font_size() * (text_margin_ + 0.5);
     }
 
- // Assume that X-axis labels are always at bottom.
+ // Assume that X-axis labels are always at bottom for 1D plot.
     if(x_axis_.label_on_)
     { // Leave space at bottom for X axis label.
        plot_bottom_ -= x_axis_label_style_.font_size() * text_margin_;
@@ -539,7 +543,7 @@
     // one would have to *not* do this,
     // but to make sure they are both assigned correctly).
 
- if(plot_window_on_) // IS this test needed????
+ if(plot_window_on_) //
     {
       // Calculate the number of chars of the longest value label.
       x_ticks_.longest_label(); // Updates label_max_length_
@@ -604,7 +608,7 @@
     } // plot_window_on_
 
     if(plot_window_on_)
- { // Draw plot window rect.
+ { // Draw plot window rectangle box.
       image.g(detail::PLOT_WINDOW_BACKGROUND).push_back(
         new rect_element(plot_left_, plot_top_, (plot_right_ - plot_left_), plot_bottom_ - plot_top_));
     } // plot_window_on_
@@ -612,7 +616,7 @@
 
   void calculate_transform()
   { //! Calculate scale and shift factors for transform from Cartesian to plot.
- // SVG image is 0, 0 at top left, Cartesian at bottom left.
+ //! SVG image is (0, 0) at top left, Cartesian (0, 0) at bottom left.
     x_scale_ = (plot_right_ - plot_left_) / (x_axis_.max_ - x_axis_.min_);
     x_shift_ = plot_left_ - (x_axis_.min_ * (plot_right_ - plot_left_) / (x_axis_.max_ - x_axis_.min_));
     y_scale_ = 1.;
@@ -682,7 +686,7 @@
     }
 
     for(unsigned int i = 0; i < serieses_.size(); ++i)
- { // For each of the data series.
+ { // Plot the data points for each of the data series.
       g_element& g_ptr = image.g(detail::PLOT_DATA_POINTS).g();
       g_ptr.style().stroke_color(serieses_[i].point_style_.stroke_color_);
       g_ptr.style().fill_color(serieses_[i].point_style_.fill_color_);

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -565,6 +565,10 @@
         image.g(PLOT_X_AXIS).style().stroke_color(black).stroke_width(x_axis_.width());
         image.g(PLOT_Y_AXIS).style().stroke_color(black).stroke_width(y_axis_.width());
 
+ image.g(PLOT_DATA_UNC3).style().stroke_color(blank).fill_color(lightgoldenrodyellow).stroke_width(1);
+ image.g(PLOT_DATA_UNC2).style().stroke_color(peachpuff).fill_color(peachpuff).stroke_width(1);
+ image.g(PLOT_DATA_UNC1).style().stroke_color(pink).fill_color(pink).stroke_width(1);
+
         //image.g(detail::PLOT_NOTES).style().fill_color(black);
 
         // Note that widths are stored in member data *and* copied here.
@@ -1351,7 +1355,7 @@
         path_element& path = g_ptr.path();
         path.style().fill_color(series.line_style_.area_fill_);
 
- bool is_fill = !series.line_style_.area_fill_.is_blank;
+ bool is_fill = !series.line_style_.area_fill_.is_blank();
         path.style().fill_on(is_fill); // Ensure includes a fill="none" if no fill.
 
         double prev_x; // Previous data points.
@@ -1421,7 +1425,7 @@
         std::pair<double, double> fwd_vtr;
         std::pair<double, double> back_vtr;
 
- bool is_fill = !series.line_style_.area_fill_.is_blank;
+ bool is_fill = !series.line_style_.area_fill_.is_blank();
         if(is_fill == false)
         {
           path.style().fill_on(false); // default path constructor is false
@@ -1623,12 +1627,12 @@
               // draw_plot_point(x, y, g_ptr, plot_point_style(lightgray, whitesmoke, s, cone)); default.
             }
 
- draw_plot_point(x, y, g_ptr, serieses_[i].limit_point_style_, 0, 0); // No uncertainty info for values at limit infinity & NaN.
+ draw_plot_point(x, y, g_ptr, serieses_[i].limit_point_style_, unc(0.), unc(0.)); // No uncertainty info for values at limit infinity & NaN.
 
             if((x > plot_left_) && (x < plot_right_) && (y > plot_top_) && (y < plot_bottom_))
             { // Is inside plot window, so draw a point.
               // draw_plot_point(x, y, g_ptr, plot_point_style(blank, blank, s, cone)); default.
- draw_plot_point(x, y, g_ptr, serieses_[i].limit_point_style_, 0, 0);
+ draw_plot_point(x, y, g_ptr, serieses_[i].limit_point_style_, unc(0.), unc(0.));
             }
           }
         } // limits point

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -5,7 +5,7 @@
   \author Jacob Voytko & Paul A. Bristow
 */
 // Copyright Jacob Voytko 2007
-// Copyright Paul A. Bristow 2007
+// Copyright Paul A. Bristow 2007, 2009
 //
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
@@ -29,7 +29,7 @@
     \details The reason that the underscore separator convention does not match
     the normal Boost format is that these names that are specified by the SVG standard.
     http://www.w3.org/TR/SVG/types.html#ColorKeywords
- tan is also renamed to tanned to avoid clash with function tan in math.h.
+ color "tan" is also renamed to "tanned" to avoid clash with global function name tan in math.h.
   */
   enum svg_color_constant
   { //! \enum svg_color_constant SVG standard names for some colors.
@@ -67,147 +67,185 @@
     blank // 'NotAColor' == 147
   }; // enum svg_color_constant
 
- // Forward declarations in this module (see svg_fwd):
+ // Forward declarations in this module (see also svg_fwd):
 
- struct svg_color;
+ class svg_color;
   void constant_to_rgb(svg_color_constant c, unsigned char& r, unsigned char& g, unsigned char& b);
   std::ostream& operator<< (std::ostream&, const svg_color&);
 
- struct svg_color
- /*! SVG standard colors, see also enum boost::svg::svg_color_constant.\n
- svg_color is the struct that contains information about RGB colors.
+ class svg_color
+ /*! \brief SVG standard colors, see also enum svg_color_constant
+ \details svg_color is the struct that contains information about RGB colors.
       For the constructor, the SVG standard specifies that numbers
       outside the normal rgb range are to be accepted,
       but are constrained to acceptable range of integer values [0, 255].
   */
   {
- friend std::ostream& operator<< (std::ostream& os, const svg_color& rhs);
-
- unsigned char r; //!< unsigned char provides range [0 to 255].
-
- unsigned char g; unsigned char b;
-
- bool is_blank; // true means "Not to be displayed" a 'pseudo-color'.
- // If true should display & write as "none".
- svg_color(int red, int green, int blue) : is_blank(false)
- { /*! \brief Construct a color from RGB values.
- \details Constrain rgb to [0 .. 255].
- Default is to construct a blank 'pseudo-color'.
- */
- red = ( red < 0 ) ? 0 : red;
- green = ( green < 0 ) ? 0 : green;
- blue = ( blue < 0 ) ? 0 : blue;
- r = (unsigned char)(( red > 255 ) ? 255 : red);
- g = (unsigned char)(( green > 255 ) ? 255 : green);
- b = (unsigned char)(( blue > 255 ) ? 255 : blue);
- } // svg_color(int red, int green, int blue)
-
- svg_color(bool is) : is_blank(!is)
- { //! Constructor from bool permits svg_color my_blank(false) as a (non-)color.
- /*! \details with same effect as svg_color my_blank(blank);
- svg_color(true) means default (black?)
- svg_color(false) means blank.
- For example:
- plot.area_fill(false) will be a blank == no fill.
- plot.area_fill(true) will be a default(black) fill.
- */ r = 0; // Safer to assign *some* value to rgb: zero, or 255 or something,
- g = 0; // rather than leaving them random.
- b = 0; // Default 'blank' color 0,0,0 is black.
- } // svg_color(bool is)
-
- svg_color(svg_color_constant col)
- { //! Set a color, including blank.
- if (col == blank)
- { // NotAColor.
- is_blank = true;
- r = 255; // Safer to assign *some* value to rgb: zero, or 255 or something,
- g = 255; // rather than leaving them random.
- b = 255; // Default 'blank' color here is white.
+ friend std::ostream& operator<<(std::ostream& os, const svg_color& color);
+ friend bool operator== (const svg_color& lhs, const svg_color& rhs);
+ friend bool operator!= (const svg_color& lhs, const svg_color& rhs);
+ friend void constant_to_rgb(svg_color_constant c, unsigned char& r, unsigned char& g, unsigned char& b);
+ friend svg_color constant_to_rgb(svg_color_constant c);
+ friend bool is_blank(const svg_color& col);
+
+ private:
+ unsigned char r_; //!< red unsigned char provides range [0 to 255].
+ unsigned char g_; //!< green unsigned char provides range [0 to 255].
+ unsigned char b_; //!< blue unsigned char provides range [0 to 255].
+ bool is_blank_; //!< true means "Not to be displayed" a 'pseudo-color'. If is_blank_ == true should write output to SVG XML file as "none".
+
+ public:
+
+ svg_color(int red, int green, int blue) : is_blank_(false)
+ { /*! \brief Construct an SVG color from RGB values.
+ \details Constrain rgb to [0 .. 255].
+ Default is to construct a 'pseudo-color' blank.
+ */
+ red = ( red < 0 ) ? 0 : red;
+ green = ( green < 0 ) ? 0 : green;
+ blue = ( blue < 0 ) ? 0 : blue;
+ r_ = (unsigned char)(( red > 255 ) ? 255 : red);
+ g_ = (unsigned char)(( green > 255 ) ? 255 : green);
+ b_ = (unsigned char)(( blue > 255 ) ? 255 : blue);
+ } // svg_color(int red, int green, int blue)
+
+ svg_color(bool is) : is_blank_(!is)
+ { //! Constructor from bool permits svg_color my_blank(false) as a (non-)color.
+ /*! \details with same effect as svg_color my_blank(blank);
+ svg_color(true) means default (black?)
+ svg_color(false) means blank.
+ For example:
+ plot.area_fill(false) will be a blank == no fill.
+ plot.area_fill(true) will be a default(black) fill.
+ */
+ r_ = 0; // Safer to assign *some* value to rgb: zero, or 255 or something,
+ g_ = 0; // rather than leaving them random.
+ b_ = 0; // Default 'blank' color 0,0,0 is black.
+ } // svg_color(bool is)
+
+ svg_color(svg_color_constant col)
+ { //! Set a color (including blank) using the SVG 'standard' colors defined in enum #svg_color_constant
+ if (col == blank)
+ { // NotAColor.
+ is_blank_ = true;
+ r_ = 255; // Safer to assign *some* value to rgb: zero, or 255 or something,
+ g_ = 255; // rather than leaving them random.
+ b_ = 255; // Default 'blank' color here is white.
+ }
+ else
+ { // Proper color.
+ is_blank_ = false;
+ constant_to_rgb(col, r_, g_, b_);
+ }
     }
- else
- { // Proper color.
- is_blank = false;
- constant_to_rgb(col, r, g, b);
+ void write(std::ostream& os)
+ { //! Write to ostream a color in svg format.
+ //! \details Usage: my_color.write(cout); Outputs: rgb(127,255,212)
+ if(!is_blank_)
+ {
+ os << "rgb(" //! Note lower case (whereas operator<< uses uppercase).
+ << (unsigned int)r_ << ","
+ << (unsigned int) g_ << ","
+ << (unsigned int)b_ << ")" ;
+ }
+ else
+ {
+ os << "none";
+ }
+ } // void write(std::ostream& os)
+
+ bool operator== (const svg_color& rhs)
+ { //! Compare colors (for equal).
+ if ((is_blank_) && (rhs.is_blank_ == true))
+ { // Both blank
+ return true;
+ }
+ return (r_ == rhs.r_) && (g_ == rhs.g_) && (b_ == rhs.b_);
     }
- }
- void write(std::ostream& os)
- { //! Write to ostream a color in svg format..
- if(!is_blank)
- {
- os << "rgb(" << (unsigned int)r << ","
- << (unsigned int) g << ","
- << (unsigned int)b << ")" ;
+
+ bool operator!= (const svg_color& rhs)
+ { //! Compare colors (for not equal).
+ if ((is_blank_) || (rhs.is_blank_ == true))
+ {
+ return true;
+ }
+ return (r_ != rhs.r_) || (g_ != rhs.g_) || (b_ != rhs.b_);
     }
- else
- {
- os << "none";
+
+ bool is_blank() const
+ { //! \return true if color is blank.
+ return is_blank_;
     }
 
- //! \details Usage: my_color.write(cout); cout << endl; outputs: rgb(127,255,212)
- } // void write(std::ostream& os)
+ unsigned int red() const
+ { //! return red component of color [0, 255]
+ return r_;
+ }
 
- bool operator== (const svg_color& rhs)
- {
- //! Compare colors (for equal)
- if ((is_blank) && (rhs.is_blank == true))
- { // Both blank
- return true;
+ unsigned int green() const
+ { //! return green component of color [0, 255]
+ return g_;
     }
- return (r == rhs.r) && (g == rhs.g) && (b == rhs.b);
- }
 
- bool operator!= (const svg_color& rhs)
- { //! Compare colors (for not equal).
- if ((is_blank) || (rhs.is_blank == true))
- {
- return true;
+ unsigned int blue() const
+ { //! return blue component of color [0, 255]
+ return b_;
     }
- return (r != rhs.r) || (g != rhs.g) || (b != rhs.b);
- }
- }; // struct svg_color
+
+ }; // class svg_color
 
   // Note operator== and operator<< are both needed to use Boost.Test.
   bool operator== (const svg_color& lhs, const svg_color& rhs)
- { //! Compare colors (for equal)
+ { //! Compare colors (for equal).
     // Note operator== and operator << both needed to use Boost.Test.
- if ((rhs.is_blank == true) && (rhs.is_blank == true))
- {
- // Both blank.
+ if ((rhs.is_blank_ == true) && (rhs.is_blank_ == true))
+ { // Both blank.
       return true;
     }
- return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
+ return (lhs.r_ == rhs.r_) && (lhs.g_ == rhs.g_) && (lhs.b_ == rhs.b_);
   }
 
   bool operator!= (const svg_color& lhs, const svg_color& rhs)
- { //! Compare colors (for not equal).
+ { //! Compare colors (for not equal).
     // Note operator== and operator << both needed to use Boost.Test.
- if ((rhs.is_blank == true) || (rhs.is_blank == true))
- {
+ if ((rhs.is_blank_ == true) || (rhs.is_blank_ == true))
+ { // Either blank.
       return true;
     }
- return (lhs.r == rhs.r) || (lhs.g == rhs.g) || (lhs.b == rhs.b);
+ return (lhs.r_ == rhs.r_) || (lhs.g_ == rhs.g_) || (lhs.b_ == rhs.b_);
+ }
+
+ bool is_blank(const svg_color& col)
+ { //! \return true if color is blank.
+ return col.is_blank_;
   }
 
- std::ostream& operator<< (std::ostream& os, const svg_color& color)
- { //! Output color to stream.
- if(!color.is_blank)
+ std::ostream& operator<<(std::ostream& os, const svg_color& color)
+ { /*!
+ \brief Output color to stream as RGB. See #svg_color_constant
+ \details for example: "RGB(138, 43 , 226)" for blueviolet.
+ This comment does not appear - for reasons entirely unclear.
+ */
+ if(!color.is_blank_)
     {
       os << "RGB(" // Note deliberate uppercase to show difference between write and operator<<
- << (unsigned int)color.r << ","
- << (unsigned int)color.g << ","
- << (unsigned int)color.b << ")" ;
+ << (unsigned int)color.r_ << ","
+ << (unsigned int)color.g_ << ","
+ << (unsigned int)color.b_ << ")";
     }
     else
     {
       os << "blank";
- } /*! Usage: svg_color my_color(127, 255, 212); cout << "my_color " << my_color << endl;
+ }
+ /*! \details Usage: svg_color my_color(127, 255, 212); cout << "my_color " << my_color << endl;
          Outputs: my_color RGB(127,255,212) cout << "magenta " << svg_color(magenta) << endl;
- but caution! cout << magenta << endl; outputs 85 because magenta is an enum! */
+ but caution! cout << magenta << endl; outputs 85 because magenta is an enum #svg_color_constant !
+ */
     return os;
   } // std::ostream& operator<<
 
   svg_color color_array[] =
- { //! SVG standard colors, see also enum svg_color_constant.
+ { //! SVG standard colors, see also enum #svg_color_constant
     svg_color(240, 248, 255), // aliceblue
     svg_color(250, 235, 215), // antiquewhite
     svg_color(0 , 255, 255), // aqua
@@ -358,23 +396,27 @@
     svg_color(true) // blank - "Not to be displayed" pseudo-color.
   }; // svg_color color_array[]
 
- void constant_to_rgb(svg_color_constant c,
- unsigned char& r, unsigned char& g, unsigned char& b)
- { //! Convert a named SVG standard color to update three rgb variables.
- // Assume is c NOT the blank color.
+ void constant_to_rgb(svg_color_constant c, unsigned char& r, unsigned char& g, unsigned char& b)
+ { /*! Convert a named SVG standard color, see enum #svg_color_constant
+ to update three variables (r, g, b) holding red, green and blue values.
+ Assumes is c NOT the blank color, and asserts if it is.
+ This comment does not appear - for reasons unclear.
+ */
     BOOST_ASSERT(c != blank);
     svg_color color(color_array[c]);
- r = color.r;
- g = color.g;
- b = color.b;
+ r = color.r_;
+ g = color.g_;
+ b = color.b_;
   } // void constant_to_rgb
 
   svg_color constant_to_rgb(svg_color_constant c)
- { /*! Convert a svg color enum constant to a svg_color.
+ { /*! Convert a svg color constant enum #svg_color_constant to a svg_color.
+ \return svg_color
       Example:
       constant_to_rgb(4) or constant_to_rgb(aquamarine)
- gives svg_color(127, 255, 212), // aquamarine
- */
+ gives svg_color(127, 255, 212) // aquamarine.
+ */
+ // This comment appears OK.
     return color_array[c];
   } // svg_color constant_to_rgb(svg_color_constant c)
 

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_fwd.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_fwd.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_fwd.hpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -23,7 +23,7 @@
 {
 
 // svg_color.hpp contains definitions.
-struct svg_color;
+class svg_color;
 enum svg_color_constant;
 void constant_to_rgb(svg_color_constant c, unsigned char &r,
                      unsigned char &g, unsigned char &b);

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -220,9 +220,9 @@
   }
 
   svg_style& svg_style::fill_color(const svg_color& col)
- { //! Set fill color (and set fill on).
+ { //! Set fill color (and set fill on true, unless color is blank).
     fill_ = col;
- fill_on_ = ! col.is_blank; // If blank fill is off or "none".
+ fill_on_ = ! is_blank(col); // If blank fill is off or "none".
     return *this; //! \return svg_style& to make chainable.
   }
 

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -1,18 +1,18 @@
 /*! \file uncertain.hpp
- \brief Class for storing Uncertainties and handling simple Propagation of according to a pure Gaussian model.
- \details
- This simplifed version assuming uncorrelated uncertainties (the common case)
- is based on code by Evan Manning (manning_at_[hidden])
- Evan Marshal Manning, C/C++ Users Journal, March 1996 page 29 to 38.
- original downloaded from ftp://beowulf.jpl.nasa.gov/pub/manning
- This is a simple model of uncertainties, designed to
- accompany an article published in C/C++ Users Journal March 1996.
- A fuller collection of even fancier classes also given in UReal.h.
- And also based on a extended version including uncertainty as standard deviation & its uncertainty
- as degrees of freedom, and other information about the value added Paul A Bristow from 31 Mar 98.
+ \brief Class for storing Uncertainties and handling simple Propagation of according to a pure Gaussian model.
+ \details
+ This simplifed version assuming uncorrelated uncertainties (the common case)
+ is based on code by Evan Manning (manning_at_[hidden])
+ Evan Marshal Manning, C/C++ Users Journal, March 1996 page 29 to 38.
+ original downloaded from ftp://beowulf.jpl.nasa.gov/pub/manning
+ This is a simple model of uncertainties, designed to
+ accompany an article published in C/C++ Users Journal March 1996.
+ A fuller collection of even fancier classes also given in UReal.h.
+ And also based on a extended version including uncertainty as standard deviation & its uncertainty
+ as degrees of freedom, and other information about the value added Paul A Bristow from 31 Mar 98.
 
- \author Paul A. Bristow
- \date Mar 2009
+ \author Paul A. Bristow
+ \date Mar 2009
 */
 // Copyright Paul A. Bristow 2009
 
@@ -27,53 +27,63 @@
 #include <boost/svg_plot/detail/pair.hpp>
 
 #include <iostream>
-using std::ostream;
+//using std::ostream;
 #include <limits>
-using std::numeric_limits;
+//using std::numeric_limits;
+#include <utility> // using std::pair;
 
 namespace boost
 {
 namespace svg
 {
+ static const double plusminus = 2.; //! Number of standard deviations used for plusminus display. Nominal factor of 2 (strictly 1.96) corresponds to 95% confidence limit.
+
+// template <bool correlated = false>
 class unc
 { /*! \brief Class for storing an observed or measured value together with information
     about its uncertainty (previously called 'error' or 'plusminus').
     \details This version assumes uncorrelated uncertainties (by far the most common case).
+ \see http://www.measurementuncertainty.org/ \n
+ International Vocabulary of Basic and General Terms in Metrology; ISO/TAG 4 1994\n
+ ISO, Guide to the expression of uncertainty in measurement, ISO, Geneva, 1993.\n
+ Eurochem, Quantifying uncertainty in analytical measurements.
 */
 public:
   unc(); // Default constructor.
   unc(double v, float u, short unsigned df, short unsigned ty);
- friend ostream& operator<< (ostream& os, const unc& u);
- friend ostream& operator<< (ostream& os, const std::pair<unc, unc>& u);
+ friend std::ostream& operator<< (std::ostream& os, const unc& u);
+ friend std::ostream& operator<< (std::ostream& os, const std::pair<unc, unc>& u);
   bool operator<(const unc& rhs)const;
   bool operator<(unc& rhs)const;
   bool operator==(const unc& rhs) const;
   unc& operator=(const unc& rhs);
 
   // Get and set member functions.
- double value() const; //!< Get most likely value, typically the mean.
- float uncertainty() const; //!< Get estimate of uncertainty, typically standard deviation.
- short unsigned deg_free() const; //!< Get degrees of freedom, usually = number of observations -1;
- short unsigned types() const; //!< Get other information about the value.
-
- void value(double);//!< Set most likely value, typically the mean.
- void uncertainty(float);//!< Set estimate of uncertainty, typically standard deviation.
- void deg_free(short unsigned); //!< Set degrees of freedom, usually = number of observations -1;
- void types(short unsigned); //!< Set other information about the value.
+ double value() const; // return most likely value, typically the mean.
+ float uncertainty() const; // returnestimate of uncertainty, typically one standard deviation.
+ short unsigned deg_free() const; // return degrees of freedom, usually = number of observations -1;
+ short unsigned types() const; // return other information about the value.
+
+ void value(double); // Set most likely value, typically the mean.
+ void uncertainty(float); // Set estimate of uncertainty, typically standard deviation.
+ void deg_free(short unsigned); // Set degrees of freedom, usually = number of observations -1;
+ void types(short unsigned); // Set other information about the value.
 
- // private?
- // Note that this should fit into 128 bytes, same as two 64 bit doubles.
+private:
+ // Note that this class should fit into 128 bytes, same as two 64 bit doubles, so it only doubles the memory required.
   double value_; //!< Most likely value, typically the mean.
- float uncertainty_; //!< Estimate of uncertainty, typically standard deviation.
+ float uncertainty_; //!< Estimate of uncertainty, typically one standard deviation.
   //! Negative values mean that uncertainty is not defined.
- short unsigned deg_free_; //!< Degrees of freedom, usually = number of observations -1;
- //! so for 2 observations, 1 degree of freedom.
- //! Range from 0 (1 observation) to 65534 = (std::numeric_limits<unsigned short int>::max)() - 1
- //! Highest value (std::numeric_limits<unsigned short int>::max)() == 0xFFFF == 65535
- //! is used to indicate deg_free_ is NOT meaningful.
- //! Note this is an integral type - some functions may provide a floating-point type,
- //! but this must be converted, even if a marginal amount of information is lost.
- short unsigned types_; //!< Reserved for other information about the value_
+ //!
+ short unsigned deg_free_; /*!< Degrees of freedom, usually = number of observations -1;
+ so for 2 observations, 1 degree of freedom.
+ Range from 0 (1 observation) to 65534 = (std::numeric_limits<unsigned short int>::max)() - 1\n
+ Highest value (std::numeric_limits<unsigned short int>::max)() == 0xFFFF == 65535
+ is used to indicate deg_free_ is NOT meaningful.\n
+ Note this is an integral type - some functions may provide a floating-point type,
+ but this must be converted, even if a marginal amount of information is lost.
+ */
+ short unsigned types_; //!< Reserved for other information about the value.
   // (Hopefully, this only uses up the bits that would otherwise be padding).
 };
 
@@ -81,105 +91,177 @@
 :
   value_(v), uncertainty_(u), deg_free_(df), types_(ty)
 { // Constructor.
- // Note the defaults.
+ // Note the defaults so that unspecified variables have 'undefined' status.
 }
 
 unc::unc()
 :
   value_(0.), uncertainty_(-1.F), deg_free_((std::numeric_limits<unsigned short int>::max)()), types_(0U)
 { // Default constructor.
- // Note the defaults so that value is zero, but others have 'unknown' status.
+ // Note the defaults so that value is zero, but others have 'undefined' status.
 }
 
-bool unc::operator<(const unc& rhs) const
-{
- return value_ <rhs.value_;
+bool unc::operator<(const unc& u) const
+{ //! Less operator only compares the value, ignoring any uncertainty information.
+ return value_ < u.value_;
 }
 
-bool unc::operator<(unc& rhs) const
-{
- return value_ <rhs.value_;
+bool unc::operator<(unc& u) const
+{ //! Less operator only compares the value, ignoring any uncertainty information.
+ return value_ < u.value_;
 }
 
-bool unc::operator ==(const unc& rhs) const
-{
- return value_ == rhs.value_; // Might check ALL are equal?
+bool unc::operator ==(const unc& u) const
+{ //! Equality operator only compares the value, ignoring any uncertainty information.
+ return value_ == u.value_; // But might check ALL are equal? Or that are approximately equal taking uncertainty infor account?
 }
 
-unc& unc::operator=(const unc& rhs)
-{
- value_ = rhs.value_;
- uncertainty_ = rhs.uncertainty_;
- deg_free_ = rhs.deg_free_;
- types_ = rhs.types_ ;
+unc& unc::operator=(const unc& u)
+{ //! Assignment simply copies all values, including those with 'undefined' status.
+ value_ = u.value_;
+ uncertainty_ = u.uncertainty_;
+ deg_free_ = u.deg_free_;
+ types_ = u.types_ ;
   return *this; //! to make chainable.
 }
 
-
-double unc::value() const //!< Get most likely value, typically the mean.
-{
+double unc::value() const
+{ //! \return Most likely value, typically the mean.
   return value_;
 }
 
-float unc::uncertainty() const//!< Get estimate of uncertainty, typically standard deviation.
-{
+float unc::uncertainty() const
+{ //! \return Estimate of uncertainty, typically standard deviation.
   return uncertainty_;
 }
 
-short unsigned unc::deg_free() const//!< Get degrees of freedom, usually = number of observations -1;
-{
+short unsigned unc::deg_free() const
+{ //! \return Degrees of freedom, usually the number of observations -1.
   return deg_free_;
 }
 
-short unsigned unc::types() const//!< Get other information about the value.
-{
+short unsigned unc::types() const
+{ //! \return Other information about the uncertaint value.
   return types_;
 }
 
-void unc::value(double v)//!< Set most likely value, typically the mean.
-{
+void unc::value(double v)
+{ //! Set most likely value, typically the mean.
   value_ = v;
 }
 
-void unc::uncertainty(float u)//!< Set estimate of uncertainty, typically standard deviation.
-{
+void unc::uncertainty(float u)
+{ //! Set estimate of uncertainty, typically standard deviation.
   uncertainty_ = u;
 }
-void unc::deg_free(short unsigned df) //!< Set degrees of freedom, usually = number of observations -1;
-{
+void unc::deg_free(short unsigned df)
+{ //! Set degrees of freedom, usually = number of observations -1;
   deg_free_ = df;
 }
 
-void unc::types(short unsigned t) //!< Set other information about the value.
-{
+void unc::types(short unsigned t)
+{ //! Set other information about the uncertain value.
   types_ = t;
 }
 
-ostream& operator<< (ostream& os, const unc& u)
-{ //! Output an value with (if defined )uncertainty and degrees of freedom.
- //! For example: "1.23 +/- 0.01 (13)".
+std::ostream& operator<< (std::ostream& os, const unc& u)
+{ /*! Output an value with (if defined) uncertainty and degrees of freedom (and type).
+ For example: "1.23 +/- 0.01 (13)".\n
+ Note that the uncertainty is input and stored as one standard deviation,
+ but output multiplied for a user configurable 'confidence factor' plusminus,
+ default two for about 95% confidence (but could also be one for 67% or 3 for 99% confidence).
+ */
   os << u.value_;
- if (u.uncertainty_ > 0)
+ if (u.uncertainty_ > 0.F)
   { // Uncertainty is defined, so output it.
- //os << char(241) //! 256 bit codepage plusminus symbol 0xF1.
- os << '\361' //! 256 bit codepage plusminus symbol 0xF1.
- << u.uncertainty_;
- //os << " +or-" << u.uncertainty_;
- // os << "&#x00A0;&#x00B1;" //! Unicode space plusminus glyph.
+ //! Note that the plus or minus can be output using several methods.
+ os << '\361' //! 256 character 8-bit codepage plusminus symbol octal 361, or
+ // os << char(241)
+ //! decimal 241 or
+ // os << char(0xF1)
+ //! hexadecimal F1, or
+ // os << "&#x00A0;&#x00B1;"
+ //! Unicode space plusminus glyph, or\n
+ //! os << " +or-" << u.uncertainty_;
+ //! Plain ANSI 7 bit code chars.
+ << u.uncertainty_ * plusminus; // Typically two standard deviation.
   };
   if (u.deg_free_ != (std::numeric_limits<unsigned short int>::max)())
   { // Degrees of freedom is defined, so output it.
     os << " (" << u.deg_free_ << ")";
   };
+
+ if (u.types_ != 0U)
+ { // If defined, output other type information (as yet unspecified).
+ os << " [" << u.types_ << "] ";
+ }
   return os;
 } // ostream& operator<< (ostream& os, const unc& u)
 
-ostream& operator<< (ostream& os, const std::pair<unc, unc>& u)
+std::ostream& operator<< (std::ostream& os, const std::pair<unc, unc>& u)
 { //! Output a pair (X and Y) value with (if defined) uncertainty and degrees of freedom.
- //! For example: "1.23 +/- 0.01 (13), 3.45 +/- 0.06 (78)".
+ //! \details For example: "1.23 +/- 0.01 (13), 3.45 +/- 0.06 (78)".
   os << u.first << ", " << u.second;
   return os;
-} // ostream& operator<< (ostream& os, const pair<unc, unc>& u)
+} // std::ostream& operator<< (ostream& os, const pair<unc, unc>& u)
+
+/*! Allow value part of variables of class unc to be assigned to, and compared with double.
+\tparam T Built-in floating-point type, float, double or long double, or uncertain type unc.
+*/
+template <class T>
+double value_of(T v);
+
+template <class T>
+double value_of(T v)
+{ //! \return value as a double.
+ return double(v);
+}
+
+template<>
+double value_of(unc v)
+{ //! \return unc.value() as a double.
+ return v.value();
+}
+
+/*! Allow uncertainty (standard deviation) part of variables of class unc to be assigned to, and compared with float.
+\tparam T Built-in floating-point type, float, double or long double, or uncertain type unc.
+*/
+template <class T>
+float unc_of(T);
+
+template <class T>
+float unc_of(T)
+{ //! \return zero always (because no uncertainty information is available for built-in double, float, or long double).
+ return float(0.);
+}
+
+template<>
+float unc_of(unc v)
+{ //! \return unc.uncertainty() as a float.
+ return v.uncertainty();
+}
+
+// Two helper functions to provide values and uncertainties as pairs.
+
+template <class T>
+std::pair<const double, double> values_of(std::pair<const T, T> vp)
+{ //! \return value (part) as a pair of doubles.
+ // so can write
+ // std::pair<const double, double> minmax = value_of(*result.first); // x min & max
+ // whether T is double or unc.
+ std::pair<const double, double> minmax = make_pair(vp.first.value(), vp.second.value());
+ return minmax;
+}
+
+template <class T>
+std::pair<const float, float> uncs_of(std::pair<const T, T> vp)
+{ //! \return uncertainty parts (if any) as a pair of floats.
+ // so can write
+ // std::pair<const float, float> minmax = value_of(*result.first); // min unc & max unc for example/
+ // whether T is built-in or unc.
+ std::pair<const double, double> minmax = make_pair(vp.first.value(), vp.second.value());
+ return minmax;
+}
 
 } // namespace svg
 } // namespace boost

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -36,15 +36,23 @@
     [ glob ../../../boost/svg_plot/detail/*.hpp ]
   :
     <doxygen:param>TAB_SIZE=2
- <doxygen:param>EXTRACT_ALL=YES
+ # <doxygen:param>EXTRACT_ALL=YES
     <doxygen:param>HIDE_UNDOC_MEMBERS=NO
     <doxygen:param>INLINE_INHERITED_MEMB=YES # Show all inherited members of a class in the documentation of that class as if those members were ordinary class members.
     <doxygen:param>SORT_MEMBER_DOCS=YES
- <doxygen:param>EXTRACT_PRIVATE=YES
+ #<doxygen:param>EXTRACT_PRIVATE=YES
+ <doxygen:param>EXTRACT_STATIC=YES
+ <doxygen:param>EXTRACT_PRIVATE=NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class will be included in the documentation
+ <doxygen:param>EXTRACT_LOCAL_CLASSES=YES
+ <doxygen:param>EXTRACT_LOCAL_METHODS=YES
+ <doxygen:param>EXTRACT_LOCAL_CLASSES=YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined locally in source files will be included in the documentation.
     <doxygen:param>ENABLE_PREPROCESSING=YES
     <doxygen:param>MACRO_EXPANSION=YES
     <doxygen:param>EXPAND_ONLY_PREDEF=YES
     <doxygen:param>SEARCH_INCLUDES=YES
+ <doxygen:param>INLINE_INFO=YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] is inserted in the documentation for inline members.
+ <doxygen:param>SORT_BRIEF_DOCS=YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief descriptions of file, namespace and class members alphabetically by member name.
+ <doxygen:param>SORT_MEMBER_DOCS=YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen will sort the (detailed) documentation of file and class members alphabetically by member name.
     <doxygen:param>SHOW_INCLUDE_FILES=NO # List of the files that are included by a file in the documentation of that file.
     <doxygen:param>REPEAT_BRIEF=YES # Prepend the brief description of a member or function before the detailed description
     <doxygen:param>BRIEF_MEMBER_DESC=YES # Include brief member descriptions after the members that are listed in the file and class

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/doxywarn.log
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/doxywarn.log (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/doxywarn.log 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -1,2 +0,0 @@
-I:/boost-sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_2d_lines.cpp:1: Warning: the name `demo_notes.cpp' supplied as the second argument in the \file statement is not an input file
-I:/boost-sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_annotation.cpp:1: Warning: the name `demo_notes.cpp' supplied as the second argument in the \file statement is not an input file

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 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -33,7 +33,7 @@
 </div></div>
 <div><p class="copyright">Copyright © 2007 to 2009 Jake Voytko and Paul A. Bristow</p></div>
 <div><div class="legalnotice">
-<a name="id800477"></a><p>
+<a name="id778632"></a><p>
         Distributed under the Boost Software License, Version 1.0. (See accompanying
         file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       </p>
@@ -171,7 +171,7 @@
 </table></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: March 17, 2009 at 16:51:52 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 20, 2009 at 19:17:12 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/auto_2d_plot.cpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -1,10 +1,7 @@
 /*! \file auto_2d_plot.cpp
-
   \brief An example to demonstrate autoscaling with *multiple* STL containers.
- \details See also auto_1d_plot.cpp and auto_1d_container.cpp.
-
+ \details See also demo_2d_autoscaling.cpp, auto_1d_plot.cpp and auto_1d_container.cpp.
   \author Paul A Bristow
-
   \date 2009
 */
 
@@ -84,36 +81,57 @@
   my_map[7.3] = 9.1;
   my_map[2.1] = 5.4;
 
-/*`Also include some 'limits' values that would confuse autoscaling.
+/*`Also include some 'at limits' values that might confuse autoscaling.
 */
   my_map[99.99] = numeric_limits<double>::quiet_NaN();
   my_map[999.9] = numeric_limits<double>::infinity();
   my_map[999.] = +numeric_limits<double>::infinity();
 
-
   /*`Next a 2D plot is created using defaults for the very many possible settings.
   */
+ try
+ { // try'n'catch clocks are needed to ensure error messages from any exceptions are shown.
+
+ /*`Construct `myplot` and add at least a title,
+ specify the both x and y axes are to use autoscaling,
+ and add the one data series to be plotted.
+ */
   svg_2d_plot my_plot;
+ my_plot.title("Autoscale example"); // Add a title.
+ my_plot.xy_autoscale(my_map); // Specify that both x and y axes are to use autoscaling,
+ my_plot.plot(my_map); // Add the one data series to be plotted
+ my_plot.write("./auto_2d_plot.svg"); // And write the SVG image to a file.
 
- /*`Add at least a title,
- specify the both x and y axes are to use autoscaling,
- and add the one data series to plotted.
+ /*`We can show the ranges chosen by autoscaling; */
+ cout << "X min " << my_plot.x_range().first << ", X max " << my_plot.x_range().second << endl;
+ cout << "Y min " << my_plot.y_range().first << ", Y max " << my_plot.y_range().second << endl;
+
+ /*`Had we know that there were no 'at limits' values, we could have chosen to skip the checks.
+ This might be important for speed if there were thousands of data values.
   */
- my_plot.title("Autoscale example");
- //my_plot.autoscale_check_limits(false); // Skip checks for speed.
- // Will fail at run-time if any infinite or NaNs.
-
- // my_plot.y_autoscale(0., 9.); // autoscale using two doubles.
- my_plot.xy_autoscale(my_map);
-
- my_plot.plot(my_map);
- /*`Finally write the SVG image to a file. */
- my_plot.write("./auto_2d_plot.svg");
+ my_plot.autoscale_check_limits(false); // Skip checks for speed.
+
+ /*`The possible cost is that it will fail at run-time if there are any infinite or NaNs.
+
+ We could also chose to autoscale either of the axes separately, for example:*/
+
+ my_plot.y_autoscale(0.4, 9.3); // autoscale using two doubles.
+
+ /*`which will chose a neater scale from 0 to 10 for the Y axis. */
+
+ my_plot.write("./auto_2d_plot2.svg"); // And write another SVG image to a file.
 
- cout << "X min " << my_plot.x_range().first << ", X max " << my_plot.x_range().second << endl;
+ /*`We can show the ranges chosen by autoscaling; */
+ cout << "X min " << my_plot.x_range().first << ", X max " << my_plot.x_range().second << endl;
   cout << "Y min " << my_plot.y_range().first << ", Y max " << my_plot.y_range().second << endl;
 
 //] [/auto_2d_plot_2]
+ }
+ catch(const std::exception& e)
+ {
+ std::cout <<
+ "\n""Message from thrown exception was:\n " << e.what() << std::endl;
+ }
 
   return 0;
 }

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_color.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_color.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_color.cpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -62,37 +62,34 @@
 
   my_colors.write("demo_colors.svg");
 
-
   {
     svg_color my_blank(false);
     cout << "svg_color my_blank(false);" << boolalpha << endl;
- cout << "my_blank.is_blank is " << my_blank.is_blank << endl;
- cout << "my_blank.r my_blank.g my_blank.b = "
- << (unsigned int)my_blank.r << ' '
- << (unsigned int)my_blank.g << ' '
- << (unsigned int)my_blank.b << endl;
- cout << "my_blank " << my_blank << endl;
+ cout << "my_blank.is_blank() " << my_blank.is_blank() << endl;
+ cout << "my_blank.red() " << my_blank.red() << endl;
+ cout << "my_blank.green() " << my_blank.green() << endl;
+ cout << "my_blank.blue() " << my_blank.blue() << endl;
     my_blank.write(cout); cout << endl;
   }
   {
     svg_color my_blank(true);
     cout << "svg_color my_blank(true)" << boolalpha << endl;
- cout << "my_blank.is_blank is " << my_blank.is_blank << endl;
+ cout << "my_blank.is_blank is " << my_blank.is_blank() << endl;
     cout << "my_blank.r my_blank.g my_blank.b = "
- << (unsigned int)my_blank.r << ' '
- << (unsigned int)my_blank.g << ' '
- << (unsigned int)my_blank.b << endl;
+ << (unsigned int)my_blank.red() << ' '
+ << (unsigned int)my_blank.green() << ' '
+ << (unsigned int)my_blank.blue() << endl;
     cout << "my_blank " << my_blank << endl; // my_blank RGB(0,0,0) == default color.
     my_blank.write(cout); cout << endl;
   }
   {
     svg_color my_blank(blank);
     cout << "svg_color my_blank(blank)" << boolalpha << endl;
- cout << "my_blank.is_blank is " << my_blank.is_blank << endl;
- cout << "my_blank.r my_blank.g my_blank.b = "
- << (unsigned int)my_blank.r << ' '
- << (unsigned int)my_blank.g << ' '
- << (unsigned int)my_blank.b << endl;
+ cout << "my_blank.is_blank is " << my_blank.is_blank() << endl;
+ cout << "my_blank.red() my_blank.green() my_blank.blue() = "
+ << (unsigned int)my_blank.red() << ' '
+ << (unsigned int)my_blank.green() << ' '
+ << (unsigned int)my_blank.blue() << endl;
     cout << "my_blank " << my_blank << endl; // my_blank RGB(0,0,0) == default color.
     my_blank.write(cout); cout << endl;
   }

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_svg.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_svg.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_svg.cpp 2009-03-23 11:07:50 EDT (Mon, 23 Mar 2009)
@@ -1,10 +1,11 @@
 /*! \file demo_svg.cpp
     \brief Demonstration of a few facets of using the SVG interface directly.
- \details This only demonstrates a very few of the possible features because most users will only need to use the plot interfaces.
- But this might provide a little guidance for producing other diagrams and drawings.
+ \details This only demonstrates a very few of the possible features
+ because most users will only need to use the plot interfaces.
+ But this might provide a little guidance for producing other diagrams and drawings.
       This module is to demonstrate features of the svg class.
       It is entirely contrived and has no other conceivable use!
- \author Paul A. Bristow
+ \author Paul A. Bristow
     \date 20 Feb 2009
 */
 // Copyright Paul A Bristow 2007


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