|
Boost-Commit : |
From: JakeVoytko_at_[hidden]
Date: 2007-08-08 14:32:57
Author: jakevoytko
Date: 2007-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
New Revision: 38513
URL: http://svn.boost.org/trac/boost/changeset/38513
Log:
Added an example for limit handling
Added:
sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp (contents, props changed)
Removed:
sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp
sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp
sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp
Text files modified:
sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
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-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
@@ -604,18 +604,22 @@
void _draw_plot_lines()
{
+
for(unsigned int i = 0; i < series.size(); ++i)
- {
- if(series[i].line_style.bezier_on)
+ {
+ if(series[i].line_style.line_on)
{
- _draw_bezier_lines(series[i]);
- }
+ if(series[i].line_style.bezier_on)
+ {
+ _draw_bezier_lines(series[i]);
+ }
- else
- {
- _draw_straight_lines(series[i]);
+ else
+ {
+ _draw_straight_lines(series[i]);
+ }
}
- }
+ }
}
void _update_image()
Added: sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/example/2d_limit.cpp 2007-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
@@ -0,0 +1,69 @@
+// 2d_limit.cpp
+// Copyright (C) Jacob Voytko 2007
+// Distributed under the Boost Software License, Version 1.0.
+// For more information, see http://www.boost.org
+// -----------------------------------------------------------------
+
+#include <boost/svg_plot/svg_2d_plot.hpp>
+#include <map>
+#include <limits>
+
+using std::map;
+using namespace boost::svg;
+
+double f(double x)
+{
+ return 1. / x;
+}
+
+int main()
+{
+ map<double, double> data1;
+
+ double inter = .5;
+
+ for(double i = -10; i <= 10.; i += inter)
+ {
+ data1[i] = f(i);
+ }
+
+ svg_2d_plot my_plot;
+
+ // Size/scale settings.
+ my_plot.image_size(500, 350)
+ .x_range(-10.5, 10.5)
+ .y_range(-1.1, 1.1);
+
+
+ // Text settings.
+ my_plot.title("Plot of 1 / x")
+ .x_label("X Axis Units")
+ .y_major_labels_on(true)
+ .y_major_grid_on(true);
+
+ // Commands.
+ my_plot.plot_window_on(true)
+ .x_major_labels_on(true);
+
+ //X axis settings.
+ my_plot.x_major_interval(2)
+ .x_major_tick_length(14)
+ .x_major_tick_width(1)
+ .x_minor_tick_length(7)
+ .x_minor_tick_width(1)
+ .x_num_minor_ticks(3)
+
+ //Y axis settings.
+ .y_major_interval(25)
+ .y_num_minor_ticks(5);
+
+ //legend settings
+ my_plot.legend_title_font_size(15);
+
+ my_plot.plot(data1, "1 / x", _point_style = square,
+ _size = 5, _line_on = false);
+
+ my_plot.write("D:\\2d_limit.svg");
+
+ return 0;
+}
Deleted: sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp 2007-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
+++ (empty file)
@@ -1,92 +0,0 @@
-#include <boost/test/included/test_exec_monitor.hpp>
-#include <boost/svg_plot/svg_2d_plot.hpp>
-
-using namespace boost::unit_test;
-using namespace boost::svg;
-using namespace boost;
-
-// test to make sure that changes to colors in one section don't change
-// colors in another section. Logically, writing different color options
-// forwards and backwards checks for all possible overwrites
-int test_main(int, char* [])
-{
- svg_1d_plot test_plot;
- test_plot.set_background_color(svg_color(0, 0, 1))
- .set_background_border_color(svg_color(0, 0, 2))
- .set_legend_background_color(svg_color(0, 0, 3))
- .set_legend_border_color(svg_color(0, 0, 4))
- .set_plot_background_color(svg_color(0, 0, 5))
- .set_title_color(svg_color(0, 0, 6))
- .set_x_axis_color(svg_color(0, 0, 7))
- .set_x_label_color(svg_color(0, 0, 8))
- .set_x_major_grid_color(svg_color(0, 0, 9))
- .set_x_minor_grid_color(svg_color(0, 0, 10))
- .set_x_major_tick_color(svg_color(0, 0, 11))
- .set_x_minor_tick_color(svg_color(0, 0, 12))
- .set_y_axis_color(svg_color(0, 0, 13))
- .set_y_label_color(svg_color(0, 0, 14))
- .set_y_major_grid_color(svg_color(0, 0, 15))
- .set_y_minor_grid_color(svg_color(0, 0, 16))
- .set_y_major_tick_color(svg_color(0, 0, 17))
- .set_y_minor_tick_color(svg_color(0, 0, 18));
-
- BOOST_CHECK(test_plot.get_background_color() == svg_color(0, 0, 1));
- BOOST_CHECK(test_plot.get_background_border_color()
- == svg_color(0, 0, 2));
- BOOST_CHECK(test_plot.get_legend_background_color() == svg_color(0,0,3));
- BOOST_CHECK(test_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(test_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(test_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(test_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(test_plot.get_x_label_color() == svg_color(0, 0, 8));
- BOOST_CHECK(test_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(test_plot.get_x_minor_grid_color() == svg_color(0, 0, 10));
- BOOST_CHECK(test_plot.get_x_major_tick_color() == svg_color(0, 0, 11));
- BOOST_CHECK(test_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
- BOOST_CHECK(test_plot.get_y_axis_color() == svg_color(0, 0, 13));
- BOOST_CHECK(test_plot.get_y_label_color() == svg_color(0, 0, 14));
- BOOST_CHECK(test_plot.get_y_major_grid_color() == svg_color(0, 0, 15));
- BOOST_CHECK(test_plot.get_y_minor_grid_color() == svg_color(0, 0, 16));
- BOOST_CHECK(test_plot.get_y_major_tick_color() == svg_color(0, 0, 17));
- BOOST_CHECK(test_plot.get_y_minor_tick_color() == svg_color(0, 0, 18));
-
- test_plot.set_y_minor_tick_color(svg_color(0, 0, 18))
- .set_y_major_tick_color(svg_color(0, 0, 17))
- .set_y_minor_grid_color(svg_color(0, 0, 16))
- .set_y_major_grid_color(svg_color(0, 0, 15))
- .set_y_label_color(svg_color(0, 0, 14))
- .set_y_axis_color(svg_color(0, 0, 13))
- .set_x_minor_tick_color(svg_color(0, 0, 12))
- .set_x_major_tick_color(svg_color(0, 0, 11))
- .set_x_minor_grid_color(svg_color(0, 0, 10))
- .set_x_major_grid_color(svg_color(0, 0, 9))
- .set_x_label_color(svg_color(0, 0, 8))
- .set_x_axis_color(svg_color(0, 0, 7))
- .set_title_color(svg_color(0, 0, 6))
- .set_plot_background_color(svg_color(0, 0, 5))
- .set_legend_border_color(svg_color(0, 0, 4))
- .set_legend_background_color(svg_color(0, 0, 3))
- .set_background_border_color(svg_color(0, 0, 2))
- .set_background_color(svg_color(0, 0, 1));
-
- BOOST_CHECK(test_plot.get_background_color() == svg_color(0, 0, 1));
- BOOST_CHECK(test_plot.get_background_border_color()
- == svg_color(0, 0, 2));
- BOOST_CHECK(test_plot.get_legend_background_color() == svg_color(0, 0, 3));
- BOOST_CHECK(test_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(test_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(test_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(test_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(test_plot.get_x_label_color() == svg_color(0, 0, 8));
- BOOST_CHECK(test_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(test_plot.get_x_minor_grid_color() == svg_color(0, 0, 10));
- BOOST_CHECK(test_plot.get_x_major_tick_color() == svg_color(0, 0, 11));
- BOOST_CHECK(test_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
- BOOST_CHECK(test_plot.get_y_axis_color() == svg_color(0, 0, 13));
- BOOST_CHECK(test_plot.get_y_label_color() == svg_color(0, 0, 14));
- BOOST_CHECK(test_plot.get_y_major_grid_color() == svg_color(0, 0, 15));
- BOOST_CHECK(test_plot.get_y_minor_grid_color() == svg_color(0, 0, 16));
- BOOST_CHECK(test_plot.get_y_major_tick_color() == svg_color(0, 0, 17));
- BOOST_CHECK(test_plot.get_y_minor_tick_color() == svg_color(0, 0, 18));
- return 0;
-}
Deleted: sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp 2007-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
+++ (empty file)
@@ -1,70 +0,0 @@
-#include <boost/test/included/test_exec_monitor.hpp>
-
-#include "../../../boost/svg_plot/svg_1d_plot.hpp"
-
-using namespace boost::unit_test;
-using namespace boost::svg;
-using namespace boost;
-
-// test to make sure that changes to colors in one section don't change
-// colors in another section. Logically, writing different color options
-// forwards and backwards checks for all possible overwrites
-int test_main(int, char* [])
-{
- svg_1d_plot test_plot;
- test_plot.set_background_color(svg_color(0, 0, 1))
- .set_background_border_color(svg_color(0, 0, 2))
- .set_legend_background_color(svg_color(0, 0, 3))
- .set_legend_border_color(svg_color(0, 0, 4))
- .set_plot_background_color(svg_color(0, 0, 5))
- .set_title_color(svg_color(0, 0, 6))
- .set_x_axis_color(svg_color(0, 0, 7))
- .set_x_label_color(svg_color(0, 0, 8))
- .set_x_major_grid_color(svg_color(0, 0, 9))
- .set_x_minor_grid_color(svg_color(0, 0, 10))
- .set_x_major_tick_color(svg_color(0, 0, 11))
- .set_x_minor_tick_color(svg_color(0, 0, 12));
-
- BOOST_CHECK(test_plot.get_background_color() == svg_color(0, 0, 1));
- BOOST_CHECK(test_plot.get_background_border_color()
- == svg_color(0, 0, 2));
- BOOST_CHECK(test_plot.get_legend_background_color() == svg_color(0, 0, 3));
- BOOST_CHECK(test_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(test_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(test_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(test_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(test_plot.get_x_label_color() == svg_color(0, 0, 8));
- BOOST_CHECK(test_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(test_plot.get_x_minor_grid_color() == svg_color(0, 0, 10));
- BOOST_CHECK(test_plot.get_x_major_tick_color() == svg_color(0, 0, 11));
- BOOST_CHECK(test_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
-
- test_plot.set_x_minor_tick_color(svg_color(0, 0, 12))
- .set_x_major_tick_color(svg_color(0, 0, 11))
- .set_x_minor_grid_color(svg_color(0, 0, 10))
- .set_x_major_grid_color(svg_color(0, 0, 9))
- .set_x_label_color(svg_color(0, 0, 8))
- .set_x_axis_color(svg_color(0, 0, 7))
- .set_title_color(svg_color(0, 0, 6))
- .set_plot_background_color(svg_color(0, 0, 5))
- .set_legend_border_color(svg_color(0, 0, 4))
- .set_legend_background_color(svg_color(0, 0, 3))
- .set_background_border_color(svg_color(0, 0, 2))
- .set_background_color(svg_color(0, 0, 1));
-
- BOOST_CHECK(test_plot.get_background_color() == svg_color(0, 0, 1));
- BOOST_CHECK(test_plot.get_background_border_color()
- == svg_color(0, 0, 2));
- BOOST_CHECK(test_plot.get_legend_background_color() == svg_color(0, 0, 3));
- BOOST_CHECK(test_plot.get_legend_border_color() == svg_color(0, 0, 4));
- BOOST_CHECK(test_plot.get_plot_background_color() == svg_color(0, 0, 5));
- BOOST_CHECK(test_plot.get_title_color() == svg_color(0, 0, 6));
- BOOST_CHECK(test_plot.get_x_axis_color() == svg_color(0, 0, 7));
- BOOST_CHECK(test_plot.get_x_label_color() == svg_color(0, 0, 8));
- BOOST_CHECK(test_plot.get_x_major_grid_color() == svg_color(0, 0, 9));
- BOOST_CHECK(test_plot.get_x_minor_grid_color() == svg_color(0, 0, 10));
- BOOST_CHECK(test_plot.get_x_major_tick_color() == svg_color(0, 0, 11));
- BOOST_CHECK(test_plot.get_x_minor_tick_color() == svg_color(0, 0, 12));
-
- return 0;
-}
Deleted: sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp 2007-08-08 14:32:56 EDT (Wed, 08 Aug 2007)
+++ (empty file)
@@ -1,90 +0,0 @@
-#include <boost/test/included/test_exec_monitor.hpp>
-
-#include "../../../boost/svg_plot/svg_1d_plot.hpp"
-
-#include <sstream>
-#include <vector>
-
-using namespace boost::unit_test;
-using namespace boost::svg;
-using namespace boost;
-using std::stringstream;
-using std::vector;
-
-double f(int x)
-{
- return 2.*x;
-}
-
-double g(int x)
-{
- return 1.5*x;
-}
-
-double h(int x)
-{
- return -1*x+3;
-}
-
-// test to make sure that the output is consistent
-int test_main(int, char* [])
-{
- stringstream test1, test2;
- vector<double> data1, data2, data3;
- svg_1d_plot my_plot;
-
- for(int i = 0; i < 10; ++i)
- {
- data1.push_back(f(i));
- data2.push_back(g(i));
- data3.push_back(h(i));
- }
-
- // size/scale settings
- my_plot.set_image_size(500, 350)
- .set_x_scale(-3, 10);
-
- // Text settings
- my_plot.set_title("Oh My!")
- .set_title_font_size(29)
- .set_x_label("Time in Months");
-
-// command settings
- my_plot.set_axis_on(true)
- .set_legend_on(true)
- .set_plot_window_on(true)
- .set_x_label_on(true)
- .set_x_major_labels_on(true);
-
- // color settings
- my_plot.set_background_color(svg_color(67, 111, 69))
- .set_legend_background_color(svg_color(207, 202,167))
- .set_plot_background_color(svg_color(136, 188, 126))
- .set_title_color(white)
- .set_x_axis_color(black)
- .set_x_major_tick_color(black)
- .set_legend_border_color(svg_color(102, 102, 84))
- .set_x_minor_tick_color(black);
-
-//axis settings
- my_plot.set_x_major_tick(2)
- .set_x_num_minor_ticks(3)
- .set_x_major_tick_length(14)
- .set_x_minor_tick_length(7)
- .set_x_major_tick_width(1)
- .set_x_minor_tick_width(1);
-
- //legend settings
- my_plot.set_legend_title_font_size(15);
-
- plot(my_plot, data2, "Lions", blue);
- plot(my_plot, data1, "Tigers", purple);
- plot(my_plot, data3, "Bears", red);
-
- my_plot.write(test1);
- my_plot.write(test2);
-
- BOOST_CHECK(test1.str() == test2.str());
-
- return 0;
-}
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