Boost logo

Boost-Commit :

From: jakevoytko_at_[hidden]
Date: 2007-06-19 00:09:30


Author: jakevoytko
Date: 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
New Revision: 7095
URL: http://svn.boost.org/trac/boost/changeset/7095

Log:
Added customizable instructions, committing early to let delete go through

Removed:
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_instruction.hpp
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_tag.hpp
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp | 66 +++++++++++++++++-------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 49 ++++++++++++++---
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp | 81 +++++++++++++++--------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot.hpp | 108 ++++++++++++++++++++++++++++++++++-----
   4 files changed, 220 insertions(+), 84 deletions(-)

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
@@ -271,23 +271,23 @@
 private:
     svg_color fill_color;
     svg_color stroke_color;
+
+ unsigned int stroke_width;
     
 public:
     svg_g_style();
     svg_g_style(const svg_color&, const svg_color&);
+
     void set_fill_color(const svg_color&);
     void set_stroke_color(const svg_color&);
+
+ void set_stroke_width(unsigned int);
     void write(std::ostream&);
 
- svg_color get_fill_color()
- {
- return svg_color(fill_color);
- }
-
- svg_color get_stroke_color()
- {
- return svg_color(stroke_color);
- }
+ svg_color get_fill_color();
+ svg_color get_stroke_color();
+
+ unsigned int get_stroke_width();
 };
 
 // -----------------------------------------------------------------
@@ -295,7 +295,7 @@
 // looked decent enough.
 // -----------------------------------------------------------------
 svg_g_style::svg_g_style():fill_color(svg_color(255, 0, 0)),
- stroke_color(svg_color(0, 0, 0))
+ stroke_color(svg_color(0, 0, 0)), stroke_width(0)
 {
 
 }
@@ -305,20 +305,11 @@
 // For changing the defaults for the colors
 // -----------------------------------------------------------------
 svg_g_style::svg_g_style(const svg_color& _fill, const svg_color& _stroke)
-:fill_color(_fill), stroke_color(_stroke)
+:fill_color(_fill), stroke_color(_stroke), stroke_width(0)
 {
 
 }
 
-void svg_g_style::write(std::ostream& rhs)
-{
- rhs << "stroke=\"";
- stroke_color.write(rhs);
- rhs << "\" fill=\"";
- fill_color.write(rhs);
- rhs<<"\"";
-}
-
 void svg_g_style::set_stroke_color(const svg_color& rhs)
 {
     stroke_color = rhs;
@@ -329,6 +320,41 @@
     fill_color = rhs;
 }
 
+void svg_g_style::set_stroke_width(unsigned int _width)
+{
+ stroke_width = _width;
+}
+
+svg_color svg_g_style::get_fill_color()
+{
+ return svg_color(fill_color);
+}
+
+svg_color svg_g_style::get_stroke_color()
+{
+ return svg_color(stroke_color);
+}
+
+unsigned int svg_g_style::get_stroke_width()
+{
+ return stroke_width;
+}
+
+void svg_g_style::write(std::ostream& rhs)
+{
+ rhs << "stroke=\"";
+ stroke_color.write(rhs);
+ rhs << "\" fill=\"";
+ fill_color.write(rhs);
+ rhs<<"\" ";
+
+ if(stroke_width > 0)
+ {
+ rhs << "stroke-width=\""
+ << stroke_width
+ << "\" ";
+ }
+}
 
 }//svg
 }//boost

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-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
@@ -35,8 +35,14 @@
 {
 public:
     virtual void write(std::ostream&) = 0;
+ virtual ~svg_element();
 };
 
+svg_element::~svg_element()
+{
+
+}
+
 // -----------------------------------------------------------------
 // The node element of our document tree
 // -----------------------------------------------------------------
@@ -54,11 +60,10 @@
     
     void set_stroke_color(const svg_color&);
     void set_fill_color(const svg_color&);
+ void set_stroke_width(unsigned int);
+
+ svg_color get_stroke_color();
 
- svg_color get_stroke_color()
- {
- return style_info.get_stroke_color();
- }
     void write(std::ostream&);
 
     g_element& g_tag(int);
@@ -104,6 +109,15 @@
     style_info.set_fill_color(_col);
 }
 
+void g_element::set_stroke_width(unsigned int _width)
+{
+ style_info.set_stroke_width(_width);
+}
+
+svg_color g_element::get_stroke_color()
+{
+ return style_info.get_stroke_color();
+}
 
 // -----------------------------------------------------------------
 // Represents a single point
@@ -164,12 +178,16 @@
 {
 private:
     double x, y;
+ int font_size;
     std::string text;
     text_style alignment;
 
 public:
     text_element(double, double, std::string);
     void write(std::ostream&);
+
+ void set_font_size(unsigned int);
+
     void set_alignment(text_style _a)
     {
         alignment = _a;
@@ -177,7 +195,7 @@
 };
 
 text_element::text_element(double _x, double _y, std::string _text)
- :x(_x), y(_y), text(_text), alignment(left_align)
+ :x(_x), y(_y), text(_text), alignment(left_align), font_size(12)
 {
     
 }
@@ -213,13 +231,26 @@
         rhs << "text-anchor=\""<<align<<"\" ";
     }
 
- rhs <<" fill=\"black\" stroke=\"black\" font-family=\"verdana\""
- <<" font-size=\"12\">"
- << text
+ rhs <<" fill=\"black\" stroke=\"black\" font-family=\"verdana\"";
+
+ if(font_size == 0)
+ {
+ rhs <<" font-size=\"12\">";
+ }
+
+ else
+ {
+ rhs <<" font-size=\""<<font_size<<"\">";
+ }
+
+ rhs << text
         <<" </text>";
 }
 
-
+void text_element::set_font_size(unsigned int _size)
+{
+ font_size = _size;
+}
 
 // -----------------------------------------------------------------
 // Represents a single block of text

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-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
@@ -16,8 +16,8 @@
 #include <iostream>
 #include <fstream>
 
-#include "svg_tag.hpp"
-#include "svg_style.hpp"
+#include "detail/svg_tag.hpp"
+#include "detail/svg_style.hpp"
 
 namespace boost {
 namespace svg {
@@ -25,15 +25,8 @@
 class svg
 {
 private:
- std::ostream *s_out;
-
- void _write_header();
- void _write_document();
-
- //Don't let people initialize this class
- //without specifying the stream. I can't think
- //of a reasonable default.
- svg();
+ void _write_header(std::ostream&);
+ void _write_document(std::ostream&);
 
 protected:
     unsigned int x_size;
@@ -42,7 +35,7 @@
     g_element document;
 
 public:
- svg(const std::string&);
+ svg();
     
     virtual ~svg();
 
@@ -50,7 +43,9 @@
     svg& operator=(const svg&);
 
     svg& image_size(unsigned int, unsigned int);
- svg& write();
+
+ svg& write(std::string);
+ svg& write(std::ostream&);
 
     svg& point(double, double);
     svg& point(double, double, g_element&);
@@ -68,46 +63,54 @@
 };
 
 // -----------------------------------------------------------------
-// Constructors will be added so that the user can specify
-// a stream instead of a filename
 // -----------------------------------------------------------------
-svg::svg(const std::string& fname)
- :s_out(new std::ofstream(fname.c_str()))
-{
+svg::svg():x_size(200), y_size(200)
+{
+
 }
 
 svg::~svg()
-{
- delete s_out;
+{
+
 }
 
-//I still need to put more thought into whether I want this class
-//copyable or not
-svg::svg(const svg& rhs)
+svg& svg::write(std::string _file)
 {
- x_size = rhs.x_size;
- y_size = rhs.y_size;
- //Todo: put something that will copy the elements from the
- //ptr_vector in rhs to this. ptr_vectors are noncopyable
+ std::ofstream fout(_file.c_str());
+
+ if(fout.fail())
+ {
+ throw "Unable to open file "+_file;
+ }
 
- //document = rhs.document;
+ _write_header(fout);
+
+ //begin svg tag
+ fout<<"<svg width=\""<<x_size<<"\" height =\""
+ <<y_size<<"\" version=\"1.1\""
+ <<" xmlns=\"http://www.w3.org/2000/svg\">"<<std::endl;
+
+ _write_document(fout);
+
+ //close off svg tag
+ fout<<"</svg>";
+
+ return *this;
 }
 
-// -----------------------------------------------------------------
-// -----------------------------------------------------------------
-svg& svg::write()
+svg& svg::write(std::ostream& s_out)
 {
- _write_header();
+ _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;
 
- _write_document();
+ _write_document(s_out);
 
     //close off svg tag
- *s_out<<"</svg>";
+ s_out<<"</svg>";
 
     return *this;
 }
@@ -115,14 +118,14 @@
 // -----------------------------------------------------------------
 // Internal function to write all of the data to the svg document
 // -----------------------------------------------------------------
-void svg::_write_document()
+void svg::_write_document(std::ostream& s_out)
 {
     //Write color information
 
     //Write all visual elements
     for(size_t i=0; i<document.size(); ++i)
     {
- document[ (unsigned int)i ].write(*s_out);
+ document[ (unsigned int)i ].write(s_out);
     }
 
     //end g tag
@@ -131,9 +134,9 @@
 // -----------------------------------------------------------------
 // This prints the svg 1.1 header into the document
 // -----------------------------------------------------------------
-void svg::_write_header()
+void svg::_write_header(std::ostream& s_out)
 {
- *s_out << "<?xml version=\"1.0\" standalone=\"no\"?>"
+ s_out << "<?xml version=\"1.0\" standalone=\"no\"?>"
            << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
            << "\"http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd\">"<<std::endl;
 }

Deleted: sandbox/SOC/2007/visualization/boost/svg_plot/svg_instruction.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_instruction.hpp 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
+++ (empty file)
@@ -1,127 +0,0 @@
-// svg_instruction.hpp
-
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-
-// -----------------------------------------------------------------
-
-#ifndef _SVG_INSTRUCTION_HPP
-#define _SVG_INSTRUCTION_HPP
-
-namespace boost {
-namespace svg {
-
-#include "svg_style.hpp"
-
-// -----------------------------------------------------------------
-// IMPORTANT: the contents of this file will likely be completely
-// rewritten when I redo the public interface for svg::svg. I'm
-// focusing on the interface for svg::svg_plot currently
-// -----------------------------------------------------------------
-
-enum instruction_type{SVG_POINT, SVG_WRITE, SVG_SIZE};
-
-// -----------------------------------------------------------------
-// The svg_instruction struct is what we are using to pass the svg
-// class arguments through the << operator interface.
-// -----------------------------------------------------------------
-struct svg_instruction
-{
- instruction_type i_type;
-
- svg_instruction(instruction_type i): i_type(i)
- {
- }
-};
-
-struct svg_point
-{
- double x, y;
-
- instruction_type i_type;
-
- svg_point(double _x, double _y, instruction_type _it): x(_x), y(_y), i_type(_it)
- {
-
- }
-};
-
-struct svg_line
-{
- double x1, y1, x2, y2;
-
- svg_line(double _x1, double _y1, double _x2, double _y2):
- x1(_x1), x2(_x2), y1(_y1), y2(_y2)
- {
-
- }
-};
-
-struct svg_text
-{
- double x, y;
- std::string text;
-
- svg_text(double _x, double _y, std::string _t):x(_x), y(_y), text(_t)
- {
-
- }
-};
-
-struct svg_stroke_color
-{
- svg_color col;
- svg_stroke_color(svg_color _c):col(_c)
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-// This allows the user to set the size of the image in centimeters
-// TODO: allow other unit identifiers
-// -----------------------------------------------------------------
-svg_point image_size(unsigned int width, unsigned int height)
-{
- if( (height <= 0) || (width <= 0) )
- {
- throw "Invalid image size";
- }
-
- return svg_point(width, height, SVG_SIZE);
-}
-
-svg_instruction write()
-{
- return svg_instruction(SVG_WRITE);
-}
-
-svg_point draw_point(double x, double y)
-{
- return svg_point(x, y, SVG_POINT);
-}
-
-svg_line draw_line(double x1, double y1, double x2, double y2)
-{
- svg_line to_ret(x1, y1, x2, y2);
-
- return to_ret;
-}
-
-svg_text draw_text(double x, double y,
- const std::string& text)
-{
- return svg_text(x, y, text);
-}
-
-svg_stroke_color stroke_color(svg_color c)
-{
- return svg_stroke_color(c);
-}
-
-}
-}
-
-#endif

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-19 00:09:29 EDT (Tue, 19 Jun 2007)
@@ -17,7 +17,7 @@
 #include <limits>
 
 #include "svg.hpp"
-#include "svg_plot_instruction.hpp"
+#include "detail/svg_plot_instruction.hpp"
 
 
 #include <boost/array.hpp>
@@ -36,10 +36,10 @@
 // "legend" is on top because either it'll be laid on top of the graph,
 // or it'll be off to the side.
 // -----------------------------------------------------------------
-#define SVG_PLOT_DOC_CHILDREN 3
+#define SVG_PLOT_DOC_CHILDREN 4
 
 enum svg_plot_doc_structure{SVG_PLOT_BACKGROUND, SVG_PLOT_PLOT,
- SVG_PLOT_LEGEND};
+ SVG_PLOT_LEGEND, SVG_PLOT_TITLE};
 
 // -----------------------------------------------------------------
 // The following enums define the children for the legend. This will be
@@ -78,17 +78,13 @@
     bool legend_on;
     std::vector<legend_point> legend;
 
- //Don't let the user use this without specifying a stream.
- //I can't think of a reasonable default, and I don't think
- //they'd want the svg formatted output spit to the console
- svg_plot();
-
     void _transform_point(double &x);
     void _clear_legend();
     void _draw_legend_header(int, int, int, int);
     void _draw_legend();
 
 public:
+ svg_plot();
     svg_plot(const std::string& file);
     
     svg_plot& x_scale(double, double);
@@ -98,21 +94,30 @@
     
     svg_plot& line_color(const svg_color&);
 
- svg_plot& write();
+ svg_plot& write(const std::string&);
+ svg_plot& write(std::ostream&);
 
     svg_plot& image_size(unsigned int, unsigned int);
 
+ svg_plot& set_title(const std::string&);
+ svg_plot& set_title_font_size(unsigned int);
+
     svg_plot& set_background_color(svg_color_constant);
     svg_plot& set_background_color(const svg_color&);
 
     svg_plot& set_legend_background_color(svg_color_constant);
     svg_plot& set_legend_background_color(const svg_color&);
 
+ svg_plot& set_axis_color(svg_color_constant);
+ svg_plot& set_axis_color(const svg_color&);
+
+ svg_plot& set_axis_thickness(unsigned int);
+
     void plot_range(std::vector<double>::const_iterator,
- std::vector<double>::const_iterator, std::string);
+ std::vector<double>::const_iterator, const std::string&);
     
     void plot_range(std::vector<double>::const_iterator,
- std::vector<double>::const_iterator, std::string, svg_color_constant);
+ std::vector<double>::const_iterator, const std::string&, svg_color_constant);
 };
 
 // -----------------------------------------------------------------
@@ -125,7 +130,7 @@
 // Note: All of the points are going to be on the same line, so
 // there is no sense calculating any aspect of the y value
 // -----------------------------------------------------------------
-svg_plot::svg_plot(const std::string& file): svg(file)
+svg_plot::svg_plot()
 {
     for(int i = 0; i < 3; ++i)
     {
@@ -215,7 +220,7 @@
 // -----------------------------------------------------------------
 void svg_plot::plot_range(std::vector<double>::const_iterator begin,
                             std::vector<double>::const_iterator end,
- std::string _str)
+ const std::string& _str)
 {
     double x;
 
@@ -251,7 +256,7 @@
 // -----------------------------------------------------------------
 void svg_plot::plot_range(std::vector<double>::const_iterator begin,
                             std::vector<double>::const_iterator end,
- std::string _str,
+ const std::string& _str,
                             svg_color_constant _col)
 {
     double x;
@@ -284,6 +289,36 @@
 }
 
 // -----------------------------------------------------------------
+// Sets the title. Currently, the title is centered at the top of
+// the screen
+// -----------------------------------------------------------------
+svg_plot& svg_plot::set_title(const std::string& _title)
+{
+ text_element title(x_size/2., 30, _title);
+
+ title.set_alignment(center_align);
+
+ document.g_tag(SVG_PLOT_TITLE)
+ .children.push_back(new text_element(title));
+
+ return (svg_plot&)*this;
+}
+
+// -----------------------------------------------------------------
+// Setting the font size for the title before the text has been
+// written causes a runtime error
+// -----------------------------------------------------------------
+svg_plot& svg_plot::set_title_font_size(unsigned int _size)
+{
+ text_element* t_ptr = static_cast<text_element*>(&(document.
+ g_tag(SVG_PLOT_TITLE).children[0]));
+
+ t_ptr->set_font_size(_size);
+
+ return (svg_plot&)*this;
+}
+
+// -----------------------------------------------------------------
 // Sets the background color in the area of the document. Specifically,
 // done by adding a rectangle to the background that hits the edges
 // of the image
@@ -324,6 +359,35 @@
 }
 
 // -----------------------------------------------------------------
+// Currently sets the color of both axes
+// -----------------------------------------------------------------
+svg_plot& svg_plot::set_axis_color(svg_color_constant _col)
+{
+ set_axis_color(constant_to_rgb(_col));
+
+ return (svg_plot&)*this;
+}
+
+svg_plot& svg_plot::set_axis_color(const svg_color& _col)
+{
+ document.g_tag(SVG_PLOT_PLOT).g_tag(SVG_PLOT_PLOT_AXIS)
+ .set_fill_color(_col);
+
+ document.g_tag(SVG_PLOT_PLOT).g_tag(SVG_PLOT_PLOT_AXIS)
+ .set_stroke_color(_col);
+
+ return (svg_plot&)*this;
+}
+
+svg_plot& svg_plot::set_axis_thickness(unsigned int _width)
+{
+ document.g_tag(SVG_PLOT_PLOT).g_tag(SVG_PLOT_PLOT_AXIS)
+ .set_stroke_width(_width);
+
+ return (svg_plot&)*this;
+}
+
+// -----------------------------------------------------------------
 // This transforms a 1-D Cartesian point into a svg point. We don't
 // use the svg-defined coordinate transform because sizing is a harder
 // problem in the svg coordinate transforms, and text would be
@@ -509,7 +573,7 @@
     }
 }
 
-svg_plot& svg_plot::write()
+svg_plot& svg_plot::write(const std::string& _str)
 {
     // Hold off drawing the legend until the very end.. it's
     // easier to draw the size that it needs at the end than
@@ -520,11 +584,23 @@
         _draw_legend();
     }
 
- svg::write();
+ svg::write(_str);
 
     return (svg_plot&)*this;
 }
 
+svg_plot& svg_plot::write(std::ostream& s_out)
+{
+ if(legend_on)
+ {
+ _draw_legend();
+ }
+
+ svg::write(s_out);
+
+ return (svg_plot&)*this;
+}
+
 template <class iter>
 void plot_range(svg_plot& _cont, iter _begin, iter _end, std::string _str)
 {

Deleted: sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_plot_instruction.hpp 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
+++ (empty file)
@@ -1,201 +0,0 @@
-// svg_plot_instruction.hpp
-
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-
-// -----------------------------------------------------------------
-
-#ifndef _SVG_PLOT_INSTRUCTION_HPP
-#define _SVG_PLOT_INSTRUCTION_HPP
-
-#include <iterator>
-#include "svg_style.hpp"
-
-namespace boost {
-namespace svg {
-
-// -----------------------------------------------------------------
-// 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_RANGE};
-
-// -----------------------------------------------------------------
-// plot_instruction is the ancestor of all of the instructions
-// that can be passed to a svg_plot
-//
-// TODO: the same for SVG
-// -----------------------------------------------------------------
-struct plot_instruction
-{
- plot_inst_type i_type;
-
- plot_instruction()
- {
- i_type=PLOT_NONE;
- }
-
- plot_instruction(plot_inst_type _i):i_type(_i)
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-// plot_commands are the commands that answer yes/no questions,
-// such as axes or no axes
-// -----------------------------------------------------------------
-struct plot_command: public plot_instruction
-{
- plot_command(plot_inst_type _i):plot_instruction(_i)
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-// plot_single_vals are in response to commands that take a single
-// argument, such as the starting position of plots
-// -----------------------------------------------------------------
-struct plot_single_val: public plot_instruction
-{
- double x;
-
- plot_single_val(double _x, plot_inst_type _i): x(_x), plot_instruction(_i)
- {
- }
-};
-
-// -----------------------------------------------------------------
-// plot_scale is to handle commands that take two double arguments
-// -----------------------------------------------------------------
-struct plot_two_vals: public plot_instruction
-{
- double x1, x2;
-
- plot_two_vals(double _x1, double _x2, plot_inst_type _i)
- :x1(_x1), x2(_x2), plot_instruction(_i)
- {
-
- }
-};
-
-
-// -----------------------------------------------------------------
-// the commands for using arguments that are based around four
-// values
-// -----------------------------------------------------------------
-struct plot_four_vals: public plot_instruction
-{
- double x1, y1, x2, y2;
-
- plot_four_vals(double _x1, double _y1, double _x2, double _y2,
- plot_inst_type _i): x1(_x1), y1(_y1), x2(_x2), y2(_y2),
- plot_instruction(_i)
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-// For arguments of a color nature
-// -----------------------------------------------------------------
-struct plot_color: public plot_instruction
-{
- svg_color col;
-
- plot_color(const svg_color& _col, plot_inst_type _i): col(_col),
- plot_instruction(_i)
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-//
-// -----------------------------------------------------------------
-struct plot_draw_range: public plot_instruction
-{
- std::vector<double> data;
-};
-
-// -----------------------------------------------------------------
-// fill_color defines the color of the points that are to be drawn
-// -----------------------------------------------------------------
-struct plot_draw_col_range: public plot_draw_range
-{
- svg_color fill_color;
-
- plot_draw_col_range(svg_color_constant _fill_color):
- fill_color(svg_color(_fill_color))
- {
-
- }
-};
-
-// -----------------------------------------------------------------
-// The following functions return the values from the user
-// interface to values that the svg_plot class can understand
-// -----------------------------------------------------------------
-plot_two_vals x_scale(double x1, double x2)
-{
- return plot_two_vals(x1, x2, PLOT_SCALE_X);
-}
-
-plot_two_vals image_size(int x, int y)
-{
- return plot_two_vals(x, y, PLOT_SIZE);
-}
-
-/*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)
-{
- plot_draw_range to_return;
-
- to_return.data.insert(to_return.data.begin(), begin, end);
-
- return to_return;
-}
-
-template <class container>
-plot_draw_col_range plot_range(container begin,
- container end,
- svg_color_constant 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()
-{
- return plot_command(PLOT_DRAW_AXIS);
-}
-
-plot_color line_color(svg_color c)
-{
- return plot_color(c, PLOT_LINE_COLOR);
-}
-
-plot_color line_color(svg_color_constant c)
-{
- return plot_color(constant_to_rgb(c), PLOT_LINE_COLOR);
-}
-
-}
-}
-
-#endif

Deleted: sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
+++ (empty file)
@@ -1,327 +0,0 @@
-// svg_style.hpp
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-
-// -----------------------------------------------------------------
-
-#ifndef _SVG_STYLE_HPP
-#define _SVG_STYLE_HPP
-
-#include <map>
-
-namespace boost {
-namespace svg {
-
-// -----------------------------------------------------------------
-// Deals with colors that have special names. The reason that the
-// underscoring does not match the normal Boost format
-// is that these are the names that are specifically allowed by the
-// SVG standard
-// -----------------------------------------------------------------
-enum svg_color_constant
-{
- aliceblue, antiquewhite, aqua, aquamarine, azure, beige,
- bisque, black, blanchedalmond, blue, blueviolet, brown,
- burlywood, cadetblue, chartreuse, chocolate, coral,
- cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan,
- darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki,
- darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
- darksalmon, darkseagreen, darkslateblue, darkslategray,
- darkslategrey, darkturquoise, darkviolet, deeppink,
- deepskyblue, dimgray, dimgrey, dodgerblue, firebrick,
- floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold,
- goldenrod, gray, grey, green, greenyellow, honeydew, hotpink,
- indianred, indigo, ivory, khaki, lavender, lavenderblush,
- lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan,
- lightgoldenrodyellow, lightgray, lightgreen, lightgrey,
- lightpink, lightsalmon, lightseagreen, lightskyblue,
- lightslategray, lightslategrey, lightsteelblue, lightyellow,
- lime, limegreen, linen, magenta, maroon, mediumaquamarine,
- mediumblue, mediumorchid, mediumpurple, mediumseagreen,
- mediumslateblue, mediumspringgreen, mediumturquoise,
- mediumvioletred, midnightblue, mintcream, mistyrose, moccasin,
- navajowhite, navy, oldlace, olive, olivedrab, orange,
- orangered, orchid, palegoldenrod, palegreen, paleturquoise,
- palevioletred, papayawhip, peachpuff, peru, pink, plum,
- powderblue, purple, red, rosybrown, royalblue, saddlebrown,
- salmon, sandybrown, seagreen, seashell, sienna, silver,
- skyblue, slateblue, slategray, slategrey, snow, springgreen,
- steelblue, tan, teal, thistle, tomato, turquoise, violet,
- wheat, white, whitesmoke, yellow, yellowgreen
-};
-
-
-void constant_to_rgb(svg_color_constant _c, unsigned char &r, unsigned char &g,
- unsigned char &b);
-
-// -----------------------------------------------------------------
-// svg_color is the struct that contains information about sRGB
-// colors.
-//
-// For the constructor: the svg standard specifies that numbers
-// outside the normal rgb range are to be accepted, but are rounded
-// to acceptable values.
-// -----------------------------------------------------------------
-struct svg_color
-{
- unsigned char r, g, b;
-
- svg_color(int _r, int _g, int _b)
- {
- _r = ( _r < 0 ) ? 0 : _r;
- _g = ( _g < 0 ) ? 0 : _g;
- _b = ( _b < 0 ) ? 0 : _b;
-
- r = (unsigned char)(( _r > 255 ) ? 255 : _r);
- g = (unsigned char)(( _g > 255 ) ? 255 : _g);
- b = (unsigned char)(( _b > 255 ) ? 255 : _b);
- }
-
- svg_color(svg_color_constant _col)
- {
- constant_to_rgb(_col, r, g, b);
- }
-
- void write(std::ostream& rhs)
- {
- rhs << "rgb(" << (unsigned int)r << "," << (unsigned int) g << ","
- << (unsigned int)b << ")" ;
- }
-};
-
-// -----------------------------------------------------------------
-// To facilitate quick lookup of the RGB values of constants
-// -----------------------------------------------------------------
-svg_color color_array[] =
-{
- svg_color(240, 248, 255), // aliceblue
- svg_color(250, 235, 215), // antiquewhite
- svg_color(0 , 255, 255), // aqua
- svg_color(127, 255, 212), // aquamarine
- svg_color(240, 255, 255), // azure
- svg_color(245, 245, 220), // beige
- svg_color(255, 228, 196), // bisque
- svg_color(0 , 0 , 0 ), // black
- svg_color(255, 235, 205), // blanchedalmond. Who thinks of these?
- svg_color(0 , 0 , 255), // blue
- svg_color(138, 43 , 226), // blueviolet
- svg_color(165, 42 , 42 ), // brown
- svg_color(222, 184, 135), // burlywood
- svg_color(95 , 158, 160), // cadetblue
- svg_color(127, 255, 0 ), // chartreuse
- svg_color(210, 105, 30 ), // chocolate
- svg_color(255, 127, 80 ), // coral
- svg_color(100, 149, 237), // cornflowerblue
- svg_color(255, 248, 220), // cornsilk
- svg_color(220, 20 , 60 ), // crimson
- svg_color(0 , 255, 255), // cyan
- svg_color(0 , 0 , 139), // darkblue
- svg_color(0 , 139, 139), // darkcyan
- svg_color(184, 134, 11 ), // darkgoldenrod
- svg_color(169, 169, 169), // darkgray
- svg_color(0 , 100, 0 ), // darkgreen
- svg_color(169, 169, 169), // darkgrey
- svg_color(189, 183, 107), // darkkhaki
- svg_color(139, 0 , 139), // darkmagenta
- svg_color(85 , 107, 47 ), // darkolivegreen
- svg_color(255, 140, 0 ), // darkorange
- svg_color(153, 50 , 204), // darkorchid
- svg_color(139, 0 , 0 ), // darkred
- svg_color(233, 150, 122), // darksalmon
- svg_color(143, 188, 143), // darkseagreen
- svg_color(72 , 61 , 139), // darkslateblue
- svg_color(47 , 79 , 79 ), // darkslategray
- svg_color(47 , 79 , 79 ), // darkslategrey
- svg_color(0 , 206, 209), // darkturquoise
- svg_color(148, 0 , 211), // darkviolet
- svg_color(255, 20 , 147), // deeppink
- svg_color(0 , 191, 255), // deepskyblue
- svg_color(105, 105, 105), // dimgray
- svg_color(105, 105, 105), // dimgrey
- svg_color(30 , 144, 255), // dodgerblue
- svg_color(178, 34 , 34 ), // firebrick
- svg_color(255, 250, 240), // floralwhite
- svg_color(34 , 139, 34 ), // forestgreen
- svg_color(255, 0 , 255), // fuchsia
- svg_color(220, 220, 220), // gainsboro
- svg_color(248, 248, 255), // ghostwhite
- svg_color(255, 215, 0 ), // gold
- svg_color(218, 165, 32 ), // goldenrod
- svg_color(128, 128, 128), // gray
- svg_color(128, 128, 128), // grey
- svg_color(0 , 128, 0 ), // green
- svg_color(173, 255, 47 ), // greenyellow
- svg_color(240, 255, 240), // honeydew
- svg_color(255, 105, 180), // hotpink
- svg_color(205, 92 , 92 ), // indianred
- svg_color(75 , 0 , 130), // indigo
- svg_color(255, 255, 240), // ivory
- svg_color(240, 230, 140), // khaki
- svg_color(230, 230, 250), // lavender
- svg_color(255, 240, 245), // lavenderblush
- svg_color(124, 252, 0 ), // lawngreen
- svg_color(255, 250, 205), // lemonchiffon
- svg_color(173, 216, 230), // lightblue
- svg_color(240, 128, 128), // lightcoral
- svg_color(224, 255, 255), // lightcyan
- svg_color(250, 250, 210), // lightgoldenrodyellow
- svg_color(211, 211, 211), // lightgray
- svg_color(144, 238, 144), // lightgreen
- svg_color(211, 211, 211), // lightgrey
- svg_color(255, 182, 193), // lightpink
- svg_color(255, 160, 122), // lightsalmon
- svg_color(32 , 178, 170), // lightseagreen
- svg_color(135, 206, 250), // lightskyblue
- svg_color(119, 136, 153), // lightslategray
- svg_color(119, 136, 153), // lightslategrey
- svg_color(176, 196, 222), // lightsteelblue
- svg_color(255, 255, 224), // lightyellow
- svg_color(0 , 255, 0 ), // lime
- svg_color(50 , 205, 50 ), // limegreen
- svg_color(250, 240, 230), // linen
- svg_color(255, 0 , 255), // magenta
- svg_color(128, 0 , 0 ), // maroon
- svg_color(102, 205, 170), // mediumaquamarine
- svg_color(0 , 0 , 205), // mediumblue
- svg_color(186, 85 , 211), // mediumorchid
- svg_color(147, 112, 219), // mediumpurple
- svg_color(60 , 179, 113), // mediumseagreen
- svg_color(123, 104, 238), // mediumslateblue
- svg_color(0 , 250, 154), // mediumspringgreen
- svg_color(72 , 209, 204), // mediumturquoise
- svg_color(199, 21 , 133), // mediumvioletred
- svg_color(25 , 25 , 112), // midnightblue
- svg_color(245, 255, 250), // mintcream
- svg_color(255, 228, 225), // mistyrose
- svg_color(255, 228, 181), // moccasin
- svg_color(255, 222, 173), // navajowhite
- svg_color(0 , 0 , 128), // navy
- svg_color(253, 245, 230), // oldlace
- svg_color(128, 128, 0 ), // olive
- svg_color(107, 142, 35 ), // olivedrab
- svg_color(255, 165, 0 ), // orange
- svg_color(255, 69 , 0 ), // orangered
- svg_color(218, 122, 214), // orchid
- svg_color(238, 232, 170), // palegoldenrod
- svg_color(152, 251, 152), // palegreen
- svg_color(175, 238, 238), // paleturquose
- svg_color(219, 112, 147), // palevioletred
- svg_color(255, 239, 213), // papayawhip
- svg_color(255, 218, 185), // peachpuff
- svg_color(205, 133, 63 ), // peru
- svg_color(255, 192, 203), // pink
- svg_color(221, 160, 221), // plum
- svg_color(176, 224, 230), // powderblue
- svg_color(128, 0 , 128), // purple
- svg_color(255, 0 , 0 ), // red
- svg_color(188, 143, 143), // rosybrown
- svg_color(65 , 105, 225), // royalblue
- svg_color(139, 69 , 19 ), // saddlebrown
- svg_color(250, 128, 114), // salmon
- svg_color(244, 164, 96 ), // sandybrown
- svg_color(46 , 139, 87 ), // seagreen
- svg_color(255, 245, 238), // seashell
- svg_color(160, 82 , 45 ), // sienna
- svg_color(192, 192, 192), // silver
- svg_color(135, 206, 235), // skyblue
- svg_color(106, 90 , 205), // slateblue
- svg_color(112, 128, 144), // slategray
- svg_color(112, 128, 144), // slategrey
- svg_color(255, 250, 250), // snow
- svg_color(0 , 255, 127), // springgreen
- svg_color(70 , 130, 180), // steelblue
- svg_color(210, 180, 140), // tan
- svg_color(0 , 128, 128), // teal
- svg_color(216, 191, 216), // thistle
- svg_color(255, 99 , 71 ), // tomato
- svg_color(64 , 224, 208), // turquoise
- svg_color(238, 130, 238), // violet
- svg_color(245, 222, 179), // wheat
- svg_color(255, 255, 255), // white
- svg_color(245, 245, 245), // whitesmoke
- svg_color(255, 255, 0 ), // yellow
- svg_color(154, 205, 50 ), // yellowgreen
-};
-
-
-void constant_to_rgb(svg_color_constant _c, unsigned char &r, unsigned char &g,
- unsigned char &b)
-{
- r = color_array[(unsigned int)_c].r;
- g = color_array[(unsigned int)_c].g;
- b = color_array[(unsigned int)_c].b;
-}
-
-svg_color constant_to_rgb(svg_color_constant _c)
-{
- return svg_color(color_array[(unsigned int)_c].r
- ,color_array[(unsigned int)_c].g
- ,color_array[(unsigned int)_c].b);
-}
-
-// -----------------------------------------------------------------
-// This is the style information for any <g> tag. This will be
-// expanded to include more data from the SVG standard when the
-// time comes.
-// -----------------------------------------------------------------
-class svg_g_style
-{
-private:
- svg_color fill_color;
- svg_color stroke_color;
-
-public:
- svg_g_style();
- svg_g_style(const svg_color&, const svg_color&);
- void set_fill_color(const svg_color&);
- void set_stroke_color(const svg_color&);
- void write(std::ostream&);
-};
-
-// -----------------------------------------------------------------
-// These are the defaults that I used in the prototype, and they
-// looked decent enough.
-// -----------------------------------------------------------------
-svg_g_style::svg_g_style():fill_color(svg_color(255, 0, 0)),
- stroke_color(svg_color(0, 0, 0))
-{
-
-}
-
-
-// -----------------------------------------------------------------
-// For changing the defaults for the colors
-// -----------------------------------------------------------------
-svg_g_style::svg_g_style(const svg_color& _fill, const svg_color& _stroke)
-:fill_color(_fill), stroke_color(_stroke)
-{
-
-}
-
-void svg_g_style::write(std::ostream& rhs)
-{
- rhs << "stroke=\"";
- stroke_color.write(rhs);
- rhs << "\" fill=\"";
- fill_color.write(rhs);
- rhs<<"\"";
-}
-
-void svg_g_style::set_stroke_color(const svg_color& rhs)
-{
- stroke_color = rhs;
-}
-
-void svg_g_style::set_fill_color(const svg_color& rhs)
-{
- fill_color = rhs;
-}
-
-
-}//svg
-}//boost
-
-
-#endif

Deleted: sandbox/SOC/2007/visualization/boost/svg_plot/svg_tag.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_tag.hpp 2007-06-19 00:09:29 EDT (Tue, 19 Jun 2007)
+++ (empty file)
@@ -1,187 +0,0 @@
-// svg_tag.hpp
-
-// Copyright (C) Jacob Voytko 2007
-//
-// Distributed under the Boost Software License, Version 1.0.
-// For more information, see http://www.boost.org
-
-// -----------------------------------------------------------------
-
-#ifndef _SVG_TAG_HPP
-#define _SVG_TAG_HPP
-
-#include <sstream>
-#include <string>
-#include <boost/ptr_container/ptr_container.hpp>
-#include <boost/noncopyable.hpp>
-
-#include "svg_style.hpp"
-
-namespace boost {
-namespace svg {
-
-
-// -----------------------------------------------------------------
-// This file defines all classes that can occur in the SVG parse
-// tree
-// -----------------------------------------------------------------
-
-
-// -----------------------------------------------------------------
-// The base class for all leaf elements
-// -----------------------------------------------------------------
-
-class svg_element
-{
-public:
- virtual void write(std::ostream&) = 0;
-};
-
-// -----------------------------------------------------------------
-// The node element of our document tree
-// -----------------------------------------------------------------
-
-class g_element: public svg_element
-{
-private:
- svg_g_style style_info;
-
-public:
- boost::ptr_vector<svg_element> children;
-
- svg_element& operator[](unsigned int);
- size_t size();
-
- void set_stroke_color(const svg_color&);
- void set_fill_color(const svg_color&);
-
- void write(std::ostream&);
-
- g_element& g_tag(int);
-};
-
-svg_element& g_element::operator[](unsigned int i)
-{
- return children[i];
-}
-
-size_t g_element::size()
-{
- return children.size();
-}
-
-void g_element::write(std::ostream& rhs)
-{
- rhs << "<g ";
- style_info.write(rhs);
- rhs<< " >" << std::endl;
-
- for(unsigned int i=0; i<children.size(); ++i)
- {
- children[i].write(rhs);
- }
-
- rhs << "</g>" << std::endl;
-
-}
-
-g_element& g_element::g_tag(int i)
-{
- return *(static_cast<g_element*>(&children[i]));
-}
-
-void g_element::set_stroke_color(const svg_color& _col)
-{
- style_info.set_stroke_color(_col);
-}
-
-void g_element::set_fill_color(const svg_color& _col)
-{
- style_info.set_fill_color(_col);
-}
-
-
-// -----------------------------------------------------------------
-// Represents a single point
-// -----------------------------------------------------------------
-class point_element: public svg_element
-{
-private:
- double x, y;
-
-public:
- point_element(double, double);
- void write(std::ostream&);
-};
-
-point_element::point_element(double _x, double _y):x(_x), y(_y)
-{
-
-}
-
-void point_element::write(std::ostream& rhs)
-{
- rhs<<"<circle cx=\""<<x<<"\" cy=\""<<y<<"\" r=\"5\"/>";
-
-}
-
-// -----------------------------------------------------------------
-// Represents a line
-// -----------------------------------------------------------------
-class line_element: public svg_element
-{
-private:
- double x1, x2, y1, y2, y;
-
-public:
- line_element(double, double, double, double);
- void write(std::ostream&);
-};
-
-line_element::line_element(double _x1, double _y1, double _x2,
- double _y2):x1(_x1), y1(_y1),
- x2(_x2), y2(_y2)
-{
-
-}
-
-void line_element::write(std::ostream& rhs)
-{
- rhs<<"<line x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
- <<y2<<"\"/>";
-}
-
-// -----------------------------------------------------------------
-// Represents a single block of text
-// -----------------------------------------------------------------
-class text_element: public svg_element
-{
-private:
- double x, y;
- std::string text;
-
-public:
- text_element(double, double, std::string);
- void write(std::ostream&);
-};
-
-text_element::text_element(double _x, double _y, std::string _text)
- :x(_x), y(_y), text(_text)
-{
-
-}
-
-void text_element::write(std::ostream& rhs)
-{
- rhs<<"<text x=\""<<x<<"\""
- <<" y=\""<<y<<"\" "
- <<" font-family=\"Veranda\" font-size=\"12\" stroke=\"black\">"
- << text
- <<" </text>";
-}
-
-
-}
-}
-
-#endif
\ No newline at end of file


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