Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51672 - 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-09 18:08:39


Author: pbristow
Date: 2009-03-09 18:08:37 EDT (Mon, 09 Mar 2009)
New Revision: 51672
URL: http://svn.boost.org/trac/boost/changeset/51672

Log:
Added prefix, suffix and separator set and get but now does not work right in 1 or 2D.
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 76 ++++++++++++++++++++++++++++-----------
   sandbox/SOC/2007/visualization/boost/svg_plot/show_1d_settings.hpp | 8 ++++
   sandbox/SOC/2007/visualization/boost/svg_plot/show_2d_settings.hpp | 7 +++
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 32 ++++++++++++++++
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 22 +++++------
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html | 5 +-
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk | 6 ---
   sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_values.cpp | 11 ++++-
   8 files changed, 122 insertions(+), 45 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-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -1046,28 +1046,19 @@
               strip_e0s(label.str()) // "1.2" or "3.4e1"...
               :
               stripped = label.str();
- //plot_point_style& sty)
- //int size = sty.size_;
- // was int marker_size = derived().series[0].point_style_.size_;
+ if (val_style.prefix_ != "")
+ { // Want a prefix like "[" or "time = ".
+ stripped = val_style.prefix_ + stripped;
+ }
             int marker_size = point_style.size_; // point marker size
             int label_size = val_style.values_text_style_.font_size();
             // Offset of value label from point must be related mainly to
             // size of the data marker, less the value label font size.
+ // May need to combine these two?
 
- //enum rotate_style
- //{ // Rotation in degrees from horizontal.
- // horizontal = 0, // normal left to right.
- // uphill = -45, // slope up.
- // upward = -90, // vertical writing up.
- // backup = -135, // slope up backwards - upside down!
- // downhill = 45, // slope down.
- // downward = 90, // vertical writing down.
- // backdown = 135, // slope down backwards.
- // upsidedown = 180 // == -180
- //};
             rotate_style rot = val_style.value_label_rotation_;
             // http://www.w3.org/TR/SVG/coords.html#RotationDefined
- // transform="rotate(-45)"
+ // transform="rotate(-45)" == uphill
 
             align_style al; // = center_align;
             switch (rot)
@@ -1159,7 +1150,7 @@
               label.precision(4); // Might need 5 to show 65535?
               //label.flags(sty.value_ioflags_); // Leave at default.
               label << "&#x00A0;(" << df << ")"; // "123"
- // Explicit space "&#x00A0;" seems necessary.
+ // Explicit space "\&#x00A0;" seems necessary.
               label_df = label.str();
               t.tspan(label_df).fill_color(val_style.df_color_).font_size(udf_font);
             }
@@ -1187,7 +1178,14 @@
           { //! Write the \b pair of data point's X and Y values as a string,.
             //! If a separator, then both on the same line, for example "1.23, 3.45", or "[5.6, 7.8]
             //! X value_style is used to provide the prefix and separator, and Y value_style to provide the suffix.
+ //! For example, x_style prefix("[ X=", and separator ",\&#x00A0;Y= ", " and Y value_style = "]"
+ //! will produce a value label like "[X=-1.23, Y=4.56]"
+ //! Note the need to use a Unicode space \&#x00A0; for get space for all browsers.
+ //! For as long a string as this you may need to make the total image size bigger,
+ //! and to orient the value labels with care.
             // draw_plot_point_values is only when both x and Y pairs are wanted.
+ using std::string;
+ using std::stringstream;
             double vx = uncx.value();
             double vy = uncy.value();
             double ux = uncx.uncertainty();
@@ -1195,8 +1193,6 @@
             double dfx = uncx.deg_free();
             double dfy = uncy.deg_free();
 
- using std::string;
- using std::stringstream;
             std::string label_xv = sv(vx, x_sty); //! Also strip unnecessary e, + and leading exponent zeros, if required.
             std::string label_yv = sv(vy, y_sty);
             if (x_sty.prefix_ != "")
@@ -1288,7 +1284,7 @@
             // and also optionally show degrees of freedom (23).
 
             string pm = "&#x00A0;&#x00B1;"; //! Unicode space plusminus glyph.
- // Spaces seem to get lost, so use 00A0 as an explicit space glyph.
+ // Spaces seem to get lost, so use \&x00A0 as an explicit space glyph.
             // Layout seems to vary with font - Times New Roman leaves no space after.
             if ((x_sty.plusminus_on_ == true)
                   && (ux > 0.)
@@ -1310,7 +1306,7 @@
               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.
+ // Explicit space "\&#x00A0;" seems necessary.
               label_xdf = label.str();
               t.tspan(label_xdf).fill_color(x_sty.df_color_).font_size(fx);
             }
@@ -1678,6 +1674,11 @@
           bool x_df_on();
           Derived& x_df_color(const svg_color& col);
           svg_color x_df_color();
+ Derived& x_decor(const std::string& pre, const std::string& sep, const std::string& suf);
+ const std::string x_suffix();
+ const std::string x_separator();
+ const std::string x_prefix();
+
           double x_major_interval();
           Derived& x_major_tick_length(double length);
           double x_major_tick_length();
@@ -3280,7 +3281,7 @@
             return derived().x_values_style_.plusminus_color_;
           }
 
- template <class Derived>
+ template <class Derived>
           Derived& axis_plot_frame<Derived>::x_df_on(bool b)
           { //! Set true if to append a degrees of freedom estimate to data point X values near data points markers.
             //! (May not be implemented yet).
@@ -3295,7 +3296,7 @@
             return derived().x_values_style_.df_on_;
           }
 
- template <class Derived>
+ template <class Derived>
           Derived& axis_plot_frame<Derived>::x_df_color(const svg_color& col)
           { //! Set the color of X degrees of freedom, for example, the color of 9 in "1.23 +-0.02 (9)".
             derived().x_values_style_.df_color_ = col;
@@ -3309,6 +3310,37 @@
           }
 
           template <class Derived>
+ Derived& axis_plot_frame<Derived>::x_decor(const std::string& pre, const std::string& sep, const std::string& suf)
+ { //! Set prefix, separator and suffix for x_style
+ //! Note if you want a space, you must use a Unicode space "\&#x00A0;",
+ //! for example, ",\&#x00A0;" rather than ", ".
+ derived().x_values_style_.prefix_ = pre;
+ derived().x_values_style_.separator_ = sep;
+ derived().x_values_style_.suffix_ = suf;
+ return derived();
+ }
+
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::x_prefix()
+ { //! Get the prefix (only used if separator != "")
+ return derived().x_values_style_.prefix_;
+ }
+
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::x_suffix()
+ { //! Get the suffix (only used if separator != "")
+ return derived().x_values_style_.suffix_;
+ }
+
+ template <class Derived>
+ const std::string axis_plot_frame<Derived>::x_separator()
+ { //! Get separator (also controls use of the prefix & suffix - they are only used if separator != "").
+ //! Note For a space, you must use a Unicode space "\&#x00A0;",
+ //! for example, ",\&#x00A0;" rather than ", ".
+ return derived().x_values_style_.separator_;
+ }
+
+ template <class Derived>
           Derived& axis_plot_frame<Derived>::x_major_tick_length(double length)
           { //! Set length of X major ticks.
             derived().x_ticks_.major_tick_length_ = length;

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/show_1d_settings.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/show_1d_settings.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/show_1d_settings.hpp 2009-03-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -240,6 +240,14 @@
   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");
+ cout << "x_plusminus_on " << plot.x_plusminus_on() << endl;
+ cout << "x_plusminus_color " << plot.x_plusminus_color() << endl;
+ cout << "x_df_on " << plot.x_df_on() << endl;
+ cout << "x_df_color " << plot.x_df_color() << endl;
+ cout << "x_prefix " << plot.x_prefix() << endl;
+ cout << "x_separator " << plot.x_separator() << endl;
+ cout << "x_suffix " << plot.x_suffix() << endl;
+
   // Not applicable to 1D
   //cout << "y_value_precision " << plot.y_value_precision() << endl;
   //cout << "y_value_ioflags " << hex << plot.y_value_ioflags() << dec << ' ';

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-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -249,6 +249,10 @@
   cout << "x_plusminus_color " << plot.x_plusminus_color() << endl;
   cout << "x_df_on " << plot.x_df_on() << endl;
   cout << "x_df_color " << plot.x_df_color() << endl;
+ cout << "x_prefix " << plot.x_prefix() << endl;
+ cout << "x_separator " << plot.x_separator() << endl;
+ cout << "x_suffix " << plot.x_suffix() << 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;
@@ -295,6 +299,9 @@
   cout << "y_plusminus_color " << plot.y_plusminus_color() << endl;
   cout << "y_df_on " << plot.y_df_on() << endl;
   cout << "y_df_color " << plot.y_df_color() << endl;
+ cout << "y_prefix " << plot.y_prefix() << endl;
+ cout << "y_separator " << plot.y_separator() << endl;
+ cout << "y_suffix " << plot.y_suffix() << endl;
 
   cout << "data lines width " << plot.data_lines_width() << endl;
 

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-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -1909,7 +1909,10 @@
       svg_2d_plot& y_df_on(bool b);
       svg_2d_plot& y_df_color(const svg_color& col);
       const svg_color y_df_color();
-
+ svg_2d_plot& y_decor(const std::string& pre, const std::string& sep, const std::string& suf);
+ const std::string y_prefix();
+ const std::string y_suffix();
+ const std::string y_separator();
       svg_2d_plot& y_autoscale(double first, double second);
       svg_2d_plot& y_autoscale(std::pair<double, double> p);
       template <class T> // T an STL container: array, vector ...
@@ -2363,6 +2366,33 @@
         return y_values_style_.df_color_;
       }
 
+ svg_2d_plot& svg_2d_plot::y_decor(const std::string& pre, const std::string& sep, const std::string& suf)
+ { //! Set prefix, separator and suffix for
+ //! Note if you want a space, you must use a Unicode space "\&#x00A0;",
+ //! for example, ",\&#x00A0;" rather than ", ".
+ y_values_style_.prefix_ = pre;
+ y_values_style_.separator_ = sep;
+ y_values_style_.suffix_ = suf;
+ return *this; //! \return reference to svg_2d_plot to make chainable.
+ }
+
+ const std::string svg_2d_plot::y_prefix()
+ { //! Get the prefix (only used if separator != "")
+ return y_values_style_.prefix_;
+ }
+
+ const std::string svg_2d_plot::y_suffix()
+ { //! Get the suffix (only used if separator != "")
+ return y_values_style_.suffix_;
+ }
+
+ const std::string svg_2d_plot::y_separator()
+ { //! Get separator (also controls use of the prefix & suffix - they are only used if separator != "").
+ //! Note For a space, you must use a Unicode space "\&#x00A0;",
+ //! for example, ",\&#x00A0;" rather than ", ".
+ return y_values_style_.separator_;
+ }
+
       svg_2d_plot& svg_2d_plot::y_autoscale(double minimum, double maximum)
       { //! Set Y min & max values to use to autoscale.
         // Does this assume first is min and second is max?

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-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -54,15 +54,19 @@
 
 enum rotate_style
 { //! \enum rotate_style Rotation in degrees clockwise from horizontal.
+ // Might include more steps for others too.
   horizontal = 0, //!< normal horizontal left to right, centered.
   //uphill = -45, //!< slope up. seems bit steep
- uphill = -30, //!< slope up.
+ slopeup = -30, //!< slope up.
+ uphill = -45, //!< 45 up.
+ steepup = -60, //!< up near vertical.
   upward = -90, //!< vertical writing up.
   backup = -135, //!< slope up backwards - upside down!
   leftward= -180, //!< horizontal to left.
   rightward = 360, //!< horizontal to right.
- // downhill = 45, //!< slope down.
- downhill = 30, //!< slope down.
+ slopedownhill = 30, //!< 30 gentle slope down.
+ downhill = 45, //!< 45 down.
+ steepdown = 60, //!< 60 steeply down.
   downward = 90, //!< vertical writing down.
   backdown = 135, //!< slope down backwards.
   upsidedown = 180 //!< upside down! (== -180)
@@ -367,11 +371,6 @@
     font_size_ = i;
     return *this; //! \return text_style& to make chainable.
     //! \return reference to text_style to make chainable.
- // error C2663: 'boost::svg::text_style::font_size' : 2 overloads have no legal conversion for 'this' pointer
- // label_style.font_size(20).font_family("sans");
- // MS docs say:
- // This error can be caused by invoking a non-const member function on a const object.
- // So removed const from text_style& font_size(unsigned i) and all others below.
   }
 
   const std::string& text_style::font_family() const
@@ -592,10 +591,9 @@
       text_style ts, const svg_color& scol = black, svg_color fcol = black, bool pm = false, bool df = false,
       // Separators [,] provide, for example: [1.23+-0.01 (3), 4.56 +-0.2 (10)]
       // default color black.
- // TODO provide access to these.
- std::string pre = "[",
- std::string sep = ",&#x00A0;", // If put ", " the trailing space seems to be ignored, so add Unicode explicit space.
- std::string suf = "]")
+ std::string pre = "", // "[",
+ std::string sep = "", // ,\&#x00A0;", // If put ", " the trailing space seems to be ignored, so add Unicode explicit space.
+ std::string suf = "") // "]")
     :
     value_label_rotation_(r), value_precision_(p), value_ioflags_(f), strip_e0s_(s),
     values_text_style_(ts), stroke_color_(scol), fill_color_(fcol),

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-09 18:08:37 EDT (Mon, 09 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="id775159"></a><p>
+<a name="id785278"></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>
@@ -136,6 +136,7 @@
 <dt><span class="section">Header <boost/svg_plot/svg_color.hpp></span></dt>
 <dt><span class="section">Header <boost/svg_plot/svg_fwd.hpp></span></dt>
 <dt><span class="section">Header <boost/svg_plot/svg_style.hpp></span></dt>
+<dt><span class="section">Header <boost/svg_plot/uncertain.hpp></span></dt>
 </dl></dd>
 <dt><span class="section"><a href="plotting_graphs_in_svg_format/implementation.html"> Implementation
     &amp; Rationale</a></span></dt>
@@ -170,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: February 27, 2009 at 15:09:53 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 09, 2009 at 16:53:48 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk 2009-03-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -28,12 +28,6 @@
 [/ Links ]
 [/ By Eric's convention prefix *and* suffix _ means a defined value. But Use JM and SW double underscore prefix convention.]
 [def __boost [@http://www.boost.org Boost]]
-[/def __iterator [@../../libs/iterator/doc/index.html Boost.Iterator]]
-[/def __basic_regex [^[classref boost::xpressive::basic_regex basic_regex<>]]]
-[/ __basic_regex == file:///I:/boost_trunk/libs/xpressive/doc/html/boost/xpressive/basic_regex.html]
-[/def __regex_match [^[funcref boost::xpressive::regex_match regex_match()]]]
-[/def __syntax_option_type [^[enumref boost::xpressive::regex_constants::syntax_option_type syntax_option_type]]]
-[/def __regex_compile [^[memberref boost::xpressive::basic_regex::compile basic_regex<>::compile()]]]
 
 [/ Generating docs for compound boost::svg::svg]
 [/ Generating XML output for class boost::svg::svg]

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_values.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_values.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/demo_1d_values.cpp 2009-03-09 18:08:37 EDT (Mon, 09 Mar 2009)
@@ -33,6 +33,9 @@
   using namespace boost::svg;
   using boost::svg::svg_1d_plot;
 
+ #include <boost/svg_plot/show_1d_settings.hpp>
+// using boost::svg::show_1d_plot_settings - Only needed for showing which settings in use.
+
 #include <iostream>
   using std::cout;
   using std::endl;
@@ -113,7 +116,9 @@
 placing the values below the horizontal Y-axis line,
 but for 2-D plots all writing orientations can be useful).
 */
- my_1d_plot.x_values_rotation(upward); // Orientation for the X-axis value labels.
+ my_1d_plot.x_values_rotation(steepup); // Orientation for the X-axis value labels.
+
+ my_1d_plot.x_decor("[ x = ", ", y=", "]");
 
 /*`To use all these settings, finally write the plot to file.
 */
@@ -121,8 +126,10 @@
 
 /*`If chosen settings do not have the expected effect, is may be helpful to display them.
 
-(All settings can be displayed with `show_1d_plot_settings(my_1d_plot)`.)
+(All the myriad settings can be displayed with `show_1d_plot_settings(my_1d_plot)`.)
 */
+ show_1d_plot_settings(my_1d_plot);
+
     cout << "my_1d_plot.x_values_font_size() " << my_1d_plot.x_values_font_size() << endl;
     cout << "my_1d_plot.x_values_font_family() " << my_1d_plot.x_values_font_family() << endl;
     cout << "my_1d_plot.x_values_color() " << my_1d_plot.x_values_color() << endl;


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