Boost logo

Boost-Commit :

From: jakevoytko_at_[hidden]
Date: 2007-07-15 18:52:55


Author: jakevoytko
Date: 2007-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
New Revision: 7441
URL: http://svn.boost.org/trac/boost/changeset/7441

Log:
Minor bug fixes

Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 57 +++++++--------------------------------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 8 +----
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp | 44 +++++++++++++++++++++++++++++-
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 9 ++++-
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 5 ++
   5 files changed, 66 insertions(+), 57 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp 2007-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
@@ -172,36 +172,6 @@
         }
     }
 
- void _draw_axis()
- {
- double x1(0.), y1(0.), y2(derived().image.get_y_size());
-
- _transform_point(x1, y1);
-
- y1 = 0.;
-
- //draw origin. Make sure it is in the window
- if(x1 > derived().plot_window_x1 && x1 < derived().plot_window_x2)
- {
- if(!derived().plot_window_on)
- {
- if(derived().title_on)
- {
- y1 += derived().title_font_size * 1.5;
- }
-
- if(derived().x_label_on)
- {
- y2 -= derived().x_label_font_size * 1.5;
- }
- }
-
- derived().image.get_g_element(PLOT_X_AXIS).line(x1, y1, x1, y2);
- }
-
- _draw_x_axis();
- }
-
     // -----------------------------------------------------------------
     // When writing to multiple documents, the contents of the plot
     // may change significantly between. Rather than figuring out what
@@ -379,23 +349,18 @@
     void _draw_plot_point(double _x, double _y,
                           g_element& g_ptr, const plot_point_style& _sty)
     {
- if(_x > derived().plot_window_x1
- && _x < derived().plot_window_x2
- && _y > derived().plot_window_y1
- && _y < derived().plot_window_y2)
- {
- int size = _sty.size;
- double half_size = size / 2.;
 
- switch(_sty.shape)
- {
- case circle:
- g_ptr.circle(_x, _y, half_size);
- break;
- case square:
- g_ptr.rect(_x - half_size, _y - half_size, size, size);
- break;
- }
+ int size = _sty.size;
+ double half_size = size / 2.;
+
+ switch(_sty.shape)
+ {
+ case circle:
+ g_ptr.circle(_x, _y, half_size);
+ break;
+ case square:
+ g_ptr.rect(_x - half_size, _y - half_size, size, size);
+ break;
         }
     }
 

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp 2007-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
@@ -298,6 +298,7 @@
     g_element& add_g_element()
     {
         children.push_back(new g_element);
+
         return *(static_cast<g_element*>(&children[children.size()-1]));
     }
 
@@ -334,14 +335,9 @@
         return *this;
     }
 
- g_element& add_g_element()
- {
- return _g.add_g_element();
- }
-
     g_element& get_g_element(int i)
     {
- return _g.g_tag(i);
+ return *(static_cast<g_element*>(&children[i]));
     }
 
     g_element& rect(double x1, double y1, double x2, double y2)

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-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
@@ -219,6 +219,40 @@
     return *this;
 }
 
+void _draw_axis()
+{
+ double x(0.), y1(0.), y2(image.get_y_size());
+
+ _transform_x(x);
+
+ y1 = 0.;
+
+ //draw origin. Make sure it is in the window
+ if(x > plot_window_x1 && x < plot_window_x2)
+ {
+ if(!plot_window_on)
+ {
+ if(title_on)
+ {
+ y1 += title_font_size * 1.5;
+ }
+ if(x_label_on)
+ {
+ y2 -= x_label_font_size * 1.5;
+ }
+ }
+
+ else
+ {
+ y1 = plot_window_y1;
+ y2 = plot_window_y2;
+ }
+
+ image.get_g_element(PLOT_X_AXIS).line(x, y1, x, y2);
+ }
+ _draw_x_axis();
+}
+
 //refactor a little
 svg_1d_plot& write(std::ostream& s_out)
 {
@@ -265,10 +299,16 @@
         {
             x = series[i].series[j];
             _transform_x(x);
- _draw_plot_point(x, y, g_ptr, series[i].point_style);
+
+ if(x > plot_window_x1
+ && x < plot_window_x2
+ && y > plot_window_y1
+ && y < plot_window_y2)
+ {
+ _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
         }
     }
-
     image.write(s_out);
 
     return (svg_1d_plot&)*this;

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-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
@@ -215,7 +215,6 @@
                 }
             }
         }
-
     }
 
     void _draw_axis()
@@ -437,7 +436,13 @@
 
             _transform_point(x, y);
             
- _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ if(x > plot_window_x1
+ && x < plot_window_x2
+ && y > plot_window_y1
+ && y < plot_window_y2)
+ {
+ _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
         }
     }
 

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp 2007-07-15 18:52:55 EDT (Sun, 15 Jul 2007)
@@ -78,7 +78,10 @@
     plot_2d(my_2d_plot, data1, "sqrt(x)");
 
     plot_2d(my_2d_plot, data2, "Not sqrt(x)",
- _size = 10);
+ _size = 10,
+ _point_style = square,
+ _stroke_color = hotpink,
+ _fill_color = yellow);
     
     plot(my_1d_plot, data3, "1D Plot");
 


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