|
Boost-Commit : |
From: jakevoytko_at_[hidden]
Date: 2007-06-11 23:15:18
Author: jakevoytko
Date: 2007-06-11 23:15:17 EDT (Mon, 11 Jun 2007)
New Revision: 6984
URL: http://svn.boost.org/trac/boost/changeset/6984
Log:
Added ability to map generic STL containers. I'm quite tired, so the only containers tested so far were std::vector and std::deque. Carpe diem!
Text files modified:
sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot.hpp | 27 +++++++++++---------
sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp | 51 ++++++++++++++++++++++++---------------
sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 1
3 files changed, 46 insertions(+), 33 deletions(-)
Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot.hpp 2007-06-11 23:15:17 EDT (Mon, 11 Jun 2007)
@@ -19,6 +19,8 @@
#include "svg_plot_instruction.hpp"
#include "svg.hpp"
+#include <boost/array.hpp>
+
namespace boost {
namespace svg {
@@ -75,12 +77,13 @@
void _x_scale(double, double);
void _plot_image_size(unsigned int, unsigned int);
- void _plot_range(std::vector<double>::iterator,
- std::vector<double>::iterator);
- void _plot_range(std::vector<double>::iterator,
- std::vector<double>::iterator,
+ void _plot_range(std::vector<double>::const_iterator,
+ std::vector<double>::const_iterator);
+ void _plot_range(std::vector<double>::const_iterator,
+ std::vector<double>::const_iterator,
svg_color);
+
void _transform_point(double &x);
void _draw_axis();
void _line_color(const svg_color&);
@@ -185,13 +188,13 @@
svg_plot& svg_plot::operator<<(const plot_draw_range& rhs)
{
- _plot_range(rhs.begin, rhs.end);
+ _plot_range(rhs.data.begin(), rhs.data.end());
return (svg_plot&)*this;
}
svg_plot& svg_plot::operator<<(const plot_draw_col_range& rhs)
{
- _plot_range(rhs.begin, rhs.end, rhs.fill_color);
+ _plot_range(rhs.data.begin(), rhs.data.end(), rhs.fill_color);
return (svg_plot&)*this;
}
@@ -239,8 +242,8 @@
// -----------------------------------------------------------------
// Actually draw data to the plot. Default color information
// -----------------------------------------------------------------
-void svg_plot::_plot_range(std::vector<double>::iterator begin,
- std::vector<double>::iterator end)
+void svg_plot::_plot_range(std::vector<double>::const_iterator begin,
+ std::vector<double>::const_iterator end)
{
double x;
@@ -248,7 +251,7 @@
double y_point = (y_window_min + y_window_max) / 2.;
- for(std::vector<double>::iterator b = begin; b!=end; ++b)
+ for(std::vector<double>::const_iterator b = begin; b!=end; ++b)
{
x = *b;
_transform_point(x);
@@ -260,8 +263,8 @@
// -----------------------------------------------------------------
// Actually draw data to the plot. Fill color information provided
// -----------------------------------------------------------------
-void svg_plot::_plot_range(std::vector<double>::iterator begin,
- std::vector<double>::iterator end,
+void svg_plot::_plot_range(std::vector<double>::const_iterator begin,
+ std::vector<double>::const_iterator end,
svg_color _col)
{
double x;
@@ -281,7 +284,7 @@
g_ptr->set_fill_color(_col);
- for(std::vector<double>::iterator b = begin; b!=end; ++b)
+ for(std::vector<double>::const_iterator b = begin; b!=end; ++b)
{
x = *b;
_transform_point(x);
Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp 2007-06-11 23:15:17 EDT (Mon, 11 Jun 2007)
@@ -20,7 +20,8 @@
// This allows us to process operations by case in switch statements
// -----------------------------------------------------------------
enum plot_inst_type{PLOT_NONE, PLOT_SCALE_X, PLOT_START,
- PLOT_SIZE, PLOT_INTERVAL, PLOT_DRAW_AXIS, PLOT_LINE_COLOR};
+ PLOT_SIZE, PLOT_INTERVAL, PLOT_DRAW_AXIS, PLOT_LINE_COLOR,
+ PLOT_RANGE};
// -----------------------------------------------------------------
// plot_instruction is the ancestor of all of the instructions
@@ -113,17 +114,12 @@
}
};
+// -----------------------------------------------------------------
+//
+// -----------------------------------------------------------------
struct plot_draw_range: public plot_instruction
{
- std::vector<double>::iterator begin;
- std::vector<double>::iterator end;
-
- plot_draw_range(std::vector<double>::iterator _b,
- std::vector<double>::iterator _e)
- {
- begin = _b;
- end = _e;
- }
+ std::vector<double> data;
};
// -----------------------------------------------------------------
@@ -133,10 +129,8 @@
{
svg_color fill_color;
- plot_draw_col_range(std::vector<double>::iterator _b,
- std::vector<double>::iterator _e,
- svg_color_constant _fill_color):
- fill_color(svg_color(_fill_color)), plot_draw_range(_b, _e)
+ plot_draw_col_range(svg_color_constant _fill_color):
+ fill_color(svg_color(_fill_color))
{
}
@@ -156,17 +150,34 @@
return plot_two_vals(x, y, PLOT_SIZE);
}
-plot_draw_range plot_range(std::vector<double>::iterator begin,
- std::vector<double>::iterator end)
+/*plot_draw_range plot_range(const Container<double, T>& begin,
+ const Container<double, T>& end)
+{
+ std::vector<double> hlal(begin, end);
+
+ return plot_draw_range(hlal.begin(), hlal.end());
+}*/
+
+template <class container>
+plot_draw_range plot_range(container begin, container end)
{
- return plot_draw_range(begin, end);
+ plot_draw_range to_return;
+
+ to_return.data.insert(to_return.data.begin(), begin, end);
+
+ return to_return;
}
-plot_draw_col_range plot_range(std::vector<double>::iterator begin,
- std::vector<double>::iterator end,
+template <class container>
+plot_draw_col_range plot_range(container begin,
+ container end,
svg_color_constant col)
{
- return plot_draw_col_range(begin, end, col);
+ plot_draw_col_range to_return(col);
+
+ to_return.data.insert(to_return.data.begin(), begin, end);
+
+ return to_return;
}
plot_command draw_axis()
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 2007-06-11 23:15:17 EDT (Mon, 11 Jun 2007)
@@ -280,7 +280,6 @@
void write(std::ostream&);
};
-
// -----------------------------------------------------------------
// These are the defaults that I used in the prototype, and they
// looked decent enough.
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