Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51637 - in sandbox/SOC/2007/visualization/boost/svg_plot: . detail
From: pbristow_at_[hidden]
Date: 2009-03-07 07:43:25


Author: pbristow
Date: 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
New Revision: 51637
URL: http://svn.boost.org/trac/boost/changeset/51637

Log:
2d uncertainty and degrees of freedom working.

Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 21 +++--
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp | 25 +++---
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/pair.hpp | 34 ++++++---
   sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp | 48 ++------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 22 +++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 132 +++++++++++++++++++++++----------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp | 8 +-
   sandbox/SOC/2007/visualization/boost/svg_plot/uncertain.hpp | 82 ++++++++++++++++++------
   8 files changed, 210 insertions(+), 162 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 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -1025,10 +1025,13 @@
           } // void draw_plot_point
 
           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.
- //! Degrees of freedom estimate (number of replicates) may optionally be appended.
+ { /*! 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.
+ 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 df = uvalue.deg_free(); // Degrees of freedom estimate for value.
@@ -1124,12 +1127,12 @@
             } // switch
 
             text_element& t = g_ptr.text(x, y, stripped, val_style.values_text_style_, al, rot); // X or Y value "1.23"
- int f = static_cast<int>(val_style.values_text_style_.font_size() * 0.8); // Make uncertainty and df a bit smaller to distringuish from value.
+ int f = static_cast<int>(val_style.values_text_style_.font_size() * 0.8); // Make uncertainty and df a bit smaller to distinguish from value.
 
             std::string label_u; // Uncertainty or plusminus.
             std::string label_df; // Degrees of freedom estimate.
             std::string pm = "&#x00A0;&#x00B1;"; //! Unicode space plusminus glyph.
- // Might also use ANSI symbol for plusminus 0xF1 == '\361' or char(241)
+ // Might also use ANSI symbol for plusminus 0xF1 == '\361' or char(241)
             // but seems to vary with different codepages
             // LOCALE_SYSTEM_DEFAULT LOCALE_IDEFAULTANSICODEPAGE == 1252
             // LOCALE_SYSTEM_DEFAULT LOCALE_IDEFAULTCODEPAGE == 850 for country 44 (UK)
@@ -1286,7 +1289,9 @@
             string pm = "&#x00A0;&#x00B1;"; //! Unicode space plusminus glyph.
             // Spaces seem to get lost, so use 00A0 as an explicit space glyph.
             // Layout seems to vary with font - Times New Roman leaves no space after.
- if (x_sty.plusminus_on_)
+ if ((x_sty.plusminus_on_ == true)
+ && (ux > 0.)
+ )
             { // Uncertainty estimate usually 95% confidence interval + or - 2 standard deviation.
               label_xu = sv(ux, x_sty, true);
               t.tspan(pm).fill_color(darkcyan);
@@ -1299,7 +1304,7 @@
                )
             { // Degrees of freedom (usually number of observations-1) used for this estimate of value.
               stringstream label;
- label.precision(4);
+ label.precision(4); // Might need 5 to show 65535?
               //label.flags(sty.value_ioflags_); // Leave at default.
               label << "&#x00A0;(" << dfx << ")"; // "123.5"
               // Explicit space "&#x00A0;" seems necessary.

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/functors.hpp 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -34,9 +34,8 @@
 namespace detail
 {
 
- // TODO change name from boost_default_convert to double_default_convert.
-class boost_default_convert
-{ /*! \class boost::svg::detail::boost_default_convert
+class double_1d_convert
+{ /*! \class boost::svg::detail::double_1d_convert
       \brief This functor allows any 1D data convertible to doubles to be plotted.
 */
 public:
@@ -47,10 +46,10 @@
     {
         return (double)val;
     }
-}; // class boost_default_convert
+}; // class double_1d_convert
 
-class boost_default_2d_convert
-{ /*! \class boost::svg::detail::boost_default_2d_convert
+class pair_double_2d_convert
+{ /*! \class boost::svg::detail::pair_double_2d_convert
       \brief This functor allows any 2 D data convertible to type std::pair<double, double> to be plotted.
 */
 public:
@@ -73,10 +72,10 @@
     {
         return std::pair<double, double>(i++, (double)a);
     }
-}; // class boost_default_2d_convert
+}; // class pair_double_2d_convert
 
-class unc_default_2d_convert
-{ /*! \class boost::svg::detail::unc_default_2d_convert
+class pair_unc_2d_convert
+{ /*! \class boost::svg::detail::pair_unc_2d_convert
       \brief This functor allows any 2D data convertible to type std::pair<unc, unc> to be plotted.
 */
 public:
@@ -98,10 +97,10 @@
     {
         return std::pair<unc, unc>(i++, (unc)a);
     }
-}; // class boost_default_2d_convert
+}; // class pair_unc_2d_convert
 
-class unc_default_convert
-{ /*! \class boost::svg::detail::unc_convert
+class unc_1d_convert
+{ /*! \class boost::svg::detail::unc_1d_convert
       \brief This functor allows any 1D data convertible to unc (uncertain doubles) to be plotted.
       \details Defaults provided by the unc class constructor ensure that
       uncertainty, degrees of freedom information, and type are set too.
@@ -117,7 +116,7 @@
       // warning C4244: 'argument' : conversion from 'long double' to 'double', possible loss of data.
       // because unc only holds double precision.
     }
-}; // class default_convert
+}; // class default_1d_convert
 
 
 } // namespace detail

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/pair.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/pair.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/pair.hpp 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -2,11 +2,11 @@
     \brief Provides a private implementation of operator<< for std::pair that
       outputs pairs with a comma separated format, for example: 1.2, 3.4
     \details Hidden in namespace detail to avoid clashes with other implementations of std::pair operator<<.
+ \date Mar 2009
+ \author Paul A. Bristow
+*/
 
- \author Paul A. Bristow
- */
-
-// Copyright Paul A. Bristow 2006 - 2008.
+// Copyright Paul A. Bristow 2006 - 2009.
 
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
@@ -16,8 +16,12 @@
 #ifndef BOOST_SVG_PAIR
 #define BOOST_SVG_PAIR
 
-// Provides a private implementation of operator<< for std::pair
-// Outputs pairs with a comma separated format, for example: 1.2, 3.4
+#include<iostream>
+ // using std::ostream;
+
+#include <utility>
+ //using std::pair;
+ //using std::make_pair;
 
 namespace boost
 {
@@ -26,9 +30,10 @@
 namespace detail
 {
   // Hidden in namespace detail to avoid clashes with other implementations of std::pair operator<<.
-
- //std::ostream& operator<< (std::ostream&, const std::pair<double, double>&);
- //template<class T1, class T2> std::ostream& operator<< (std::ostream&, std::pair<T1, T1>&);
+ template<class T1, class T2>
+ std::ostream& operator<< (std::ostream& os, const std::pair<T1, T2>& p);
+ std::ostream& operator<< (std::ostream& os, const std::pair<double, double>& p);
+ //std::ostream& operator<< (std::ostream& os, const std::pair<unc, unc>& p);
 
   template<class T1, class T2>
   std::ostream& operator<< (std::ostream& os, const std::pair<T1, T2>& p)
@@ -40,13 +45,20 @@
 
   std::ostream& operator<< (std::ostream& os, const std::pair<double, double>& p)
   { // Output a pair of double values.
- int precision = os.precision(3); // Save & use rather than default precision(6)
+ //int precision = os.precision(5); // Save & use rather than default precision(6).
       os << p.first << ", " << p.second;
       // Outputs: 1.2, 3.4
- os.precision(precision); // Restore.
+ //os.precision(precision); // Restore.
       return os;
   } // std::ostream& operator<<
 
+ //std::pair<class T1, class T2>& operator=(const pair& rhs)
+ //{
+ // first = rhs.first;
+ // second = rhs.second;
+ // return *this; //! to make chainable.
+ //}
+
   // Maybe better as:
   //template<typename charT, typename traits, typename T1, typename T2>
   //inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const std::pair<T1, T2>& p)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -97,45 +97,6 @@
   os.flags(flags); // Restore.
 } // outFmtFlags
 
- namespace detail
- {
-
- //std::ostream& operator<< (std::ostream&, const std::pair<double, double>&);
- //template<class T1, class T2> std::ostream& operator<< (std::ostream&, std::pair<T1, T1>&);
-
- template<class T1, class T2>
- std::ostream& operator<< (std::ostream& os, const std::pair<T1, T2>& p)
- { // Output a pair of values.
- os << p.first << ", " << p.second;
- // Outputs: 1.2, 3.4
- return os;
- } // std::ostream& operator<<
-
- std::ostream& operator<< (std::ostream& os, const std::pair<double, double>& p)
- { // Output a pair of values.
- int precision = os.precision(3); // Save & use rather than default precision(6)
- os << p.first << ", " << p.second;
- // Outputs: 1.2, 3.4
- os.precision(precision); // Restore.
- return os;
- } // std::ostream& operator<<
-
- // Maybe better as:
- //template<typename charT, typename traits, typename T1, typename T2>
- //inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const std::pair<T1, T2>& p)
- //{
- // return os << p.first << " " << p.second;
- //}
- //
- //// Explicit double, double.
- //template<typename charT, typename traits>
- //inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const std::pair<double, double>& p)
- //{
- // return os << p.first << " " << p.second;
- //}
- // but OK for this purpose.
- } // namespace detail
-
   const std::string l_or_r(int i)
   {
    return ((i < 0) ? "left" : ((i == 0) ? "none" : "right"));
@@ -229,6 +190,7 @@
   cout << "title_font_weight " << plot.title_font_weight() << endl;
   //cout << "title_font_width " << plot.title_font_width() << endl;
   // Not useful at present, so not longer implemented.
+ cout << "x_values_on " << plot.x_values_on() << endl;
   cout << "x_value_precision " << plot.x_value_precision() << endl;
   cout << "x_value_ioflags " << hex << plot.x_value_ioflags() << dec << ' ';
   outFmtFlags(plot.x_value_ioflags(), cout, ".\n");
@@ -242,7 +204,6 @@
   cout << "y_autoscale " << plot.y_autoscale() << endl;
   cout << "xy_autoscale " << plot.xy_autoscale() << endl;
   cout << "x_autoscale_check_limits " << plot.autoscale_check_limits() << endl;
-
   cout << "x_axis_on " << plot.x_axis_on() << endl;
   cout << "x_axis_color() " << plot.x_axis_color() << endl;
   cout << "x_axis_label_color " << plot.x_axis_label_color() << endl;
@@ -281,6 +242,9 @@
   cout << "x_ticks_on_window_or_axis " << t_or_b(plot.x_ticks_on_window_or_axis()) << endl;
   cout << "y_axis_position " << plot.y_axis_position() << endl;
   cout << "x_axis_position " << plot.x_axis_position() << endl;
+ cout << "x_plusminus_on " << plot.x_plusminus_on() << endl;
+ cout << "x_df_on " << plot.x_df_on() << endl;
+ cout << "xy_values_on " << plot.xy_values_on() << endl;
   cout << "y_label_on " << plot.y_label_on() << endl;
   cout << "y_label_axis " << plot.y_label_axis() << endl;
   cout << "y_axis_color " << plot.y_axis_color() << endl;
@@ -321,6 +285,10 @@
   cout << "y_ticks_on_window_or_axis " << l_or_r(plot.y_ticks_on_window_or_axis()) << endl;
   cout << "y_max " << plot.y_max() << endl;
   cout << "y_min " << plot.y_min() << endl;
+ cout << "y_values_on " << plot.y_values_on() << endl;
+ cout << "y_plusminus_on " << plot.y_plusminus_on() << endl;
+ cout << "y_df_on " << plot.y_df_on() << endl;
+
   cout << "data lines width " << plot.data_lines_width() << endl;
 
 

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -32,7 +32,7 @@
 #include "svg_style.hpp"
 #include "detail/axis_plot_frame.hpp" // Code shared with 2D.
 #include <boost/svg_plot/detail/functors.hpp>
-using boost::svg::detail::unc_default_convert;
+using boost::svg::detail::unc_1d_convert;
 #include "detail/numeric_limits_handling.hpp"
 #include <boost/svg_plot/uncertain.hpp>
 // using boost::svg::unc;
@@ -771,9 +771,9 @@
   template <class T>
   svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "");
   template <class T, class U>
- svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_convert);
+ svg_1d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = double_1d_convert);
   template <class T, class U>
- svg_1d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_convert);
+ svg_1d_plot_series& plot(const T& container, const std::string& title = "", U functor = double_1d_convert);
 }; // class svg_1d_plot
 
 // svg_1d_plot Member functions definitions.
@@ -818,13 +818,13 @@
 
   template <class T>
   svg_1d_plot_series& svg_1d_plot::plot(const T& container, const std::string& title /*= "" */)
- { /*! Add a data series to the plot (by default, converting to doubles), with optional title.
+ { /*! Add a data series to the plot (by default, converting to unc doubles), with optional title.
      Note that this version assumes that *ALL* the data values in the container are used.
     */
     serieses_.push_back(
       svg_1d_plot_series(
- boost::make_transform_iterator(container.begin(), detail::unc_default_convert()),
- boost::make_transform_iterator(container.end(), detail::unc_default_convert()),
+ boost::make_transform_iterator(container.begin(), detail::unc_1d_convert()),
+ boost::make_transform_iterator(container.end(), detail::unc_1d_convert()),
       title)
     );
    /*
@@ -842,15 +842,15 @@
 
   template <class T>
   svg_1d_plot_series& svg_1d_plot::plot(const T& begin, const T& end, const std::string& title)
- { //! Add a data series to the plot (by default, converting to doubles), with optional title.
+ { //! Add a data series to the plot (by default, converting to unc doubles), with optional title.
     /*!
     Note that this version permits a partial range, begin to end, of the container to be used.
     \return a reference to data series just added.
     */
     serieses_.push_back(
       svg_1d_plot_series(
- boost::make_transform_iterator(begin, detail::boost_default_convert()),
- boost::make_transform_iterator(end, detail::boost_default_convert()),
+ boost::make_transform_iterator(begin, detail::unc_1d_convert()),
+ boost::make_transform_iterator(end, detail::unc_1d_convert()),
       title)
     );
     //! For example: my_1d_plot.plot(my_data.begin(), my_data.end(), "My container");
@@ -860,7 +860,7 @@
   } // plot
 
   template <class T, class U>
- svg_1d_plot_series& svg_1d_plot::plot(const T& begin, const T& end, const std::string& title /* = ""*/, U functor /* = boost_default_convert */)
+ svg_1d_plot_series& svg_1d_plot::plot(const T& begin, const T& end, const std::string& title /* = ""*/, U functor /* = double_1d_convert */)
   { /*! Add a data series to the plot, with optional title. (Version with custom functor, rather than to double).
       Note that this version permits a partial range, begin to end, of the container to be used.
       \return a reference to data series just added.
@@ -875,7 +875,7 @@
   } // plot
 
   template <class T, class U>
- svg_1d_plot_series& svg_1d_plot::plot(const T& container, const std::string& title /* = "" */, U functor/*= boost_default_convert*/)
+ svg_1d_plot_series& svg_1d_plot::plot(const T& container, const std::string& title /* = "" */, U functor/*= double_1d_convert*/)
   { //! Add a data series to the plot, with optional title.
   /*!
     This version of plot includes a functor, allowing other than just convert data values to double(the default).

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-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -5,6 +5,7 @@
   Very many functions allow fine control of the appearance and layout of plots, data markers and lines.
   Items common to 1D and 2D use axis_plot_frame.
   \author Jacob Voytko & Paul A. Bristow
+ \date Mar 2009
  */
 
 // Copyright Jacob Voytko 2007
@@ -28,6 +29,8 @@
 // using boost::make_transform_iterator;
 
 #include "svg_style.hpp"
+#include "uncertain.hpp"
+// using boost.svg::unc;
 #include "detail/axis_plot_frame.hpp"
 #include "detail/numeric_limits_handling.hpp"
 #include "detail/functors.hpp"
@@ -53,7 +56,7 @@
     // Forward declarations.
     const std::string strip_e0s(std::string s); // Strip unncessary zeros and e and sign.
     class svg_2d_plot; // Plot framework.
- class svg_2d_plot_series; // plot data series.
+ class svg_2d_plot_series; // One series of data to plot.
 
     class svg_2d_plot_series
     { /*! \class boost::svg::svg_2d_plot_series
@@ -70,7 +73,7 @@
 
     public:
       // 2-D Data series points to plot.
- std::multimap<double, double> series_; //!< Normal 'OK to plot' data values.
+ std::multimap<unc, unc> series_; //!< Normal 'OK to plot' data values.
       std::multimap<double, double> series_limits_; //!< 'limit' values: too big or small, or NaN.
 
       std::string title_; //!< Title of data series (to show on legend using legend style).
@@ -141,13 +144,17 @@
   { // Constructor.
     for(T i = begin; i != end; ++i)
     { // Sort data points into normal and limited series.
- if(detail::pair_is_limit(*i))
+ std::pair<unc, unc> temp = *i;
+ unc ux = temp.first;
+ unc uy = temp.second;
+ std::pair<double, double> xy = std::make_pair<double, double>(ux.value(), uy.value());
+ if(detail::pair_is_limit(xy))
       { // Either x and/or y is at limit.
- series_limits_.insert(*i);
+ series_limits_.insert(xy);
       }
       else
       { // Normal data values for both x and y.
- series_.insert(*i);
+ series_.insert(temp);
       }
     }
   } // svg_2d_plot_series
@@ -1330,11 +1337,7 @@
       } // void draw_y_minor_tick
 
       void draw_straight_lines(const svg_2d_plot_series& series)
- { //! Add straight line between series of data points (rather than a Bezier curve).
- double prev_x; // Previous data points.
- double prev_y;
- double temp_x(0.);
- double temp_y;
+ { //! Add line between series of data points (straight rather than a Bezier curve).
 
         g_element& g_ptr = image.g(detail::PLOT_DATA_LINES).g();
         g_ptr.clip_id(plot_window_clip_);
@@ -1347,14 +1350,17 @@
         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.
+ double prev_y;
         if(series.series_.size() > 1)
- { // Need at least two points for a line ;-)
- std::multimap<double, double>::const_iterator j = series.series_.begin();
+ { // Need at least two points for a line.
+ std::multimap<unc, unc>::const_iterator j = series.series_.begin();
 
           // If we have to fill the area under the plot,
           // we first have to move from the X-axis (y = 0) to the first point,
           // and again at the end after the last point.
- prev_x = (*j).first;
+ unc prev_ux = (*j).first;
+ prev_x = prev_ux.value();
           prev_y = 0.; // X-axis.
           transform_point(prev_x, prev_y);
           if(is_fill)
@@ -1362,7 +1368,9 @@
             //path.style().fill_color(series.line_style_.area_fill_); // Duplicates so no longer needed?
             path.M(prev_x, prev_y);
           }
- transform_y(prev_y = (*j).second);
+ unc prev_uy = (*j).second;
+ prev_y = prev_uy.value();
+ transform_y(prev_y);
           if(is_fill)
           { // Area fill wanted.
             // path.style().fill_color(series.line_style_.area_fill_); // Duplicates so no longer needed?
@@ -1374,23 +1382,23 @@
           }
           ++j; // so now refers to 2nd point to plot.
 
+ double temp_x(0.);
+ double temp_y;
           for(; j != series.series_.end(); ++j)
           {
- temp_x = (*j).first;
- temp_y = (*j).second;
+ unc temp_ux = (*j).first;
+ temp_x = temp_ux.value();
+ unc temp_uy = (*j).second;
+ temp_y = temp_uy.value();
             transform_point(temp_x, temp_y);
             path.L(temp_x, temp_y); // Line to next point.
- //if(is_fill) // This seems to stop area-fill and is not needed anyway.
- //{
- // //path.M(temp_x, temp_y);
- //}
             prev_x = temp_x;
             prev_y = temp_y;
           } // for j'th point
 
           if(is_fill)
           { // Area fill wanted.
- transform_y(temp_y = 0.); // X-axis line coordinate.
+ transform_y(temp_y); // X-axis line coordinate.
             path.L(temp_x, temp_y).z(); // Draw line to X-axis & closepath with Z.
           }
         }
@@ -1405,7 +1413,7 @@
 
         std::pair<double, double> n; // current point.
         std::pair<double, double> n_minus_1; // penultimate.
- std::pair<double, double> n_minus_2;
+ std::pair<double, double> n_minus_2; // 'pen-penultimate'.
         std::pair<double, double> fwd_vtr;
         std::pair<double, double> back_vtr;
 
@@ -1420,11 +1428,15 @@
         }
 
         if(series.series_.size() > 2)
- { // Need >= 3 for a cubic curve (start point, 2 control points, and end point).
- std::multimap<double, double>::const_iterator iter = series.series_.begin();
- n_minus_1 = *(iter++); // begin()
+ { // Need >= 3 points for a cubic curve (start point, 2 control points, and end point).
+ std::multimap<unc, unc>::const_iterator iter = series.series_.begin();
+ std::pair<unc, unc> un_minus_1 = *(iter++); // 1st unc X & Y data.
+ n_minus_1 = std::make_pair(un_minus_1.first.value(), un_minus_1.second.value()); // X and Y values.
+ //n_minus_1 = *(iter++); // begin()
           transform_pair(n_minus_1);
- n = *(iter++); // middle
+
+ std::pair<unc, unc> un = *(iter++); // middle
+ n = std::make_pair(un.first.value(), un.second.value()); // X and Y values.
           transform_pair(n);
           path.M(n_minus_1.first, n_minus_1.second); // move m_minus_1, the 1st data point.
 
@@ -1442,7 +1454,8 @@
           {
             n_minus_2 = n_minus_1;
             n_minus_1 = n;
- n = *iter;
+ std::pair<unc, unc> un = *iter; // middle
+ n = std::make_pair(un.first.value(), un.second.value()); // X and Y values.
             transform_pair(n);
 
             back_vtr.first = ((n_minus_1.first - n.first) + // (x diff - x previous diff) * control
@@ -1502,13 +1515,16 @@
             .fill_color(serieses_[i].point_style_.fill_color_)
             .stroke_color(serieses_[i].point_style_.stroke_color_);
 
- for(std::multimap<double, double>::const_iterator j = serieses_[i].series_.begin();
+ for(std::multimap<unc, unc>::const_iterator j = serieses_[i].series_.begin();
             j != serieses_[i].series_.end(); ++j)
           {
- x = j->first;
- double vx = x; // Note the true x value.
- y = j->second;
- double vy = y; // Note the true y value.
+ unc ux = j->first;
+ x = ux.value(); // Just the X value.
+ //double vx = x; // Note the true X value.
+ unc uy = j->first;
+ uy = j->second;
+ y = uy.value(); // Just the Y value
+ //double vy = y; // Note the true Y value.
             transform_point(x, y);
             if((x > plot_left_) && (x < plot_right_) && (y > plot_top_) && (y < plot_bottom_))
             { // Is inside plot window, so draw a point.
@@ -1518,17 +1534,17 @@
               { // Show the value of the X data point too.
                 // void draw_plot_point_value(double x, double y, g_element& g_ptr, value_style& val_style, plot_point_style& point_style, double value)
 
- draw_plot_point_value(x, y, g_ptr_vx, x_values_style_, serieses_[i].point_style_, vx);
+ draw_plot_point_value(x, y, g_ptr_vx, x_values_style_, serieses_[i].point_style_, ux);
               }
               g_element& g_ptr_vy = image.g(detail::PLOT_Y_POINT_VALUES).g();
               if (y_values_on_)
               { // show the value of the Y data point too.
- draw_plot_point_value(x, y, g_ptr_vy, y_values_style_,serieses_[i].point_style_, vy);
+ draw_plot_point_value(x, y, g_ptr_vy, y_values_style_,serieses_[i].point_style_, uy);
               }
 
               if (xy_values_on_)
               { // Show the values of the X & Y data as a pair.
- draw_plot_point_values(x, y, g_ptr_vx, g_ptr_vy, x_values_style_, y_values_style_, vx, vy);
+ draw_plot_point_values(x, y, g_ptr_vx, g_ptr_vy, x_values_style_, y_values_style_, ux, uy);
               }
             } // if in side window
           } // for j
@@ -1637,11 +1653,13 @@
 
           double h_w = serieses_[i].bar_style_.width_; // For block bar chart.
           //double h_h = 0.;
- for(std::multimap<double, double>::const_iterator j = serieses_[i].series_.begin();
+ for(std::multimap<unc, unc>::const_iterator j = serieses_[i].series_.begin();
             j != serieses_[i].series_.end(); ++j)
           { // All the 'good' data points.
- x = j->first;
- y = j->second;
+ unc ux = j->first;
+ x = ux.value();
+ unc uy = j->second;
+ y = uy.value();
             transform_point(x, y);
             if((x > plot_left_) && (x < plot_right_) && (y > plot_top_) && (y < plot_bottom_))
             { // Is inside plot window, so some bar to draw.
@@ -1726,23 +1744,27 @@
             path.style().fill_color(blank);
           }
 
- std::multimap<double, double>::const_iterator last = serieses_[i].series_.end();
+ std::multimap<unc, unc>::const_iterator last = serieses_[i].series_.end();
           last--; // Final pair with first the last bin end, and value zero or NaN.
- if (last->second != 0)
+ unc u = last->second;
+ if (u.value() != 0)
           {
             std::cout << "Last bin end " << last->first << " should have zero value! but is " << last->second << std::endl;
             // Or Throw? or skip this series?
           }
- for(std::multimap<double, double>::const_iterator j = serieses_[i].series_.begin();
+ for(std::multimap<unc, unc>::const_iterator j = serieses_[i].series_.begin();
             j != last; ++j)
           { // All the 'good' 'real' data points.
- double x = j->first;
- double y = j->second;
- std::multimap<double, double>::const_iterator j_next = j;
+ unc ux = j->first;
+ double x = ux.value();
+ unc uy = j->second;
+ double y = uy.value();
+ std::multimap<unc, unc>::const_iterator j_next = j;
             j_next++;
             if (j != last)
             { // Draw a column (perhaps filled) to show bin.
- double x_next = j_next->first;
+ unc ux_next= j_next->first;
+ double x_next = ux_next.value();
               double w = x_next - x;
               double h = y / w;
               // std::cout << x << ' ' << y << ' ' << w << ' ' << h << std::endl;
@@ -1947,11 +1969,11 @@
       template <class T>
       svg_2d_plot_series& plot(const T& container, const std::string& title = "");
       template <class T, class U>
- svg_2d_plot_series& plot(const T& container, const std::string& title = "", U functor = boost_default_2d_convert);
+ svg_2d_plot_series& plot(const T& container, const std::string& title = "", U functor = pair_double_2d_convert);
       template <class T>
       svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "");
       template <class T, class U>
- svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = boost_default_2d_convert);
+ svg_2d_plot_series& plot(const T& begin, const T& end, const std::string& title = "", U functor = pair_double_2d_convert);
 
  }; // class svg_2d_plot : public detail::axis_plot_frame<svg_2d_plot>
 
@@ -2679,26 +2701,26 @@
     return *this; //! \return reference to svg_2d_plot to make chainable.
   } // write(file)
 
- template <class T> //! \tparam T Type of data in series (must be convertible to double).
+ template <class T> //! \tparam T Type of data in series (must be convertible to unc double).
   svg_2d_plot_series& svg_2d_plot::plot(const T& container, const std::string& title)
   { /*! Add a container of a data series to the plot.
       This version assumes that *ALL* the data value in the container is used.
       \code
 my_plot.plot(data1, "Sqrt(x)");
       \endcode
- Version converting to double with \c boost_default_2d_convert.
+ Version converting to double with \c pair_double_2d_convert.
     */
     serieses_.push_back(
       svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), detail::boost_default_2d_convert()),
- boost::make_transform_iterator(container.end(), detail::boost_default_2d_convert()),
+ boost::make_transform_iterator(container.begin(), detail::pair_unc_2d_convert()),
+ boost::make_transform_iterator(container.end(), detail::pair_unc_2d_convert()),
       title)
     );
     return serieses_[serieses_.size()-1]; //! \return Reference to data series just added to make chainable.
   }
 
   template <class T, class U>
- svg_2d_plot_series& svg_2d_plot::plot(const T& container, const std::string& title /* = "" */, U functor /* = boost_default_2d_convert*/)
+ svg_2d_plot_series& svg_2d_plot::plot(const T& container, const std::string& title /* = "" */, U functor /* = pair_double_2d_convert*/)
   { /*! This version permits a custom functor (rather than default conversion to double).\n
        Note that this version assumes that *ALL* the data value in the container is used.
     */
@@ -2713,7 +2735,7 @@
 
   template <class T>
   svg_2d_plot_series& svg_2d_plot::plot(const T& begin, const T& end, const std::string& title)
- { /*! Add a data series to the plot (by default, converting automatically to doubles).\n
+ { /*! Add a data series to the plot (by default, converting automatically to unc doubles).\n
       This version permits part of the container to be used, a partial range, using iterators begin to end.\n
       For example:
       \code
@@ -2725,8 +2747,8 @@
    */
     serieses_.push_back(
       svg_2d_plot_series(
- boost::make_transform_iterator(begin, detail::boost_default_convert()),
- boost::make_transform_iterator(end, detail::boost_default_convert()),
+ boost::make_transform_iterator(begin, detail::unc_1d_convert()),
+ boost::make_transform_iterator(end, detail::unc_1d_convert()),
       title)
     );
     return serieses_[series_.size() - 1]; //! \return Reference to data series just added to make chainable.

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_boxplot.hpp 2009-03-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -1981,8 +1981,8 @@
   { //!< Add a data series (the whole container) to boxplot.
     series.push_back(
       svg_boxplot_series(
- boost::make_transform_iterator(container.begin(), detail::boost_default_convert()),
- boost::make_transform_iterator(container.end(), detail::boost_default_convert()),
+ boost::make_transform_iterator(container.begin(), detail::double_1d_convert()),
+ boost::make_transform_iterator(container.end(), detail::double_1d_convert()),
         title, bw, bs, ms, as,
         wl, minws, maxws,
         os, extos, q_def, vs, ss
@@ -2002,8 +2002,8 @@
     }
     series.push_back( // Add a new data series for a boxplot.
       svg_boxplot_series(
- boost::make_transform_iterator(container.begin(), detail::boost_default_convert()),
- boost::make_transform_iterator(container.end(), detail::boost_default_convert()),
+ boost::make_transform_iterator(container.begin(), detail::double_1d_convert()),
+ boost::make_transform_iterator(container.end(), detail::double_1d_convert()),
         title, box_width_, box_style_, median_style_, axis_style_,
         whisker_length_, min_whisker_style_, max_whisker_style_,
         mild_outlier_, ext_outlier_, quartile_definition_, values_style_, series_style_

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-07 07:43:23 EST (Sat, 07 Mar 2009)
@@ -8,14 +8,14 @@
    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 on a extended version including uncertainty as standard deviation & its uncertainty
+ 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
 
 */
-// Copyright Paul A. Bristow 2008
+// Copyright Paul A. Bristow 2009
 
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
@@ -25,6 +25,8 @@
 #ifndef BOOST_SVG_UNCERTAIN_HPP
 #define BOOST_SVG_UNCERTAIN_HPP
 
+#include <boost/svg_plot/detail/pair.hpp>
+
 #include <iostream>
 using std::ostream;
 #include <limits>
@@ -43,6 +45,12 @@
   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);
+ 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(); //!< Get most likely value, typically the mean.
   float uncertainty(); //!< Get estimate of uncertainty, typically standard deviation.
@@ -79,28 +87,36 @@
 
 unc::unc()
 :
- value_(0), uncertainty_(-1.F), deg_free_((std::numeric_limits<unsigned short int>::max)()), types_(0U)
-{ // Constructor.
- // Note the defaults.
+ 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.
 }
-ostream& operator<< (ostream& os, const unc& u)
+
+bool unc::operator<(const unc& rhs) const
 {
- os << u.value_;
- if (u.uncertainty_ > 0)
- { // Uncertainty is defined, so show 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.
- };
- if (u.deg_free_ != (std::numeric_limits<unsigned short int>::max)())
- { // Degrees of freedom is defined, so show it.
- os << " (" << u.deg_free_ << ") ";
- };
- return os;
+ return value_ <rhs.value_;
+}
+
+bool unc::operator<(unc& rhs) const
+{
+ return value_ <rhs.value_;
+}
+
+bool unc::operator ==(const unc& rhs) const
+{
+ return value_ == rhs.value_; // Might check ALL are equal?
+}
+
+unc& unc::operator=(const unc& rhs)
+{
+ value_ = rhs.value_;
+ uncertainty_ = rhs.uncertainty_;
+ deg_free_ = rhs.deg_free_;
+ types_ = rhs.types_ ;
+ return *this; //! to make chainable.
 }
 
+
 double unc::value() //!< Get most likely value, typically the mean.
 {
   return value_;
@@ -140,6 +156,32 @@
   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)".
+ os << u.value_;
+ if (u.uncertainty_ > 0)
+ { // 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.
+ };
+ if (u.deg_free_ != (std::numeric_limits<unsigned short int>::max)())
+ { // Degrees of freedom is defined, so output it.
+ os << " (" << u.deg_free_ << ")";
+ };
+ return os;
+} // ostream& operator<< (ostream& os, const unc& u)
+
+ostream& operator<< (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)".
+ os << u.first << ", " << u.second;
+ return os;
+} // ostream& operator<< (ostream& os, const pair<unc, unc>& u)
+
 } // namespace svg
 } // namespace boost
 #endif // BOOST_SVG_UNCERTAIN_HPP


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