Boost logo

Boost-Commit :

From: JakeVoytko_at_[hidden]
Date: 2007-08-01 20:29:26


Author: jakevoytko
Date: 2007-08-01 20:29:26 EDT (Wed, 01 Aug 2007)
New Revision: 38350
URL: http://svn.boost.org/trac/boost/changeset/38350

Log:
Added rudimentary number limits handling
Added:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 37 ++++++++++++++++++++++++++++++++++++-
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 14 ++++++++++----
   2 files changed, 46 insertions(+), 5 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-08-01 20:29:26 EDT (Wed, 01 Aug 2007)
@@ -14,6 +14,7 @@
 #include "../svg_style.hpp"
 #include "../svg.hpp"
 #include "svg_tag.hpp"
+#include "numeric_limits_handling.hpp"
 
 namespace boost{
 namespace svg{
@@ -31,6 +32,8 @@
     {
         x = derived().x_scale* x + derived().x_shift;
         y = derived().y_scale* y + derived().y_shift;
+
+ _adjust_limits(x, y);
     }
 
     void _transform_x(double &x)
@@ -176,6 +179,11 @@
         }
     }
 
+ void limit_style( )
+ {
+
+ }
+
     void _draw_x_axis()
     {
         double y1(0.);
@@ -408,10 +416,37 @@
         derived().image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
     }
 
+ void _adjust_limits(double& _x, double& _y)
+ {
+ if(detail::limit_max(_x))
+ {
+ _x = derived().plot_x2;
+ }
+ if(detail::limit_max(_y))
+ {
+ _y = derived().plot_y1;
+ }
+ if(detail::limit_min(_x))
+ {
+ _x = derived().plot_x1;
+ }
+ if(detail::limit_min(_y))
+ {
+ _y = derived().plot_y1;
+ }
+ if(detail::limit_NaN(_x))
+ {
+ _x = 0;
+ }
+ if(detail::limit_NaN(_y))
+ {
+ _y = 0;
+ }
+ }
+
     void _draw_plot_point(double _x, double _y,
                           g_element& g_ptr, const plot_point_style& _sty)
     {
-
         int size = _sty.size;
         double half_size = size / 2.;
 

Added: sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/numeric_limits_handling.hpp 2007-08-01 20:29:26 EDT (Wed, 01 Aug 2007)
@@ -0,0 +1,40 @@
+// numeric_limits_handling.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_NUMERIC_LIMITS_HANDLING_DETAIL_HPP
+#define _BOOST_SVG_NUMERIC_LIMITS_HANDLING_DETAIL_HPP
+
+#include <limits>
+
+namespace boost{
+namespace svg{
+namespace detail{
+
+bool limit_max(double a)
+{
+ return (a == std::numeric_limits<double>::max()
+ || a == std::numeric_limits<double>::infinity());
+}
+
+bool limit_min(double a)
+{
+ return (a == std::numeric_limits<double>::min()
+ || a == -std::numeric_limits<double>::infinity()
+ || a == std::numeric_limits<double>::denorm_min());
+}
+
+bool limit_NaN(double a)
+{
+ return (a == std::numeric_limits<double>::quiet_NaN()
+ || a == std::numeric_limits<double>::signaling_NaN());
+}
+
+}
+}
+}
+#endif

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-08-01 20:29:26 EDT (Wed, 01 Aug 2007)
@@ -4,6 +4,8 @@
 #include <vector>
 #include <cmath>
 #include <map>
+#include <iostream>
+#include <limits>
 
 using std::multimap;
 using std::vector;
@@ -35,6 +37,8 @@
     }
 };
 
+using namespace std;
+
 int main()
 {
     using namespace boost::svg;
@@ -47,13 +51,15 @@
 
     double pi = 3.1415926535;
   
- for(double i=0; i<10; i+=pi/4.)
+ data2[1.5] = std::numeric_limits<double>::infinity();
+ for(double i=0; i<10; i+=pi/8.)
     {
- data1[i] = f(i);
+ //data1[i] = f(i);
         data2[i] = g(i);
- data3.push_back(h(i));
+ //data3.push_back(h(i));
     }
 
+ cout<<"Done with first part"<<endl;
     // size/scale settings
     my_2d_plot.image_size(500, 350);
 
@@ -85,7 +91,7 @@
     //my_2d_plot.plot(data1, "sqrt(x)", _bezier_on = true, _size = 5);
 
     my_2d_plot.plot(data2, "Not sqrt(x)",
- _bezier_on = true,
+ _area_fill_color = orange,
         _size = 6,
         _point_style = square,
         _stroke_color = hotpink,


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