Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2007-10-17 06:29:00


Author: pbristow
Date: 2007-10-17 06:29:00 EDT (Wed, 17 Oct 2007)
New Revision: 40112
URL: http://svn.boost.org/trac/boost/changeset/40112

Log:
added comments
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp | 20 +++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 64 ++++++++++----------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 124 +++++++++++++++++++--------------------
   3 files changed, 103 insertions(+), 105 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp 2007-10-17 06:29:00 EDT (Wed, 17 Oct 2007)
@@ -5,7 +5,7 @@
 // Distributed under the Boost Software License, Version 1.0.
 // For more information, see http://www.boost.org
 
-// -----------------------------------------------------------------
+// -----------------------------------------------------------------
 
 #ifndef _BOOST_SVG_SVG_HPP
 #define _BOOST_SVG_SVG_HPP
@@ -16,7 +16,7 @@
 #include <exception>
 #include <vector>
 
-#include "stylesheet.hpp"
+#include "stylesheet.hpp" // TODO better to be called svg_stylesheet.hpp?
 #include "detail/svg_tag.hpp"
 #include "svg_style.hpp"
 
@@ -28,7 +28,7 @@
 protected:
     unsigned int x_size;
     unsigned int y_size;
-
+
     g_element document;
 
         std::vector<clip_path_element> clip_paths;
@@ -47,7 +47,7 @@
         {
             clip_paths[ (unsigned int)i ].write(s_out);
         }
-
+
                 //Write all visual elements
         for(size_t i=0; i<document.size(); ++i)
         {
@@ -84,7 +84,7 @@
     svg& write(const std::string& _file)
     {
         std::ofstream f_out(_file.c_str());
-
+
         if(f_out.fail())
         {
             throw std::runtime_error("Unable to open file "+_file);
@@ -101,7 +101,7 @@
         _write_header(_s_out);
 
         //begin svg tag
- _s_out<<"<svg width=\""<<x_size<<"\" height =\""
+ _s_out<<"<svg width=\""<<x_size<<"\" height =\""
                         <<y_size<<"\" version=\"1.1\""
                         <<" xmlns=\"http://www.w3.org/2000/svg\">"<<std::endl;
 
@@ -146,11 +146,11 @@
     // -----------------------------------------------------------------
     // Writes the information about text to the document
     // -----------------------------------------------------------------
- svg& text(double x, double y, const std::string& text,
- int text_size = 12, text_style align = center_align,
+ svg& text(double x, double y, const std::string& text,
+ int text_size = 12, text_style align = center_align,
         int rotation = 0)
     {
- document.push_back(new text_element(x, y, text, text_size, align,
+ document.push_back(new text_element(x, y, text, text_size, align,
                                             rotation));
 
         return *this;
@@ -162,7 +162,7 @@
 
         return *this;
     }
-
+
     path_element& path()
     {
         document.push_back(new path_element());

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp 2007-10-17 06:29:00 EDT (Wed, 17 Oct 2007)
@@ -2,7 +2,7 @@
 
 // Copyright (C) Jacob Voytko 2007
 // Copyright Paul A. Bristow 2007
-// Added disable warning 4180 in Boost.Parameter.
+// Added disable warning 4180 in Boost.Parameter Sep 2007.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // For more information, see http://www.boost.org
@@ -52,7 +52,7 @@
 // -----------------------------------------------------------------
 // Parameter names for plot() function
 // -----------------------------------------------------------------
-
+
 #if defined (BOOST_MSVC)
 # pragma warning(push)
 # pragma warning (disable: 4512) // "assignment operator could not be generated."
@@ -91,11 +91,11 @@
 
     std::string title;
     plot_point_style point_style;
-
+
 
     // -------------------------------------------------------------
- // Scan each data point between the iterators that are passed,
- // sorting them into the correcet std::veector
+ // Scan each data point between the iterators that are passed,
+ // sorting them into the correct std::vector.
     // -------------------------------------------------------------
     template <class T>
     svg_plot_series(T _begin, T _end, const std::string& _title,
@@ -126,29 +126,29 @@
 class svg_1d_plot: public detail::axis_plot_frame<svg_1d_plot>
 {
 protected:
- // stored so as to avoid rewriting style information constantly
+ // stored so as to avoid rewriting style information constantly.
     svg image;
 
     text_element title_info;
     text_element x_label_info;
 
- // border information for the plot window. Initially will be set
- // to the width and height of the graph
+ // border information for the plot window. Initially will be set
+ // to the width and height of the graph.
     int plot_x1, plot_y1,
         plot_x2, plot_y2;
 
- // axis information
+ // axis information.
     unsigned int x_major_length, x_major_width,
                  x_minor_length, x_minor_width, x_num_minor,
 
- // misc information
- legend_title_size;
-
- // double axis information. y_axis stored as one point because this
- // is a 1D graph
+ // misc information.
+ legend_title_size;
+
+ // axis information.
+ // (y_axis stored as one point because this is a 1D graph).
     double x_min, x_max;
     double x_axis;
-
+
     double x_major;
 
     // Yes/no questions
@@ -167,13 +167,13 @@
 private:
     friend class detail::axis_plot_frame<svg_1d_plot>;
 
- // where we will be storing the data points for transformation
+ // where we will be storing the data points for transformation.
     std::vector<svg_plot_series> series;
 
     double x_scale, x_shift;
     double y_scale, y_shift;
 
-
+
     void _calculate_transform()
     {
         x_scale = (plot_x2-plot_x1)/(x_max-x_min);
@@ -189,7 +189,7 @@
         double x(0.), y1(0.), y2(image.get_y_size());
 
         _transform_x(x);
-
+
         y1 = 0.;
 
         //draw origin. Make sure it is in the window
@@ -251,11 +251,11 @@
                     x_minor_length ;
             }
 
- //for the title. Will take into account font size soon
+ //for the title. Will take into account font size soon TODO
             plot_y1 +=40;
 
             image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
- new rect_element(plot_x1, plot_y1,
+ new rect_element(plot_x1, plot_y1,
                             (plot_x2-plot_x1), plot_y2-plot_y1));
         }
     }
@@ -268,7 +268,7 @@
 
         // draw background
         image.get_g_element(detail::PLOT_BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
+ new rect_element(0, 0, image.get_x_size(),
                      image.get_y_size()));
 
         _draw_title();
@@ -293,7 +293,7 @@
         double x(0), y(0);
 
         _transform_y(y);
-
+
         //draw points
         for(unsigned int i=0; i<series.size(); ++i)
         {
@@ -307,9 +307,9 @@
                 x = series[i].series[j];
                 _transform_x(x);
 
- if(x > plot_x1
+ if(x > plot_x1
                 && x < plot_x2
- && y > plot_y1
+ && y > plot_y1
                 && y < plot_y2)
                 {
                     _draw_plot_point(x, y, g_ptr, series[i].point_style);
@@ -328,17 +328,17 @@
 
 public:
 
-// see documentation for default settings rationale
+// see documentation for default settings rationale.
 svg_1d_plot(): title_info(0, 0, "Plot of data", 30),
                       x_label_info(0, 0, "X Axis", 12),
- x_min(-10), x_max(10),
+ x_min(-10), x_max(10),
                       use_legend(false), use_title(true),
                       use_plot_window(false), use_x_label(false),
                       use_x_major_grid(false), use_x_minor_grid(false),
                       use_x_external_style(false), show_x_axis_lines(true),
                       show_y_axis_lines(true),
- x_major(3), x_minor_length(10),
- x_major_length(20), x_num_minor(2),
+ x_major(3), x_minor_length(10),
+ x_major_length(20), x_num_minor(2),
                       legend_title_size(12),
                       x_scale(1.), x_shift(0),
                       y_scale(1.), y_shift(0)
@@ -382,7 +382,7 @@
 // first clears all unnecessary data from the graph, builds the
 // document tree, and then calls the write function for the root
 // document node, which calls all other nodes through the Visitor
-// pattern
+// pattern.
 // -----------------------------------------------------------------
 svg_1d_plot& write(const std::string& _str)
 {
@@ -417,7 +417,7 @@
     (void),
     plot,
     tag,
- (required
+ (required
         (container, *)
         (title, (const std::string&))
     )
@@ -436,8 +436,8 @@
 {
     series.push_back(svg_plot_series(
         boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor),
- title,
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
         plot_point_style(stroke_color, fill_color, size, point_style)
     ));
 }

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp 2007-10-17 06:29:00 EDT (Wed, 17 Oct 2007)
@@ -1,11 +1,11 @@
-// svg_1d_plot.hpp
+// svg_2d_plot.hpp
 
 // Copyright (C) Jacob Voytko 2007
 //
 // Distributed under the Boost Software License, Version 1.0.
 // For more information, see http://www.boost.org
 
-// -----------------------------------------------------------------
+// -----------------------------------------------------------------
 
 #ifndef _BOOST_SVG_SVG_2D_PLOT_HPP
 #define _BOOST_SVG_SVG_2D_PLOT_HPP
@@ -43,11 +43,9 @@
 #include <iterator>
 #include <exception>
 
-
 namespace boost {
 namespace svg {
 
-
 #ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
 #define BOOST_SVG_BOOST_PARAMETER_NAMES
 
@@ -76,7 +74,7 @@
     plot_line_style line_style;
 
     template <class T>
- svg_2d_plot_series(T _begin,
+ svg_2d_plot_series(T _begin,
                        T _end,
                        std::string _title,
                        const plot_point_style& _point,
@@ -98,36 +96,36 @@
             {
                 series.insert(*i);
             }
- }
+ }
     }
-};
+}; // struct svg_2d_plot_series
 
 class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
 {
 private:
     friend class detail::axis_plot_frame<svg_2d_plot>;
-
+
     double x_scale, x_shift;
     double y_scale, y_shift;
 
- // stored so as to avoid rewriting style information constantly
+ // Stored so as to avoid rewriting style information constantly.
     svg image;
 
     text_element title_info;
     text_element x_label_info;
     text_element y_label_info;
 
- // border information for the plot window. Initially will be set to the width
- // and height of the graph
+ // Border information for the plot window.
+ // Initially will be set to the width and height of the graph.
     int plot_x1;
- int plot_x2;
- int plot_y1;
+ int plot_x2;
+ int plot_y1;
     int plot_y2;
 
- // axis information. y_axis stored as one point because this is a 1D graph
+ // X axis information.
     double x_min, x_max;
     double x_axis;
-
+
     double x_major;
 
     unsigned int x_major_length, x_major_width,
@@ -135,7 +133,7 @@
     unsigned int x_num_minor;
     unsigned int legend_title_size;
 
- // Yes/no questions
+ // Yes/no questions.
     bool use_x_major_labels;
     bool use_x_major_grid;
     bool use_x_minor_grid;
@@ -152,12 +150,12 @@
     bool use_y_major_grid;
     bool use_y_minor_grid;
 
- // where we will be storing the data points for transformation
+ // Where we will be storing the data points for transformation.
     std::vector<svg_2d_plot_series> series;
 
     std::string plot_window_clip;
 
- // axis information
+ // Y axis information.
     double y_min, y_max;
 
     double y_major, y_axis;
@@ -167,12 +165,12 @@
 
     bool use_y_label;
     bool use_y_major_labels;
-
+
     void _draw_y_minor_ticks(double j, path_element& tick_path,
                              path_element& grid_path)
     {
         double y1(0.), x1(0.), x2(image.get_y_size());
-
+
         // draw the grid if needed
         if(use_y_minor_grid)
         {
@@ -182,7 +180,7 @@
             {
                 x2 -= 12 * 1.5;
             }
-
+
             else
             {
                 x1 = plot_x1 + 1;
@@ -212,7 +210,7 @@
 
         _transform_y(y1);
 
- //make sure that we are drawing inside of the allowed window
+ // Make sure that we are drawing inside of the allowed window.
         if(y1 < plot_y2 && y1 > plot_y1)
         {
             tick_path.M(x1, y1).L(x2, y1);
@@ -237,7 +235,7 @@
                 x1 = plot_x1 + 1;
                 x2 = plot_x2 - 1;
             }
-
+
             grid_path.M(x1, y1).L(x2, y1);
         }
 
@@ -246,11 +244,11 @@
 
         _transform_y(y1);
 
- //make sure that we are drawing inside of the allowed window
+ // Make sure that we are drawing inside of the allowed window.
         if(y1 < plot_y2 && y1 > plot_y1)
         {
             double y_tick_length = y_major_length / 2.;
-
+
             if(use_y_external_style)
             {
                 x1 = plot_x1;
@@ -262,7 +260,7 @@
                 x1 = y_axis + y_tick_length/2.;
                 x2 = y_axis - y_tick_length/2.;
             }
-
+
             tick_path.M(x1, y1).L(x2, y1);
 
             if(use_y_major_labels)
@@ -282,13 +280,13 @@
 
                 if(!use_y_external_style && i != 0)
                 {
- image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
                         y1, fmt.str());
                 }
 
                 if(use_y_external_style)
                 {
- image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1 + 12,
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1 + 12,
                         y1, fmt.str(), 12, center_align, -90);
 
                 }
@@ -300,16 +298,16 @@
     {
         double x1(0.);
 
- // draw the axis line
+ // Draw the axis line.
         _transform_x(x1);
         image.get_g_element(detail::PLOT_Y_AXIS).line(x1, plot_y1, x1, plot_y2);
 
         y_axis = x1;
 
- path_element& minor_tick_path =
+ path_element& minor_tick_path =
             image.get_g_element(detail::PLOT_Y_MINOR_TICKS).path();
 
- path_element& major_tick_path =
+ path_element& major_tick_path =
             image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).path();
 
         path_element& minor_grid_path =
@@ -340,7 +338,7 @@
             _draw_y_major_ticks(i, major_tick_path, major_grid_path);
         }
 
- // draw the ticks on the negative side
+ // draw the ticks on the negative side.
         for(double i = 0; i > y_min; i -= y_major)
         {
             // draw minor ticks
@@ -363,18 +361,18 @@
     {
         image.get_g_element(detail::PLOT_Y_LABEL).style().stroke_color(black);
 
- image.get_g_element(detail::PLOT_Y_LABEL).push_back(new
- text_element(12, (plot_y2 + plot_y1)/2.,
+ image.get_g_element(detail::PLOT_Y_LABEL).push_back(new
+ text_element(12, (plot_y2 + plot_y1)/2.,
             y_label_info.text(),
             12, center_align, -90));
     }
 
-
+
     void _calculate_transform()
     {
         x_scale = (plot_x2 - plot_x1) / (x_max - x_min);
         x_shift = plot_x1 - x_min *(plot_x2-plot_x1)/(x_max-x_min);
-
+
              y_scale = -(plot_y2-plot_y1)/(y_max-y_min);
 
              y_shift = plot_y1 - (y_max *(plot_y1-plot_y2)/(y_max-y_min));
@@ -411,7 +409,7 @@
             plot_y1+=5;
             plot_y2-=5;
 
-
+
             if(use_legend)
             {
                 plot_x2 -= 155;
@@ -419,7 +417,7 @@
 
             if(use_y_external_style)
             {
- plot_x1 +=
+ plot_x1 +=
                     y_major_length > y_minor_length ?
                     y_major_length :
                     y_minor_length ;
@@ -434,7 +432,7 @@
             }
 
             image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
- new rect_element(plot_x1, plot_y1,
+ new rect_element(plot_x1, plot_y1,
                             (plot_x2-plot_x1), plot_y2-plot_y1));
         }
     }
@@ -476,7 +474,7 @@
 
             _transform_pair(n_minus_1);
             _transform_pair(n);
-
+
             path.M(n_minus_1.first, n_minus_1.second);
 
             for(; iter != series.series.end(); ++iter)
@@ -487,7 +485,7 @@
 
                 _transform_pair(n);
 
- back_vtr.first = ((n_minus_1.first - n.first) +
+ back_vtr.first = ((n_minus_1.first - n.first) +
                                  (n_minus_2.first - n_minus_1.first)) * .2;
 
                 back_vtr.second = ((n_minus_1.second - n.second) +
@@ -508,7 +506,7 @@
         {
             _draw_straight_lines(series);
         }
-
+
     }
 
     void _draw_straight_lines(const svg_2d_plot_series& series)
@@ -562,7 +560,7 @@
                 _transform_point(temp_x, temp_y);
 
                 path.L(temp_x, temp_y);
-
+
                 if(series.line_style.area_fill == blank)
                 {
                     path.M(temp_x, temp_y);
@@ -602,7 +600,7 @@
 
         // Draw background.
         image.get_g_element(detail::PLOT_BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
+ new rect_element(0, 0, image.get_x_size(),
                      image.get_y_size()));
 
         _draw_title();
@@ -613,7 +611,7 @@
         // We don't want to allow overlap of the plot window lines, thus the
         // minor adjustments.
 
- image.clip_path(rect_element(plot_x1 + 1, plot_y1 + 1,
+ image.clip_path(rect_element(plot_x1 + 1, plot_y1 + 1,
                                      plot_x2 - plot_x1 - 2, plot_y2 - plot_y1 - 2),
                         plot_window_clip);
 
@@ -640,7 +638,7 @@
             _draw_y_label();
         }
 
- // Draw lines between non-limit points
+ // Draw lines between non-limit points.
 
         _draw_plot_lines();
 
@@ -649,19 +647,19 @@
         for(unsigned int i=0; i<series.size(); ++i)
         {
             g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
-
+
             g_ptr.style()
                  .fill_color(series[i].point_style.fill_color)
                  .stroke_color(series[i].point_style.stroke_color);
 
- for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
+ for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
                 j!=series[i].series.end(); ++j)
             {
                 x = j->first;
                 y = j->second;
 
                 _transform_point(x, y);
-
+
                 if(x > plot_x1 && x < plot_x2
                 && y > plot_y1 && y < plot_y2)
                 {
@@ -674,15 +672,15 @@
         for(unsigned int i=0; i<series.size(); ++i)
         {
             g_element& g_ptr = image.get_g_element(detail::PLOT_LIMIT_POINTS);
-
- for(std::multimap<double,double>::const_iterator j = series[i].series_limits.begin();
+
+ for(std::multimap<double,double>::const_iterator j = series[i].series_limits.begin();
                 j!=series[i].series_limits.end(); ++j)
             {
                 x = j->first;
                 y = j->second;
 
                 _transform_point(x, y);
-
+
                 _draw_plot_point(x, y, g_ptr, plot_point_style(blank, blank, 10, circle));
             }
         }
@@ -693,19 +691,19 @@
 svg_2d_plot(): title_info(0, 0, "Plot of data", 30),
                       x_label_info(0, 0, "X Axis", 12),
                       y_label_info(0, 0, "Y Axis", 12),
- x_min(-10), x_max(10),
- y_min(-10), y_max(10),
- x_major(3), x_num_minor(2),
+ x_min(-10), x_max(10),
+ y_min(-10), y_max(10),
+ x_major(3), x_num_minor(2),
                       y_major(3), use_y_label(false),
                       x_minor_length(10), x_major_length(20),
                       x_major_width(2), x_minor_width(1),
- y_minor_length(10), y_num_minor(2),
+ y_minor_length(10), y_num_minor(2),
                       y_major_length(20), legend_title_size(12),
                       plot_window_clip("__clip_window"),
                       use_x_major_labels(true), use_x_major_grid(false),
                       use_x_minor_grid(false), use_x_label(false),
                       use_title(true), use_legend(false), use_axis(true),
- use_plot_window(false), use_y_major_labels(false),
+ use_plot_window(false), use_y_major_labels(false),
                       use_x_external_style(false), use_y_external_style(false),
                       show_x_axis_lines(true), show_y_axis_lines(true),
                       use_y_major_grid(false), use_y_minor_grid(false)
@@ -713,13 +711,13 @@
 {
     image_size(500, 350);
 
- //build the document tree.. add children of the root node
+ // Build the document tree.. add children of the root node.
     for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
     {
         image.add_g_element();
     }
 
- // set color defaults
+ // Set color defaults.
     image.get_g_element(detail::PLOT_BACKGROUND)
         .style().fill_color(white);
 
@@ -944,7 +942,7 @@
     (void),
     plot,
     tag,
- (required
+ (required
         (container, *)
         (title, (const std::string&))
     )
@@ -972,9 +970,9 @@
 
     series.push_back(
         svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor),
- title,
+ boost::make_transform_iterator(container.begin(), x_functor),
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
         plot_point_style(fill_color, stroke_color, size, point_style),
         line_style
         ));


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