Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2007-07-26 19:57:22


Author: dgregor
Date: 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
New Revision: 7558
URL: http://svn.boost.org/trac/boost/changeset/7558

Log:
Fix eol-style and mime-types
Properties modified:
   sandbox/SOC/2007/bigint/Jamfile.v2 (props changed)
   sandbox/SOC/2007/bigint/boost.png (props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_config.hpp (props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_default.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_serialize.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_fixed.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_vector.hpp (contents, props changed)
   sandbox/SOC/2007/bigint/boost/bigint/bigint_util.hpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/build/Jamfile.v2 (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/example.cpp (contents, props changed)
   sandbox/SOC/2007/bigint/libs/bigint/index.html (contents, props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/Jamfile.v2 (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/arithmetics.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/can_convert_to.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/comparison.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/functions.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/number_conversion.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/serialization.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/stream.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/string_conversion.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/test/unary.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/bigint/todo.txt (props changed)
   sandbox/SOC/2007/bigint/libs/detail/utf8_codecvt_facet.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/build/Jamfile.v2 (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/build/serialization.jam (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_archive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_archive_impl.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_iarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_iserializer.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_oarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_oserializer.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_pointer_iserializer.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_pointer_oserializer.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_serializer_map.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_text_iprimitive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_text_oprimitive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_text_wiprimitive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_text_woprimitive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_xml_archive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/basic_xml_grammar.ipp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/binary_iarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/binary_oarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/binary_wiarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/binary_woarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/codecvt_null.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/extended_type_info.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/extended_type_info_no_rtti.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/extended_type_info_typeid.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/polymorphic_iarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/polymorphic_oarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/stl_port.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/text_iarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/text_oarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/text_wiarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/text_woarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/utf8_codecvt_facet.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/void_cast.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_grammar.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_iarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_oarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_wgrammar.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_wiarchive.cpp (props changed)
   sandbox/SOC/2007/bigint/libs/serialization/src/xml_woarchive.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_ds.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_functions.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_functions.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_functions.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/meta_functions.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/Makefile.dbg_exc_mt (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/backward_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/backward_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/backward_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/bidirectional_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/bidirectional_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/bidirectional_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_list_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_list_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/facet_list_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/forward_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/forward_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/forward_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/halfedge_list_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/halfedge_list_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/halfedge_list_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_backward_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_backward_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_backward_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_bidirectional_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_bidirectional_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_bidirectional_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_facet_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_facet_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_facet_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_forward_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_forward_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_forward_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_vertex_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_vertex_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/mutable_vertex_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_list_hds_concept_archetype.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_list_hds_concept_archetype.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_archetypes/vertex_list_hds_concept_archetype.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/Makefile.dbg_exc_mt (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/backward_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/backward_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/backward_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/bidirectional_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/bidirectional_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/bidirectional_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_list_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_list_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/facet_list_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/forward_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/forward_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/forward_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/halfedge_list_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/halfedge_list_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/halfedge_list_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_backward_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_backward_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_backward_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_bidirectional_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_bidirectional_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_bidirectional_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_facet_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_facet_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_facet_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_forward_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_forward_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_forward_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_vertex_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_vertex_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/mutable_vertex_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_list_hds_concept.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_list_hds_concept.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts/vertex_list_hds_concept.t.cpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_concepts_archetypes.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_selectors.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/dev/hds_traits.hpp (props changed)
   sandbox/SOC/2007/geometry/libs/hdstl/tools/doc.pl (props changed)
   sandbox/SOC/2007/graphs/README (props changed)
   sandbox/SOC/2007/graphs/boost/graph/clique.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/clustering_coefficient.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/connectivity.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/constant_property_map.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/cycle.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/degree_distribution.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/directed_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/distance.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/exterior_property.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/complete_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/cycle_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/options.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/path_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/prism_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/star_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/web_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/generators/wheel_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/named_parameters.hpp (props changed)
   sandbox/SOC/2007/graphs/boost/graph/undirected_graph.hpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/Jamfile.v2 (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/bibliography.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/boost_concepts.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/boost_reference.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/a_star_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/adjacency_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/adjacency_matrix.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/bellman_ford_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/bfs_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/bidirectional_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/clique_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/concepts.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/cycle_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/descriptor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/dfs_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/dijkstra_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/edge_list_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/event_visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/event_visitor_list.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/exterior_property.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/graphs.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/incidence_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/mutable_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/mutable_property_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/property_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/utility.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/vertex_list_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/visitor.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/concepts/visitors.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/guide/adjacency_list.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/guide/directed_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/guide/guide.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/guide/undirected_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/history.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/images/eq/Makefile (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/images/reference/Makefile (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/introduction.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/adjacency_list.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/breadth_first_search.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/clique.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/closeness.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/connected_components.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/connectivity.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/cycle.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/depth_first_search.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/directed_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/distance_recorder.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/distributions.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/eccentricity.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/edge_list.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/exterior_vertex_property.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/geodesic.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/predecessor_recorder.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/property_writer.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/reference.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/strong_components.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/time_stamper.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/reference/undirected_graph.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/sgi_concepts.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/theory.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/tour.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/doc/tutorial.qbk (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/imdb/Jamfile.v2 (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/imdb/README (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/imdb/fuzzy.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/imdb/imdb.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/makefile/Jamfile.v2 (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/makefile/build_order.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/makefile/cycle.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/Jamfile.v2 (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/kevin_bacon.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/movies.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/movies.hpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/six_degrees.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/stats.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/Jamfile.v2 (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/clique.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/cluster.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/components.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/cycle.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/distance.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/exterior.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/generate.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/index.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/misc.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/mutable.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/properties.cpp (props changed)
   sandbox/SOC/2007/graphs/libs/graph/test/range.cpp (props changed)
   sandbox/SOC/2007/visualization/Jamfile.v2 (props changed)
   sandbox/SOC/2007/visualization/Jamrules (props changed)
   sandbox/SOC/2007/visualization/boost-build.jam (props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg.hpp (props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_1d_plot.hpp (props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp (contents, props changed)
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/Jamfile.v2 (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/boostbook.css (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/index.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/color.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/intro.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_1d_plot_interface.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_2d_plot_interface.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/svg_interface.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/html/svg_plot/tutorial.html (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.xml (props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp (contents, props changed)
   sandbox/SOC/2007/visualization/project-root.jam (props changed)
Text files modified:
   sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp | 1358 ++++++++++++++--------------
   sandbox/SOC/2007/bigint/boost/bigint/bigint_default.hpp | 1580 ++++++++++++++++----------------
   sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp | 814 ++++++++--------
   sandbox/SOC/2007/bigint/boost/bigint/bigint_serialize.hpp | 90
   sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_fixed.hpp | 166 +-
   sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_vector.hpp | 136 +-
   sandbox/SOC/2007/bigint/libs/bigint/example.cpp | 222 ++--
   sandbox/SOC/2007/bigint/libs/bigint/index.html | 1036 +++++++++++-----------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/axis_plot_frame.hpp | 1874 ++++++++++++++++++++--------------------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style.hpp | 756 ++++++++--------
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp | 56
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 1348 ++++++++++++++--------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 1720 ++++++++++++++++++------------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp | 542 +++++-----
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_style.hpp | 278 ++--
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 192 ++--
   sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk | 1160 ++++++++++++------------
   sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 | 30
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp | 184 +-
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp | 140 +-
   sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp | 180 +-
   21 files changed, 6931 insertions(+), 6931 deletions(-)

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,679 +1,679 @@
-/* Boost bigint.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_HPP
-#define BOOST_BIGINT_BIGINT_HPP
-
-#include <string>
-#include <algorithm>
-
-#include <boost/detail/workaround.hpp>
-#include <boost/cstdint.hpp>
-
-#include <boost/bigint/bigint_config.hpp>
-#include <boost/bigint/bigint_util.hpp>
-
-namespace boost {
-template <typename I> class bigint_base
-{
- I impl;
-
-public:
- bigint_base()
- {
- }
-
- bigint_base(int number)
- {
- impl.assign(number);
- }
-
- bigint_base(unsigned int number)
- {
- impl.assign(number);
- }
-
- bigint_base(int64_t number)
- {
- impl.assign(number);
- }
-
- bigint_base(uint64_t number)
- {
- impl.assign(number);
- }
-
- explicit bigint_base(const char* str, int base = 10)
- {
- impl.assign(str, base);
- }
-
- explicit bigint_base(const wchar_t* str, int base = 10)
- {
- impl.assign(str, base);
- }
-
- explicit bigint_base(const std::string& str, int base = 10)
- {
- impl.assign(str.c_str(), base);
- }
-
- explicit bigint_base(const std::wstring& str, int base = 10)
- {
- impl.assign(str.c_str(), base);
- }
-
- // - basic arithmetic operations (addition, subtraction, multiplication, division)
- const bigint_base& operator+=(const bigint_base& other)
- {
- impl.add(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator-=(const bigint_base& other)
- {
- impl.sub(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator*=(const bigint_base& other)
- {
- impl.mul(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator/=(const bigint_base& other)
- {
- impl.div(impl, other.impl);
- return *this;
- }
-
- // - modulo
- const bigint_base& operator%=(const bigint_base& other)
- {
- impl.mod(impl, other.impl);
- return *this;
- }
-
- // - bit operations (bit logic (or, and, xor), bit shifts (left/right))
- const bigint_base& operator|=(const bigint_base& other)
- {
- impl.or_(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator&=(const bigint_base& other)
- {
- impl.and_(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator^=(const bigint_base& other)
- {
- impl.xor_(impl, other.impl);
- return *this;
- }
-
- const bigint_base& operator<<=(uint64_t other)
- {
- impl.lshift(impl, other);
- return *this;
- }
-
- const bigint_base& operator>>=(uint64_t other)
- {
- impl.rshift(impl, other);
- return *this;
- }
-
- const bigint_base& operator++()
- {
- impl.inc();
- return *this;
- }
-
- bigint_base operator++(int)
- {
- bigint_base old = *this;
- impl.inc();
- return old;
- }
-
- const bigint_base& operator--()
- {
- impl.dec();
- return *this;
- }
-
- bigint_base operator--(int)
- {
- bigint_base old = *this;
- impl.dec();
- return old;
- }
-
- // unary operators
- bigint_base operator+() const
- {
- return *this;
- }
-
- bigint_base operator-() const
- {
- bigint_base<I> result;
- result.impl.negate(impl);
- return result;
- }
-
- bigint_base operator~() const
- {
- bigint_base<I> result;
- result.impl.not_(impl);
- return result;
- }
-
- // implicit conversion to "bool"
-
-#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
-
- operator bool () const
- {
- return impl;
- }
-
-#elif defined( _MANAGED )
-
-private:
- static void unspecified_bool( bigint_base*** )
- {
- }
-
- typedef void (*unspecified_bool_type)( bigint_base*** );
-
-public:
- operator unspecified_bool_type() const // never throws
- {
- return impl.is_zero() ? 0 : unspecified_bool;
- }
-
-#elif \
- ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
- ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
-
-private:
- typedef std::string (bigint_base::*unspecified_bool_type)(int) const;
-
-public:
- operator unspecified_bool_type() const // never throws
- {
- return impl.is_zero() ? 0 : &bigint_base::str;
- }
-
-#else
-
-private:
- typedef I* bigint_base::*unspecified_bool_type;
-
-public:
- operator unspecified_bool_type() const // never throws
- {
- return impl.is_zero() ? 0 : &bigint_base::impl;
- }
-
-#endif
-
- // operator! is redundant, but some compilers need it
-
- bool operator! () const // never throws
- {
- return impl.is_zero();
- }
-
- std::string str(int base = 10) const
- {
- return impl.str(base);
- }
-
- std::wstring wstr(int base = 10) const
- {
- return impl.wstr(base);
- }
-
- // conversion to numeric types (including 64 bit)
- template <typename T> bool can_convert_to() const
- {
- return impl.template can_convert_to<T>();
- }
-
- template <typename T> T to_number() const
- {
- return impl.template to_number<T>();
- }
-
- // - basic arithmetic operations (addition, subtraction, multiplication, division)
- friend bigint_base operator+(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.add(lhs.impl, rhs.impl);
- return result;
- }
-
- friend bigint_base operator-(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.sub(lhs.impl, rhs.impl);
- return result;
- }
-
- friend bigint_base operator*(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.mul(lhs.impl, rhs.impl);
- return result;
- }
-
- friend bigint_base operator/(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.div(lhs.impl, rhs.impl);
- return result;
- }
-
- // - modulo
- friend bigint_base operator%(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.mod(lhs.impl, rhs.impl);
- return result;
- }
-
- // - bit operations (bit logic (or, and, xor), bit shifts (left/right))
- friend bigint_base operator|(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.or_(lhs.impl, rhs.impl);
- return result;
- }
-
- friend bigint_base operator&(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.and_(lhs.impl, rhs.impl);
- return result;
- }
-
- friend bigint_base operator^(const bigint_base& lhs, const bigint_base& rhs)
- {
- bigint_base<I> result;
- result.impl.xor_(lhs.impl, rhs.impl);
- return result;
- }
-
- // do we need << and >> for bigints?
- friend bigint_base operator<<(const bigint_base& lhs, boost::uint64_t rhs)
- {
- bigint_base<I> result;
- result.impl.lshift(lhs.impl, rhs);
- return result;
- }
-
- friend bigint_base operator>>(const bigint_base& lhs, boost::uint64_t rhs)
- {
- bigint_base<I> result;
- result.impl.rshift(lhs.impl, rhs);
- return result;
- }
-
- friend bool operator<(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) < 0;
- }
-
- friend bool operator<=(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) <= 0;
- }
-
- friend bool operator>(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) > 0;
- }
-
- friend bool operator>=(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) >= 0;
- }
-
- friend bool operator==(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) == 0;
- }
-
- friend bool operator!=(const bigint_base& lhs, const bigint_base& rhs)
- {
- return lhs.impl.compare(rhs.impl) != 0;
- }
-
- friend bigint_base abs(const bigint_base& value)
- {
- bigint_base result;
- result.impl.abs(value.impl);
- return result;
- }
-
- friend bigint_base pow(const bigint_base<I>& lhs, boost::uint64_t rhs)
- {
- bigint_base result;
- result.impl.pow(lhs.impl, rhs);
- return result;
- }
-
- // non-standard. Do we need to change it (introduce some equivalent to div_t type) or is it ok?
- friend bigint_base div(const bigint_base& lhs, const bigint_base& rhs, bigint_base& remainder)
- {
- bigint_base result;
- result.impl.div(lhs.impl, rhs.impl, remainder.impl);
- return result;
- }
-
- friend bigint_base sqrt(const bigint_base& lhs)
- {
- bigint_base result;
- result.impl.sqrt(lhs.impl);
- return result;
- }
-
- template <typename T, typename Tr> friend std::basic_ostream<T, Tr>& operator<<(std::basic_ostream<T, Tr>& lhs, const bigint_base& rhs)
- {
- typename std::basic_ostream<T, Tr>::sentry ok(lhs);
-
- if (ok)
- {
- try
- {
- std::ios_base::fmtflags flags = lhs.flags() ;
- std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
- std::ios_base::fmtflags uppercase = flags & std::ios_base::uppercase;
- std::ios_base::fmtflags showpos = flags & std::ios_base::showpos;
- std::ios_base::fmtflags showbase = flags & std::ios_base::showbase;
-
- int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
-
- std::basic_string<T> str = detail::bigint::to_string(rhs, base, T());
-
- if (uppercase && base == 16) std::transform(str.begin(), str.end(), str.begin(), detail::bigint::toupper());
-
- typename std::basic_string<T>::size_type pad_length = 0;
-
- // str[0] is safe, to_string will never return empty string
- if (showpos && str[0] != '-')
- {
- str.insert(str.begin(), '+');
- pad_length = 1;
- }
- else pad_length = (str[0] == '-');
-
- const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
-
- std::string grouping = punct.grouping();
-
- if (!grouping.empty())
- {
- std::basic_string<T> nstr;
-
- typename std::basic_string<T>::reverse_iterator it = str.rbegin();
- typename std::basic_string<T>::reverse_iterator end = str.rend();
- if (pad_length > 0) --end; // skip sign
-
- size_t group_id = 0;
- size_t chars_to_go = str.size() - pad_length;
-
- while (it != end)
- {
- char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
-
- if (!nstr.empty()) nstr += punct.thousands_sep();
-
- if (limit <= 0)
- {
- nstr.append(it, end);
- break;
- }
-
- size_t count = (std::min)(static_cast<size_t>(limit), chars_to_go);
-
- nstr.append(it, it + count);
-
- it += count;
- chars_to_go -= count;
-
- if (group_id < grouping.size()) ++group_id;
- }
-
- std::reverse(nstr.begin(), nstr.end());
-
- str.replace(str.begin() + pad_length, str.end(), nstr.begin(), nstr.end());
- }
-
- if (showbase && (base == 16 || base == 8))
- {
- const T str_0X[] = {T('0'), T('X'), T()};
- const T str_0x[] = {T('0'), T('x'), T()};
- const T str_0[] = {T('0'), T()};
-
- str.insert(pad_length, base == 16 ? (uppercase ? str_0X : str_0x) : str_0);
- if (base == 16) pad_length += 2;
- }
-
- if (lhs.width() != 0)
- {
- std::streamsize width = lhs.width();
- lhs.width(0);
-
- if (width > 0 && static_cast<size_t>(width) > str.length())
- {
- std::ios_base::fmtflags adjustfield = flags & std::ios_base::adjustfield;
-
- typename std::basic_string<T>::size_type pad_pos = 0; // pad before
-
- if (adjustfield == std::ios_base::left) pad_pos = str.length();
- else if (adjustfield == std::ios_base::internal) pad_pos = pad_length;
-
- str.insert(pad_pos, width - str.length(), lhs.fill());
- }
- }
-
- return lhs << str;
- }
- catch (...)
- {
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
- }
- else return lhs;
- }
-
- template <typename T, typename Tr> friend std::basic_istream<T, Tr>& operator>>(std::basic_istream<T, Tr>& lhs, bigint_base& rhs)
- {
- typename std::basic_istream<T, Tr>::sentry ok(lhs);
-
- if (ok)
- {
- try
- {
- std::ios_base::fmtflags flags = lhs.flags() ;
- std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
-
- int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
-
- int sign = 1;
-
- std::basic_string<T> str;
-
- if (flags & std::ios_base::skipws)
- {
- // skip whitespaces
- while (lhs.peek() != Tr::eof() && detail::bigint::isspace(static_cast<T>(lhs.peek())))
- lhs.get();
- }
-
- if (lhs.peek() == T('-') || lhs.peek() == T('+'))
- {
- sign = lhs.get() == T('-') ? -1 : 1;
- }
-
- T char_table[] = {T('0'), T('1'), T('2'), T('3'), T('4'), T('5'), T('6'), T('7'), T('8'), T('9'),
- T('a'), T('b'), T('c'), T('d'), T('e'), T('f'), T('A'), T('B'), T('C'), T('D'),
- T('E'), T('F'), T()};
-
- size_t char_table_size = base == 16 ? sizeof(char_table) / sizeof(char_table[0]) : base;
-
- if (lhs.peek() == T('0'))
- {
- lhs.get();
-
- if (lhs.peek() == T('x') || lhs.peek() == T('X')) // 0x 0X
- lhs.get(); // skip
- else
- {
- while (lhs.peek() == T('0')) lhs.get(); // skip zeroes
-
- if (Tr::find(char_table, char_table_size, lhs.peek()) == 0) // next symbol is non-digit, we needed that 0
- str += T('0');
- }
- }
-
- const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
-
- typename Tr::int_type ch;
-
- while ((ch = lhs.peek()) != Tr::eof())
- {
- // do we allow this kind of character?
- if (ch == punct.thousands_sep() || Tr::find(char_table, char_table_size, ch) != 0)
- {
- str += lhs.get();
- }
- else
- {
- // have we read any valid data?
- if (str.empty())
- {
- // no.
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
-
- break;
- }
- }
-
- std::string grouping = punct.grouping();
-
- if (!grouping.empty())
- {
- typename std::basic_string<T>::reverse_iterator it = str.rbegin();
- typename std::basic_string<T>::reverse_iterator end = str.rend();
-
- size_t group_id = 0;
-
- while (it != end)
- {
- char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
-
- typename std::basic_string<T>::reverse_iterator sep_it = std::find(it, end, punct.thousands_sep());
-
- if (limit <= 0) // unlimited sequence of digits
- {
- if (sep_it != str.rend()) // there's another separator, error
- {
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
-
- break;
- }
-
- // limited sequence of digits
-
- // we're not at the end
- if (sep_it != str.rend())
- {
- // digit sequence sizes do not match
- if (limit != std::distance(it, sep_it))
- {
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
- else
- {
- it = sep_it;
- ++it;
- }
- }
- else if (limit < std::distance(it, sep_it)) // we're at the end, and our sequence size is larger
- {
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
- else
- {
- // we're at the end
- break;
- }
-
- if (group_id < grouping.size()) ++group_id;
- }
-
- // remove all separators, we don't need them
- str.erase(std::remove(str.begin(), str.end(), punct.thousands_sep()), str.end());
- }
-
- rhs = bigint_base(str, base);
- if (sign == -1) rhs.impl.negate(rhs.impl);
-
- return lhs;
- }
- catch (...)
- {
- lhs.setstate(std::ios_base::badbit); // may throw
- return lhs;
- }
- }
- else return lhs;
- }
-};
-} // namespace boost
-
-// Do we have GMP?
-#ifdef BOOST_BIGINT_HAS_GMP_SUPPORT
-
-#include <boost/bigint/bigint_gmp.hpp>
-
-namespace boost {
-
-typedef bigint_base<detail::bigint_gmp_implementation> bigint;
-
-} // namespace boost
-
-#else
-
-#include <boost/bigint/bigint_default.hpp>
-#include <boost/bigint/bigint_storage_vector.hpp>
-
-namespace boost {
-
-typedef bigint_base<detail::bigint_default_implementation<detail::bigint_storage_vector> > bigint;
-
-} // namespace boost
-
-#endif
-
-#endif // BOOST_BIGINT_BIGINT_HPP
+/* Boost bigint.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_HPP
+#define BOOST_BIGINT_BIGINT_HPP
+
+#include <string>
+#include <algorithm>
+
+#include <boost/detail/workaround.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/bigint/bigint_config.hpp>
+#include <boost/bigint/bigint_util.hpp>
+
+namespace boost {
+template <typename I> class bigint_base
+{
+ I impl;
+
+public:
+ bigint_base()
+ {
+ }
+
+ bigint_base(int number)
+ {
+ impl.assign(number);
+ }
+
+ bigint_base(unsigned int number)
+ {
+ impl.assign(number);
+ }
+
+ bigint_base(int64_t number)
+ {
+ impl.assign(number);
+ }
+
+ bigint_base(uint64_t number)
+ {
+ impl.assign(number);
+ }
+
+ explicit bigint_base(const char* str, int base = 10)
+ {
+ impl.assign(str, base);
+ }
+
+ explicit bigint_base(const wchar_t* str, int base = 10)
+ {
+ impl.assign(str, base);
+ }
+
+ explicit bigint_base(const std::string& str, int base = 10)
+ {
+ impl.assign(str.c_str(), base);
+ }
+
+ explicit bigint_base(const std::wstring& str, int base = 10)
+ {
+ impl.assign(str.c_str(), base);
+ }
+
+ // - basic arithmetic operations (addition, subtraction, multiplication, division)
+ const bigint_base& operator+=(const bigint_base& other)
+ {
+ impl.add(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator-=(const bigint_base& other)
+ {
+ impl.sub(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator*=(const bigint_base& other)
+ {
+ impl.mul(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator/=(const bigint_base& other)
+ {
+ impl.div(impl, other.impl);
+ return *this;
+ }
+
+ // - modulo
+ const bigint_base& operator%=(const bigint_base& other)
+ {
+ impl.mod(impl, other.impl);
+ return *this;
+ }
+
+ // - bit operations (bit logic (or, and, xor), bit shifts (left/right))
+ const bigint_base& operator|=(const bigint_base& other)
+ {
+ impl.or_(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator&=(const bigint_base& other)
+ {
+ impl.and_(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator^=(const bigint_base& other)
+ {
+ impl.xor_(impl, other.impl);
+ return *this;
+ }
+
+ const bigint_base& operator<<=(uint64_t other)
+ {
+ impl.lshift(impl, other);
+ return *this;
+ }
+
+ const bigint_base& operator>>=(uint64_t other)
+ {
+ impl.rshift(impl, other);
+ return *this;
+ }
+
+ const bigint_base& operator++()
+ {
+ impl.inc();
+ return *this;
+ }
+
+ bigint_base operator++(int)
+ {
+ bigint_base old = *this;
+ impl.inc();
+ return old;
+ }
+
+ const bigint_base& operator--()
+ {
+ impl.dec();
+ return *this;
+ }
+
+ bigint_base operator--(int)
+ {
+ bigint_base old = *this;
+ impl.dec();
+ return old;
+ }
+
+ // unary operators
+ bigint_base operator+() const
+ {
+ return *this;
+ }
+
+ bigint_base operator-() const
+ {
+ bigint_base<I> result;
+ result.impl.negate(impl);
+ return result;
+ }
+
+ bigint_base operator~() const
+ {
+ bigint_base<I> result;
+ result.impl.not_(impl);
+ return result;
+ }
+
+ // implicit conversion to "bool"
+
+#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
+
+ operator bool () const
+ {
+ return impl;
+ }
+
+#elif defined( _MANAGED )
+
+private:
+ static void unspecified_bool( bigint_base*** )
+ {
+ }
+
+ typedef void (*unspecified_bool_type)( bigint_base*** );
+
+public:
+ operator unspecified_bool_type() const // never throws
+ {
+ return impl.is_zero() ? 0 : unspecified_bool;
+ }
+
+#elif \
+ ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
+ ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
+
+private:
+ typedef std::string (bigint_base::*unspecified_bool_type)(int) const;
+
+public:
+ operator unspecified_bool_type() const // never throws
+ {
+ return impl.is_zero() ? 0 : &bigint_base::str;
+ }
+
+#else
+
+private:
+ typedef I* bigint_base::*unspecified_bool_type;
+
+public:
+ operator unspecified_bool_type() const // never throws
+ {
+ return impl.is_zero() ? 0 : &bigint_base::impl;
+ }
+
+#endif
+
+ // operator! is redundant, but some compilers need it
+
+ bool operator! () const // never throws
+ {
+ return impl.is_zero();
+ }
+
+ std::string str(int base = 10) const
+ {
+ return impl.str(base);
+ }
+
+ std::wstring wstr(int base = 10) const
+ {
+ return impl.wstr(base);
+ }
+
+ // conversion to numeric types (including 64 bit)
+ template <typename T> bool can_convert_to() const
+ {
+ return impl.template can_convert_to<T>();
+ }
+
+ template <typename T> T to_number() const
+ {
+ return impl.template to_number<T>();
+ }
+
+ // - basic arithmetic operations (addition, subtraction, multiplication, division)
+ friend bigint_base operator+(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.add(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ friend bigint_base operator-(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.sub(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ friend bigint_base operator*(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.mul(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ friend bigint_base operator/(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.div(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ // - modulo
+ friend bigint_base operator%(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.mod(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ // - bit operations (bit logic (or, and, xor), bit shifts (left/right))
+ friend bigint_base operator|(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.or_(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ friend bigint_base operator&(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.and_(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ friend bigint_base operator^(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ bigint_base<I> result;
+ result.impl.xor_(lhs.impl, rhs.impl);
+ return result;
+ }
+
+ // do we need << and >> for bigints?
+ friend bigint_base operator<<(const bigint_base& lhs, boost::uint64_t rhs)
+ {
+ bigint_base<I> result;
+ result.impl.lshift(lhs.impl, rhs);
+ return result;
+ }
+
+ friend bigint_base operator>>(const bigint_base& lhs, boost::uint64_t rhs)
+ {
+ bigint_base<I> result;
+ result.impl.rshift(lhs.impl, rhs);
+ return result;
+ }
+
+ friend bool operator<(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) < 0;
+ }
+
+ friend bool operator<=(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) <= 0;
+ }
+
+ friend bool operator>(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) > 0;
+ }
+
+ friend bool operator>=(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) >= 0;
+ }
+
+ friend bool operator==(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) == 0;
+ }
+
+ friend bool operator!=(const bigint_base& lhs, const bigint_base& rhs)
+ {
+ return lhs.impl.compare(rhs.impl) != 0;
+ }
+
+ friend bigint_base abs(const bigint_base& value)
+ {
+ bigint_base result;
+ result.impl.abs(value.impl);
+ return result;
+ }
+
+ friend bigint_base pow(const bigint_base<I>& lhs, boost::uint64_t rhs)
+ {
+ bigint_base result;
+ result.impl.pow(lhs.impl, rhs);
+ return result;
+ }
+
+ // non-standard. Do we need to change it (introduce some equivalent to div_t type) or is it ok?
+ friend bigint_base div(const bigint_base& lhs, const bigint_base& rhs, bigint_base& remainder)
+ {
+ bigint_base result;
+ result.impl.div(lhs.impl, rhs.impl, remainder.impl);
+ return result;
+ }
+
+ friend bigint_base sqrt(const bigint_base& lhs)
+ {
+ bigint_base result;
+ result.impl.sqrt(lhs.impl);
+ return result;
+ }
+
+ template <typename T, typename Tr> friend std::basic_ostream<T, Tr>& operator<<(std::basic_ostream<T, Tr>& lhs, const bigint_base& rhs)
+ {
+ typename std::basic_ostream<T, Tr>::sentry ok(lhs);
+
+ if (ok)
+ {
+ try
+ {
+ std::ios_base::fmtflags flags = lhs.flags() ;
+ std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
+ std::ios_base::fmtflags uppercase = flags & std::ios_base::uppercase;
+ std::ios_base::fmtflags showpos = flags & std::ios_base::showpos;
+ std::ios_base::fmtflags showbase = flags & std::ios_base::showbase;
+
+ int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
+
+ std::basic_string<T> str = detail::bigint::to_string(rhs, base, T());
+
+ if (uppercase && base == 16) std::transform(str.begin(), str.end(), str.begin(), detail::bigint::toupper());
+
+ typename std::basic_string<T>::size_type pad_length = 0;
+
+ // str[0] is safe, to_string will never return empty string
+ if (showpos && str[0] != '-')
+ {
+ str.insert(str.begin(), '+');
+ pad_length = 1;
+ }
+ else pad_length = (str[0] == '-');
+
+ const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
+
+ std::string grouping = punct.grouping();
+
+ if (!grouping.empty())
+ {
+ std::basic_string<T> nstr;
+
+ typename std::basic_string<T>::reverse_iterator it = str.rbegin();
+ typename std::basic_string<T>::reverse_iterator end = str.rend();
+ if (pad_length > 0) --end; // skip sign
+
+ size_t group_id = 0;
+ size_t chars_to_go = str.size() - pad_length;
+
+ while (it != end)
+ {
+ char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
+
+ if (!nstr.empty()) nstr += punct.thousands_sep();
+
+ if (limit <= 0)
+ {
+ nstr.append(it, end);
+ break;
+ }
+
+ size_t count = (std::min)(static_cast<size_t>(limit), chars_to_go);
+
+ nstr.append(it, it + count);
+
+ it += count;
+ chars_to_go -= count;
+
+ if (group_id < grouping.size()) ++group_id;
+ }
+
+ std::reverse(nstr.begin(), nstr.end());
+
+ str.replace(str.begin() + pad_length, str.end(), nstr.begin(), nstr.end());
+ }
+
+ if (showbase && (base == 16 || base == 8))
+ {
+ const T str_0X[] = {T('0'), T('X'), T()};
+ const T str_0x[] = {T('0'), T('x'), T()};
+ const T str_0[] = {T('0'), T()};
+
+ str.insert(pad_length, base == 16 ? (uppercase ? str_0X : str_0x) : str_0);
+ if (base == 16) pad_length += 2;
+ }
+
+ if (lhs.width() != 0)
+ {
+ std::streamsize width = lhs.width();
+ lhs.width(0);
+
+ if (width > 0 && static_cast<size_t>(width) > str.length())
+ {
+ std::ios_base::fmtflags adjustfield = flags & std::ios_base::adjustfield;
+
+ typename std::basic_string<T>::size_type pad_pos = 0; // pad before
+
+ if (adjustfield == std::ios_base::left) pad_pos = str.length();
+ else if (adjustfield == std::ios_base::internal) pad_pos = pad_length;
+
+ str.insert(pad_pos, width - str.length(), lhs.fill());
+ }
+ }
+
+ return lhs << str;
+ }
+ catch (...)
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ }
+ else return lhs;
+ }
+
+ template <typename T, typename Tr> friend std::basic_istream<T, Tr>& operator>>(std::basic_istream<T, Tr>& lhs, bigint_base& rhs)
+ {
+ typename std::basic_istream<T, Tr>::sentry ok(lhs);
+
+ if (ok)
+ {
+ try
+ {
+ std::ios_base::fmtflags flags = lhs.flags() ;
+ std::ios_base::fmtflags basefield = flags & std::ios_base::basefield;
+
+ int base = (basefield == std::ios_base::hex) ? 16 : (basefield == std::ios_base::oct) ? 8 : 10;
+
+ int sign = 1;
+
+ std::basic_string<T> str;
+
+ if (flags & std::ios_base::skipws)
+ {
+ // skip whitespaces
+ while (lhs.peek() != Tr::eof() && detail::bigint::isspace(static_cast<T>(lhs.peek())))
+ lhs.get();
+ }
+
+ if (lhs.peek() == T('-') || lhs.peek() == T('+'))
+ {
+ sign = lhs.get() == T('-') ? -1 : 1;
+ }
+
+ T char_table[] = {T('0'), T('1'), T('2'), T('3'), T('4'), T('5'), T('6'), T('7'), T('8'), T('9'),
+ T('a'), T('b'), T('c'), T('d'), T('e'), T('f'), T('A'), T('B'), T('C'), T('D'),
+ T('E'), T('F'), T()};
+
+ size_t char_table_size = base == 16 ? sizeof(char_table) / sizeof(char_table[0]) : base;
+
+ if (lhs.peek() == T('0'))
+ {
+ lhs.get();
+
+ if (lhs.peek() == T('x') || lhs.peek() == T('X')) // 0x 0X
+ lhs.get(); // skip
+ else
+ {
+ while (lhs.peek() == T('0')) lhs.get(); // skip zeroes
+
+ if (Tr::find(char_table, char_table_size, lhs.peek()) == 0) // next symbol is non-digit, we needed that 0
+ str += T('0');
+ }
+ }
+
+ const std::numpunct<T>& punct = std::use_facet<std::numpunct<T> >(lhs.getloc());
+
+ typename Tr::int_type ch;
+
+ while ((ch = lhs.peek()) != Tr::eof())
+ {
+ // do we allow this kind of character?
+ if (ch == punct.thousands_sep() || Tr::find(char_table, char_table_size, ch) != 0)
+ {
+ str += lhs.get();
+ }
+ else
+ {
+ // have we read any valid data?
+ if (str.empty())
+ {
+ // no.
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+
+ break;
+ }
+ }
+
+ std::string grouping = punct.grouping();
+
+ if (!grouping.empty())
+ {
+ typename std::basic_string<T>::reverse_iterator it = str.rbegin();
+ typename std::basic_string<T>::reverse_iterator end = str.rend();
+
+ size_t group_id = 0;
+
+ while (it != end)
+ {
+ char limit = group_id >= grouping.size() ? (grouping.empty() ? 0 : grouping[grouping.size() - 1]) : grouping[group_id];
+
+ typename std::basic_string<T>::reverse_iterator sep_it = std::find(it, end, punct.thousands_sep());
+
+ if (limit <= 0) // unlimited sequence of digits
+ {
+ if (sep_it != str.rend()) // there's another separator, error
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+
+ break;
+ }
+
+ // limited sequence of digits
+
+ // we're not at the end
+ if (sep_it != str.rend())
+ {
+ // digit sequence sizes do not match
+ if (limit != std::distance(it, sep_it))
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ else
+ {
+ it = sep_it;
+ ++it;
+ }
+ }
+ else if (limit < std::distance(it, sep_it)) // we're at the end, and our sequence size is larger
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ else
+ {
+ // we're at the end
+ break;
+ }
+
+ if (group_id < grouping.size()) ++group_id;
+ }
+
+ // remove all separators, we don't need them
+ str.erase(std::remove(str.begin(), str.end(), punct.thousands_sep()), str.end());
+ }
+
+ rhs = bigint_base(str, base);
+ if (sign == -1) rhs.impl.negate(rhs.impl);
+
+ return lhs;
+ }
+ catch (...)
+ {
+ lhs.setstate(std::ios_base::badbit); // may throw
+ return lhs;
+ }
+ }
+ else return lhs;
+ }
+};
+} // namespace boost
+
+// Do we have GMP?
+#ifdef BOOST_BIGINT_HAS_GMP_SUPPORT
+
+#include <boost/bigint/bigint_gmp.hpp>
+
+namespace boost {
+
+typedef bigint_base<detail::bigint_gmp_implementation> bigint;
+
+} // namespace boost
+
+#else
+
+#include <boost/bigint/bigint_default.hpp>
+#include <boost/bigint/bigint_storage_vector.hpp>
+
+namespace boost {
+
+typedef bigint_base<detail::bigint_default_implementation<detail::bigint_storage_vector> > bigint;
+
+} // namespace boost
+
+#endif
+
+#endif // BOOST_BIGINT_BIGINT_HPP

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_default.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_default.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_default.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,790 +1,790 @@
-/* Boost bigint_default.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_DEFAULT_HPP
-#define BOOST_BIGINT_BIGINT_DEFAULT_HPP
-
-#include <limits>
-
-#include <boost/scoped_array.hpp>
-
-#include <boost/bigint/bigint_util.hpp>
-
-namespace boost { namespace detail {
- // Default implementation
- template <template <class> class Storage> struct bigint_default_implementation
- {
- typedef unsigned int limb_t;
- typedef boost::uint64_t limb2_t;
-
- enum { limb_bit_number = sizeof(limb_t) * 8 };
- #define limb_max std::numeric_limits<limb_t>::max()
-
- Storage<limb_t> data;
- bool negative;
-
- bigint_default_implementation(): negative(false)
- {
- }
-
- void assign(int number)
- {
- assign(static_cast<int64_t>(number));
- }
-
- void assign(unsigned int number)
- {
- assign(static_cast<uint64_t>(number));
- }
-
- void assign(int64_t number)
- {
- // number is [-2^32, 2^32-1]
- // if number == -2^32, it's bit representation is 10...0, -number is 01...1+1 = 10...0 (the same)
- // converting to uint64_t yields still 10...0, it's exactly 2^32. In other cases we're safe.
- assign(static_cast<uint64_t>(number >= 0 ? number : -number));
-
- negative = (number < 0);
- }
-
- void assign(uint64_t number)
- {
- size_t size = 0;
-
- if (number != 0)
- {
- data.resize(1);
- data[0] = static_cast<limb_t>(number & limb_max);
-
- size = 1;
- }
-
- if (number > limb_max)
- {
- data.resize(64 / limb_bit_number); // we know that limb_bit_number is 2^n
-
- number >>= limb_bit_number;
-
- while (number > 0)
- {
- data[size++] = static_cast<limb_t>(number & limb_max);
- number >>= limb_bit_number;
- }
- }
-
- data.resize(size);
- negative = false;
- }
-
- // *this = *this * a + b
- void _mul_add(limb_t a, limb_t b)
- {
- limb_t carry = b;
-
- for (limb_t* i = data.begin(); i != data.end(); ++i)
- {
- limb2_t result = static_cast<limb2_t>(*i) * a + carry;
-
- *i = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
-
- if (carry != 0)
- {
- data.resize(data.size() + 1);
- data[data.size()-1] = carry;
- }
- }
-
- template <typename Ch> void _assign_str(const Ch* str, int base)
- {
- assert(base >= 2 && base <= 36);
-
- // skip whitespace
- while (detail::bigint::isspace(*str)) ++str;
-
- negative = false;
-
- if (*str == Ch('-'))
- {
- negative = true;
- ++str;
- }
- else if (*str == Ch('+'))
- {
- ++str;
- }
-
- static const unsigned char digit_value_tab[] =
- {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
- };
-
- // skip zeros
- while (*str == Ch('0')) ++str;
-
- // is there anything left?
- if (!*str)
- {
- assign(0);
- return;
- }
-
- data.resize(0);
-
- for (; *str; ++str)
- {
- if (!detail::bigint::is_ascii(*str) || digit_value_tab[static_cast<unsigned int>(*str)] >= base)
- {
- break;
- }
-
- _mul_add(static_cast<limb_t>(base), digit_value_tab[static_cast<unsigned int>(*str)]);
- }
- }
-
- void assign(const char* str, int base)
- {
- _assign_str(str, base);
- }
-
- void assign(const wchar_t* str, int base)
- {
- _assign_str(str, base);
- }
-
- void _add_unsigned(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- limb_t carry = 0;
-
- size_t li_size = lhs.data.size();
- size_t ri_size = rhs.data.size();
-
- data.resize((std::max)(lhs.data.size(), rhs.data.size()) + 1);
-
- const limb_t* li = lhs.data.begin();
- const limb_t* li_end = li + li_size;
- const limb_t* ri = rhs.data.begin();
- const limb_t* ri_end = ri + ri_size;
-
- limb_t* i = data.begin();
-
- for (; li != li_end && ri != ri_end; ++li, ++ri)
- {
- limb2_t result = static_cast<limb2_t>(*li) + *ri + carry;
-
- *i++ = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
-
- for (; li != li_end; ++li)
- {
- limb2_t result = static_cast<limb2_t>(*li) + carry;
-
- *i++ = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
-
- for (; ri != ri_end; ++ri)
- {
- limb2_t result = static_cast<limb2_t>(*ri) + carry;
-
- *i++ = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
-
- if (carry != 0)
- {
- *i = carry;
- }
- else
- {
- data.resize(data.size() - 1);
- }
- }
-
- void _normalize()
- {
- if (data.empty()) return;
-
- // strip zeroes
- const limb_t* i = data.end();
-
- do
- {
- --i;
- }
- while (i != data.begin() && *i == 0);
-
- if (i == data.begin() && *i == 0)
- {
- data.resize(0);
- negative = false;
- }
- else
- {
- data.resize((i - data.begin()) + 1);
- }
- }
-
- bool _sub_unsigned(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- limb_t borrow = 0;
-
- size_t li_size = lhs.data.size();
- size_t ri_size = rhs.data.size();
-
- data.resize((std::max)(lhs.data.size(), rhs.data.size()));
-
- const limb_t* li = lhs.data.begin();
- const limb_t* li_end = li + li_size;
- const limb_t* ri = rhs.data.begin();
- const limb_t* ri_end = ri + ri_size;
-
- limb_t* i = data.begin();
-
- for (; li != li_end && ri != ri_end; ++li, ++ri)
- {
- limb2_t result = static_cast<limb2_t>(*ri) + borrow;
-
- if (result > *li)
- {
- result = static_cast<limb2_t>(limb_max) + 1 + *li - result;
- borrow = 1;
- }
- else
- {
- result = *li - result;
- borrow = 0;
- }
-
- *i++ = static_cast<limb_t>(result & limb_max);
- }
-
- for (; li != li_end; ++li)
- {
- limb2_t result = borrow;
-
- if (result > *li)
- {
- result = static_cast<limb2_t>(limb_max) + 1 + *li - result;
- borrow = 1;
- }
- else
- {
- result = *li - result;
- borrow = 0;
- }
-
- *i++ = static_cast<limb_t>(result & limb_max);
- }
-
- for (; ri != ri_end; ++ri)
- {
- limb2_t result = static_cast<limb2_t>(*ri) + borrow;
-
- if (result > 0)
- {
- result = static_cast<limb2_t>(limb_max) + 1 - result;
- borrow = 1;
- }
- else
- {
- borrow = 0;
- }
-
- *i++ = static_cast<limb_t>(result & limb_max);
- }
-
- if (borrow != 0)
- {
- // we borrowed 2^number of bits in our number - we have to subtract it
- // for this we need to complement all limbs to 2, and add 1 to the last limb.
- for (limb_t* j = data.begin(); j != data.end(); ++j)
- *j = limb_max- *j;
-
- data[0]++;
- }
-
- _normalize();
-
- return borrow != 0;
- }
-
- void add(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.negative == rhs.negative) // positive + positive or negative + negative
- {
- negative = lhs.negative;
- _add_unsigned(lhs, rhs);
- }
- else if (lhs.negative) // negative + positive
- {
- negative = _sub_unsigned(rhs, lhs);
- }
- else // positive + negative
- {
- negative = _sub_unsigned(lhs, rhs);
- }
- }
-
- void sub(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.negative != rhs.negative) // positive - negative or negative - positive
- {
- negative = lhs.negative;
- _add_unsigned(lhs, rhs);
- }
- else if (lhs.negative) // negative - negative
- {
- negative = _sub_unsigned(rhs, lhs);
- }
- else // positive - positive
- {
- negative = _sub_unsigned(lhs, rhs);
- }
- }
-
- void mul(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.is_zero() || rhs.is_zero())
- {
- assign(0);
- return;
- }
-
- if (this == &lhs || this == &rhs)
- {
- bigint_default_implementation copy;
- copy.mul(lhs, rhs);
- *this = copy;
- return;
- }
-
- data.resize(lhs.data.size() + rhs.data.size());
- std::fill(data.begin(), data.end(), 0);
-
- limb_t* i = data.begin();
-
- for (const limb_t* li = lhs.data.begin(); li != lhs.data.end(); ++li, ++i)
- {
- limb_t carry = 0;
-
- limb_t* ci = i;
-
- for (const limb_t* ri = rhs.data.begin(); ri != rhs.data.end(); ++ri)
- {
- limb2_t result = static_cast<limb2_t>(*li) * *ri + *ci + carry;
-
- *ci++ = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
-
- while (carry != 0)
- {
- limb2_t result = static_cast<limb2_t>(*ci) + carry;
-
- *ci++ = static_cast<limb_t>(result & limb_max);
-
- carry = static_cast<limb_t>(result >> limb_bit_number);
- }
- }
-
- _normalize();
-
- negative = lhs.negative ? !rhs.negative : rhs.negative;
- }
-
- void div(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- }
-
- void mod(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- }
-
- template <bool complement> limb_t _convert(limb_t limb)
- {
- return complement ? limb_max - limb : limb;
- }
-
- template <bool complement> limb_t _convert_first(limb_t limb)
- {
- return complement ? limb_max - limb + 1 : limb;
- }
-
- template <bool lhs_neg, bool rhs_neg> void _or_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- const bool neg = lhs_neg || rhs_neg; // sign bit is or-ed
- negative = neg;
-
- size_t li_size = lhs.data.size();
- size_t ri_size = rhs.data.size();
-
- data.resize((std::max)(lhs.data.size(), rhs.data.size()));
-
- const limb_t* li = lhs.data.begin();
- const limb_t* li_end = li + li_size;
- const limb_t* ri = rhs.data.begin();
- const limb_t* ri_end = ri + ri_size;
-
- limb_t* i = data.begin();
-
- if (li != li_end && ri != ri_end)
- {
- *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) | _convert_first<rhs_neg>(*ri));
- ++li;
- ++ri;
- }
-
- for (; li != li_end && ri != ri_end; ++li, ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) | _convert<rhs_neg>(*ri));
- }
-
- for (; li != li_end; ++li)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) | _convert<rhs_neg>(0)); // or with rhs sign bit
- }
-
- for (; ri != ri_end; ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(0) | _convert<rhs_neg>(*ri)); // or with lhs sign bit
- }
-
- _normalize();
- }
-
- void or_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.negative)
- rhs.negative ? _or_<true, true>(lhs, rhs) : _or_<true, false>(lhs, rhs);
- else
- rhs.negative ? _or_<false, true>(lhs, rhs) : _or_<false, false>(lhs, rhs);
- }
-
- template <bool lhs_neg, bool rhs_neg> void _and_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- const bool neg = lhs_neg && rhs_neg; // sign bit is and-ed
- negative = neg;
-
- size_t li_size = lhs.data.size();
- size_t ri_size = rhs.data.size();
-
- data.resize((std::max)(lhs.data.size(), rhs.data.size()));
-
- const limb_t* li = lhs.data.begin();
- const limb_t* li_end = li + li_size;
- const limb_t* ri = rhs.data.begin();
- const limb_t* ri_end = ri + ri_size;
-
- limb_t* i = data.begin();
-
- if (li != li_end && ri != ri_end)
- {
- *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) & _convert_first<rhs_neg>(*ri));
- ++li;
- ++ri;
- }
-
- for (; li != li_end && ri != ri_end; ++li, ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) & _convert<rhs_neg>(*ri));
- }
-
- for (; li != li_end; ++li)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) & _convert<rhs_neg>(0)); // and with rhs sign bit
- }
-
- for (; ri != ri_end; ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(0) & _convert<rhs_neg>(*ri)); // and with lhs sign bit
- }
-
- _normalize();
- }
-
- void and_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.negative)
- rhs.negative ? _and_<true, true>(lhs, rhs) : _and_<true, false>(lhs, rhs);
- else
- rhs.negative ? _and_<false, true>(lhs, rhs) : _and_<false, false>(lhs, rhs);
- }
-
- template <bool lhs_neg, bool rhs_neg> void _xor_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- const bool neg = lhs_neg ? !rhs_neg : rhs_neg; // sign bit is xor-ed
- negative = neg;
-
- size_t li_size = lhs.data.size();
- size_t ri_size = rhs.data.size();
-
- data.resize((std::max)(lhs.data.size(), rhs.data.size()));
-
- const limb_t* li = lhs.data.begin();
- const limb_t* li_end = li + li_size;
- const limb_t* ri = rhs.data.begin();
- const limb_t* ri_end = ri + ri_size;
-
- limb_t* i = data.begin();
-
- if (li != li_end && ri != ri_end)
- {
- *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) ^ _convert_first<rhs_neg>(*ri));
- ++li;
- ++ri;
- }
-
- for (; li != li_end && ri != ri_end; ++li, ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) ^ _convert<rhs_neg>(*ri));
- }
-
- for (; li != li_end; ++li)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(*li) ^ _convert<rhs_neg>(0)); // xor with rhs sign bit
- }
-
- for (; ri != ri_end; ++ri)
- {
- *i++ = _convert<neg>(_convert<lhs_neg>(0) ^ _convert<rhs_neg>(*ri)); // xor with lhs sign bit
- }
-
- _normalize();
- }
-
- void xor_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
- {
- if (lhs.negative)
- rhs.negative ? _xor_<true, true>(lhs, rhs) : _xor_<true, false>(lhs, rhs);
- else
- rhs.negative ? _xor_<false, true>(lhs, rhs) : _xor_<false, false>(lhs, rhs);
- }
-
- void not_(const bigint_default_implementation& lhs)
- {
- // ~value == -(value + 1) == -value-1
- negate(lhs);
- dec();
- }
-
- void negate(const bigint_default_implementation& lhs)
- {
- data = lhs.data;
- negative = !lhs.negative;
- if (data.empty()) negative = false;
- }
-
- void lshift(const bigint_default_implementation& lhs, boost::uint64_t rhs)
- {
- }
-
- void rshift(const bigint_default_implementation& lhs, boost::uint64_t rhs)
- {
- }
-
- void inc()
- {
- bigint_default_implementation one;
- one.assign(1);
-
- add(*this, one);
- }
-
- void dec()
- {
- bigint_default_implementation one;
- one.assign(1);
-
- sub(*this, one);
- }
-
- int compare(const bigint_default_implementation& rhs) const
- {
- if (negative != rhs.negative) return negative > rhs.negative ? -1 : 1;
-
- int result = negative ? -1 : 1;
-
- if (data.size() != rhs.data.size()) return result * (data.size() < rhs.data.size() ? -1 : 1);
- if (data.empty()) return 0;
-
- const limb_t* li = data.end();
- const limb_t* ri = rhs.data.end();
-
- do
- {
- --li; --ri;
-
- if (*li < *ri)
- {
- return -result;
- }
- else if (*li > *ri)
- {
- return result;
- }
- }
- while (li != data.begin());
-
- return 0;
- }
-
- // *this = *this / a, return division remainder
- limb_t _div_rem(limb_t a)
- {
- if (data.empty()) return 0;
-
- limb_t remainder = 0;
-
- limb_t* i = data.end();
-
- do
- {
- --i;
-
- limb2_t result = (static_cast<limb2_t>(remainder) << limb_bit_number) + *i;
-
- *i = static_cast<limb_t>(result / a);
-
- remainder = static_cast<limb_t>(result % a);
- }
- while (i != data.begin());
-
- if (*(data.end() - 1) == 0) data.resize(data.size() - 1);
-
- return remainder;
- }
-
- template <typename Ch> std::basic_string<Ch> _to_str(int base) const
- {
- assert(base >= 2 && base <= 36);
-
- if (data.empty()) return std::basic_string<Ch>(1, Ch('0'));
-
- std::basic_string<Ch> result;
-
- bigint_default_implementation copy = *this;
-
- static const Ch digit_char_tab[] =
- {
- Ch('0'), Ch('1'), Ch('2'), Ch('3'), Ch('4'), Ch('5'), Ch('6'), Ch('7'), Ch('8'), Ch('9'),
- Ch('a'), Ch('b'), Ch('c'), Ch('d'), Ch('e'), Ch('f'), Ch('g'), Ch('h'), Ch('i'), Ch('j'),
- Ch('k'), Ch('l'), Ch('m'), Ch('n'), Ch('o'), Ch('p'), Ch('q'), Ch('r'), Ch('s'), Ch('t'),
- Ch('u'), Ch('v'), Ch('w'), Ch('x'), Ch('y'), Ch('z')
- };
-
- while (!copy.data.empty())
- {
- result += digit_char_tab[copy._div_rem(static_cast<limb_t>(base))];
- }
-
- if (negative) result += '-';
-
- std::reverse(result.begin(), result.end());
-
- return result;
- }
-
- std::string str(int base) const
- {
- return _to_str<char>(base);
- }
-
- std::wstring wstr(int base) const
- {
- return _to_str<wchar_t>(base);
- }
-
- boost::uint64_t _to_uint64() const
- {
- boost::uint64_t value = 0;
- boost::uint64_t power = 1;
-
- for (const limb_t* i = data.begin(); i != data.end(); ++i)
- {
- value += *i * power;
- power <<= limb_bit_number;
- }
-
- return value;
- }
-
- template <typename T> bool can_convert_to() const
- {
- // Only integer types supported
- if (!std::numeric_limits<T>::is_integer) return false;
-
- boost::uint64_t max_value;
-
- size_t count = data.size();
-
- if (negative)
- {
- max_value = static_cast<boost::uint64_t>(-static_cast<boost::int64_t>((std::numeric_limits<T>::min)()));
- }
- else
- {
- max_value = (std::numeric_limits<T>::max)();
- }
-
- if (count * limb_bit_number > sizeof(boost::uint64_t) * 8) // we can't fit in uint64 => we won't fit in anything else
- return false;
-
- return max_value >= _to_uint64();
- }
-
- template <typename T> T to_number() const
- {
- if (!std::numeric_limits<T>::is_integer) return T();
-
- boost::uint64_t value = _to_uint64();
-
- return negative ? static_cast<T>(-static_cast<boost::int64_t>(value)) : static_cast<T>(value);
- }
-
- bool is_zero() const
- {
- return data.empty();
- }
-
- void abs(const bigint_default_implementation& rhs)
- {
- data = rhs.data;
- negative = false;
- }
-
- void pow(const bigint_default_implementation& lhs, boost::uint64_t rhs)
- {
- }
-
- void div(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs, bigint_default_implementation& remainder)
- {
- }
-
- void sqrt(const bigint_default_implementation& lhs)
- {
- }
- };
-} } // namespace boost::detail
-
-#endif // BOOST_BIGINT_BIGINT_DEFAULT_HPP
+/* Boost bigint_default.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_DEFAULT_HPP
+#define BOOST_BIGINT_BIGINT_DEFAULT_HPP
+
+#include <limits>
+
+#include <boost/scoped_array.hpp>
+
+#include <boost/bigint/bigint_util.hpp>
+
+namespace boost { namespace detail {
+ // Default implementation
+ template <template <class> class Storage> struct bigint_default_implementation
+ {
+ typedef unsigned int limb_t;
+ typedef boost::uint64_t limb2_t;
+
+ enum { limb_bit_number = sizeof(limb_t) * 8 };
+ #define limb_max std::numeric_limits<limb_t>::max()
+
+ Storage<limb_t> data;
+ bool negative;
+
+ bigint_default_implementation(): negative(false)
+ {
+ }
+
+ void assign(int number)
+ {
+ assign(static_cast<int64_t>(number));
+ }
+
+ void assign(unsigned int number)
+ {
+ assign(static_cast<uint64_t>(number));
+ }
+
+ void assign(int64_t number)
+ {
+ // number is [-2^32, 2^32-1]
+ // if number == -2^32, it's bit representation is 10...0, -number is 01...1+1 = 10...0 (the same)
+ // converting to uint64_t yields still 10...0, it's exactly 2^32. In other cases we're safe.
+ assign(static_cast<uint64_t>(number >= 0 ? number : -number));
+
+ negative = (number < 0);
+ }
+
+ void assign(uint64_t number)
+ {
+ size_t size = 0;
+
+ if (number != 0)
+ {
+ data.resize(1);
+ data[0] = static_cast<limb_t>(number & limb_max);
+
+ size = 1;
+ }
+
+ if (number > limb_max)
+ {
+ data.resize(64 / limb_bit_number); // we know that limb_bit_number is 2^n
+
+ number >>= limb_bit_number;
+
+ while (number > 0)
+ {
+ data[size++] = static_cast<limb_t>(number & limb_max);
+ number >>= limb_bit_number;
+ }
+ }
+
+ data.resize(size);
+ negative = false;
+ }
+
+ // *this = *this * a + b
+ void _mul_add(limb_t a, limb_t b)
+ {
+ limb_t carry = b;
+
+ for (limb_t* i = data.begin(); i != data.end(); ++i)
+ {
+ limb2_t result = static_cast<limb2_t>(*i) * a + carry;
+
+ *i = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+
+ if (carry != 0)
+ {
+ data.resize(data.size() + 1);
+ data[data.size()-1] = carry;
+ }
+ }
+
+ template <typename Ch> void _assign_str(const Ch* str, int base)
+ {
+ assert(base >= 2 && base <= 36);
+
+ // skip whitespace
+ while (detail::bigint::isspace(*str)) ++str;
+
+ negative = false;
+
+ if (*str == Ch('-'))
+ {
+ negative = true;
+ ++str;
+ }
+ else if (*str == Ch('+'))
+ {
+ ++str;
+ }
+
+ static const unsigned char digit_value_tab[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+
+ // skip zeros
+ while (*str == Ch('0')) ++str;
+
+ // is there anything left?
+ if (!*str)
+ {
+ assign(0);
+ return;
+ }
+
+ data.resize(0);
+
+ for (; *str; ++str)
+ {
+ if (!detail::bigint::is_ascii(*str) || digit_value_tab[static_cast<unsigned int>(*str)] >= base)
+ {
+ break;
+ }
+
+ _mul_add(static_cast<limb_t>(base), digit_value_tab[static_cast<unsigned int>(*str)]);
+ }
+ }
+
+ void assign(const char* str, int base)
+ {
+ _assign_str(str, base);
+ }
+
+ void assign(const wchar_t* str, int base)
+ {
+ _assign_str(str, base);
+ }
+
+ void _add_unsigned(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ limb_t carry = 0;
+
+ size_t li_size = lhs.data.size();
+ size_t ri_size = rhs.data.size();
+
+ data.resize((std::max)(lhs.data.size(), rhs.data.size()) + 1);
+
+ const limb_t* li = lhs.data.begin();
+ const limb_t* li_end = li + li_size;
+ const limb_t* ri = rhs.data.begin();
+ const limb_t* ri_end = ri + ri_size;
+
+ limb_t* i = data.begin();
+
+ for (; li != li_end && ri != ri_end; ++li, ++ri)
+ {
+ limb2_t result = static_cast<limb2_t>(*li) + *ri + carry;
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+
+ for (; li != li_end; ++li)
+ {
+ limb2_t result = static_cast<limb2_t>(*li) + carry;
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+
+ for (; ri != ri_end; ++ri)
+ {
+ limb2_t result = static_cast<limb2_t>(*ri) + carry;
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+
+ if (carry != 0)
+ {
+ *i = carry;
+ }
+ else
+ {
+ data.resize(data.size() - 1);
+ }
+ }
+
+ void _normalize()
+ {
+ if (data.empty()) return;
+
+ // strip zeroes
+ const limb_t* i = data.end();
+
+ do
+ {
+ --i;
+ }
+ while (i != data.begin() && *i == 0);
+
+ if (i == data.begin() && *i == 0)
+ {
+ data.resize(0);
+ negative = false;
+ }
+ else
+ {
+ data.resize((i - data.begin()) + 1);
+ }
+ }
+
+ bool _sub_unsigned(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ limb_t borrow = 0;
+
+ size_t li_size = lhs.data.size();
+ size_t ri_size = rhs.data.size();
+
+ data.resize((std::max)(lhs.data.size(), rhs.data.size()));
+
+ const limb_t* li = lhs.data.begin();
+ const limb_t* li_end = li + li_size;
+ const limb_t* ri = rhs.data.begin();
+ const limb_t* ri_end = ri + ri_size;
+
+ limb_t* i = data.begin();
+
+ for (; li != li_end && ri != ri_end; ++li, ++ri)
+ {
+ limb2_t result = static_cast<limb2_t>(*ri) + borrow;
+
+ if (result > *li)
+ {
+ result = static_cast<limb2_t>(limb_max) + 1 + *li - result;
+ borrow = 1;
+ }
+ else
+ {
+ result = *li - result;
+ borrow = 0;
+ }
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+ }
+
+ for (; li != li_end; ++li)
+ {
+ limb2_t result = borrow;
+
+ if (result > *li)
+ {
+ result = static_cast<limb2_t>(limb_max) + 1 + *li - result;
+ borrow = 1;
+ }
+ else
+ {
+ result = *li - result;
+ borrow = 0;
+ }
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+ }
+
+ for (; ri != ri_end; ++ri)
+ {
+ limb2_t result = static_cast<limb2_t>(*ri) + borrow;
+
+ if (result > 0)
+ {
+ result = static_cast<limb2_t>(limb_max) + 1 - result;
+ borrow = 1;
+ }
+ else
+ {
+ borrow = 0;
+ }
+
+ *i++ = static_cast<limb_t>(result & limb_max);
+ }
+
+ if (borrow != 0)
+ {
+ // we borrowed 2^number of bits in our number - we have to subtract it
+ // for this we need to complement all limbs to 2, and add 1 to the last limb.
+ for (limb_t* j = data.begin(); j != data.end(); ++j)
+ *j = limb_max- *j;
+
+ data[0]++;
+ }
+
+ _normalize();
+
+ return borrow != 0;
+ }
+
+ void add(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.negative == rhs.negative) // positive + positive or negative + negative
+ {
+ negative = lhs.negative;
+ _add_unsigned(lhs, rhs);
+ }
+ else if (lhs.negative) // negative + positive
+ {
+ negative = _sub_unsigned(rhs, lhs);
+ }
+ else // positive + negative
+ {
+ negative = _sub_unsigned(lhs, rhs);
+ }
+ }
+
+ void sub(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.negative != rhs.negative) // positive - negative or negative - positive
+ {
+ negative = lhs.negative;
+ _add_unsigned(lhs, rhs);
+ }
+ else if (lhs.negative) // negative - negative
+ {
+ negative = _sub_unsigned(rhs, lhs);
+ }
+ else // positive - positive
+ {
+ negative = _sub_unsigned(lhs, rhs);
+ }
+ }
+
+ void mul(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.is_zero() || rhs.is_zero())
+ {
+ assign(0);
+ return;
+ }
+
+ if (this == &lhs || this == &rhs)
+ {
+ bigint_default_implementation copy;
+ copy.mul(lhs, rhs);
+ *this = copy;
+ return;
+ }
+
+ data.resize(lhs.data.size() + rhs.data.size());
+ std::fill(data.begin(), data.end(), 0);
+
+ limb_t* i = data.begin();
+
+ for (const limb_t* li = lhs.data.begin(); li != lhs.data.end(); ++li, ++i)
+ {
+ limb_t carry = 0;
+
+ limb_t* ci = i;
+
+ for (const limb_t* ri = rhs.data.begin(); ri != rhs.data.end(); ++ri)
+ {
+ limb2_t result = static_cast<limb2_t>(*li) * *ri + *ci + carry;
+
+ *ci++ = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+
+ while (carry != 0)
+ {
+ limb2_t result = static_cast<limb2_t>(*ci) + carry;
+
+ *ci++ = static_cast<limb_t>(result & limb_max);
+
+ carry = static_cast<limb_t>(result >> limb_bit_number);
+ }
+ }
+
+ _normalize();
+
+ negative = lhs.negative ? !rhs.negative : rhs.negative;
+ }
+
+ void div(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ }
+
+ void mod(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ }
+
+ template <bool complement> limb_t _convert(limb_t limb)
+ {
+ return complement ? limb_max - limb : limb;
+ }
+
+ template <bool complement> limb_t _convert_first(limb_t limb)
+ {
+ return complement ? limb_max - limb + 1 : limb;
+ }
+
+ template <bool lhs_neg, bool rhs_neg> void _or_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ const bool neg = lhs_neg || rhs_neg; // sign bit is or-ed
+ negative = neg;
+
+ size_t li_size = lhs.data.size();
+ size_t ri_size = rhs.data.size();
+
+ data.resize((std::max)(lhs.data.size(), rhs.data.size()));
+
+ const limb_t* li = lhs.data.begin();
+ const limb_t* li_end = li + li_size;
+ const limb_t* ri = rhs.data.begin();
+ const limb_t* ri_end = ri + ri_size;
+
+ limb_t* i = data.begin();
+
+ if (li != li_end && ri != ri_end)
+ {
+ *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) | _convert_first<rhs_neg>(*ri));
+ ++li;
+ ++ri;
+ }
+
+ for (; li != li_end && ri != ri_end; ++li, ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) | _convert<rhs_neg>(*ri));
+ }
+
+ for (; li != li_end; ++li)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) | _convert<rhs_neg>(0)); // or with rhs sign bit
+ }
+
+ for (; ri != ri_end; ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(0) | _convert<rhs_neg>(*ri)); // or with lhs sign bit
+ }
+
+ _normalize();
+ }
+
+ void or_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.negative)
+ rhs.negative ? _or_<true, true>(lhs, rhs) : _or_<true, false>(lhs, rhs);
+ else
+ rhs.negative ? _or_<false, true>(lhs, rhs) : _or_<false, false>(lhs, rhs);
+ }
+
+ template <bool lhs_neg, bool rhs_neg> void _and_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ const bool neg = lhs_neg && rhs_neg; // sign bit is and-ed
+ negative = neg;
+
+ size_t li_size = lhs.data.size();
+ size_t ri_size = rhs.data.size();
+
+ data.resize((std::max)(lhs.data.size(), rhs.data.size()));
+
+ const limb_t* li = lhs.data.begin();
+ const limb_t* li_end = li + li_size;
+ const limb_t* ri = rhs.data.begin();
+ const limb_t* ri_end = ri + ri_size;
+
+ limb_t* i = data.begin();
+
+ if (li != li_end && ri != ri_end)
+ {
+ *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) & _convert_first<rhs_neg>(*ri));
+ ++li;
+ ++ri;
+ }
+
+ for (; li != li_end && ri != ri_end; ++li, ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) & _convert<rhs_neg>(*ri));
+ }
+
+ for (; li != li_end; ++li)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) & _convert<rhs_neg>(0)); // and with rhs sign bit
+ }
+
+ for (; ri != ri_end; ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(0) & _convert<rhs_neg>(*ri)); // and with lhs sign bit
+ }
+
+ _normalize();
+ }
+
+ void and_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.negative)
+ rhs.negative ? _and_<true, true>(lhs, rhs) : _and_<true, false>(lhs, rhs);
+ else
+ rhs.negative ? _and_<false, true>(lhs, rhs) : _and_<false, false>(lhs, rhs);
+ }
+
+ template <bool lhs_neg, bool rhs_neg> void _xor_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ const bool neg = lhs_neg ? !rhs_neg : rhs_neg; // sign bit is xor-ed
+ negative = neg;
+
+ size_t li_size = lhs.data.size();
+ size_t ri_size = rhs.data.size();
+
+ data.resize((std::max)(lhs.data.size(), rhs.data.size()));
+
+ const limb_t* li = lhs.data.begin();
+ const limb_t* li_end = li + li_size;
+ const limb_t* ri = rhs.data.begin();
+ const limb_t* ri_end = ri + ri_size;
+
+ limb_t* i = data.begin();
+
+ if (li != li_end && ri != ri_end)
+ {
+ *i++ = _convert_first<neg>(_convert_first<lhs_neg>(*li) ^ _convert_first<rhs_neg>(*ri));
+ ++li;
+ ++ri;
+ }
+
+ for (; li != li_end && ri != ri_end; ++li, ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) ^ _convert<rhs_neg>(*ri));
+ }
+
+ for (; li != li_end; ++li)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(*li) ^ _convert<rhs_neg>(0)); // xor with rhs sign bit
+ }
+
+ for (; ri != ri_end; ++ri)
+ {
+ *i++ = _convert<neg>(_convert<lhs_neg>(0) ^ _convert<rhs_neg>(*ri)); // xor with lhs sign bit
+ }
+
+ _normalize();
+ }
+
+ void xor_(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs)
+ {
+ if (lhs.negative)
+ rhs.negative ? _xor_<true, true>(lhs, rhs) : _xor_<true, false>(lhs, rhs);
+ else
+ rhs.negative ? _xor_<false, true>(lhs, rhs) : _xor_<false, false>(lhs, rhs);
+ }
+
+ void not_(const bigint_default_implementation& lhs)
+ {
+ // ~value == -(value + 1) == -value-1
+ negate(lhs);
+ dec();
+ }
+
+ void negate(const bigint_default_implementation& lhs)
+ {
+ data = lhs.data;
+ negative = !lhs.negative;
+ if (data.empty()) negative = false;
+ }
+
+ void lshift(const bigint_default_implementation& lhs, boost::uint64_t rhs)
+ {
+ }
+
+ void rshift(const bigint_default_implementation& lhs, boost::uint64_t rhs)
+ {
+ }
+
+ void inc()
+ {
+ bigint_default_implementation one;
+ one.assign(1);
+
+ add(*this, one);
+ }
+
+ void dec()
+ {
+ bigint_default_implementation one;
+ one.assign(1);
+
+ sub(*this, one);
+ }
+
+ int compare(const bigint_default_implementation& rhs) const
+ {
+ if (negative != rhs.negative) return negative > rhs.negative ? -1 : 1;
+
+ int result = negative ? -1 : 1;
+
+ if (data.size() != rhs.data.size()) return result * (data.size() < rhs.data.size() ? -1 : 1);
+ if (data.empty()) return 0;
+
+ const limb_t* li = data.end();
+ const limb_t* ri = rhs.data.end();
+
+ do
+ {
+ --li; --ri;
+
+ if (*li < *ri)
+ {
+ return -result;
+ }
+ else if (*li > *ri)
+ {
+ return result;
+ }
+ }
+ while (li != data.begin());
+
+ return 0;
+ }
+
+ // *this = *this / a, return division remainder
+ limb_t _div_rem(limb_t a)
+ {
+ if (data.empty()) return 0;
+
+ limb_t remainder = 0;
+
+ limb_t* i = data.end();
+
+ do
+ {
+ --i;
+
+ limb2_t result = (static_cast<limb2_t>(remainder) << limb_bit_number) + *i;
+
+ *i = static_cast<limb_t>(result / a);
+
+ remainder = static_cast<limb_t>(result % a);
+ }
+ while (i != data.begin());
+
+ if (*(data.end() - 1) == 0) data.resize(data.size() - 1);
+
+ return remainder;
+ }
+
+ template <typename Ch> std::basic_string<Ch> _to_str(int base) const
+ {
+ assert(base >= 2 && base <= 36);
+
+ if (data.empty()) return std::basic_string<Ch>(1, Ch('0'));
+
+ std::basic_string<Ch> result;
+
+ bigint_default_implementation copy = *this;
+
+ static const Ch digit_char_tab[] =
+ {
+ Ch('0'), Ch('1'), Ch('2'), Ch('3'), Ch('4'), Ch('5'), Ch('6'), Ch('7'), Ch('8'), Ch('9'),
+ Ch('a'), Ch('b'), Ch('c'), Ch('d'), Ch('e'), Ch('f'), Ch('g'), Ch('h'), Ch('i'), Ch('j'),
+ Ch('k'), Ch('l'), Ch('m'), Ch('n'), Ch('o'), Ch('p'), Ch('q'), Ch('r'), Ch('s'), Ch('t'),
+ Ch('u'), Ch('v'), Ch('w'), Ch('x'), Ch('y'), Ch('z')
+ };
+
+ while (!copy.data.empty())
+ {
+ result += digit_char_tab[copy._div_rem(static_cast<limb_t>(base))];
+ }
+
+ if (negative) result += '-';
+
+ std::reverse(result.begin(), result.end());
+
+ return result;
+ }
+
+ std::string str(int base) const
+ {
+ return _to_str<char>(base);
+ }
+
+ std::wstring wstr(int base) const
+ {
+ return _to_str<wchar_t>(base);
+ }
+
+ boost::uint64_t _to_uint64() const
+ {
+ boost::uint64_t value = 0;
+ boost::uint64_t power = 1;
+
+ for (const limb_t* i = data.begin(); i != data.end(); ++i)
+ {
+ value += *i * power;
+ power <<= limb_bit_number;
+ }
+
+ return value;
+ }
+
+ template <typename T> bool can_convert_to() const
+ {
+ // Only integer types supported
+ if (!std::numeric_limits<T>::is_integer) return false;
+
+ boost::uint64_t max_value;
+
+ size_t count = data.size();
+
+ if (negative)
+ {
+ max_value = static_cast<boost::uint64_t>(-static_cast<boost::int64_t>((std::numeric_limits<T>::min)()));
+ }
+ else
+ {
+ max_value = (std::numeric_limits<T>::max)();
+ }
+
+ if (count * limb_bit_number > sizeof(boost::uint64_t) * 8) // we can't fit in uint64 => we won't fit in anything else
+ return false;
+
+ return max_value >= _to_uint64();
+ }
+
+ template <typename T> T to_number() const
+ {
+ if (!std::numeric_limits<T>::is_integer) return T();
+
+ boost::uint64_t value = _to_uint64();
+
+ return negative ? static_cast<T>(-static_cast<boost::int64_t>(value)) : static_cast<T>(value);
+ }
+
+ bool is_zero() const
+ {
+ return data.empty();
+ }
+
+ void abs(const bigint_default_implementation& rhs)
+ {
+ data = rhs.data;
+ negative = false;
+ }
+
+ void pow(const bigint_default_implementation& lhs, boost::uint64_t rhs)
+ {
+ }
+
+ void div(const bigint_default_implementation& lhs, const bigint_default_implementation& rhs, bigint_default_implementation& remainder)
+ {
+ }
+
+ void sqrt(const bigint_default_implementation& lhs)
+ {
+ }
+ };
+} } // namespace boost::detail
+
+#endif // BOOST_BIGINT_BIGINT_DEFAULT_HPP

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_gmp.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,407 +1,407 @@
-/* Boost bigint_gmp.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_GMP_HPP
-#define BOOST_BIGINT_BIGINT_GMP_HPP
-
-#include <limits>
-
-#include <boost/scoped_array.hpp>
-
-#include <boost/bigint/bigint_util.hpp>
-
-#include <gmp.h>
-
-namespace boost { namespace detail {
- // GMP-based implementation
- struct bigint_gmp_implementation
- {
- mpz_t data;
-
- bigint_gmp_implementation()
- {
- mpz_init(data);
- }
-
- ~bigint_gmp_implementation()
- {
- mpz_clear(data);
- }
-
- bigint_gmp_implementation(const bigint_gmp_implementation& other)
- {
- mpz_init_set(data, other.data);
- }
-
- bigint_gmp_implementation& operator=(const bigint_gmp_implementation& other)
- {
- if (this != &other)
- {
- mpz_clear(data);
- mpz_init_set(data, other.data);
- }
- return *this;
- }
-
- void assign(int number)
- {
- mpz_set_si(data, number);
- }
-
- void assign(unsigned int number)
- {
- mpz_set_ui(data, number);
- }
-
- void assign(int64_t number)
- {
- // number is [-2^32, 2^32-1]
- // if number == -2^32, it's bit representation is 10...0, -number is 01...1+1 = 10...0 (the same)
- // converting to uint64_t yields still 10...0, it's exactly 2^32. In other cases we're safe.
- assign(static_cast<uint64_t>(number >= 0 ? number : -number));
-
- if (number < 0) mpz_neg(data, data);
- }
-
- void assign(uint64_t number)
- {
- mp_size_t size;
-
- data->_mp_d[0] = static_cast<mp_limb_t>(number & GMP_NUMB_MAX);
- size = number != 0;
-
- if (number > GMP_NUMB_MAX)
- {
- mpz_realloc(data, 64 / GMP_NUMB_BITS); // we know that GMP_NUMB_BITS is 2^n
-
- number >>= GMP_NUMB_BITS;
-
- while (number > 0)
- {
- data->_mp_d[size++] = static_cast<mp_limb_t>(number & GMP_NUMB_MAX);
- number >>= GMP_NUMB_BITS;
- }
- }
-
- data->_mp_size = size;
- }
-
- template <typename Ch> void _assign_str(const Ch* str, int base)
- {
- assert(base >= 2 && base <= 36);
-
- // skip whitespace
- while (detail::bigint::isspace(*str)) ++str;
-
- int sign = 1;
-
- if (*str == Ch('-'))
- {
- sign = -1;
- ++str;
- }
- else if (*str == Ch('+'))
- {
- ++str;
- }
-
- static const unsigned char digit_value_tab[] =
- {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
- };
-
- // skip zeros
- while (*str == Ch('0')) ++str;
-
- // is there anything left?
- if (!*str)
- {
- assign(0);
- return;
- }
-
- size_t d_size = detail::bigint::length(str);
- scoped_array<unsigned char> d(new unsigned char[d_size]);
-
- for (size_t i = 0; i < d_size; ++i)
- {
- if (!detail::bigint::is_ascii(*str) || digit_value_tab[static_cast<unsigned int>(*str)] >= base
- )
- {
- d_size = i;
- break;
- }
-
- d[i] = digit_value_tab[static_cast<unsigned int>(*str++)];
- }
-
- if (d_size == 0)
- {
- assign(0);
- return;
- }
-
- size_t d_bits = detail::bigint::get_bit_count(d_size, base);
-
- mpz_init2(data, static_cast<unsigned long>(d_bits));
- data->_mp_size = sign * mpn_set_str(data->_mp_d, d.get(), d_size, base);
- }
-
- void assign(const char* str, int base)
- {
- _assign_str(str, base);
- }
-
- void assign(const wchar_t* str, int base)
- {
- _assign_str(str, base);
- }
-
- void add(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_add(data, lhs.data, rhs.data);
- }
-
- void sub(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_sub(data, lhs.data, rhs.data);
- }
-
- void mul(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_mul(data, lhs.data, rhs.data);
- }
-
- void div(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_tdiv_q(data, lhs.data, rhs.data);
- }
-
- void mod(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_tdiv_r(data, lhs.data, rhs.data);
- }
-
- void or_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_ior(data, lhs.data, rhs.data);
- }
-
- void and_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_and(data, lhs.data, rhs.data);
- }
-
- void xor_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
- {
- mpz_xor(data, lhs.data, rhs.data);
- }
-
- void not_(const bigint_gmp_implementation& lhs)
- {
- mpz_com(data, lhs.data);
- }
-
- void negate(const bigint_gmp_implementation& lhs)
- {
- mpz_neg(data, lhs.data);
- }
-
- void lshift(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
- {
- unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
-
- if (rhs <= max_arg)
- {
- mpz_mul_2exp(data, lhs.data, static_cast<unsigned long>(rhs));
- }
- else
- {
- mpz_clear(data);
- mpz_init_set(data, lhs.data);
-
- while (rhs > 0)
- {
- unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
- mpz_mul_2exp(data, data, value);
- rhs -= value;
- }
- }
- }
-
- void rshift(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
- {
- unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
-
- if (rhs <= max_arg)
- {
- mpz_div_2exp(data, lhs.data, static_cast<unsigned long>(rhs));
- }
- else
- {
- mpz_clear(data);
- mpz_init_set(data, lhs.data);
-
- while (rhs > 0)
- {
- unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
- mpz_div_2exp(data, data, value);
- rhs -= value;
- }
- }
- }
-
- void inc()
- {
- mpz_add_ui(data, data, 1);
- }
-
- void dec()
- {
- mpz_sub_ui(data, data, 1);
- }
-
- int compare(const bigint_gmp_implementation& rhs) const
- {
- return mpz_cmp(data, rhs.data);
- }
-
- std::string str(int base) const
- {
- assert(base >= 2 && base <= 36);
-
- size_t s_size = mpz_sizeinbase(data, base) + (mpz_sgn(data) < 0);
- scoped_array<char> s(new char[s_size + 1]);
- mpz_get_str(s.get(), base, data);
-
- std::string result(s.get()); // NRVO
- return result;
- }
-
- std::wstring wstr(int base) const
- {
- assert(base >= 2 && base <= 36);
-
- size_t s_size = mpz_sizeinbase(data, base) + (mpz_sgn(data) < 0);
- scoped_array<char> s(new char[s_size + 1]);
- mpz_get_str(s.get(), base, data);
-
- std::wstring result(s.get(), s.get() + strlen(s.get()));
- return result;
- }
-
- boost::uint64_t _to_uint64() const
- {
- boost::uint64_t value = 0;
- boost::uint64_t power = 1;
-
- int count = data->_mp_size >= 0 ? data->_mp_size : -data->_mp_size; // abs() does not work on MSVC8
-
- for (int i = 0; i < count; ++i)
- {
- value += data->_mp_d[i] * power;
- power <<= GMP_NUMB_BITS;
- }
-
- return value;
- }
-
- template <typename T> bool can_convert_to() const
- {
- // Only integer types supported
- if (!std::numeric_limits<T>::is_integer) return false;
-
- boost::uint64_t max_value;
- int count;
-
- if (mpz_sgn(data) < 0)
- {
- count = -data->_mp_size;
- max_value = static_cast<boost::uint64_t>(-static_cast<boost::int64_t>((std::numeric_limits<T>::min)()));
- }
- else
- {
- count = data->_mp_size;
- max_value = (std::numeric_limits<T>::max)();
- }
-
- if (static_cast<size_t>(count) * GMP_NUMB_BITS > sizeof(boost::uint64_t) * 8) // we can't fit in uint64 => we won't fit in anything else
- return false;
-
- return max_value >= _to_uint64();
- }
-
- template <typename T> T to_number() const
- {
- if (!std::numeric_limits<T>::is_integer) return T();
-
- boost::uint64_t value = _to_uint64();
-
- return data->_mp_size >= 0 ? static_cast<T>(value) : static_cast<T>(-static_cast<boost::int64_t>(value));
- }
-
- bool is_zero() const
- {
- return mpz_sgn(data) == 0;
- }
-
- void abs(const bigint_gmp_implementation& rhs)
- {
- mpz_abs(data, rhs.data);
- }
-
- void pow(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
- {
- unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
-
- if (rhs <= max_arg)
- {
- mpz_pow_ui(data, lhs.data, static_cast<unsigned long>(rhs));
- }
- else
- {
- mpz_clear(data);
- mpz_init_set_ui(data, 1);
-
- mpz_t temp;
-
- mpz_init(temp);
-
- while (rhs > 0)
- {
- unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
- mpz_pow_ui(temp, lhs.data, value);
- mpz_mul(data, data, temp);
- rhs -= value;
- }
-
- mpz_clear(temp);
- }
- }
-
- void div(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs, bigint_gmp_implementation& remainder)
- {
- mpz_tdiv_qr(data, remainder.data, lhs.data, rhs.data);
- }
-
- void sqrt(const bigint_gmp_implementation& lhs)
- {
- mpz_sqrt(data, lhs.data);
- }
- };
-} } // namespace boost::detail
-
-#endif // BOOST_BIGINT_BIGINT_GMP_HPP
+/* Boost bigint_gmp.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_GMP_HPP
+#define BOOST_BIGINT_BIGINT_GMP_HPP
+
+#include <limits>
+
+#include <boost/scoped_array.hpp>
+
+#include <boost/bigint/bigint_util.hpp>
+
+#include <gmp.h>
+
+namespace boost { namespace detail {
+ // GMP-based implementation
+ struct bigint_gmp_implementation
+ {
+ mpz_t data;
+
+ bigint_gmp_implementation()
+ {
+ mpz_init(data);
+ }
+
+ ~bigint_gmp_implementation()
+ {
+ mpz_clear(data);
+ }
+
+ bigint_gmp_implementation(const bigint_gmp_implementation& other)
+ {
+ mpz_init_set(data, other.data);
+ }
+
+ bigint_gmp_implementation& operator=(const bigint_gmp_implementation& other)
+ {
+ if (this != &other)
+ {
+ mpz_clear(data);
+ mpz_init_set(data, other.data);
+ }
+ return *this;
+ }
+
+ void assign(int number)
+ {
+ mpz_set_si(data, number);
+ }
+
+ void assign(unsigned int number)
+ {
+ mpz_set_ui(data, number);
+ }
+
+ void assign(int64_t number)
+ {
+ // number is [-2^32, 2^32-1]
+ // if number == -2^32, it's bit representation is 10...0, -number is 01...1+1 = 10...0 (the same)
+ // converting to uint64_t yields still 10...0, it's exactly 2^32. In other cases we're safe.
+ assign(static_cast<uint64_t>(number >= 0 ? number : -number));
+
+ if (number < 0) mpz_neg(data, data);
+ }
+
+ void assign(uint64_t number)
+ {
+ mp_size_t size;
+
+ data->_mp_d[0] = static_cast<mp_limb_t>(number & GMP_NUMB_MAX);
+ size = number != 0;
+
+ if (number > GMP_NUMB_MAX)
+ {
+ mpz_realloc(data, 64 / GMP_NUMB_BITS); // we know that GMP_NUMB_BITS is 2^n
+
+ number >>= GMP_NUMB_BITS;
+
+ while (number > 0)
+ {
+ data->_mp_d[size++] = static_cast<mp_limb_t>(number & GMP_NUMB_MAX);
+ number >>= GMP_NUMB_BITS;
+ }
+ }
+
+ data->_mp_size = size;
+ }
+
+ template <typename Ch> void _assign_str(const Ch* str, int base)
+ {
+ assert(base >= 2 && base <= 36);
+
+ // skip whitespace
+ while (detail::bigint::isspace(*str)) ++str;
+
+ int sign = 1;
+
+ if (*str == Ch('-'))
+ {
+ sign = -1;
+ ++str;
+ }
+ else if (*str == Ch('+'))
+ {
+ ++str;
+ }
+
+ static const unsigned char digit_value_tab[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+
+ // skip zeros
+ while (*str == Ch('0')) ++str;
+
+ // is there anything left?
+ if (!*str)
+ {
+ assign(0);
+ return;
+ }
+
+ size_t d_size = detail::bigint::length(str);
+ scoped_array<unsigned char> d(new unsigned char[d_size]);
+
+ for (size_t i = 0; i < d_size; ++i)
+ {
+ if (!detail::bigint::is_ascii(*str) || digit_value_tab[static_cast<unsigned int>(*str)] >= base
+ )
+ {
+ d_size = i;
+ break;
+ }
+
+ d[i] = digit_value_tab[static_cast<unsigned int>(*str++)];
+ }
+
+ if (d_size == 0)
+ {
+ assign(0);
+ return;
+ }
+
+ size_t d_bits = detail::bigint::get_bit_count(d_size, base);
+
+ mpz_init2(data, static_cast<unsigned long>(d_bits));
+ data->_mp_size = sign * mpn_set_str(data->_mp_d, d.get(), d_size, base);
+ }
+
+ void assign(const char* str, int base)
+ {
+ _assign_str(str, base);
+ }
+
+ void assign(const wchar_t* str, int base)
+ {
+ _assign_str(str, base);
+ }
+
+ void add(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_add(data, lhs.data, rhs.data);
+ }
+
+ void sub(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_sub(data, lhs.data, rhs.data);
+ }
+
+ void mul(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_mul(data, lhs.data, rhs.data);
+ }
+
+ void div(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_tdiv_q(data, lhs.data, rhs.data);
+ }
+
+ void mod(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_tdiv_r(data, lhs.data, rhs.data);
+ }
+
+ void or_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_ior(data, lhs.data, rhs.data);
+ }
+
+ void and_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_and(data, lhs.data, rhs.data);
+ }
+
+ void xor_(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs)
+ {
+ mpz_xor(data, lhs.data, rhs.data);
+ }
+
+ void not_(const bigint_gmp_implementation& lhs)
+ {
+ mpz_com(data, lhs.data);
+ }
+
+ void negate(const bigint_gmp_implementation& lhs)
+ {
+ mpz_neg(data, lhs.data);
+ }
+
+ void lshift(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
+ {
+ unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
+
+ if (rhs <= max_arg)
+ {
+ mpz_mul_2exp(data, lhs.data, static_cast<unsigned long>(rhs));
+ }
+ else
+ {
+ mpz_clear(data);
+ mpz_init_set(data, lhs.data);
+
+ while (rhs > 0)
+ {
+ unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
+ mpz_mul_2exp(data, data, value);
+ rhs -= value;
+ }
+ }
+ }
+
+ void rshift(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
+ {
+ unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
+
+ if (rhs <= max_arg)
+ {
+ mpz_div_2exp(data, lhs.data, static_cast<unsigned long>(rhs));
+ }
+ else
+ {
+ mpz_clear(data);
+ mpz_init_set(data, lhs.data);
+
+ while (rhs > 0)
+ {
+ unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
+ mpz_div_2exp(data, data, value);
+ rhs -= value;
+ }
+ }
+ }
+
+ void inc()
+ {
+ mpz_add_ui(data, data, 1);
+ }
+
+ void dec()
+ {
+ mpz_sub_ui(data, data, 1);
+ }
+
+ int compare(const bigint_gmp_implementation& rhs) const
+ {
+ return mpz_cmp(data, rhs.data);
+ }
+
+ std::string str(int base) const
+ {
+ assert(base >= 2 && base <= 36);
+
+ size_t s_size = mpz_sizeinbase(data, base) + (mpz_sgn(data) < 0);
+ scoped_array<char> s(new char[s_size + 1]);
+ mpz_get_str(s.get(), base, data);
+
+ std::string result(s.get()); // NRVO
+ return result;
+ }
+
+ std::wstring wstr(int base) const
+ {
+ assert(base >= 2 && base <= 36);
+
+ size_t s_size = mpz_sizeinbase(data, base) + (mpz_sgn(data) < 0);
+ scoped_array<char> s(new char[s_size + 1]);
+ mpz_get_str(s.get(), base, data);
+
+ std::wstring result(s.get(), s.get() + strlen(s.get()));
+ return result;
+ }
+
+ boost::uint64_t _to_uint64() const
+ {
+ boost::uint64_t value = 0;
+ boost::uint64_t power = 1;
+
+ int count = data->_mp_size >= 0 ? data->_mp_size : -data->_mp_size; // abs() does not work on MSVC8
+
+ for (int i = 0; i < count; ++i)
+ {
+ value += data->_mp_d[i] * power;
+ power <<= GMP_NUMB_BITS;
+ }
+
+ return value;
+ }
+
+ template <typename T> bool can_convert_to() const
+ {
+ // Only integer types supported
+ if (!std::numeric_limits<T>::is_integer) return false;
+
+ boost::uint64_t max_value;
+ int count;
+
+ if (mpz_sgn(data) < 0)
+ {
+ count = -data->_mp_size;
+ max_value = static_cast<boost::uint64_t>(-static_cast<boost::int64_t>((std::numeric_limits<T>::min)()));
+ }
+ else
+ {
+ count = data->_mp_size;
+ max_value = (std::numeric_limits<T>::max)();
+ }
+
+ if (static_cast<size_t>(count) * GMP_NUMB_BITS > sizeof(boost::uint64_t) * 8) // we can't fit in uint64 => we won't fit in anything else
+ return false;
+
+ return max_value >= _to_uint64();
+ }
+
+ template <typename T> T to_number() const
+ {
+ if (!std::numeric_limits<T>::is_integer) return T();
+
+ boost::uint64_t value = _to_uint64();
+
+ return data->_mp_size >= 0 ? static_cast<T>(value) : static_cast<T>(-static_cast<boost::int64_t>(value));
+ }
+
+ bool is_zero() const
+ {
+ return mpz_sgn(data) == 0;
+ }
+
+ void abs(const bigint_gmp_implementation& rhs)
+ {
+ mpz_abs(data, rhs.data);
+ }
+
+ void pow(const bigint_gmp_implementation& lhs, boost::uint64_t rhs)
+ {
+ unsigned long max_arg = (std::numeric_limits<unsigned long>::max)();
+
+ if (rhs <= max_arg)
+ {
+ mpz_pow_ui(data, lhs.data, static_cast<unsigned long>(rhs));
+ }
+ else
+ {
+ mpz_clear(data);
+ mpz_init_set_ui(data, 1);
+
+ mpz_t temp;
+
+ mpz_init(temp);
+
+ while (rhs > 0)
+ {
+ unsigned long value = (rhs > max_arg) ? max_arg : static_cast<unsigned long>(rhs);
+ mpz_pow_ui(temp, lhs.data, value);
+ mpz_mul(data, data, temp);
+ rhs -= value;
+ }
+
+ mpz_clear(temp);
+ }
+ }
+
+ void div(const bigint_gmp_implementation& lhs, const bigint_gmp_implementation& rhs, bigint_gmp_implementation& remainder)
+ {
+ mpz_tdiv_qr(data, remainder.data, lhs.data, rhs.data);
+ }
+
+ void sqrt(const bigint_gmp_implementation& lhs)
+ {
+ mpz_sqrt(data, lhs.data);
+ }
+ };
+} } // namespace boost::detail
+
+#endif // BOOST_BIGINT_BIGINT_GMP_HPP

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_serialize.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_serialize.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_serialize.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,45 +1,45 @@
-/* Boost bigint.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_SERIALIZE_HPP
-#define BOOST_BIGINT_BIGINT_SERIALIZE_HPP
-
-#include <boost/bigint/bigint.hpp>
-
-#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
-#include <boost/serialization/extended_type_info_typeid.hpp>
-#endif
-
-#include <boost/serialization/string.hpp>
-#include <boost/serialization/split_free.hpp>
-
-namespace boost { namespace serialization {
-
-template <class Archive, typename I> void save(Archive & ar, const bigint_base<I> & t, const unsigned int)
-{
- std::string data = t.str();
- ar & BOOST_SERIALIZATION_NVP(data);
-}
-
-template <class Archive, typename I> void load(Archive & ar, bigint_base<I> & t, const unsigned int)
-{
- std::string data;
- ar & BOOST_SERIALIZATION_NVP(data);
-
- t = bigint_base<I>(data); // load_construct_data ?
-}
-
-template <class Archive, typename I> inline void serialize(Archive & ar, bigint_base<I> & t, const unsigned int file_version)
-{
- split_free(ar, t, file_version);
-}
-
-} } // namespace boost::serialization
-
-#endif // BOOST_BIGINT_BIGINT_SERIALIZE_HPP
+/* Boost bigint.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_SERIALIZE_HPP
+#define BOOST_BIGINT_BIGINT_SERIALIZE_HPP
+
+#include <boost/bigint/bigint.hpp>
+
+#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
+#include <boost/serialization/extended_type_info_typeid.hpp>
+#endif
+
+#include <boost/serialization/string.hpp>
+#include <boost/serialization/split_free.hpp>
+
+namespace boost { namespace serialization {
+
+template <class Archive, typename I> void save(Archive & ar, const bigint_base<I> & t, const unsigned int)
+{
+ std::string data = t.str();
+ ar & BOOST_SERIALIZATION_NVP(data);
+}
+
+template <class Archive, typename I> void load(Archive & ar, bigint_base<I> & t, const unsigned int)
+{
+ std::string data;
+ ar & BOOST_SERIALIZATION_NVP(data);
+
+ t = bigint_base<I>(data); // load_construct_data ?
+}
+
+template <class Archive, typename I> inline void serialize(Archive & ar, bigint_base<I> & t, const unsigned int file_version)
+{
+ split_free(ar, t, file_version);
+}
+
+} } // namespace boost::serialization
+
+#endif // BOOST_BIGINT_BIGINT_SERIALIZE_HPP

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_fixed.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_fixed.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_fixed.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,83 +1,83 @@
-/* Boost bigint_storage_fixed.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP
-#define BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP
-
-#include <vector>
-
-namespace boost { namespace detail {
-template <size_t N> struct bigint_storage_fixed
-{
- template <typename T> class type
- {
- T data[N / sizeof(T)];
- size_t count;
-
- public:
- type(): count(0)
- {
- }
-
- size_t _max_size()
- {
- return (N / sizeof(T));
- }
-
- void resize(size_t size)
- {
- if (size > _max_size()) throw std::bad_alloc();
-
- count = size;
- }
-
- size_t size() const
- {
- return count;
- }
-
- bool empty() const
- {
- return count == 0;
- }
-
- const T* begin() const
- {
- return data;
- }
-
- T* begin()
- {
- return data;
- }
-
- const T* end() const
- {
- return data + count;
- }
-
- T* end()
- {
- return data + count;
- }
-
- const T& operator[](size_t index) const
- {
- return begin()[index];
- }
-
- T& operator[](size_t index)
- {
- return begin()[index];
- }
- };
-};
-} } // namespace boost::detail
-
-#endif // BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP
+/* Boost bigint_storage_fixed.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP
+#define BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP
+
+#include <vector>
+
+namespace boost { namespace detail {
+template <size_t N> struct bigint_storage_fixed
+{
+ template <typename T> class type
+ {
+ T data[N / sizeof(T)];
+ size_t count;
+
+ public:
+ type(): count(0)
+ {
+ }
+
+ size_t _max_size()
+ {
+ return (N / sizeof(T));
+ }
+
+ void resize(size_t size)
+ {
+ if (size > _max_size()) throw std::bad_alloc();
+
+ count = size;
+ }
+
+ size_t size() const
+ {
+ return count;
+ }
+
+ bool empty() const
+ {
+ return count == 0;
+ }
+
+ const T* begin() const
+ {
+ return data;
+ }
+
+ T* begin()
+ {
+ return data;
+ }
+
+ const T* end() const
+ {
+ return data + count;
+ }
+
+ T* end()
+ {
+ return data + count;
+ }
+
+ const T& operator[](size_t index) const
+ {
+ return begin()[index];
+ }
+
+ T& operator[](size_t index)
+ {
+ return begin()[index];
+ }
+ };
+};
+} } // namespace boost::detail
+
+#endif // BOOST_BIGINT_BIGINT_STORAGE_FIXED_HPP

Modified: sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_vector.hpp
==============================================================================
--- sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_vector.hpp (original)
+++ sandbox/SOC/2007/bigint/boost/bigint/bigint_storage_vector.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,68 +1,68 @@
-/* Boost bigint_storage_vector.hpp header file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#ifndef BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP
-#define BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP
-
-#include <vector>
-
-namespace boost { namespace detail {
-template <typename T> class bigint_storage_vector
-{
- std::vector<T> data;
-
-public:
- void resize(size_t size)
- {
- data.resize(size);
- }
-
- size_t size() const
- {
- return data.size();
- }
-
- bool empty() const
- {
- return data.empty();
- }
-
- const T* begin() const
- {
- return data.empty() ? 0 : &*data.begin();
- }
-
- T* begin()
- {
- return data.empty() ? 0 : &*data.begin();
- }
-
- const T* end() const
- {
- return data.empty() ? 0 : &*(data.end()-1)+1;
- }
-
- T* end()
- {
- return data.empty() ? 0 : &*(data.end()-1)+1;
- }
-
- const T& operator[](size_t index) const
- {
- return begin()[index];
- }
-
- T& operator[](size_t index)
- {
- return begin()[index];
- }
-};
-} } // namespace boost::detail
-
-#endif // BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP
+/* Boost bigint_storage_vector.hpp header file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP
+#define BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP
+
+#include <vector>
+
+namespace boost { namespace detail {
+template <typename T> class bigint_storage_vector
+{
+ std::vector<T> data;
+
+public:
+ void resize(size_t size)
+ {
+ data.resize(size);
+ }
+
+ size_t size() const
+ {
+ return data.size();
+ }
+
+ bool empty() const
+ {
+ return data.empty();
+ }
+
+ const T* begin() const
+ {
+ return data.empty() ? 0 : &*data.begin();
+ }
+
+ T* begin()
+ {
+ return data.empty() ? 0 : &*data.begin();
+ }
+
+ const T* end() const
+ {
+ return data.empty() ? 0 : &*(data.end()-1)+1;
+ }
+
+ T* end()
+ {
+ return data.empty() ? 0 : &*(data.end()-1)+1;
+ }
+
+ const T& operator[](size_t index) const
+ {
+ return begin()[index];
+ }
+
+ T& operator[](size_t index)
+ {
+ return begin()[index];
+ }
+};
+} } // namespace boost::detail
+
+#endif // BOOST_BIGINT_BIGINT_STORAGE_VECTOR_HPP

Modified: sandbox/SOC/2007/bigint/libs/bigint/example.cpp
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/example.cpp (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/example.cpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,111 +1,111 @@
-/* Boost bigint example.cpp test file
- *
- * Copyright 2007 Arseny Kapoulkine
- *
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or
- * copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-
-#include <boost/bigint/bigint.hpp>
-
-#include <iostream>
-
-using boost::bigint;
-
-// Raise a to the power n for log(n)
-template <typename T> inline const T power_logN(const T& a, unsigned int n)
-{
- if (n <= 0) return 1;
-
- T result(1);
-
- unsigned int power_of_two = 1;
-
- // Find largest power of two that is > n
- while (power_of_two < n && (power_of_two << 1) != 0)
- power_of_two <<= 1;
-
- if (power_of_two > n)
- power_of_two >>= 1;
- else if (power_of_two == n) // handle large n
- {
- power_of_two >>= 1;
- result = a;
- }
-
- while (power_of_two > 0)
- {
- if ((n & power_of_two) != 0)
- {
- result *= result;
- result *= a;
- }
- else
- result *= result;
-
- power_of_two >>= 1;
- }
-
- return result;
-}
-
-struct mat22
-{
- bigint m00, m01;
- bigint m10, m11;
-
- mat22()
- {
- }
-
- mat22(int): m00(1), m01(0),
- m10(0), m11(1)
- {
- }
-
- const mat22& operator*=(const mat22& m)
- {
- mat22 result;
-
- result.m00 = m00 * m.m00 + m01 * m.m10;
- result.m01 = m00 * m.m01 + m01 * m.m11;
-
- result.m10 = m10 * m.m00 + m11 * m.m10;
- result.m11 = m10 * m.m01 + m11 * m.m11;
-
- *this = result;
-
- return *this;
- }
-};
-
-const bigint fibonacci(unsigned int n)
-{
- if (n == 0) return 0;
- else if (n < 3) return 1;
-
- mat22 base;
- base.m00 = 0; base.m01 = 1;
- base.m10 = 1; base.m11 = 1;
-
- // (base^n).m11 == (N+1)-th fibonacci number
- return power_logN(base, n - 1).m11;
-}
-
-int main()
-{
- while (true)
- {
- std::cout << "Enter number (negative number to exit): ";
-
- int n;
- std::cin >> n;
-
- if (n < 0) break;
-
- std::cout << n << "-th fibonacci number: " << fibonacci(static_cast<unsigned int>(n)) << std::endl;
- }
-
- return 0;
-}
+/* Boost bigint example.cpp test file
+ *
+ * Copyright 2007 Arseny Kapoulkine
+ *
+ * Distributed under the Boost Software License, Version 1.0.
+ * (See accompanying file LICENSE_1_0.txt or
+ * copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <boost/bigint/bigint.hpp>
+
+#include <iostream>
+
+using boost::bigint;
+
+// Raise a to the power n for log(n)
+template <typename T> inline const T power_logN(const T& a, unsigned int n)
+{
+ if (n <= 0) return 1;
+
+ T result(1);
+
+ unsigned int power_of_two = 1;
+
+ // Find largest power of two that is > n
+ while (power_of_two < n && (power_of_two << 1) != 0)
+ power_of_two <<= 1;
+
+ if (power_of_two > n)
+ power_of_two >>= 1;
+ else if (power_of_two == n) // handle large n
+ {
+ power_of_two >>= 1;
+ result = a;
+ }
+
+ while (power_of_two > 0)
+ {
+ if ((n & power_of_two) != 0)
+ {
+ result *= result;
+ result *= a;
+ }
+ else
+ result *= result;
+
+ power_of_two >>= 1;
+ }
+
+ return result;
+}
+
+struct mat22
+{
+ bigint m00, m01;
+ bigint m10, m11;
+
+ mat22()
+ {
+ }
+
+ mat22(int): m00(1), m01(0),
+ m10(0), m11(1)
+ {
+ }
+
+ const mat22& operator*=(const mat22& m)
+ {
+ mat22 result;
+
+ result.m00 = m00 * m.m00 + m01 * m.m10;
+ result.m01 = m00 * m.m01 + m01 * m.m11;
+
+ result.m10 = m10 * m.m00 + m11 * m.m10;
+ result.m11 = m10 * m.m01 + m11 * m.m11;
+
+ *this = result;
+
+ return *this;
+ }
+};
+
+const bigint fibonacci(unsigned int n)
+{
+ if (n == 0) return 0;
+ else if (n < 3) return 1;
+
+ mat22 base;
+ base.m00 = 0; base.m01 = 1;
+ base.m10 = 1; base.m11 = 1;
+
+ // (base^n).m11 == (N+1)-th fibonacci number
+ return power_logN(base, n - 1).m11;
+}
+
+int main()
+{
+ while (true)
+ {
+ std::cout << "Enter number (negative number to exit): ";
+
+ int n;
+ std::cin >> n;
+
+ if (n < 0) break;
+
+ std::cout << n << "-th fibonacci number: " << fibonacci(static_cast<unsigned int>(n)) << std::endl;
+ }
+
+ return 0;
+}

Modified: sandbox/SOC/2007/bigint/libs/bigint/index.html
==============================================================================
--- sandbox/SOC/2007/bigint/libs/bigint/index.html (original)
+++ sandbox/SOC/2007/bigint/libs/bigint/index.html 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,518 +1,518 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>Big Integer Library</title>
-</head>
-<body>
-<h1><img src="../../boost.png" alt="boost.png (6897 bytes)"
- align="middle" width="277" height="86">
-Big Integers</h1>
-
-<h2><a name="Contents">Contents</a></h2>
-
-<ol>
- <li>Class bigint synopsis</li>
- <li>Rationale</li>
- <li>Background</li>
- <li>Interface
- <ul>
- <li>Choosing the implementation</li>
- <li>Constructors</li>
- <li>Arithmetic operations</li>
- <li>Bitwise operations</li>
- <li>Input and Output</li>
- <li>Conversions</li>
- <li>Other functions</li>
- <li>Serialization</li>
- </ul></li>
- <li>Performance</li>
- <li>Exceptions</li>
- <li>References</li>
- <li>History and Acknowledgements</li>
-</ol>
-
-<h2><a name="Class_bigint_synopsis">Class bigint synopsis</a></h2>
-<pre>
-#include &lt;boost/bigint/bigint.hpp&gt;
-
-namespace boost {
-template &lt;typename I&gt; class bigint_base
-{
- typedef <em>implementation-defined</em> bool_type;
-
-public:
- // Constructors
- bigint_base(); // Zero
- bigint_base(int number);
- bigint_base(unsigned int number);
- bigint_base(int64_t number);
- bigint_base(uint64_t number);
-
- // String constructors for variable digit base; default is decimal
- explicit bigint_base(const char* str, int base = 10);
- explicit bigint_base(const wchar_t* str, int base = 10);
- explicit bigint_base(const std::string&amp; str, int base = 10);
- explicit bigint_base(const std::wstring&amp; str, int base = 10);
-
- // Arithmetic operators
- const bigint_base&amp; operator+=(const bigint_base&amp; other);
- const bigint_base&amp; operator-=(const bigint_base&amp; other);
- const bigint_base&amp; operator*=(const bigint_base&amp; other);
- const bigint_base&amp; operator/=(const bigint_base&amp; other);
- const bigint_base&amp; operator%=(const bigint_base&amp; other);
-
- // Arithmetic operators
- friend bigint_base operator+(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator-(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator*(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator/(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator%(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
-
- // Bitwise logical operators
- const bigint_base&amp; operator|=(const bigint_base&amp; other);
- const bigint_base&amp; operator&amp;=(const bigint_base&amp; other);
- const bigint_base&amp; operator^=(const bigint_base&amp; other);
-
- // Bitwise logical operators
- friend bigint_base operator|(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator&amp;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bigint_base operator^(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
-
- // Shift operators
- const bigint_base&amp; operator&lt;&lt;=(uint64_t other);
- const bigint_base&amp; operator&gt;&gt;=(uint64_t other);
-
- // Shift operators
- friend bigint_base operator&lt;&lt;(const bigint_base&amp; lhs, boost::uint64_t rhs);
- friend bigint_base operator&gt;&gt;(const bigint_base&amp; lhs, boost::uint64_t rhs);
-
- // Increment and decrement; both prefix and postfix forms are supported
- const bigint_base&amp; operator++();
- bigint_base operator++(int);
- const bigint_base&amp; operator--();
- bigint_base operator--(int);
-
- // Unary operators
- bigint_base operator+() const;
- bigint_base operator-() const;
- bigint_base operator~() const;
-
- // Bool conversions
- operator bool_type() const;
- bool operator!() const;
-
- // String conversion for variable digit base; default is decimal
- std::string str(int base = 10) const;
- std::wstring wstr(int base = 10) const;
-
- // Converting from bigint to any primitive integer type, including 64-bit ones
- template &lt;typename T&gt; bool can_convert_to() const;
- template &lt;typename T&gt; T to_number() const;
-
- // Comparison operators
- friend bool operator&lt;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bool operator&lt;=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bool operator&gt;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bool operator&gt;=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bool operator==(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
- friend bool operator!=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
-
- // Free functions
- friend bigint_base abs(const bigint_base&amp; value);
- friend bigint_base pow(const bigint_base&lt;I&gt;&amp; lhs, boost::uint64_t rhs);
- friend bigint_base div(const bigint_base&amp; lhs, const bigint_base&amp; rhs, bigint_base&amp; remainder);
- friend bigint_base sqrt(const bigint_base&amp; lhs);
-
- // Stream input/output
- template &lt;typename T, typename Tr&gt; friend std::basic_ostream&lt;T, Tr&gt;&amp; operator&lt;&lt;(std::basic_ostream&lt;T, Tr&gt;&amp; lhs, const bigint_base&amp; rhs);
- template &lt;typename T, typename Tr&gt; friend std::basic_istream&lt;T, Tr&gt;&amp; operator&gt;&gt;(std::basic_istream&lt;T, Tr&gt;&amp; lhs, bigint_base&amp; rhs);
-};
-
-} // namespace boost
-
-typedef bigint_base&lt;<em>implementation-defined</em>&gt; bigint;
-</pre>
-
-<h2><a name="Rationale">Rationale</a></h2>
-
-<p>Standard C++ without third-party libraries offers support for several integer
-types, though all of them have limited range of values. This range is enough
-for majority of applications, but in some cases, which include scientific and
-cryptography-related applications, there is a need for so called "arbitrary
-precision numbers" - those are the numbers which have precision limited only by
-amount of available memory.</p>
-
-<p>Note that due to the lack of hardware support for arbitrary precision integers,
-any operations that can be performed with them are slower than the corresponding
-operations for native (C++ built-in) types; therefore they should not be treated
-as a complete replacement for existing types, but rather as a possibility to trade
-performance for precision.</p>
-
-<p>There are several different third-party libraries available, they have different
-performance/portability characteristics; this library provides a numeric type
-<b>bigint</b>, strictly defines the set of operations that can be performed and their
-behavior, provides a portable (albeit slow) implementation of said operations; and
-also provides a implementation which uses the fastest available arbitrary precision
-library, GNU MP.</p>
-
-<p>The library is intended to be highly extensible and encourages developers to create
-their own implementation that would close the gap between 'portable' and 'gmp' implementations
-in terms of performance; a set of correctness and performance tests is provided to
-ease the development of such implementations.</p>
-
-<h2><a name="Background">Background</a></h2>
-
-<p>The <b>bigint</b> number class provides an implementation of integer concept. The representation
-is always exact, and there are no overflows/underflows; all operations except division by zero,
-evaluating remainder from the division by zero or evaluating square root of negative number are
-perfectly defined, and give the value that does not depend on implementation. Everything except
-the visible behavior - including in-memory representation, operations performance/memory complexity -
-depends on the implementations. Implementation authors are encouraged to provide information about
-memory requirements and performance complexities (the table for two existing implementations is
-present in this documentation) to help the user of the library choose the implementation that will
-suite his or her needs best of all.</p>
-
-<p><b>bigint</b> class is designed so that it is compatible with the built-in integer types in the
-largest extent possible; this means that all arithmetical and logical types available are available
-for <b>bigint</b> class; <b>bigint</b> is implicitly constructible from integer types so that integer
-types can be used where compiler is expecting <b>bigint</b> - both in operators and functions; some
-of integer functions present in C++ standard are also redefined for <b>bigint</b>.</p>
-
-<h2><a name="Interface">Interface</a></h2>
-
-<h3><a name="Choosing_implementation">Choosing the implementation</a></h3>
-
-<p>The bigint library consists of two distinct parts - the interface class <b>bigint_base</b>, and a set
-of implementation classes. <b>bigint_base</b> is a templated class with a single template parameter - the
-actual implementation. There is a convenience typedef, <b>bigint</b>, which equals to <b>bigint_base</b>,
-parametrized by the most advanced implementation available. As library provides only two implementations
-by default, <b>bigint</b> is equal to GMP-based implementation if the define BOOST_BIGINT_HAS_GMP_SUPPORT
-is set in <i>boost_config.hpp</i> file; otherwise <b>bigint</b> uses the portable implementation.</p>
-
-<p>In most cases users should just use <b>bigint</b>, but if they have a need to use the specific implementation,
-they can use it like this:
-
-<pre>
- #include "header_with_specific_implementation_class.hpp"
-
- typedef boost::bigint_base&lt;specific_implementation_class&gt; bigint_special;
-
- bigint_special a = 1, b = a * (a - 4);
-</pre>
-
-<font color="#ff0000">As this can change and bigint_base can be parametrized by both implementation and storage class
-in future, this section has to be revised before the project ends</font>
-</p>
-
-<h3><a name="Constructors">Constructors</a></h3>
-
-<p><b>bigint</b> class has three types of constructors: default constructor, constructors from built-in integer types, and
-constructors from strings.</p>
-
-<p>Default constructor initializes <b>bigint</b> class instance to zero; note that as <b>bigint</b> class is an implementation
-of integer concept, there is no such distinction between positive and negative zero.</p>
-
-<p>Integer constructors initialize <b>bigint</b> from build-in integer types; the result of constructor is that <b>bigint</b>
-instance contains the exact representation of the passed value. Note that these constructors are <em>not</em> declared as explicit;
-this means that you can freely use values of build-in integer types where you have to use <b>bigint</b>; for example, this is
-correct:
-
-<pre>
- int a = 10;
- boost::bigint b = 3;
- boost::bigint c = b + a;
- boost::bigint d = c / 49;
-</pre>
-
-<font color="#ff0000"><b>bigint</b> relies on the presence of 64-bit integer support, but this may change in the future</font>
-</p>
-
-<p>String constructors initialize <b>bigint</b> from string in the certain format. Strings can be wide, and you can pass either
-a <b>std::string</b>/<b>std::wstring</b> or the pointer to the null-terminated character sequence. The accepted number format
-is as follows:</p>
-
-<pre>
-[spaces][sign][digits]
-</pre>
-
-<p>'spaces' is a group of whitespace symbols (as detected by ::isspace/::iswspace CRT functions), there can be zero or more symbols
-in it.</p>
-
-<p>'sign' is either an empty string, '+' or '-' symbol. '+' sign is ignored, '-' sets the number to the negative one (string "-3" will
-initialize <b>bigint</b> instance to -3, string "+3" will initialize it to 3).</p>
-
-<p>'digits' is a group of digits belonging to the character set of the base that is passed to the constructor; base is a number
-that is greater or equal to 2 and less or equal to 36; bases outside of allowed range lead to undefined results <font color="#ff0000">
-perhaps we should change that and initialize number to 0 if base is &lt; 2 or &gt; 36?</font>. For bases less or equal than 10,
-the character set of digits from 0 to (base-1) is used. For bases greater than 10, the character set consists of digits from 0
-to 9, and then the letters from 'A' (ASCII character 'A') to the last needed letter for the set to reach the needed size. Letters are not case sensitive.
-Letter 'A' corresponds to digit 10, letter 'B' corresponds to digit 11 and so on. Letter 'Z' (if applicable - this is an allowed
-letter only for base = 36) corresponds to digit 35.</p>
-
-<p>The group of digits is interpreted as a number that is written from the most significant digit to the least significant one;
-there can be an arbitrary number of zero digits ('0') preceding the group.
-
-<p>Examples:
-<ul>
-<li>For base 2, only characters '0' and '1' can be used. String "1100" in base 2 corresponds to the number 12 (decimal).</li>
-<li>For base 10, any digit characters can be used. String "1234" in base 10 corresponds to the number 1234 (decimal).</li>
-<li>For base 16, any digit characters can be used. Additionally characters 'A'-'F' and 'a'-'f' can be used. String "Ff4a" in base 16 corresponds to the number 65354 (decimal). Note that letter case is irrelevant.</li>
-<li>For base 36, any digit characters can be used. Additionally characters 'A'-'Z' and 'a'-'z' can be used. String "ZZ" in base 36 corresponds to the number 1295 (decimal).</li>
-</ul>
-</p>
-
-<p>If the input string has characters that are not allowed in the input string, the first such character
-and <em>all</em> consecutive characters (including allowed ones) are ignored.
-If there are no digit characters before the first discarded characters, the number is initialized to 0 (for example,
-passing "-A23" as an input string and 10 as base will initialize the number to 0, as it will ignore all characters
-from 'A' onward, including 'A').</p>
-
-<h3><a name="Arithmetic_operations">Arithmetic operations</a></h3>
-
-<p>All of the standard numeric operators are defined for the <b>bigint</b> class. These include:</p>
-
-<pre>
- + +=
- - -=
- * *=
- / /=
- % %=
- ++ -- (both prefix and postfix)
- == !=
- &lt; &gt;
- &lt;= &gt;=
- + (unary)
- - (unary)
-</pre>
-
-<p>They have the same semantics as the standard ones.</p>
-
-<p>Some things that have to be noted:</p>
-
-<ul>
-<li>Division by zero (and taking remainder from the division by zero, i.e. i % 0) generates division by zero for the built-in
-<b>int</b> type; therefore, division by zero results in undefined behavior.</li>
-<li>Operations never produce an overflow/underflow and the result is perfectly accurate.</li>
-<li>The result of +, +=, -, -=, *, *=, ++, --, &lt;, &lt;=, &gt;, &gt;=, ==, !=, unary + and unary - operators is exactly the
-same as the result of corresponding operations for the mathematical integer concept.</li>
-<li>Division operation (/ and /=) results in so called truncated division; this means that if the dividend is not exactly
-divisible by the divisor, the result is equal to the result of real number division which is later truncated to the integer
-number which has the absolute value which is less than that of the real number quotient. Such truncation is also called rounding
-towards zero. Here are some examples to clarify the concept:
- <ul>
- <li>60 / 15 == 4. 60 is exactly divisible by 15, no truncation takes place.</li>
- <li>-60 / 15 == -4. -60 is exactly divisible by 15, no truncation takes place.</li>
- <li>60 / -15 == -4. 60 is exactly divisible by -15, no truncation takes place.</li>
- <li>3 / 2 == 1. 3 is not exactly divisible by 2; the quotient of real number division is 1.5, it is truncated to 1.</li>
- <li>-3 / 2 == -1. -3 is not exactly divisible by 2; the quotient of real number division is -1.5, it is truncated to -1.</li>
- <li>3 / -2 == -1. 3 is not exactly divisible by -2; the quotient of real number division is -1.5, it is truncated to -1.</li>
- <li>-3 / -2 == 1. -3 is not exactly divisible by -2; the quotient of real number division is 1.5, it is truncated to 1.</li>
- </ul>
-</li>
-<li>Modulo operation (% and %=) is implemented in terms of truncated division; this means, that if a / b == c, then a % b == a - b * c. This means that:
- <ul>
- <li>Modulo by zero results in undefined behavior</li>
- <li>If a is exactly divisible by b, a % b == 0</li>
- <li>Otherwise, the sign of a % b is always equal to the sign of a.
- </ul>
-Here are some examples to clarify the concept:
- <ul>
- <li>34 % 5 == 4. 34 / 5 == 6 (see above for the description of truncating division), 34 % 5 == 34 - (6 * 5) == 4.</li>
- <li>34 % -5 == 4. 34 / -5 == -6, 34 % -5 == 34 - (-6 * -5) == 4.</li>
- <li>-34 % 5 == -4. -34 / 5 == -6, -34 % 5 == -34 - (-6 * 5) == -4.</li>
- <li>-34 % -5 == -4. -34 / -5 == 6, -34 % -5 == -34 - (6 * -5) == -4.</li>
- </ul>
-</li>
-</ul>
-
-<h3><a name="Bitwise_operations">Bitwise operations</a></h3>
-
-<p>All of the standard bitwise operators are defined for the <b>bigint</b> class. These include:</p>
-
-<pre>
- &amp; &amp;=
- | |=
- ^ ^=
- ~ (unary)
- &lt;&lt; &lt;&lt;=
- &gt;&gt; &gt;&gt;=
-</pre>
-
-<p>These functions operate with a bit representation of numbers. Note that though there are no strict requirements for
-storage of <b>bigint</b> implementations, bitwise operators are guaranteed to operate with the following representation:
-positive numbers are represented as a sequence of bits, most significant bit is first, least significant bit is last, the
-sequence of bits is equal to the representation of the number in binary number system; zero is represented as a single bit 0;
-negative numbers are represented as 2-complement of their absolute value (note that this means that negative number have an
-infinite number of 1s at the beginning; for the purpose of bitwise operations we assume that positive numbers have an infinite
-number of 0s at the beginning).</p>
-
-<p>Given such representation, the result of each bit operation is defined as the number representation of a bit sequence, which
-is constructed from two bit sequences of operands (to be precise, of two bit sequences, which are bit representation of the operands),
-or of a bit sequence of a single operand in case of unary operator, by applying the bitwise operator to those sequences.</p>
-
-<p>Examples to clarify the concept:
-<ul>
-<li>3 & 6 == 11b & 110b == 10b == 2</li>
-<li>3 | 6 == 11b | 110b == 111b == 7</li>
-<li>3 ^ 6 == 11b ^ 110b == 101b == 5</li>
-<li>-3 & 6 == -(11b) & 110b == 1....1101b & 0....0110b == 0....0100b == 100b == 4</li>
-<li>-3 | 6 == -(11b) & 110b == 1....1101b | 0....0110b == 1....1111b == -(1b) == -1</li>
-<li>-3 ^ 6 == -(11b) & 110b == 1....1101b ^ 0....0110b == 1....1011b == -(101b) == -5</li>
-<li>~(-3) == ~(-(11b)) == ~1....1101b == 0....0010b == 2</li>
-<li>-3 << 2 == -(11b) << 2 == 1....1101b << 2 == 1....110100b == -(1100b) == -12</li>
-<li>-3 >> 2 == -(11b) >> 2 == 1....1101b >> 2 == 1....11b == -(1b) == -1</li>
-</ul>
-</p>
-
-<p>Note that shift operators can't shift more than for 2^64 digits; this is beyond the limit of memory anyway (2^64 bits means
-2^61 bytes for storage, which is equal to 2^31 Gb of data) and is not going to change.</p>
-
-<h3><a name="Input_and_Output">Input and Output</a></h3>
-
-<p>Input and output operators <tt>&lt;&lt;</tt> and <tt>&gt;&gt;</tt>
-are provided. They meet all flags and locale requirements (that is, you
-can use <code>showpos, oct, hex</code> and other flags, decimal separators
-are also supported. Input operator stops at the first unrecognized character.
-In short, input and output operators behave exactly as you would expect them to
-behave for build-in integer types.</p>
-
-<h3><a name="Conversions">Conversions</a></h3>
-
-<p>There is a conversion operator to an unspecified Boolean type (most likely a
-member pointer). This operator converts a <b>bigint</b> to <code>false</code> if it
-represents zero, and <code>true</code> otherwise. This conversion allows a
-bigint for use as the first argument of operator <code>?:</code>; as either
-argument of operators <code>&amp;&amp;</code> or <code>||</code> without
-forfeiting short-circuit evaluation; as a condition for a <code>do</code>,
-<code>if</code>, <code>while</code>, or <code>for</code> statement; and as a
-conditional declaration for <code>if</code>, <code>while</code>, or
-<code>for</code> statements. The nature of the type used, and that any names
-for that nature are kept private, should prevent any inappropriate non-boolean
-use like numeric or pointer operations or as a <code>switch</code> condition.</p>
-
-<p>Note: the provided <code>operator!</code> is not strictly necessary from the point of C++ standard,
-and is a workaround for some compilers.</p>
-
-<p><b>bigint</b> values can be converted to strings of arbitrary base (provided it
-meets the conditions 2 &lt;= base &lt;= 36). The output string consists of sign
-(a symbol '-' present only if the value is negative) and of a sequence of characters
-that represent digits. This sequence consists of the same characters that can
-occur in the string passed to the string constructors of bigint; the description
-of the values and their meaning can be seen in the Constructors
-section. No unnecessary zeroes or whitespace characters are added to the output string
-(if the value is equal to 0, the string "0" is returned); all letter symbols are
-lowercase. Generally, the following always holds true:
-
-<pre>
- bigint(value.str()) == value
-</pre>
-</p>
-
-<p>While <b>bigint</b> provides storage and operations for numbers of arbitrary precision,
-sometimes the stored values fit into C++ built-in integer types, and sometimes there's a need
-to convert from <b>bigint</b> to one of those types. You can check whether such conversion is
-possible via <code>can_convert_to</code> function, and convert <b>bigint</b> to a value of built-in
-integer type via <code>to_number</code> function. Note that if <code>value.can_convert_to<T>()</code>
-is <code>false</code>, the result of <code>value.convert_to<T>()</code> is undefined. If <code>value.can_convert_to<T>()</code>
-is <code>true</code>, the following always holds true:
-
-<pre>
- bigint(value.convert_to<T>()) == value
-</pre>
-
-These functions work only for types which have traits in <code>std::numeric_limits</code>, and do not have to work for types
-which are longer than 64 bit even if such types are natively supported.</p>
-
-<h3><a name="Other_functions">Other functions</a></h3>
-
-<p><code>abs</code> function returns an absolute value of passed parameter.</p>
-
-<p><code>pow</code> function returns the passed parameter raised to the specified power. Negative powers are naturally not supported. pow(0, 0) == 1.</p>
-
-<p><code>div</code> function returns both quotient and remainder for the division. The division is a truncated one; for further reference, see section Arithmetic operations.
-This function is similar to standard <code>div</code> function for integers.</p>
-
-<p><code>sqrt</code> function computes a square root of the passed parameter. Passing a negative value to <code>sqrt</code> results in undefined behavior.</p>
-
-<h3><a name="Serialization">Serialization</a></h3>
-
-<p><b>bigint</b> has built-in support for serialization via Boost.Serialization library. You need to include a separate header,
-&lt;boost/bigint/bigint_serialize.hpp&gt;, and then you can serialize <b>bigint</b> values to all archives. The storage format is the decimal string
-representation, though this is an implementation detail and may change in future.</p>
-
-<h2><a name="Performance">Performance</a></h2>
-
-<p>While different <b>bigint</b> implementations have different performance characteristics, developers are encouraged to
-provide a table with summary performance of implemented methods. Such table for existing implementations exists here.
-N means the length of the value itself (applicable only for methods), A1, A2, etc. mean length of the function
-arguments, and M means maximum of the lengths of both value and function arguments (M = max(N, A1, A2, ...)).</p>
-
-<p>'Length' means number of bits for integer arguments and number of characters for strings.</p>
-
-<table><tr><th>Function(s)</th><th>'gmp' implementation</th></tr>
-<tr><td>default ctor</td><td>O(1)</td></tr>
-<tr><td>integer ctors</td><td>O(1)</td></tr>
-<tr><td>string ctors</td><td>O(A1) <font color="#ff0000">check</font></td></tr>
-<tr><td>+, -, +=, -=</td><td>O(M)</td></tr>
-<tr><td>*, *=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
-<tr><td>/, /=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
-<tr><td>%, %=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
-<tr><td>&amp;, &amp;=, |, |=, ^, ^=</td><td>O(M)</td></tr>
-<tr><td>&lt;&lt;, &gt;&gt;</td><td>O(max(A1, 2<sup>A2</sup>)) <font color="#808080"> NB. O(2<sup>A2</sup>) is equal to O(shift amount)</font></td></tr>
-<tr><td>&lt;&lt;=, &gt;&gt;=</td><td>O(max(N, 2<sup>A1</sup>)) <font color="#808080"> NB. O(2<sup>A1</sup>) is equal to O(shift amount)</font></td></tr>
-<tr><td>++, --</td><td>O(N)</td></tr>
-<tr><td>+, -</td><td>O(1)</td></tr>
-<tr><td>~</td><td>O(N)</td></tr>
-<tr><td>bool conversions</td><td>O(1)</td></tr>
-<tr><td>string conversions</td><td>O(N) <font color="#ff0000">check</font></td></tr>
-<tr><td>can_convert_to</td><td>O(1)</font></td></tr>
-<tr><td>to_number</td><td>O(N)</font></td></tr>
-<tr><td>comparison operators</td><td>O(M)</font></td></tr>
-<tr><td>abs</td><td>O(M)</font></td></tr>
-<tr><td>pow</td><td>O(A1 * A2) <font color="#ff0000">check</font></td></tr>
-<tr><td>div</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
-<tr><td>sqrt</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
-</table>
-
-<h2><a name="Exceptions">Exceptions</a></h2>
-
-<p>Most implementations of <b>bigint</b> allocate memory for various uses (both temporary
-memory and memory for value storage); therefore any <b>bigint</b> function (except <b>bigint</b>
-destructor) may throw a <code>std::bad_alloc</code> exception. There are no other possible
-exceptions.</p>
-
-<h2><a name="References">References</a></h2>
-<ul>
-<li>The bigint header itself: bigint.hpp</li>
-<li>Some example code: example.cpp</li>
-<li>The regression tests: test/</li>
-</ul>
-
-<h2><a name="History_and_Acknowledgements">History and Acknowledgements</a></h2>
-
-<p>The library was implemented by me (Arseny Kapoulkine) as a Boost project for
-Google Summer of Code.</p>
-
-<p>Jeff Garland helped with different design and implementation-related things
-during the project.</p>
-
-<p>Jarrad Waterloo reminded me of some issues in the initial design that were
-overlooked (64-bit integer support, various bases for string conversion).</p>
-
-<p>Phil Endecott reminded me to take special care of negative numbers in implementation
-and documentation of bitwise operators.</p>
-
-<p>I shamelessly stole small parts of Boost.Rational documentation (and based
-the whole structure of this file on it), which was written by Paul Moore and
-Daryle Walker.</p>
-
-<p>Revised June 16, 2007</p>
-
-<p>&copy; Copyright Arseny Kapoulkine 2007. Permission to
-copy, use, modify, sell and distribute this document is granted provided this
-copyright notice appears in all copies. This document is provided &quot;as
-is&quot; without express or implied warranty, and with no claim as to its
-suitability for any purpose.</p>
-</body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>Big Integer Library</title>
+</head>
+<body>
+<h1><img src="../../boost.png" alt="boost.png (6897 bytes)"
+ align="middle" width="277" height="86">
+Big Integers</h1>
+
+<h2><a name="Contents">Contents</a></h2>
+
+<ol>
+ <li>Class bigint synopsis</li>
+ <li>Rationale</li>
+ <li>Background</li>
+ <li>Interface
+ <ul>
+ <li>Choosing the implementation</li>
+ <li>Constructors</li>
+ <li>Arithmetic operations</li>
+ <li>Bitwise operations</li>
+ <li>Input and Output</li>
+ <li>Conversions</li>
+ <li>Other functions</li>
+ <li>Serialization</li>
+ </ul></li>
+ <li>Performance</li>
+ <li>Exceptions</li>
+ <li>References</li>
+ <li>History and Acknowledgements</li>
+</ol>
+
+<h2><a name="Class_bigint_synopsis">Class bigint synopsis</a></h2>
+<pre>
+#include &lt;boost/bigint/bigint.hpp&gt;
+
+namespace boost {
+template &lt;typename I&gt; class bigint_base
+{
+ typedef <em>implementation-defined</em> bool_type;
+
+public:
+ // Constructors
+ bigint_base(); // Zero
+ bigint_base(int number);
+ bigint_base(unsigned int number);
+ bigint_base(int64_t number);
+ bigint_base(uint64_t number);
+
+ // String constructors for variable digit base; default is decimal
+ explicit bigint_base(const char* str, int base = 10);
+ explicit bigint_base(const wchar_t* str, int base = 10);
+ explicit bigint_base(const std::string&amp; str, int base = 10);
+ explicit bigint_base(const std::wstring&amp; str, int base = 10);
+
+ // Arithmetic operators
+ const bigint_base&amp; operator+=(const bigint_base&amp; other);
+ const bigint_base&amp; operator-=(const bigint_base&amp; other);
+ const bigint_base&amp; operator*=(const bigint_base&amp; other);
+ const bigint_base&amp; operator/=(const bigint_base&amp; other);
+ const bigint_base&amp; operator%=(const bigint_base&amp; other);
+
+ // Arithmetic operators
+ friend bigint_base operator+(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator-(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator*(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator/(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator%(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+
+ // Bitwise logical operators
+ const bigint_base&amp; operator|=(const bigint_base&amp; other);
+ const bigint_base&amp; operator&amp;=(const bigint_base&amp; other);
+ const bigint_base&amp; operator^=(const bigint_base&amp; other);
+
+ // Bitwise logical operators
+ friend bigint_base operator|(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator&amp;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bigint_base operator^(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+
+ // Shift operators
+ const bigint_base&amp; operator&lt;&lt;=(uint64_t other);
+ const bigint_base&amp; operator&gt;&gt;=(uint64_t other);
+
+ // Shift operators
+ friend bigint_base operator&lt;&lt;(const bigint_base&amp; lhs, boost::uint64_t rhs);
+ friend bigint_base operator&gt;&gt;(const bigint_base&amp; lhs, boost::uint64_t rhs);
+
+ // Increment and decrement; both prefix and postfix forms are supported
+ const bigint_base&amp; operator++();
+ bigint_base operator++(int);
+ const bigint_base&amp; operator--();
+ bigint_base operator--(int);
+
+ // Unary operators
+ bigint_base operator+() const;
+ bigint_base operator-() const;
+ bigint_base operator~() const;
+
+ // Bool conversions
+ operator bool_type() const;
+ bool operator!() const;
+
+ // String conversion for variable digit base; default is decimal
+ std::string str(int base = 10) const;
+ std::wstring wstr(int base = 10) const;
+
+ // Converting from bigint to any primitive integer type, including 64-bit ones
+ template &lt;typename T&gt; bool can_convert_to() const;
+ template &lt;typename T&gt; T to_number() const;
+
+ // Comparison operators
+ friend bool operator&lt;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bool operator&lt;=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bool operator&gt;(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bool operator&gt;=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bool operator==(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+ friend bool operator!=(const bigint_base&amp; lhs, const bigint_base&amp; rhs);
+
+ // Free functions
+ friend bigint_base abs(const bigint_base&amp; value);
+ friend bigint_base pow(const bigint_base&lt;I&gt;&amp; lhs, boost::uint64_t rhs);
+ friend bigint_base div(const bigint_base&amp; lhs, const bigint_base&amp; rhs, bigint_base&amp; remainder);
+ friend bigint_base sqrt(const bigint_base&amp; lhs);
+
+ // Stream input/output
+ template &lt;typename T, typename Tr&gt; friend std::basic_ostream&lt;T, Tr&gt;&amp; operator&lt;&lt;(std::basic_ostream&lt;T, Tr&gt;&amp; lhs, const bigint_base&amp; rhs);
+ template &lt;typename T, typename Tr&gt; friend std::basic_istream&lt;T, Tr&gt;&amp; operator&gt;&gt;(std::basic_istream&lt;T, Tr&gt;&amp; lhs, bigint_base&amp; rhs);
+};
+
+} // namespace boost
+
+typedef bigint_base&lt;<em>implementation-defined</em>&gt; bigint;
+</pre>
+
+<h2><a name="Rationale">Rationale</a></h2>
+
+<p>Standard C++ without third-party libraries offers support for several integer
+types, though all of them have limited range of values. This range is enough
+for majority of applications, but in some cases, which include scientific and
+cryptography-related applications, there is a need for so called "arbitrary
+precision numbers" - those are the numbers which have precision limited only by
+amount of available memory.</p>
+
+<p>Note that due to the lack of hardware support for arbitrary precision integers,
+any operations that can be performed with them are slower than the corresponding
+operations for native (C++ built-in) types; therefore they should not be treated
+as a complete replacement for existing types, but rather as a possibility to trade
+performance for precision.</p>
+
+<p>There are several different third-party libraries available, they have different
+performance/portability characteristics; this library provides a numeric type
+<b>bigint</b>, strictly defines the set of operations that can be performed and their
+behavior, provides a portable (albeit slow) implementation of said operations; and
+also provides a implementation which uses the fastest available arbitrary precision
+library, GNU MP.</p>
+
+<p>The library is intended to be highly extensible and encourages developers to create
+their own implementation that would close the gap between 'portable' and 'gmp' implementations
+in terms of performance; a set of correctness and performance tests is provided to
+ease the development of such implementations.</p>
+
+<h2><a name="Background">Background</a></h2>
+
+<p>The <b>bigint</b> number class provides an implementation of integer concept. The representation
+is always exact, and there are no overflows/underflows; all operations except division by zero,
+evaluating remainder from the division by zero or evaluating square root of negative number are
+perfectly defined, and give the value that does not depend on implementation. Everything except
+the visible behavior - including in-memory representation, operations performance/memory complexity -
+depends on the implementations. Implementation authors are encouraged to provide information about
+memory requirements and performance complexities (the table for two existing implementations is
+present in this documentation) to help the user of the library choose the implementation that will
+suite his or her needs best of all.</p>
+
+<p><b>bigint</b> class is designed so that it is compatible with the built-in integer types in the
+largest extent possible; this means that all arithmetical and logical types available are available
+for <b>bigint</b> class; <b>bigint</b> is implicitly constructible from integer types so that integer
+types can be used where compiler is expecting <b>bigint</b> - both in operators and functions; some
+of integer functions present in C++ standard are also redefined for <b>bigint</b>.</p>
+
+<h2><a name="Interface">Interface</a></h2>
+
+<h3><a name="Choosing_implementation">Choosing the implementation</a></h3>
+
+<p>The bigint library consists of two distinct parts - the interface class <b>bigint_base</b>, and a set
+of implementation classes. <b>bigint_base</b> is a templated class with a single template parameter - the
+actual implementation. There is a convenience typedef, <b>bigint</b>, which equals to <b>bigint_base</b>,
+parametrized by the most advanced implementation available. As library provides only two implementations
+by default, <b>bigint</b> is equal to GMP-based implementation if the define BOOST_BIGINT_HAS_GMP_SUPPORT
+is set in <i>boost_config.hpp</i> file; otherwise <b>bigint</b> uses the portable implementation.</p>
+
+<p>In most cases users should just use <b>bigint</b>, but if they have a need to use the specific implementation,
+they can use it like this:
+
+<pre>
+ #include "header_with_specific_implementation_class.hpp"
+
+ typedef boost::bigint_base&lt;specific_implementation_class&gt; bigint_special;
+
+ bigint_special a = 1, b = a * (a - 4);
+</pre>
+
+<font color="#ff0000">As this can change and bigint_base can be parametrized by both implementation and storage class
+in future, this section has to be revised before the project ends</font>
+</p>
+
+<h3><a name="Constructors">Constructors</a></h3>
+
+<p><b>bigint</b> class has three types of constructors: default constructor, constructors from built-in integer types, and
+constructors from strings.</p>
+
+<p>Default constructor initializes <b>bigint</b> class instance to zero; note that as <b>bigint</b> class is an implementation
+of integer concept, there is no such distinction between positive and negative zero.</p>
+
+<p>Integer constructors initialize <b>bigint</b> from build-in integer types; the result of constructor is that <b>bigint</b>
+instance contains the exact representation of the passed value. Note that these constructors are <em>not</em> declared as explicit;
+this means that you can freely use values of build-in integer types where you have to use <b>bigint</b>; for example, this is
+correct:
+
+<pre>
+ int a = 10;
+ boost::bigint b = 3;
+ boost::bigint c = b + a;
+ boost::bigint d = c / 49;
+</pre>
+
+<font color="#ff0000"><b>bigint</b> relies on the presence of 64-bit integer support, but this may change in the future</font>
+</p>
+
+<p>String constructors initialize <b>bigint</b> from string in the certain format. Strings can be wide, and you can pass either
+a <b>std::string</b>/<b>std::wstring</b> or the pointer to the null-terminated character sequence. The accepted number format
+is as follows:</p>
+
+<pre>
+[spaces][sign][digits]
+</pre>
+
+<p>'spaces' is a group of whitespace symbols (as detected by ::isspace/::iswspace CRT functions), there can be zero or more symbols
+in it.</p>
+
+<p>'sign' is either an empty string, '+' or '-' symbol. '+' sign is ignored, '-' sets the number to the negative one (string "-3" will
+initialize <b>bigint</b> instance to -3, string "+3" will initialize it to 3).</p>
+
+<p>'digits' is a group of digits belonging to the character set of the base that is passed to the constructor; base is a number
+that is greater or equal to 2 and less or equal to 36; bases outside of allowed range lead to undefined results <font color="#ff0000">
+perhaps we should change that and initialize number to 0 if base is &lt; 2 or &gt; 36?</font>. For bases less or equal than 10,
+the character set of digits from 0 to (base-1) is used. For bases greater than 10, the character set consists of digits from 0
+to 9, and then the letters from 'A' (ASCII character 'A') to the last needed letter for the set to reach the needed size. Letters are not case sensitive.
+Letter 'A' corresponds to digit 10, letter 'B' corresponds to digit 11 and so on. Letter 'Z' (if applicable - this is an allowed
+letter only for base = 36) corresponds to digit 35.</p>
+
+<p>The group of digits is interpreted as a number that is written from the most significant digit to the least significant one;
+there can be an arbitrary number of zero digits ('0') preceding the group.
+
+<p>Examples:
+<ul>
+<li>For base 2, only characters '0' and '1' can be used. String "1100" in base 2 corresponds to the number 12 (decimal).</li>
+<li>For base 10, any digit characters can be used. String "1234" in base 10 corresponds to the number 1234 (decimal).</li>
+<li>For base 16, any digit characters can be used. Additionally characters 'A'-'F' and 'a'-'f' can be used. String "Ff4a" in base 16 corresponds to the number 65354 (decimal). Note that letter case is irrelevant.</li>
+<li>For base 36, any digit characters can be used. Additionally characters 'A'-'Z' and 'a'-'z' can be used. String "ZZ" in base 36 corresponds to the number 1295 (decimal).</li>
+</ul>
+</p>
+
+<p>If the input string has characters that are not allowed in the input string, the first such character
+and <em>all</em> consecutive characters (including allowed ones) are ignored.
+If there are no digit characters before the first discarded characters, the number is initialized to 0 (for example,
+passing "-A23" as an input string and 10 as base will initialize the number to 0, as it will ignore all characters
+from 'A' onward, including 'A').</p>
+
+<h3><a name="Arithmetic_operations">Arithmetic operations</a></h3>
+
+<p>All of the standard numeric operators are defined for the <b>bigint</b> class. These include:</p>
+
+<pre>
+ + +=
+ - -=
+ * *=
+ / /=
+ % %=
+ ++ -- (both prefix and postfix)
+ == !=
+ &lt; &gt;
+ &lt;= &gt;=
+ + (unary)
+ - (unary)
+</pre>
+
+<p>They have the same semantics as the standard ones.</p>
+
+<p>Some things that have to be noted:</p>
+
+<ul>
+<li>Division by zero (and taking remainder from the division by zero, i.e. i % 0) generates division by zero for the built-in
+<b>int</b> type; therefore, division by zero results in undefined behavior.</li>
+<li>Operations never produce an overflow/underflow and the result is perfectly accurate.</li>
+<li>The result of +, +=, -, -=, *, *=, ++, --, &lt;, &lt;=, &gt;, &gt;=, ==, !=, unary + and unary - operators is exactly the
+same as the result of corresponding operations for the mathematical integer concept.</li>
+<li>Division operation (/ and /=) results in so called truncated division; this means that if the dividend is not exactly
+divisible by the divisor, the result is equal to the result of real number division which is later truncated to the integer
+number which has the absolute value which is less than that of the real number quotient. Such truncation is also called rounding
+towards zero. Here are some examples to clarify the concept:
+ <ul>
+ <li>60 / 15 == 4. 60 is exactly divisible by 15, no truncation takes place.</li>
+ <li>-60 / 15 == -4. -60 is exactly divisible by 15, no truncation takes place.</li>
+ <li>60 / -15 == -4. 60 is exactly divisible by -15, no truncation takes place.</li>
+ <li>3 / 2 == 1. 3 is not exactly divisible by 2; the quotient of real number division is 1.5, it is truncated to 1.</li>
+ <li>-3 / 2 == -1. -3 is not exactly divisible by 2; the quotient of real number division is -1.5, it is truncated to -1.</li>
+ <li>3 / -2 == -1. 3 is not exactly divisible by -2; the quotient of real number division is -1.5, it is truncated to -1.</li>
+ <li>-3 / -2 == 1. -3 is not exactly divisible by -2; the quotient of real number division is 1.5, it is truncated to 1.</li>
+ </ul>
+</li>
+<li>Modulo operation (% and %=) is implemented in terms of truncated division; this means, that if a / b == c, then a % b == a - b * c. This means that:
+ <ul>
+ <li>Modulo by zero results in undefined behavior</li>
+ <li>If a is exactly divisible by b, a % b == 0</li>
+ <li>Otherwise, the sign of a % b is always equal to the sign of a.
+ </ul>
+Here are some examples to clarify the concept:
+ <ul>
+ <li>34 % 5 == 4. 34 / 5 == 6 (see above for the description of truncating division), 34 % 5 == 34 - (6 * 5) == 4.</li>
+ <li>34 % -5 == 4. 34 / -5 == -6, 34 % -5 == 34 - (-6 * -5) == 4.</li>
+ <li>-34 % 5 == -4. -34 / 5 == -6, -34 % 5 == -34 - (-6 * 5) == -4.</li>
+ <li>-34 % -5 == -4. -34 / -5 == 6, -34 % -5 == -34 - (6 * -5) == -4.</li>
+ </ul>
+</li>
+</ul>
+
+<h3><a name="Bitwise_operations">Bitwise operations</a></h3>
+
+<p>All of the standard bitwise operators are defined for the <b>bigint</b> class. These include:</p>
+
+<pre>
+ &amp; &amp;=
+ | |=
+ ^ ^=
+ ~ (unary)
+ &lt;&lt; &lt;&lt;=
+ &gt;&gt; &gt;&gt;=
+</pre>
+
+<p>These functions operate with a bit representation of numbers. Note that though there are no strict requirements for
+storage of <b>bigint</b> implementations, bitwise operators are guaranteed to operate with the following representation:
+positive numbers are represented as a sequence of bits, most significant bit is first, least significant bit is last, the
+sequence of bits is equal to the representation of the number in binary number system; zero is represented as a single bit 0;
+negative numbers are represented as 2-complement of their absolute value (note that this means that negative number have an
+infinite number of 1s at the beginning; for the purpose of bitwise operations we assume that positive numbers have an infinite
+number of 0s at the beginning).</p>
+
+<p>Given such representation, the result of each bit operation is defined as the number representation of a bit sequence, which
+is constructed from two bit sequences of operands (to be precise, of two bit sequences, which are bit representation of the operands),
+or of a bit sequence of a single operand in case of unary operator, by applying the bitwise operator to those sequences.</p>
+
+<p>Examples to clarify the concept:
+<ul>
+<li>3 & 6 == 11b & 110b == 10b == 2</li>
+<li>3 | 6 == 11b | 110b == 111b == 7</li>
+<li>3 ^ 6 == 11b ^ 110b == 101b == 5</li>
+<li>-3 & 6 == -(11b) & 110b == 1....1101b & 0....0110b == 0....0100b == 100b == 4</li>
+<li>-3 | 6 == -(11b) & 110b == 1....1101b | 0....0110b == 1....1111b == -(1b) == -1</li>
+<li>-3 ^ 6 == -(11b) & 110b == 1....1101b ^ 0....0110b == 1....1011b == -(101b) == -5</li>
+<li>~(-3) == ~(-(11b)) == ~1....1101b == 0....0010b == 2</li>
+<li>-3 << 2 == -(11b) << 2 == 1....1101b << 2 == 1....110100b == -(1100b) == -12</li>
+<li>-3 >> 2 == -(11b) >> 2 == 1....1101b >> 2 == 1....11b == -(1b) == -1</li>
+</ul>
+</p>
+
+<p>Note that shift operators can't shift more than for 2^64 digits; this is beyond the limit of memory anyway (2^64 bits means
+2^61 bytes for storage, which is equal to 2^31 Gb of data) and is not going to change.</p>
+
+<h3><a name="Input_and_Output">Input and Output</a></h3>
+
+<p>Input and output operators <tt>&lt;&lt;</tt> and <tt>&gt;&gt;</tt>
+are provided. They meet all flags and locale requirements (that is, you
+can use <code>showpos, oct, hex</code> and other flags, decimal separators
+are also supported. Input operator stops at the first unrecognized character.
+In short, input and output operators behave exactly as you would expect them to
+behave for build-in integer types.</p>
+
+<h3><a name="Conversions">Conversions</a></h3>
+
+<p>There is a conversion operator to an unspecified Boolean type (most likely a
+member pointer). This operator converts a <b>bigint</b> to <code>false</code> if it
+represents zero, and <code>true</code> otherwise. This conversion allows a
+bigint for use as the first argument of operator <code>?:</code>; as either
+argument of operators <code>&amp;&amp;</code> or <code>||</code> without
+forfeiting short-circuit evaluation; as a condition for a <code>do</code>,
+<code>if</code>, <code>while</code>, or <code>for</code> statement; and as a
+conditional declaration for <code>if</code>, <code>while</code>, or
+<code>for</code> statements. The nature of the type used, and that any names
+for that nature are kept private, should prevent any inappropriate non-boolean
+use like numeric or pointer operations or as a <code>switch</code> condition.</p>
+
+<p>Note: the provided <code>operator!</code> is not strictly necessary from the point of C++ standard,
+and is a workaround for some compilers.</p>
+
+<p><b>bigint</b> values can be converted to strings of arbitrary base (provided it
+meets the conditions 2 &lt;= base &lt;= 36). The output string consists of sign
+(a symbol '-' present only if the value is negative) and of a sequence of characters
+that represent digits. This sequence consists of the same characters that can
+occur in the string passed to the string constructors of bigint; the description
+of the values and their meaning can be seen in the Constructors
+section. No unnecessary zeroes or whitespace characters are added to the output string
+(if the value is equal to 0, the string "0" is returned); all letter symbols are
+lowercase. Generally, the following always holds true:
+
+<pre>
+ bigint(value.str()) == value
+</pre>
+</p>
+
+<p>While <b>bigint</b> provides storage and operations for numbers of arbitrary precision,
+sometimes the stored values fit into C++ built-in integer types, and sometimes there's a need
+to convert from <b>bigint</b> to one of those types. You can check whether such conversion is
+possible via <code>can_convert_to</code> function, and convert <b>bigint</b> to a value of built-in
+integer type via <code>to_number</code> function. Note that if <code>value.can_convert_to<T>()</code>
+is <code>false</code>, the result of <code>value.convert_to<T>()</code> is undefined. If <code>value.can_convert_to<T>()</code>
+is <code>true</code>, the following always holds true:
+
+<pre>
+ bigint(value.convert_to<T>()) == value
+</pre>
+
+These functions work only for types which have traits in <code>std::numeric_limits</code>, and do not have to work for types
+which are longer than 64 bit even if such types are natively supported.</p>
+
+<h3><a name="Other_functions">Other functions</a></h3>
+
+<p><code>abs</code> function returns an absolute value of passed parameter.</p>
+
+<p><code>pow</code> function returns the passed parameter raised to the specified power. Negative powers are naturally not supported. pow(0, 0) == 1.</p>
+
+<p><code>div</code> function returns both quotient and remainder for the division. The division is a truncated one; for further reference, see section Arithmetic operations.
+This function is similar to standard <code>div</code> function for integers.</p>
+
+<p><code>sqrt</code> function computes a square root of the passed parameter. Passing a negative value to <code>sqrt</code> results in undefined behavior.</p>
+
+<h3><a name="Serialization">Serialization</a></h3>
+
+<p><b>bigint</b> has built-in support for serialization via Boost.Serialization library. You need to include a separate header,
+&lt;boost/bigint/bigint_serialize.hpp&gt;, and then you can serialize <b>bigint</b> values to all archives. The storage format is the decimal string
+representation, though this is an implementation detail and may change in future.</p>
+
+<h2><a name="Performance">Performance</a></h2>
+
+<p>While different <b>bigint</b> implementations have different performance characteristics, developers are encouraged to
+provide a table with summary performance of implemented methods. Such table for existing implementations exists here.
+N means the length of the value itself (applicable only for methods), A1, A2, etc. mean length of the function
+arguments, and M means maximum of the lengths of both value and function arguments (M = max(N, A1, A2, ...)).</p>
+
+<p>'Length' means number of bits for integer arguments and number of characters for strings.</p>
+
+<table><tr><th>Function(s)</th><th>'gmp' implementation</th></tr>
+<tr><td>default ctor</td><td>O(1)</td></tr>
+<tr><td>integer ctors</td><td>O(1)</td></tr>
+<tr><td>string ctors</td><td>O(A1) <font color="#ff0000">check</font></td></tr>
+<tr><td>+, -, +=, -=</td><td>O(M)</td></tr>
+<tr><td>*, *=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
+<tr><td>/, /=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
+<tr><td>%, %=</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
+<tr><td>&amp;, &amp;=, |, |=, ^, ^=</td><td>O(M)</td></tr>
+<tr><td>&lt;&lt;, &gt;&gt;</td><td>O(max(A1, 2<sup>A2</sup>)) <font color="#808080"> NB. O(2<sup>A2</sup>) is equal to O(shift amount)</font></td></tr>
+<tr><td>&lt;&lt;=, &gt;&gt;=</td><td>O(max(N, 2<sup>A1</sup>)) <font color="#808080"> NB. O(2<sup>A1</sup>) is equal to O(shift amount)</font></td></tr>
+<tr><td>++, --</td><td>O(N)</td></tr>
+<tr><td>+, -</td><td>O(1)</td></tr>
+<tr><td>~</td><td>O(N)</td></tr>
+<tr><td>bool conversions</td><td>O(1)</td></tr>
+<tr><td>string conversions</td><td>O(N) <font color="#ff0000">check</font></td></tr>
+<tr><td>can_convert_to</td><td>O(1)</font></td></tr>
+<tr><td>to_number</td><td>O(N)</font></td></tr>
+<tr><td>comparison operators</td><td>O(M)</font></td></tr>
+<tr><td>abs</td><td>O(M)</font></td></tr>
+<tr><td>pow</td><td>O(A1 * A2) <font color="#ff0000">check</font></td></tr>
+<tr><td>div</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
+<tr><td>sqrt</td><td><= O(M<sup>2</sup>) <font color="#ff0000">provide more precise info</font></td></tr>
+</table>
+
+<h2><a name="Exceptions">Exceptions</a></h2>
+
+<p>Most implementations of <b>bigint</b> allocate memory for various uses (both temporary
+memory and memory for value storage); therefore any <b>bigint</b> function (except <b>bigint</b>
+destructor) may throw a <code>std::bad_alloc</code> exception. There are no other possible
+exceptions.</p>
+
+<h2><a name="References">References</a></h2>
+<ul>
+<li>The bigint header itself: bigint.hpp</li>
+<li>Some example code: example.cpp</li>
+<li>The regression tests: test/</li>
+</ul>
+
+<h2><a name="History_and_Acknowledgements">History and Acknowledgements</a></h2>
+
+<p>The library was implemented by me (Arseny Kapoulkine) as a Boost project for
+Google Summer of Code.</p>
+
+<p>Jeff Garland helped with different design and implementation-related things
+during the project.</p>
+
+<p>Jarrad Waterloo reminded me of some issues in the initial design that were
+overlooked (64-bit integer support, various bases for string conversion).</p>
+
+<p>Phil Endecott reminded me to take special care of negative numbers in implementation
+and documentation of bitwise operators.</p>
+
+<p>I shamelessly stole small parts of Boost.Rational documentation (and based
+the whole structure of this file on it), which was written by Paul Moore and
+Daryle Walker.</p>
+
+<p>Revised June 16, 2007</p>
+
+<p>&copy; Copyright Arseny Kapoulkine 2007. Permission to
+copy, use, modify, sell and distribute this document is granted provided this
+copyright notice appears in all copies. This document is provided &quot;as
+is&quot; without express or implied warranty, and with no claim as to its
+suitability for any purpose.</p>
+</body>
+</html>

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-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,937 +1,937 @@
-// svg_1d_plot.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_AXIS_PLOT_FRAME_HPP
-#define _BOOST_SVG_AXIS_PLOT_FRAME_HPP
-
-#include <string>
-#include "../svg_style.hpp"
-#include "svg_tag.hpp"
-
-namespace boost{
-namespace svg{
-namespace detail{
-
-template <class Derived>
-class axis_plot_frame
-{
-protected:
- // -----------------------------------------------------------------
- // We don't use the SVG coordinate transform because then text would
- // be flipped. I'm considering using it to scale the image for resizes.
- // -----------------------------------------------------------------
- void _transform_point(double &x, double &y)
- {
- x = derived().x_scale* x + derived().x_shift;
- y = derived().y_scale* y + derived().y_shift;
- }
-
- void _transform_x(double &x)
- {
- x = derived().x_scale* x + derived().x_shift;
- }
-
- void _transform_y(double &y)
- {
- y = derived().y_scale* y + derived().y_shift;
- }
-
- void _draw_x_minor_ticks(double j, path_element& tick_path,
- path_element& grid_path)
- {
- double x1(0.), y1(0.), y2(derived().image.get_y_size());
-
- // draw the grid if needed
- if(derived().use_x_minor_grid)
- {
- _transform_x(x1 = j);
-
- if(!derived().use_plot_window)
- {
- // spacing for labels
- if(derived().use_title)
- {
- y1 += derived().title_info.font_size() * 1.5;
- }
-
- if(derived().use_x_label)
- {
- y2 -= derived().x_label_info.font_size() * 1.5;
- }
- }
-
- if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
- {
- grid_path.M(x1, y1).L(x1, y2);
- }
- }
-
- double x_tick_length = derived().x_minor_length / 2.;
-
- if(derived().use_x_external_style)
- {
- y1 = derived().plot_y2;
- y2 = derived().plot_y2 + x_tick_length;
- }
-
- else
- {
- y1 = derived().x_axis + x_tick_length;
- y2 = derived().x_axis - x_tick_length;
- }
- x1=j;
-
- _transform_x(x1);
-
- //make sure that we are drawing inside of the allowed window
- if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
- {
- tick_path.M(x1, y1).L(x1, y2);
- }
- }
-
- void _draw_x_major_ticks(double i, path_element& tick_path, path_element& grid_path)
- {
- double x1(i), y1(0.), y2(derived().image.get_x_size());
-
- if(derived().use_x_major_grid)
- {
- _transform_x(x1 = i);
-
- if(!derived().use_plot_window)
- {
- if(derived().use_title)
- {
- y1 += derived().title_info.font_size() * 1.5;
- }
-
- if(derived().use_x_label)
- {
- y2 -= derived().x_label_info.font_size() * 1.5;
- }
- }
-
- if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
- {
- grid_path.M(x1, y1).L(x1, y2);
- }
- }
-
- //draw major tick
- x1=i;
-
- _transform_x(x1);
-
- //make sure that we are drawing inside of the allowed window
- if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
- {
- double x_tick_length = derived().x_major_length / 2.;
-
- if(derived().use_x_external_style)
- {
- y1 = derived().plot_y2;
- y2 = derived().plot_y2 + x_tick_length;
- }
-
- else
- {
- y1 = derived().x_axis + x_tick_length;
- y2 = derived().x_axis - x_tick_length;
- }
-
- tick_path.M(x1, y1).L(x1, y2);
-
- if(derived().use_x_major_labels)
- {
- std::stringstream fmt;
- fmt<<i;
-
- if(derived().use_x_external_style)
- {
- y1 += derived().x_major_length;
- }
-
- else
- {
- y1 += (2 + derived().x_major_length/2);
- }
-
- derived().image.get_g_element(PLOT_PLOT_LABELS).text(x1,
- y1, fmt.str());
- }
- }
- }
-
- void _draw_x_axis()
- {
- double y1(0.);
-
- // draw the axis line
- _transform_y(y1);
-
- derived().x_axis = y1;
-
- path_element& minor_tick_path =
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).path();
-
- path_element& major_tick_path =
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).path();
-
- path_element& minor_grid_path =
- derived().image.get_g_element(PLOT_X_MINOR_GRID).path();
-
- path_element& major_grid_path =
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).path();
-
- if(derived().show_x_axis_lines)
- {
- derived().image.get_g_element(PLOT_X_AXIS).line(derived().plot_x1, derived().x_axis,
- derived().plot_x2, derived().x_axis);
- }
-
- // x_minor_jump is the interval between minor ticks
- double x_minor_jump = derived().x_major/
- ((double)(derived().x_num_minor + 1.) );
-
- // draw the ticks on the positive side
- for(double i = 0; i < derived().x_max; i += derived().x_major)
- {
- for(double j = i + x_minor_jump;
- j < i + derived().x_major;
- j += x_minor_jump)
- {
- _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _draw_x_major_ticks(i, major_tick_path, major_grid_path);
- }
-
- // draw the ticks on the negative side
- for(double i = 0; i > derived().x_min; i -= derived().x_major)
- {
- // draw minor ticks
- for(double j=i; j>i-derived().x_major; j-=derived().x_major / (derived().x_num_minor+1))
- {
- _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _draw_x_major_ticks(i, major_tick_path, major_grid_path);
- }
- }
-
- // -----------------------------------------------------------------
- // When writing to multiple documents, the contents of the plot
- // may change significantly between. Rather than figuring out what
- // has and has not changed, just erase the contents of the legend
- // in the document and start over.
- // -----------------------------------------------------------------
- void _clear_all()
- {
- _clear_legend();
- _clear_background();
- _clear_x_axis();
- _clear_y_axis();
- _clear_title();
- _clear_points();
- _clear_plot_background();
- _clear_grids();
- }
-
- void _clear_background()
- {
- derived().image.get_g_element(PLOT_BACKGROUND).clear();
- }
-
- void _clear_title()
- {
- derived().image.get_g_element(PLOT_TITLE).clear();
- }
-
- void _clear_points()
- {
- derived().image.get_g_element(PLOT_PLOT_POINTS).clear();
- }
-
- void _clear_plot_background()
- {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).clear();
- }
-
- void _clear_legend()
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).clear();
- derived().image.get_g_element(PLOT_LEGEND_POINTS).clear();
- derived().image.get_g_element(PLOT_LEGEND_TEXT).clear();
- }
-
- void _clear_x_axis()
- {
- derived().image.get_g_element(PLOT_X_AXIS).clear();
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).clear();
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).clear();
- derived().image.get_g_element(PLOT_X_LABEL).clear();
- derived().image.get_g_element(PLOT_PLOT_LABELS).clear();
- }
-
- void _clear_y_axis()
- {
- derived().image.get_g_element(PLOT_Y_AXIS).clear();
- }
-
- void _clear_grids()
- {
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).clear();
- derived().image.get_g_element(PLOT_X_MINOR_GRID).clear();
- }
-
- void _draw_legend_header(int _x, int _y, int _width)
- {
- // 2 added to y argument for padding.
- text_element legend_header(_x+(_width/2.), _y + derived().legend_title_size + 2, "Legend");
-
- legend_header.alignment(center_align);
- legend_header.font_size(derived().legend_title_size);
-
- derived().image.get_g_element(PLOT_LEGEND_TEXT).push_back(new text_element(legend_header));
- }
-
- // -----------------------------------------------------------------
- // Important note: there are a lot of magic numbers that are temporary
- // fill-ins for the time when the legend system is more configurable.
- // This will happen bit-by-bit, as I give the user options to change
- // these values
- // -----------------------------------------------------------------
- void _draw_legend()
- {
- int num_points = (int)(derived().series.size());
-
- int legend_width(150);
- int legend_height(25);
-
- int x_size = derived().image.get_x_size();
-
- // Figure out how wide the legend should be
- if(x_size < 200)
- {
- legend_width = x_size;
- }
-
- unsigned int legend_x_start(derived().plot_x2 + 5);
- unsigned int legend_y_start(derived().plot_y1);
-
- if((unsigned int)(derived().plot_x2) >= derived().image.get_x_size())
- {
- legend_x_start-=160;
- legend_y_start+=5;
- }
-
- if(derived().use_title)
- {
- // -5 removes the padding
- legend_y_start += (int)(derived().title_info.font_size() * 1.5) - 5;
- }
-
- // legend_height = title_spacing + (space per element)(num_elements)
- // + (end spacing)
- legend_height = (int)(derived().legend_title_size*1.5 + (25 * num_points) + 10);
-
- g_element* g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_BACKGROUND));
-
- g_ptr->push_back(new rect_element(legend_x_start,
- legend_y_start,
- legend_width,
- legend_height));
-
- _draw_legend_header(legend_x_start, legend_y_start, legend_width);
-
- g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_POINTS));
-
- g_element* g_inner_ptr = g_ptr;
-
- for(unsigned int i=0; i<derived().series.size(); ++i)
- {
- g_inner_ptr = &(g_ptr->add_g_element());
-
- g_inner_ptr->style().fill_color(derived().series[i].point_style.fill_color)
- .stroke_color(derived().series[i].point_style.stroke_color);
-
- _draw_plot_point(legend_x_start + 25,
- legend_y_start + derived().legend_title_size + 20 + i*25,
- *g_inner_ptr,
- derived().series[i].point_style);
-
- g_inner_ptr = &(derived().image.get_g_element(PLOT_LEGEND_TEXT));
-
- g_inner_ptr->push_back(new text_element(legend_x_start + 40,
- legend_y_start + derived().legend_title_size + 25 + i*25,
- derived().series[i].title, derived().legend_title_size,
- left_align));
- }
- }
-
- void _draw_title()
- {
- if(derived().use_title)
- {
- text_element title(derived().image.get_x_size()/2.,
- derived().title_info.font_size(),
- derived().title_info.text());
-
- title.alignment(center_align);
- title.font_size(derived().title_info.font_size());
- derived().image.get_g_element(PLOT_TITLE).push_back(new text_element(title));
- }
- }
-
- void _draw_x_label()
- {
- text_element to_use((derived().plot_x2 + derived().plot_x1) / 2.,
- derived().image.get_y_size() - 8, derived().x_label_info.text());
-
- to_use.font_size(12);
- to_use.alignment(center_align);
-
- derived().image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
- }
-
- 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.;
-
- 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;
- }
- }
-
-private:
- Derived& derived() { return static_cast<Derived&>(*this); }
- const Derived& derived()const{return static_cast<const Derived&>(*this); }
-public:
-
- Derived& image_size(unsigned int x, unsigned int y)
- {
- derived().image.image_size(x, y);
- return derived();
- }
-
- Derived& title(const std::string& _title)
- {
- derived().title_info.text(_title);
- return derived();
- }
-
- Derived& title_font_size(unsigned int _size)
- {
- derived().title_info.font_size() = _size;
- return derived();
- }
-
- Derived& legend_title_font_size(unsigned int _size)
- {
- derived().legend_title_font_size = _size;
- return derived();
- }
-
- Derived& legend_on(bool _cmd)
- {
- derived().use_legend = _cmd;
-
- if(_cmd)
- {
- derived().image.get_g_element(detail::PLOT_LEGEND_BACKGROUND)
- .style().fill_color(white)
- .stroke_color(black);
- }
- return derived();
- }
-
- Derived& plot_window_on(bool _cmd)
- {
- derived().use_plot_window = _cmd;
-
- if(_cmd)
- {
- derived().image.get_g_element(detail::PLOT_PLOT_BACKGROUND)
- .style().fill_color(white)
- .stroke_color(black);
- }
- return derived();
- }
-
- Derived& x_label_on(bool _cmd)
- {
- derived().use_x_label = _cmd;
- return derived();
- }
-
- Derived& x_major_labels_on(bool _cmd)
- {
- derived().x_major_labels_on = _cmd;
- return derived();
- }
-
- Derived& title_on(bool _cmd)
- {
- derived().use_title = _cmd;
- return derived();
- }
-
- Derived& x_major_grid_on(bool _is)
- {
- derived().use_x_major_grid = _is;
- return derived();
- }
-
- Derived& x_minor_grid_on(bool _is)
- {
- derived().use_x_minor_grid = _is;
- return derived();
- }
-
- Derived& axis_on(bool _is)
- {
- derived().show_x_axis_lines = _is;
- derived().show_y_axis_lines = _is;
- return derived();
- }
-
- Derived& x_axis_on(bool _is)
- {
- derived().show_x_axis_lines = _is;
- return derived();
- }
-
- Derived& y_axis_on(bool _is)
- {
- derived().show_y_axis_lines = _is;
- return derived();
- }
- // -----------------------------------------------------------------
- // Color settings: Customization of colors found in the plot
- //
- // title_color()
- // background_color()
- // legend_background_color()
- // plot_background_color()
- // axis_color()
- // x_major_tick_color()
- // x_minor_tick_color()
- // -----------------------------------------------------------------
-
- Derived& title_color(svg_color_constant _col)
- {
- title_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& title_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_TITLE).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_TITLE).style().fill_color(_col);
- return derived();
- }
-
- Derived& background_color(svg_color_constant _col)
- {
- background_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& legend_background_color(svg_color_constant _col)
- {
- legend_background_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& legend_background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& legend_border_color(svg_color_constant _col)
- {
- legend_border_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& legend_border_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color(_col);
- return derived();
- }
-
- Derived& background_border_color(svg_color_constant _col)
- {
- derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
- return derived();
- }
-
- Derived& background_border_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
- return derived();
- }
-
- Derived& plot_background_color(svg_color_constant _col)
- {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& plot_background_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_axis_color(svg_color_constant _col)
- {
- x_axis_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& x_axis_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_AXIS).style()
- .fill_color(_col);
-
- derived().image.get_g_element(PLOT_X_AXIS).style()
- .stroke_color(_col);
-
- return derived();
- }
-
- Derived& x_major_tick_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_major_tick_color(svg_color_constant _col)
- {
- x_major_tick_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& x_label_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_X_LABEL).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_label_color(svg_color_constant _col)
- {
- x_label_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& x_minor_tick_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_minor_tick_color(svg_color_constant _col)
- {
- x_minor_tick_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& x_major_grid_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_major_grid_color(svg_color_constant _col)
- {
- x_major_grid_color(constant_to_rgb(_col));
- return derived();
- }
-
- Derived& x_minor_grid_color(const svg_color& _col)
- {
- derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color(_col);
- derived().image.get_g_element(PLOT_X_MINOR_GRID).style().fill_color(_col);
- return derived();
- }
-
- Derived& x_minor_grid_color(svg_color_constant _col)
- {
- x_minor_grid_color(constant_to_rgb(_col));
- return derived();
- }
-
- // -----------------------------------------------------------------
- // Axis information: Settings for customization of axis information
- //
- // x_axis_width()
- // x_major_tick()
- // x_major_tick_length()
- // x_major_tick_width()
- // x_minor_tick_length()
- // x_minor_tick_width()
- // x_label_text()
- // x_num_minor_ticks()
- // x_scale()
- // -----------------------------------------------------------------
-
- Derived& x_axis_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_label(const std::string& _str)
- {
- derived().x_label_info.text(_str);
- return derived();
- }
-
- Derived& x_major_tick(double _inter)
- {
- derived().x_major_tick = _inter;
- return derived();
- }
-
- Derived& x_major_tick_length(unsigned int _length)
- {
- derived().x_major_tick_length = _length;
- return derived();
- }
-
- Derived& x_major_tick_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_minor_tick_length(unsigned int _length)
- {
- derived().x_minor_tick_length = _length;
- return derived();
- }
-
- Derived& x_minor_tick_width(unsigned int _width)
- {
- derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(_width);
- return derived();
- }
-
- Derived& x_num_minor_ticks(unsigned int _num)
- {
- derived().x_num_minor_ticks = _num;
- return derived();
- }
-
- Derived& x_scale(double x1, double x2)
- {
- if(x2 <= x1)
- {
- throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
- }
-
- derived().x_min = x1;
- derived().x_max = x2;
-
- return derived();
- }
-
- unsigned int get_image_x_size()
- {
- return derived().image.get_x_size();
- }
-
- unsigned int get_image_y_size()
- {
- return derived().image.get_x_size();
- }
-
- std::string get_title()
- {
- return derived().title;
- }
-
- unsigned int get_legend_title_font_size()
- {
- return derived().legend_title_font_size;
- }
-
- bool get_legend()
- {
- return derived().use_legend;
- }
-
- bool get_plot_window()
- {
- return derived().use_plot_window;
- }
-
- bool get_x_label()
- {
- return derived().use_x_label;
- }
-
- bool get_x_major_labels()
- {
- return derived().x_major_labels_on;
- }
-
- // color information
- svg_color get_title_color()
- {
- return derived().image.get_g_element(PLOT_TITLE).style().get_fill_color();
- }
-
- svg_color get_background_color()
- {
- return derived().image.get_g_element(PLOT_BACKGROUND).style().get_fill_color();
- }
-
- svg_color get_background_border_color()
- {
- return derived().image.get_g_element(PLOT_BACKGROUND).style().get_stroke_color();
- }
-
- svg_color get_legend_background_color()
- {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_fill_color();
- }
-
- svg_color get_legend_border_color()
- {
- return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_stroke_color();
- }
-
- svg_color get_plot_background_color()
- {
- return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().get_fill_color();
- }
-
- svg_color get_x_axis_color()
- {
- return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_color();
- }
-
- svg_color get_x_label_color()
- {
- return derived().image.get_g_element(PLOT_X_LABEL).style().get_fill_color();
- }
-
- svg_color get_x_major_tick_color()
- {
- return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_color();
- }
-
- svg_color get_x_minor_tick_color()
- {
- return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_color();
- }
-
- svg_color get_x_major_grid_color()
- {
- return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().get_stroke_color();
- }
-
- svg_color get_x_minor_grid_color()
- {
- return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().get_stroke_color();
- }
-
- // axis information
- double get_x_min()
- {
- return derived().x_min;
- }
-
- double get_x_max()
- {
- return derived().x_max;
- }
-
- unsigned int get_x_axis_width()
- {
- return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_width();
- }
-
- double get_x_major_tick()
- {
- return derived().x_major_tick;
- }
-
- unsigned int get_x_major_tick_length()
- {
- return derived().x_major_tick_length;
- }
-
- unsigned int get_x_minor_tick_length()
- {
- return derived().x_minor_tick_length;
- }
-
- unsigned int get_x_num_minor_ticks()
- {
- return derived().x_num_minor_ticks;
- }
-
- unsigned int get_x_major_tick_width()
- {
- return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_width();
- }
-
- unsigned int get_x_minor_tick_width()
- {
- return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_width();
- }
-
- std::string get_x_label_text()
- {
- return derived().x_label;
- }
-
- svg& get_svg()
- {
- derived()._update_image();
-
- return derived().image;
- }
-
- const svg& get_svg() const
- {
- derived()._update_image();
-
- return derived().image;
- }
-};
-
-} // detail
-} // svg
-} // boost
-
-#endif
+// svg_1d_plot.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_AXIS_PLOT_FRAME_HPP
+#define _BOOST_SVG_AXIS_PLOT_FRAME_HPP
+
+#include <string>
+#include "../svg_style.hpp"
+#include "svg_tag.hpp"
+
+namespace boost{
+namespace svg{
+namespace detail{
+
+template <class Derived>
+class axis_plot_frame
+{
+protected:
+ // -----------------------------------------------------------------
+ // We don't use the SVG coordinate transform because then text would
+ // be flipped. I'm considering using it to scale the image for resizes.
+ // -----------------------------------------------------------------
+ void _transform_point(double &x, double &y)
+ {
+ x = derived().x_scale* x + derived().x_shift;
+ y = derived().y_scale* y + derived().y_shift;
+ }
+
+ void _transform_x(double &x)
+ {
+ x = derived().x_scale* x + derived().x_shift;
+ }
+
+ void _transform_y(double &y)
+ {
+ y = derived().y_scale* y + derived().y_shift;
+ }
+
+ void _draw_x_minor_ticks(double j, path_element& tick_path,
+ path_element& grid_path)
+ {
+ double x1(0.), y1(0.), y2(derived().image.get_y_size());
+
+ // draw the grid if needed
+ if(derived().use_x_minor_grid)
+ {
+ _transform_x(x1 = j);
+
+ if(!derived().use_plot_window)
+ {
+ // spacing for labels
+ if(derived().use_title)
+ {
+ y1 += derived().title_info.font_size() * 1.5;
+ }
+
+ if(derived().use_x_label)
+ {
+ y2 -= derived().x_label_info.font_size() * 1.5;
+ }
+ }
+
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ grid_path.M(x1, y1).L(x1, y2);
+ }
+ }
+
+ double x_tick_length = derived().x_minor_length / 2.;
+
+ if(derived().use_x_external_style)
+ {
+ y1 = derived().plot_y2;
+ y2 = derived().plot_y2 + x_tick_length;
+ }
+
+ else
+ {
+ y1 = derived().x_axis + x_tick_length;
+ y2 = derived().x_axis - x_tick_length;
+ }
+ x1=j;
+
+ _transform_x(x1);
+
+ //make sure that we are drawing inside of the allowed window
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ tick_path.M(x1, y1).L(x1, y2);
+ }
+ }
+
+ void _draw_x_major_ticks(double i, path_element& tick_path, path_element& grid_path)
+ {
+ double x1(i), y1(0.), y2(derived().image.get_x_size());
+
+ if(derived().use_x_major_grid)
+ {
+ _transform_x(x1 = i);
+
+ if(!derived().use_plot_window)
+ {
+ if(derived().use_title)
+ {
+ y1 += derived().title_info.font_size() * 1.5;
+ }
+
+ if(derived().use_x_label)
+ {
+ y2 -= derived().x_label_info.font_size() * 1.5;
+ }
+ }
+
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ grid_path.M(x1, y1).L(x1, y2);
+ }
+ }
+
+ //draw major tick
+ x1=i;
+
+ _transform_x(x1);
+
+ //make sure that we are drawing inside of the allowed window
+ if(x1 < derived().plot_x2 && x1 > derived().plot_x1)
+ {
+ double x_tick_length = derived().x_major_length / 2.;
+
+ if(derived().use_x_external_style)
+ {
+ y1 = derived().plot_y2;
+ y2 = derived().plot_y2 + x_tick_length;
+ }
+
+ else
+ {
+ y1 = derived().x_axis + x_tick_length;
+ y2 = derived().x_axis - x_tick_length;
+ }
+
+ tick_path.M(x1, y1).L(x1, y2);
+
+ if(derived().use_x_major_labels)
+ {
+ std::stringstream fmt;
+ fmt<<i;
+
+ if(derived().use_x_external_style)
+ {
+ y1 += derived().x_major_length;
+ }
+
+ else
+ {
+ y1 += (2 + derived().x_major_length/2);
+ }
+
+ derived().image.get_g_element(PLOT_PLOT_LABELS).text(x1,
+ y1, fmt.str());
+ }
+ }
+ }
+
+ void _draw_x_axis()
+ {
+ double y1(0.);
+
+ // draw the axis line
+ _transform_y(y1);
+
+ derived().x_axis = y1;
+
+ path_element& minor_tick_path =
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).path();
+
+ path_element& major_tick_path =
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).path();
+
+ path_element& minor_grid_path =
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).path();
+
+ path_element& major_grid_path =
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).path();
+
+ if(derived().show_x_axis_lines)
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).line(derived().plot_x1, derived().x_axis,
+ derived().plot_x2, derived().x_axis);
+ }
+
+ // x_minor_jump is the interval between minor ticks
+ double x_minor_jump = derived().x_major/
+ ((double)(derived().x_num_minor + 1.) );
+
+ // draw the ticks on the positive side
+ for(double i = 0; i < derived().x_max; i += derived().x_major)
+ {
+ for(double j = i + x_minor_jump;
+ j < i + derived().x_major;
+ j += x_minor_jump)
+ {
+ _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+
+ _draw_x_major_ticks(i, major_tick_path, major_grid_path);
+ }
+
+ // draw the ticks on the negative side
+ for(double i = 0; i > derived().x_min; i -= derived().x_major)
+ {
+ // draw minor ticks
+ for(double j=i; j>i-derived().x_major; j-=derived().x_major / (derived().x_num_minor+1))
+ {
+ _draw_x_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+
+ _draw_x_major_ticks(i, major_tick_path, major_grid_path);
+ }
+ }
+
+ // -----------------------------------------------------------------
+ // When writing to multiple documents, the contents of the plot
+ // may change significantly between. Rather than figuring out what
+ // has and has not changed, just erase the contents of the legend
+ // in the document and start over.
+ // -----------------------------------------------------------------
+ void _clear_all()
+ {
+ _clear_legend();
+ _clear_background();
+ _clear_x_axis();
+ _clear_y_axis();
+ _clear_title();
+ _clear_points();
+ _clear_plot_background();
+ _clear_grids();
+ }
+
+ void _clear_background()
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).clear();
+ }
+
+ void _clear_title()
+ {
+ derived().image.get_g_element(PLOT_TITLE).clear();
+ }
+
+ void _clear_points()
+ {
+ derived().image.get_g_element(PLOT_PLOT_POINTS).clear();
+ }
+
+ void _clear_plot_background()
+ {
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).clear();
+ }
+
+ void _clear_legend()
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).clear();
+ derived().image.get_g_element(PLOT_LEGEND_POINTS).clear();
+ derived().image.get_g_element(PLOT_LEGEND_TEXT).clear();
+ }
+
+ void _clear_x_axis()
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).clear();
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).clear();
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).clear();
+ derived().image.get_g_element(PLOT_X_LABEL).clear();
+ derived().image.get_g_element(PLOT_PLOT_LABELS).clear();
+ }
+
+ void _clear_y_axis()
+ {
+ derived().image.get_g_element(PLOT_Y_AXIS).clear();
+ }
+
+ void _clear_grids()
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).clear();
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).clear();
+ }
+
+ void _draw_legend_header(int _x, int _y, int _width)
+ {
+ // 2 added to y argument for padding.
+ text_element legend_header(_x+(_width/2.), _y + derived().legend_title_size + 2, "Legend");
+
+ legend_header.alignment(center_align);
+ legend_header.font_size(derived().legend_title_size);
+
+ derived().image.get_g_element(PLOT_LEGEND_TEXT).push_back(new text_element(legend_header));
+ }
+
+ // -----------------------------------------------------------------
+ // Important note: there are a lot of magic numbers that are temporary
+ // fill-ins for the time when the legend system is more configurable.
+ // This will happen bit-by-bit, as I give the user options to change
+ // these values
+ // -----------------------------------------------------------------
+ void _draw_legend()
+ {
+ int num_points = (int)(derived().series.size());
+
+ int legend_width(150);
+ int legend_height(25);
+
+ int x_size = derived().image.get_x_size();
+
+ // Figure out how wide the legend should be
+ if(x_size < 200)
+ {
+ legend_width = x_size;
+ }
+
+ unsigned int legend_x_start(derived().plot_x2 + 5);
+ unsigned int legend_y_start(derived().plot_y1);
+
+ if((unsigned int)(derived().plot_x2) >= derived().image.get_x_size())
+ {
+ legend_x_start-=160;
+ legend_y_start+=5;
+ }
+
+ if(derived().use_title)
+ {
+ // -5 removes the padding
+ legend_y_start += (int)(derived().title_info.font_size() * 1.5) - 5;
+ }
+
+ // legend_height = title_spacing + (space per element)(num_elements)
+ // + (end spacing)
+ legend_height = (int)(derived().legend_title_size*1.5 + (25 * num_points) + 10);
+
+ g_element* g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_BACKGROUND));
+
+ g_ptr->push_back(new rect_element(legend_x_start,
+ legend_y_start,
+ legend_width,
+ legend_height));
+
+ _draw_legend_header(legend_x_start, legend_y_start, legend_width);
+
+ g_ptr = &(derived().image.get_g_element(PLOT_LEGEND_POINTS));
+
+ g_element* g_inner_ptr = g_ptr;
+
+ for(unsigned int i=0; i<derived().series.size(); ++i)
+ {
+ g_inner_ptr = &(g_ptr->add_g_element());
+
+ g_inner_ptr->style().fill_color(derived().series[i].point_style.fill_color)
+ .stroke_color(derived().series[i].point_style.stroke_color);
+
+ _draw_plot_point(legend_x_start + 25,
+ legend_y_start + derived().legend_title_size + 20 + i*25,
+ *g_inner_ptr,
+ derived().series[i].point_style);
+
+ g_inner_ptr = &(derived().image.get_g_element(PLOT_LEGEND_TEXT));
+
+ g_inner_ptr->push_back(new text_element(legend_x_start + 40,
+ legend_y_start + derived().legend_title_size + 25 + i*25,
+ derived().series[i].title, derived().legend_title_size,
+ left_align));
+ }
+ }
+
+ void _draw_title()
+ {
+ if(derived().use_title)
+ {
+ text_element title(derived().image.get_x_size()/2.,
+ derived().title_info.font_size(),
+ derived().title_info.text());
+
+ title.alignment(center_align);
+ title.font_size(derived().title_info.font_size());
+ derived().image.get_g_element(PLOT_TITLE).push_back(new text_element(title));
+ }
+ }
+
+ void _draw_x_label()
+ {
+ text_element to_use((derived().plot_x2 + derived().plot_x1) / 2.,
+ derived().image.get_y_size() - 8, derived().x_label_info.text());
+
+ to_use.font_size(12);
+ to_use.alignment(center_align);
+
+ derived().image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
+ }
+
+ 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.;
+
+ 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;
+ }
+ }
+
+private:
+ Derived& derived() { return static_cast<Derived&>(*this); }
+ const Derived& derived()const{return static_cast<const Derived&>(*this); }
+public:
+
+ Derived& image_size(unsigned int x, unsigned int y)
+ {
+ derived().image.image_size(x, y);
+ return derived();
+ }
+
+ Derived& title(const std::string& _title)
+ {
+ derived().title_info.text(_title);
+ return derived();
+ }
+
+ Derived& title_font_size(unsigned int _size)
+ {
+ derived().title_info.font_size() = _size;
+ return derived();
+ }
+
+ Derived& legend_title_font_size(unsigned int _size)
+ {
+ derived().legend_title_font_size = _size;
+ return derived();
+ }
+
+ Derived& legend_on(bool _cmd)
+ {
+ derived().use_legend = _cmd;
+
+ if(_cmd)
+ {
+ derived().image.get_g_element(detail::PLOT_LEGEND_BACKGROUND)
+ .style().fill_color(white)
+ .stroke_color(black);
+ }
+ return derived();
+ }
+
+ Derived& plot_window_on(bool _cmd)
+ {
+ derived().use_plot_window = _cmd;
+
+ if(_cmd)
+ {
+ derived().image.get_g_element(detail::PLOT_PLOT_BACKGROUND)
+ .style().fill_color(white)
+ .stroke_color(black);
+ }
+ return derived();
+ }
+
+ Derived& x_label_on(bool _cmd)
+ {
+ derived().use_x_label = _cmd;
+ return derived();
+ }
+
+ Derived& x_major_labels_on(bool _cmd)
+ {
+ derived().x_major_labels_on = _cmd;
+ return derived();
+ }
+
+ Derived& title_on(bool _cmd)
+ {
+ derived().use_title = _cmd;
+ return derived();
+ }
+
+ Derived& x_major_grid_on(bool _is)
+ {
+ derived().use_x_major_grid = _is;
+ return derived();
+ }
+
+ Derived& x_minor_grid_on(bool _is)
+ {
+ derived().use_x_minor_grid = _is;
+ return derived();
+ }
+
+ Derived& axis_on(bool _is)
+ {
+ derived().show_x_axis_lines = _is;
+ derived().show_y_axis_lines = _is;
+ return derived();
+ }
+
+ Derived& x_axis_on(bool _is)
+ {
+ derived().show_x_axis_lines = _is;
+ return derived();
+ }
+
+ Derived& y_axis_on(bool _is)
+ {
+ derived().show_y_axis_lines = _is;
+ return derived();
+ }
+ // -----------------------------------------------------------------
+ // Color settings: Customization of colors found in the plot
+ //
+ // title_color()
+ // background_color()
+ // legend_background_color()
+ // plot_background_color()
+ // axis_color()
+ // x_major_tick_color()
+ // x_minor_tick_color()
+ // -----------------------------------------------------------------
+
+ Derived& title_color(svg_color_constant _col)
+ {
+ title_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& title_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_TITLE).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_TITLE).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& background_color(svg_color_constant _col)
+ {
+ background_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& background_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& legend_background_color(svg_color_constant _col)
+ {
+ legend_background_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& legend_background_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& legend_border_color(svg_color_constant _col)
+ {
+ legend_border_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& legend_border_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().stroke_color(_col);
+ return derived();
+ }
+
+ Derived& background_border_color(svg_color_constant _col)
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
+ return derived();
+ }
+
+ Derived& background_border_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_BACKGROUND).style().stroke_color(_col);
+ return derived();
+ }
+
+ Derived& plot_background_color(svg_color_constant _col)
+ {
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& plot_background_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_axis_color(svg_color_constant _col)
+ {
+ x_axis_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& x_axis_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).style()
+ .fill_color(_col);
+
+ derived().image.get_g_element(PLOT_X_AXIS).style()
+ .stroke_color(_col);
+
+ return derived();
+ }
+
+ Derived& x_major_tick_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_major_tick_color(svg_color_constant _col)
+ {
+ x_major_tick_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& x_label_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_LABEL).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_LABEL).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_label_color(svg_color_constant _col)
+ {
+ x_label_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& x_minor_tick_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_minor_tick_color(svg_color_constant _col)
+ {
+ x_minor_tick_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& x_major_grid_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_major_grid_color(svg_color_constant _col)
+ {
+ x_major_grid_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ Derived& x_minor_grid_color(const svg_color& _col)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().stroke_color(_col);
+ derived().image.get_g_element(PLOT_X_MINOR_GRID).style().fill_color(_col);
+ return derived();
+ }
+
+ Derived& x_minor_grid_color(svg_color_constant _col)
+ {
+ x_minor_grid_color(constant_to_rgb(_col));
+ return derived();
+ }
+
+ // -----------------------------------------------------------------
+ // Axis information: Settings for customization of axis information
+ //
+ // x_axis_width()
+ // x_major_tick()
+ // x_major_tick_length()
+ // x_major_tick_width()
+ // x_minor_tick_length()
+ // x_minor_tick_width()
+ // x_label_text()
+ // x_num_minor_ticks()
+ // x_scale()
+ // -----------------------------------------------------------------
+
+ Derived& x_axis_width(unsigned int _width)
+ {
+ derived().image.get_g_element(PLOT_X_AXIS).style().stroke_width(_width);
+ return derived();
+ }
+
+ Derived& x_label(const std::string& _str)
+ {
+ derived().x_label_info.text(_str);
+ return derived();
+ }
+
+ Derived& x_major_tick(double _inter)
+ {
+ derived().x_major_tick = _inter;
+ return derived();
+ }
+
+ Derived& x_major_tick_length(unsigned int _length)
+ {
+ derived().x_major_tick_length = _length;
+ return derived();
+ }
+
+ Derived& x_major_tick_width(unsigned int _width)
+ {
+ derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().stroke_width(_width);
+ return derived();
+ }
+
+ Derived& x_minor_tick_length(unsigned int _length)
+ {
+ derived().x_minor_tick_length = _length;
+ return derived();
+ }
+
+ Derived& x_minor_tick_width(unsigned int _width)
+ {
+ derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().stroke_width(_width);
+ return derived();
+ }
+
+ Derived& x_num_minor_ticks(unsigned int _num)
+ {
+ derived().x_num_minor_ticks = _num;
+ return derived();
+ }
+
+ Derived& x_scale(double x1, double x2)
+ {
+ if(x2 <= x1)
+ {
+ throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
+ }
+
+ derived().x_min = x1;
+ derived().x_max = x2;
+
+ return derived();
+ }
+
+ unsigned int get_image_x_size()
+ {
+ return derived().image.get_x_size();
+ }
+
+ unsigned int get_image_y_size()
+ {
+ return derived().image.get_x_size();
+ }
+
+ std::string get_title()
+ {
+ return derived().title;
+ }
+
+ unsigned int get_legend_title_font_size()
+ {
+ return derived().legend_title_font_size;
+ }
+
+ bool get_legend()
+ {
+ return derived().use_legend;
+ }
+
+ bool get_plot_window()
+ {
+ return derived().use_plot_window;
+ }
+
+ bool get_x_label()
+ {
+ return derived().use_x_label;
+ }
+
+ bool get_x_major_labels()
+ {
+ return derived().x_major_labels_on;
+ }
+
+ // color information
+ svg_color get_title_color()
+ {
+ return derived().image.get_g_element(PLOT_TITLE).style().get_fill_color();
+ }
+
+ svg_color get_background_color()
+ {
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().get_fill_color();
+ }
+
+ svg_color get_background_border_color()
+ {
+ return derived().image.get_g_element(PLOT_BACKGROUND).style().get_stroke_color();
+ }
+
+ svg_color get_legend_background_color()
+ {
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_fill_color();
+ }
+
+ svg_color get_legend_border_color()
+ {
+ return derived().image.get_g_element(PLOT_LEGEND_BACKGROUND).style().get_stroke_color();
+ }
+
+ svg_color get_plot_background_color()
+ {
+ return derived().image.get_g_element(PLOT_PLOT_BACKGROUND).style().get_fill_color();
+ }
+
+ svg_color get_x_axis_color()
+ {
+ return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_color();
+ }
+
+ svg_color get_x_label_color()
+ {
+ return derived().image.get_g_element(PLOT_X_LABEL).style().get_fill_color();
+ }
+
+ svg_color get_x_major_tick_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_color();
+ }
+
+ svg_color get_x_minor_tick_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_color();
+ }
+
+ svg_color get_x_major_grid_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_GRID).style().get_stroke_color();
+ }
+
+ svg_color get_x_minor_grid_color()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_GRID).style().get_stroke_color();
+ }
+
+ // axis information
+ double get_x_min()
+ {
+ return derived().x_min;
+ }
+
+ double get_x_max()
+ {
+ return derived().x_max;
+ }
+
+ unsigned int get_x_axis_width()
+ {
+ return derived().image.get_g_element(PLOT_X_AXIS).style().get_stroke_width();
+ }
+
+ double get_x_major_tick()
+ {
+ return derived().x_major_tick;
+ }
+
+ unsigned int get_x_major_tick_length()
+ {
+ return derived().x_major_tick_length;
+ }
+
+ unsigned int get_x_minor_tick_length()
+ {
+ return derived().x_minor_tick_length;
+ }
+
+ unsigned int get_x_num_minor_ticks()
+ {
+ return derived().x_num_minor_ticks;
+ }
+
+ unsigned int get_x_major_tick_width()
+ {
+ return derived().image.get_g_element(PLOT_X_MAJOR_TICKS).style().get_stroke_width();
+ }
+
+ unsigned int get_x_minor_tick_width()
+ {
+ return derived().image.get_g_element(PLOT_X_MINOR_TICKS).style().get_stroke_width();
+ }
+
+ std::string get_x_label_text()
+ {
+ return derived().x_label;
+ }
+
+ svg& get_svg()
+ {
+ derived()._update_image();
+
+ return derived().image;
+ }
+
+ const svg& get_svg() const
+ {
+ derived()._update_image();
+
+ return derived().image;
+ }
+};
+
+} // detail
+} // svg
+} // boost
+
+#endif

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-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,378 +1,378 @@
-// 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 _BOOST_SVG_SVG_STYLE_HPP
-#define _BOOST_SVG_SVG_STYLE_HPP
-
-#include <ostream>
-
-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 << ")" ;
- }
-
- bool operator==(const svg_color& rhs)
- {
- return r == rhs.r && g == rhs.g && b == rhs.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, 112, 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_style
-{
-private:
- svg_color fill_color;
- svg_color stroke_color;
-
- unsigned int stroke_width;
-
-public:
- svg_style():fill_color(svg_color(0, 0, 0)),
- stroke_color(svg_color(0, 0, 0)), stroke_width(0)
- {
-
- }
-
- svg_style(const svg_color& _fill, const svg_color& _stroke,
- unsigned int _width = 0):
- fill_color(_fill), stroke_color(_stroke),
- stroke_width(_width)
- {
-
- }
-
- // setters
- svg_style& set_fill_color(const svg_color& _col)
- {
- fill_color = _col;
- return *this;
- }
-
- svg_style& set_stroke_color(const svg_color& _col)
- {
- stroke_color = _col;
- return *this;
- }
-
- svg_style& set_stroke_width(unsigned int _width)
- {
- stroke_width = _width;
- return *this;
- }
-
- // getters
- svg_color get_fill_color() { return svg_color(fill_color); };
- svg_color get_stroke_color() { return svg_color(stroke_color); };
- unsigned int get_stroke_width() { return stroke_width; };
-
-
- void 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
- << "\" ";
- }
- }
-};
-
-enum plot_doc_structure{PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND,
- PLOT_X_MINOR_GRID, PLOT_X_MAJOR_GRID, PLOT_Y_AXIS, PLOT_X_AXIS,
- PLOT_Y_MINOR_TICKS, PLOT_X_MINOR_TICKS, PLOT_Y_MAJOR_TICKS,
- PLOT_X_MAJOR_TICKS, PLOT_PLOT_LABELS, PLOT_PLOT_LINES, PLOT_PLOT_POINTS,
- PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
- PLOT_Y_LABEL, PLOT_X_LABEL, PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
-
-enum point_shape{none, circle, square, point};
-
-struct plot_point_style
-{
- point_shape shape;
- svg_color stroke_color;
- svg_color fill_color;
- int size;
-
- plot_point_style(const svg_color& _fill,
- const svg_color& _stroke, int _size = 10, point_shape _shape = circle):
- fill_color(_fill), stroke_color(_stroke), size(_size), shape(_shape)
- {
-
- }
-};
-
-struct plot_line_style
-{
- svg_color color;
- bool line_on;
-
- plot_line_style(const svg_color& _col, bool _on):
- color(_col), line_on(_on)
- {
- }
-};
-
-}//svg
-}//boost
-
-
-#endif
+// 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 _BOOST_SVG_SVG_STYLE_HPP
+#define _BOOST_SVG_SVG_STYLE_HPP
+
+#include <ostream>
+
+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 << ")" ;
+ }
+
+ bool operator==(const svg_color& rhs)
+ {
+ return r == rhs.r && g == rhs.g && b == rhs.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, 112, 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_style
+{
+private:
+ svg_color fill_color;
+ svg_color stroke_color;
+
+ unsigned int stroke_width;
+
+public:
+ svg_style():fill_color(svg_color(0, 0, 0)),
+ stroke_color(svg_color(0, 0, 0)), stroke_width(0)
+ {
+
+ }
+
+ svg_style(const svg_color& _fill, const svg_color& _stroke,
+ unsigned int _width = 0):
+ fill_color(_fill), stroke_color(_stroke),
+ stroke_width(_width)
+ {
+
+ }
+
+ // setters
+ svg_style& set_fill_color(const svg_color& _col)
+ {
+ fill_color = _col;
+ return *this;
+ }
+
+ svg_style& set_stroke_color(const svg_color& _col)
+ {
+ stroke_color = _col;
+ return *this;
+ }
+
+ svg_style& set_stroke_width(unsigned int _width)
+ {
+ stroke_width = _width;
+ return *this;
+ }
+
+ // getters
+ svg_color get_fill_color() { return svg_color(fill_color); };
+ svg_color get_stroke_color() { return svg_color(stroke_color); };
+ unsigned int get_stroke_width() { return stroke_width; };
+
+
+ void 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
+ << "\" ";
+ }
+ }
+};
+
+enum plot_doc_structure{PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND,
+ PLOT_X_MINOR_GRID, PLOT_X_MAJOR_GRID, PLOT_Y_AXIS, PLOT_X_AXIS,
+ PLOT_Y_MINOR_TICKS, PLOT_X_MINOR_TICKS, PLOT_Y_MAJOR_TICKS,
+ PLOT_X_MAJOR_TICKS, PLOT_PLOT_LABELS, PLOT_PLOT_LINES, PLOT_PLOT_POINTS,
+ PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
+ PLOT_Y_LABEL, PLOT_X_LABEL, PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
+
+enum point_shape{none, circle, square, point};
+
+struct plot_point_style
+{
+ point_shape shape;
+ svg_color stroke_color;
+ svg_color fill_color;
+ int size;
+
+ plot_point_style(const svg_color& _fill,
+ const svg_color& _stroke, int _size = 10, point_shape _shape = circle):
+ fill_color(_fill), stroke_color(_stroke), size(_size), shape(_shape)
+ {
+
+ }
+};
+
+struct plot_line_style
+{
+ svg_color color;
+ bool line_on;
+
+ plot_line_style(const svg_color& _col, bool _on):
+ color(_col), line_on(_on)
+ {
+ }
+};
+
+}//svg
+}//boost
+
+
+#endif

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_style_detail.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,28 +1,28 @@
-// 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 _BOOST_SVG_SVG_STYLE_DETAIL_HPP
-#define _BOOST_SVG_SVG_STYLE_DETAIL_HPP
-
-namespace boost{
-namespace svg{
-namespace detail{
-
-enum plot_doc_structure{PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND,
- PLOT_Y_MINOR_GRID, PLOT_Y_MAJOR_GRID, PLOT_X_MINOR_GRID,
- PLOT_X_MAJOR_GRID, PLOT_Y_AXIS, PLOT_X_AXIS,
- PLOT_Y_MINOR_TICKS, PLOT_X_MINOR_TICKS, PLOT_Y_MAJOR_TICKS,
- PLOT_X_MAJOR_TICKS, PLOT_PLOT_LABELS, PLOT_Y_LABEL, PLOT_X_LABEL,
- PLOT_PLOT_LINES, PLOT_PLOT_POINTS,
- PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
- PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
-
-}
-}
-}
-#endif
+// 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 _BOOST_SVG_SVG_STYLE_DETAIL_HPP
+#define _BOOST_SVG_SVG_STYLE_DETAIL_HPP
+
+namespace boost{
+namespace svg{
+namespace detail{
+
+enum plot_doc_structure{PLOT_BACKGROUND, PLOT_PLOT_BACKGROUND,
+ PLOT_Y_MINOR_GRID, PLOT_Y_MAJOR_GRID, PLOT_X_MINOR_GRID,
+ PLOT_X_MAJOR_GRID, PLOT_Y_AXIS, PLOT_X_AXIS,
+ PLOT_Y_MINOR_TICKS, PLOT_X_MINOR_TICKS, PLOT_Y_MAJOR_TICKS,
+ PLOT_X_MAJOR_TICKS, PLOT_PLOT_LABELS, PLOT_Y_LABEL, PLOT_X_LABEL,
+ PLOT_PLOT_LINES, PLOT_PLOT_POINTS,
+ PLOT_LEGEND_BACKGROUND, PLOT_LEGEND_POINTS, PLOT_LEGEND_TEXT,
+ PLOT_TITLE, SVG_PLOT_DOC_CHILDREN};
+
+}
+}
+}
+#endif

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-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,674 +1,674 @@
-// 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
-
-#if defined (BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4127) // "conditional expression is constant."
-# pragma warning(disable: 4512) // "assignment operator could not be generated."
-# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
-#endif
-
-#include <boost/ptr_container/ptr_container.hpp>
-#include "../svg_style.hpp"
-
-#include <sstream>
-#include <string>
-
-#if defined (BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-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
-{
-protected:
- svg_style style_info;
- std::string id_name;
-
-public:
- virtual void write(std::ostream& rhs) = 0;
-
- virtual ~svg_element()
- {
-
- }
-
- svg_style& style(){ return style_info; }
- const svg_style& style() const{ return style_info; }
-
- void id(const std::string& _id) { id_name = _id; }
- std::string id( ) { return std::string(id_name); }
-};
-
-// -----------------------------------------------------------------
-// Represents a single block of text
-// -----------------------------------------------------------------
-class rect_element: public svg_element
-{
-private:
- double x, y, height, width;
-
-public:
-
- rect_element(double _x, double _y, double _w, double _h)
- :x(_x), y(_y), width(_w), height(_h)
- {
-
- }
-
- void write(std::ostream& rhs)
- {
- rhs<<"<rect x=\""<<x<<"\""
- <<" y=\""<<y<<"\" "
- <<" width=\""<<width<<"\" "
- <<" height=\""<<height<<"\"/>"
- ;
- }
-};
-
-// -----------------------------------------------------------------
-// Represents a single point
-// -----------------------------------------------------------------
-class circle_element: public svg_element
-{
-private:
- double x, y, radius;
-
-public:
- circle_element(double _x, double _y, double _radius = 5):x(_x), y(_y),
- radius(_radius)
- {
-
- }
-
- void write(std::ostream& rhs)
- {
- rhs<<"<circle cx=\""
- <<x<<"\" cy=\""
- <<y<<"\" r=\""
- <<radius<<"\"/>";
- }
-};
-
-// -----------------------------------------------------------------
-// Represents a line
-// -----------------------------------------------------------------
-class line_element: public svg_element
-{
-private:
- double x1, x2, y1, y2, y;
-
-public:
- line_element(double _x1, double _y1, double _x2,
- double _y2):x1(_x1), y1(_y1),
- x2(_x2), y2(_y2)
- {
-
- }
-
- void write(std::ostream& rhs)
- {
- rhs<<"<line x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
- <<y2<<"\"/>";
- }
-};
-
-// -----------------------------------------------------------------
-// Represents a single block of text
-// -----------------------------------------------------------------
-enum text_style{left_align, right_align, center_align};
-
-class text_element: public svg_element
-{
-private:
- double x_coord, y_coord;
- int size;
- std::string txt;
- text_style align;
-
-public:
- void alignment(text_style _a)
- {
- align = _a;
- }
-
- int font_size()
- {
- return size;
- }
-
- double x(double _x)
- {
- x_coord = _x;
- }
-
- double y(double _y)
- {
- y_coord = _y;
- }
-
- text_element(double _x, double _y, std::string _text, int _size = 12,
- text_style _align = center_align)
- :x_coord(_x), y_coord(_y), txt(_text), size(_size), align(_align)
- {
-
- }
-
- void write(std::ostream& rhs)
- {
- std::string output;
-
- switch(align)
- {
- case left_align:
- output = "start";
- break;
-
- case right_align:
- output = "end";
- break;
-
- case center_align:
- output = "middle";
- break;
-
- default:
- output = "";
- break;
- }
-
- rhs << "<text x=\"" << x_coord << "\""
- <<" y=\"" << y_coord << "\" ";
-
- if(output != "")
- {
- rhs << "text-anchor=\"" << output << "\" ";
- }
-
- rhs << " font-family=\"verdana\"";
-
- if(size == 0)
- {
- rhs << " font-size=\"12\">";
- }
-
- else
- {
- rhs << " font-size=\"" << size << "\">";
- }
-
- rhs << txt
- <<" </text>";
- }
-
- void font_size(unsigned int _size){ size = _size; }
- void text(const std::string& _txt) { txt = _txt; }
-
- std::string text()
- {
- return txt;
- }
-};
-
-class clip_path_element: public svg_element
-{
-private:
- std::string element_id;
- rect_element rect;
-
-public:
-
- clip_path_element(const std::string& _id, const rect_element& _rect):
- element_id(_id), rect(_rect)
- {
-
- }
-
- void write(std::ostream& rhs)
- {
- rhs << "<clip-path id=\"" << element_id << "\">" <<std::endl;
-
- rect.write(rhs);
-
- rhs<<std::endl<<"</clip-path>";
- }
-};
-
-
-struct path_point
-{
- bool relative;
-
- virtual void write(std::ostream& rhs) = 0;
-
- virtual ~path_point()
- {
-
- }
-
- path_point(bool _rel): relative(_rel)
- {
-
- }
-};
-
-struct m_path: public path_point
-{
- double x, y;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"m";
- }
-
- else
- {
- o_str<<"M";
- }
-
- o_str<<x<<" "<<y<<" ";
- }
-
- m_path(double _x, double _y, bool _rel = false):
- x(_x), y(_y), path_point(_rel)
- {
- }
-};
-
-struct z_path: public path_point
-{
- void write(std::ostream& o_str)
- {
- o_str<<"Z ";
- }
-
- z_path():path_point(false){}
-};
-
-struct l_path: public path_point
-{
- double x, y;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"l";
- }
-
- else
- {
- o_str<<"L";
- }
-
- o_str<<x<<" "<<y<<" ";
- }
-
- l_path(double _x, double _y, bool _rel = false):
- x(_x), y(_y), path_point(_rel)
- {
- }
-};
-
-struct h_path: public path_point
-{
- double x;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"h";
- }
-
- else
- {
- o_str<<"H";
- }
-
- o_str<<x<<" ";
- }
-
- h_path(double _x, bool _rel = false):
- x(_x), path_point(_rel)
- {
- }
-};
-
-struct v_path: public path_point
-{
- double y;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"v";
- }
-
- else
- {
- o_str<<"V";
- }
-
- o_str<<y<<" ";
- }
-
- v_path(double _y, bool _rel = false):
- y(_y), path_point(_rel)
- {
- }
-};
-
-struct c_path: public path_point
-{
- double x1, y1, x2, y2, x, y;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"c";
- }
-
- else
- {
- o_str<<"C";
- }
-
- o_str<<x1<<" "<<y1<<" "
- <<x2<<" "<<y2<<" "
- <<x<<" "<<y<<" ";
- }
-
- c_path(double _x1, double _y1, double _x2, double _y2,
- double _x, double _y, bool _rel = false):
- x1(_x1), y1(_y1), x2(_x2), y2(_y2), x(_x), y(_y), path_point(_rel)
- {
-
- }
-};
-
-struct q_path: public path_point
-{
- double x1, y1, x, y;
-
- void write(std::ostream& o_str)
- {
- if(relative)
- {
- o_str<<"q";
- }
-
- else
- {
- o_str<<"Q";
- }
-
- o_str<<x1<<" "<<y1<<" "
- <<x<<" "<<y<<" ";
- }
-
- q_path(double _x1, double _y1,
- double _x, double _y, bool _rel = false):
- x1(_x1), y1(_y1), x(_x), y(_y), path_point(_rel)
- {
-
- }
-};
-
-class path_element: public svg_element
-{
-private:
- ptr_vector<path_point> path;
-public:
-
- path_element(const path_element& rhs)//:path(rhs.path.release())
- {
- path = (const_cast<path_element&>(rhs)).path.release();
- }
-
- path_element() { }
-
- path_element& m(double x, double y)
- {
- path.push_back(new m_path(x, y, true));
- return *this;
- }
-
- path_element& M(double x, double y)
- {
- path.push_back(new m_path(x, y, false));
- return *this;
- }
-
- path_element& z()
- {
- path.push_back(new z_path());
- return *this;
- }
-
- path_element& l(double x, double y)
- {
- path.push_back(new l_path(x, y, true));
- return *this;
- }
-
- path_element& L(double x, double y)
- {
- path.push_back(new l_path(x, y, false));
- return *this;
- }
-
- path_element& h(double x)
- {
- path.push_back(new h_path(x, true));
- return *this;
- }
-
- path_element& H(double x)
- {
- path.push_back(new h_path(x, false));
- return *this;
- }
-
- path_element& v(double y)
- {
- path.push_back(new v_path(y, true));
- return *this;
- }
-
- path_element& V(double y)
- {
- path.push_back(new v_path(y, false));
- return *this;
- }
-
- path_element& c(double x1, double y1, double x2, double y2, double x, double y)
- {
- path.push_back(new c_path(x1, y1, x2, y2, x, y, true));
- return *this;
- }
-
- path_element& C(double x1, double y1, double x2, double y2, double x, double y)
- {
- path.push_back(new c_path(x1, y1, x2, y2, x, y, false));
- return *this;
- }
-
- path_element& q(double x1, double y1, double x, double y)
- {
- path.push_back(new q_path(x1, y1, x, y, true));
- return *this;
- }
-
- path_element& Q(double x1, double y1, double x, double y)
- {
- path.push_back(new q_path(x1, y1, x, y, false));
- return *this;
- }
-
- void write(std::ostream& o_str)
- {
- o_str<<"<path d=\"";
-
- for(ptr_vector<path_point>::iterator i = path.begin();
- i!=path.end();
- ++i)
- {
- (*i).write(o_str);
- }
- o_str<<"\" ";
-
- style_info.write(o_str);
-
- o_str<<"/>";
- }
-};
-
-
-// -----------------------------------------------------------------
-// The node element of our document tree
-// -----------------------------------------------------------------
-class g_element: public svg_element
-{
-private:
- ptr_vector<svg_element> children;
- std::string clip_name;
-
- bool clip_on;
-
-public:
-
- g_element():clip_on(false)
- {
-
- }
-
- svg_element& operator[](unsigned int i)
- {
- return children[i];
- }
-
- size_t size()
- {
- return children.size();
- }
-
- void 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_tag(int i)
- {
- return *(static_cast<g_element*>(&children[i]));
- }
-
- //returns a reference to the node created
- g_element& add_g_element()
- {
- children.push_back(new g_element);
-
- return *(static_cast<g_element*>(&children[children.size()-1]));
- }
-
- void push_back(svg_element* _g)
- {
- children.push_back(_g);
- }
-
- void clear()
- {
- children.clear();
- }
-
- void use_clip(bool _use)
- {
- clip_on = _use;
- }
-
- void clip(const std::string& _name)
- {
- clip_on = true;
- clip_name = _name;
- }
-
- g_element& circle(double x, double y, double radius = 5.)
- {
- children.push_back(new circle_element(x, y, radius));
- return *this;
- }
-
- g_element& text(double x, double y, std::string text)
- {
- children.push_back(new text_element(x, y, text));
- return *this;
- }
-
- g_element& get_g_element(int i)
- {
- return *(static_cast<g_element*>(&children[i]));
- }
-
- g_element& rect(double x1, double y1, double x2, double y2)
- {
- children.push_back(new rect_element(x1, y1, x2, y2));
-
- return *this;
- }
-
- g_element& line(double x1, double y1, double x2, double y2)
- {
- children.push_back(new line_element(x1, y1, x2, y2));
-
- return *this;
- }
-
- path_element& path()
- {
- children.push_back(new path_element());
- return *(static_cast<path_element*>(&(children[(unsigned int)(children.size()-1)])));
- }
-};
-
-}
-}
-
-#endif
+// 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
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4127) // "conditional expression is constant."
+# pragma warning(disable: 4512) // "assignment operator could not be generated."
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+#include <boost/ptr_container/ptr_container.hpp>
+#include "../svg_style.hpp"
+
+#include <sstream>
+#include <string>
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+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
+{
+protected:
+ svg_style style_info;
+ std::string id_name;
+
+public:
+ virtual void write(std::ostream& rhs) = 0;
+
+ virtual ~svg_element()
+ {
+
+ }
+
+ svg_style& style(){ return style_info; }
+ const svg_style& style() const{ return style_info; }
+
+ void id(const std::string& _id) { id_name = _id; }
+ std::string id( ) { return std::string(id_name); }
+};
+
+// -----------------------------------------------------------------
+// Represents a single block of text
+// -----------------------------------------------------------------
+class rect_element: public svg_element
+{
+private:
+ double x, y, height, width;
+
+public:
+
+ rect_element(double _x, double _y, double _w, double _h)
+ :x(_x), y(_y), width(_w), height(_h)
+ {
+
+ }
+
+ void write(std::ostream& rhs)
+ {
+ rhs<<"<rect x=\""<<x<<"\""
+ <<" y=\""<<y<<"\" "
+ <<" width=\""<<width<<"\" "
+ <<" height=\""<<height<<"\"/>"
+ ;
+ }
+};
+
+// -----------------------------------------------------------------
+// Represents a single point
+// -----------------------------------------------------------------
+class circle_element: public svg_element
+{
+private:
+ double x, y, radius;
+
+public:
+ circle_element(double _x, double _y, double _radius = 5):x(_x), y(_y),
+ radius(_radius)
+ {
+
+ }
+
+ void write(std::ostream& rhs)
+ {
+ rhs<<"<circle cx=\""
+ <<x<<"\" cy=\""
+ <<y<<"\" r=\""
+ <<radius<<"\"/>";
+ }
+};
+
+// -----------------------------------------------------------------
+// Represents a line
+// -----------------------------------------------------------------
+class line_element: public svg_element
+{
+private:
+ double x1, x2, y1, y2, y;
+
+public:
+ line_element(double _x1, double _y1, double _x2,
+ double _y2):x1(_x1), y1(_y1),
+ x2(_x2), y2(_y2)
+ {
+
+ }
+
+ void write(std::ostream& rhs)
+ {
+ rhs<<"<line x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
+ <<y2<<"\"/>";
+ }
+};
+
+// -----------------------------------------------------------------
+// Represents a single block of text
+// -----------------------------------------------------------------
+enum text_style{left_align, right_align, center_align};
+
+class text_element: public svg_element
+{
+private:
+ double x_coord, y_coord;
+ int size;
+ std::string txt;
+ text_style align;
+
+public:
+ void alignment(text_style _a)
+ {
+ align = _a;
+ }
+
+ int font_size()
+ {
+ return size;
+ }
+
+ double x(double _x)
+ {
+ x_coord = _x;
+ }
+
+ double y(double _y)
+ {
+ y_coord = _y;
+ }
+
+ text_element(double _x, double _y, std::string _text, int _size = 12,
+ text_style _align = center_align)
+ :x_coord(_x), y_coord(_y), txt(_text), size(_size), align(_align)
+ {
+
+ }
+
+ void write(std::ostream& rhs)
+ {
+ std::string output;
+
+ switch(align)
+ {
+ case left_align:
+ output = "start";
+ break;
+
+ case right_align:
+ output = "end";
+ break;
+
+ case center_align:
+ output = "middle";
+ break;
+
+ default:
+ output = "";
+ break;
+ }
+
+ rhs << "<text x=\"" << x_coord << "\""
+ <<" y=\"" << y_coord << "\" ";
+
+ if(output != "")
+ {
+ rhs << "text-anchor=\"" << output << "\" ";
+ }
+
+ rhs << " font-family=\"verdana\"";
+
+ if(size == 0)
+ {
+ rhs << " font-size=\"12\">";
+ }
+
+ else
+ {
+ rhs << " font-size=\"" << size << "\">";
+ }
+
+ rhs << txt
+ <<" </text>";
+ }
+
+ void font_size(unsigned int _size){ size = _size; }
+ void text(const std::string& _txt) { txt = _txt; }
+
+ std::string text()
+ {
+ return txt;
+ }
+};
+
+class clip_path_element: public svg_element
+{
+private:
+ std::string element_id;
+ rect_element rect;
+
+public:
+
+ clip_path_element(const std::string& _id, const rect_element& _rect):
+ element_id(_id), rect(_rect)
+ {
+
+ }
+
+ void write(std::ostream& rhs)
+ {
+ rhs << "<clip-path id=\"" << element_id << "\">" <<std::endl;
+
+ rect.write(rhs);
+
+ rhs<<std::endl<<"</clip-path>";
+ }
+};
+
+
+struct path_point
+{
+ bool relative;
+
+ virtual void write(std::ostream& rhs) = 0;
+
+ virtual ~path_point()
+ {
+
+ }
+
+ path_point(bool _rel): relative(_rel)
+ {
+
+ }
+};
+
+struct m_path: public path_point
+{
+ double x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"m";
+ }
+
+ else
+ {
+ o_str<<"M";
+ }
+
+ o_str<<x<<" "<<y<<" ";
+ }
+
+ m_path(double _x, double _y, bool _rel = false):
+ x(_x), y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct z_path: public path_point
+{
+ void write(std::ostream& o_str)
+ {
+ o_str<<"Z ";
+ }
+
+ z_path():path_point(false){}
+};
+
+struct l_path: public path_point
+{
+ double x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"l";
+ }
+
+ else
+ {
+ o_str<<"L";
+ }
+
+ o_str<<x<<" "<<y<<" ";
+ }
+
+ l_path(double _x, double _y, bool _rel = false):
+ x(_x), y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct h_path: public path_point
+{
+ double x;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"h";
+ }
+
+ else
+ {
+ o_str<<"H";
+ }
+
+ o_str<<x<<" ";
+ }
+
+ h_path(double _x, bool _rel = false):
+ x(_x), path_point(_rel)
+ {
+ }
+};
+
+struct v_path: public path_point
+{
+ double y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"v";
+ }
+
+ else
+ {
+ o_str<<"V";
+ }
+
+ o_str<<y<<" ";
+ }
+
+ v_path(double _y, bool _rel = false):
+ y(_y), path_point(_rel)
+ {
+ }
+};
+
+struct c_path: public path_point
+{
+ double x1, y1, x2, y2, x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"c";
+ }
+
+ else
+ {
+ o_str<<"C";
+ }
+
+ o_str<<x1<<" "<<y1<<" "
+ <<x2<<" "<<y2<<" "
+ <<x<<" "<<y<<" ";
+ }
+
+ c_path(double _x1, double _y1, double _x2, double _y2,
+ double _x, double _y, bool _rel = false):
+ x1(_x1), y1(_y1), x2(_x2), y2(_y2), x(_x), y(_y), path_point(_rel)
+ {
+
+ }
+};
+
+struct q_path: public path_point
+{
+ double x1, y1, x, y;
+
+ void write(std::ostream& o_str)
+ {
+ if(relative)
+ {
+ o_str<<"q";
+ }
+
+ else
+ {
+ o_str<<"Q";
+ }
+
+ o_str<<x1<<" "<<y1<<" "
+ <<x<<" "<<y<<" ";
+ }
+
+ q_path(double _x1, double _y1,
+ double _x, double _y, bool _rel = false):
+ x1(_x1), y1(_y1), x(_x), y(_y), path_point(_rel)
+ {
+
+ }
+};
+
+class path_element: public svg_element
+{
+private:
+ ptr_vector<path_point> path;
+public:
+
+ path_element(const path_element& rhs)//:path(rhs.path.release())
+ {
+ path = (const_cast<path_element&>(rhs)).path.release();
+ }
+
+ path_element() { }
+
+ path_element& m(double x, double y)
+ {
+ path.push_back(new m_path(x, y, true));
+ return *this;
+ }
+
+ path_element& M(double x, double y)
+ {
+ path.push_back(new m_path(x, y, false));
+ return *this;
+ }
+
+ path_element& z()
+ {
+ path.push_back(new z_path());
+ return *this;
+ }
+
+ path_element& l(double x, double y)
+ {
+ path.push_back(new l_path(x, y, true));
+ return *this;
+ }
+
+ path_element& L(double x, double y)
+ {
+ path.push_back(new l_path(x, y, false));
+ return *this;
+ }
+
+ path_element& h(double x)
+ {
+ path.push_back(new h_path(x, true));
+ return *this;
+ }
+
+ path_element& H(double x)
+ {
+ path.push_back(new h_path(x, false));
+ return *this;
+ }
+
+ path_element& v(double y)
+ {
+ path.push_back(new v_path(y, true));
+ return *this;
+ }
+
+ path_element& V(double y)
+ {
+ path.push_back(new v_path(y, false));
+ return *this;
+ }
+
+ path_element& c(double x1, double y1, double x2, double y2, double x, double y)
+ {
+ path.push_back(new c_path(x1, y1, x2, y2, x, y, true));
+ return *this;
+ }
+
+ path_element& C(double x1, double y1, double x2, double y2, double x, double y)
+ {
+ path.push_back(new c_path(x1, y1, x2, y2, x, y, false));
+ return *this;
+ }
+
+ path_element& q(double x1, double y1, double x, double y)
+ {
+ path.push_back(new q_path(x1, y1, x, y, true));
+ return *this;
+ }
+
+ path_element& Q(double x1, double y1, double x, double y)
+ {
+ path.push_back(new q_path(x1, y1, x, y, false));
+ return *this;
+ }
+
+ void write(std::ostream& o_str)
+ {
+ o_str<<"<path d=\"";
+
+ for(ptr_vector<path_point>::iterator i = path.begin();
+ i!=path.end();
+ ++i)
+ {
+ (*i).write(o_str);
+ }
+ o_str<<"\" ";
+
+ style_info.write(o_str);
+
+ o_str<<"/>";
+ }
+};
+
+
+// -----------------------------------------------------------------
+// The node element of our document tree
+// -----------------------------------------------------------------
+class g_element: public svg_element
+{
+private:
+ ptr_vector<svg_element> children;
+ std::string clip_name;
+
+ bool clip_on;
+
+public:
+
+ g_element():clip_on(false)
+ {
+
+ }
+
+ svg_element& operator[](unsigned int i)
+ {
+ return children[i];
+ }
+
+ size_t size()
+ {
+ return children.size();
+ }
+
+ void 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_tag(int i)
+ {
+ return *(static_cast<g_element*>(&children[i]));
+ }
+
+ //returns a reference to the node created
+ g_element& add_g_element()
+ {
+ children.push_back(new g_element);
+
+ return *(static_cast<g_element*>(&children[children.size()-1]));
+ }
+
+ void push_back(svg_element* _g)
+ {
+ children.push_back(_g);
+ }
+
+ void clear()
+ {
+ children.clear();
+ }
+
+ void use_clip(bool _use)
+ {
+ clip_on = _use;
+ }
+
+ void clip(const std::string& _name)
+ {
+ clip_on = true;
+ clip_name = _name;
+ }
+
+ g_element& circle(double x, double y, double radius = 5.)
+ {
+ children.push_back(new circle_element(x, y, radius));
+ return *this;
+ }
+
+ g_element& text(double x, double y, std::string text)
+ {
+ children.push_back(new text_element(x, y, text));
+ return *this;
+ }
+
+ g_element& get_g_element(int i)
+ {
+ return *(static_cast<g_element*>(&children[i]));
+ }
+
+ g_element& rect(double x1, double y1, double x2, double y2)
+ {
+ children.push_back(new rect_element(x1, y1, x2, y2));
+
+ return *this;
+ }
+
+ g_element& line(double x1, double y1, double x2, double y2)
+ {
+ children.push_back(new line_element(x1, y1, x2, y2));
+
+ return *this;
+ }
+
+ path_element& path()
+ {
+ children.push_back(new path_element());
+ return *(static_cast<path_element*>(&(children[(unsigned int)(children.size()-1)])));
+ }
+};
+
+}
+}
+
+#endif

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-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,860 +1,860 @@
-// svg_1d_plot.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_SVG_2D_PLOT_HPP
-#define _BOOST_SVG_SVG_2D_PLOT_HPP
-
-#define BOOST_PARAMETER_MAX_ARITY 11
-
-#include <boost/bind.hpp>
-
-#if defined (BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4512) // "assignment operator could not be generated."
-# pragma warning(disable: 4127) // "conditional expression is constant."
-# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
-#endif
-
-#include <boost/parameter/preprocessor.hpp>
-#include <boost/parameter/name.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-
-#include "svg_style.hpp"
-#include "detail/axis_plot_frame.hpp"
-#include "svg.hpp"
-
-#if defined (BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-#include <map>
-#include <string>
-#include <sstream>
-#include <utility>
-#include <ostream>
-#include <iterator>
-#include <exception>
-
-
-namespace boost {
-namespace svg {
-
-
-#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
-#define BOOST_SVG_BOOST_PARAMETER_NAMES
-
-BOOST_PARAMETER_NAME(my_plot)
-BOOST_PARAMETER_NAME(container)
-BOOST_PARAMETER_NAME(title)
-BOOST_PARAMETER_NAME(stroke_color)
-BOOST_PARAMETER_NAME(fill_color)
-BOOST_PARAMETER_NAME(point_style)
-BOOST_PARAMETER_NAME(x_functor)
-BOOST_PARAMETER_NAME(size)
-#endif
-
-BOOST_PARAMETER_NAME(line_on)
-BOOST_PARAMETER_NAME(line_color)
-BOOST_PARAMETER_NAME(area_fill_color)
-
-class boost_default_2d_convert
-{
-public:
- typedef std::pair<double, double> result_type;
-
- template <class T, class U>
- std::pair<double, double> operator()(const std::pair<T, U>& a) const
- {
- return std::pair<double, double>((double)(a.first), (double)(a.second));
- }
-};
-
-struct svg_2d_plot_series
-{
- std::multimap<double, double> series;
- std::string title;
- plot_point_style point_style;
- plot_line_style line_style;
-
- template <class T>
- svg_2d_plot_series(T _begin,
- T _end,
- std::string _title,
- const plot_point_style& _point,
- const plot_line_style& _line):
- series(_begin,_end),
- title(_title),
- point_style(_point),
- line_style(_line)
- {
-
- }
-};
-
-class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
-{
-private:
- friend class detail::axis_plot_frame<svg_2d_plot>;
-
- double x_scale, x_shift;
- double y_scale, y_shift;
-
- // stored so as to avoid rewriting style information constantly
- svg image;
-
- text_element title_info;
- text_element x_label_info;
-
- // border information for the plot window. Initially will be set to the width
- // and height of the graph
- int plot_x1;
- int plot_x2;
- int plot_y1;
- int plot_y2;
-
- // axis information. y_axis stored as one point because this is a 1D graph
- double x_min, x_max;
- double x_axis;
-
- double x_major;
-
- unsigned int x_major_length, x_major_width,
- x_minor_length, x_minor_width;
- unsigned int x_num_minor;
- unsigned int legend_title_size;
-
- // Yes/no questions
- bool use_x_major_labels;
- bool use_x_major_grid;
- bool use_x_minor_grid;
- bool use_x_label;
-
- bool use_title;
- bool use_legend;
- bool use_axis;
- bool use_plot_window;
- bool use_x_external_style;
- bool use_y_external_style;
- bool show_x_axis_lines;
- bool show_y_axis_lines;
- bool use_y_major_grid;
- bool use_y_minor_grid;
-
- // where we will be storing the data points for transformation
- std::vector<svg_2d_plot_series> series;
-
- // strings having to do with labels
- std::string y_label;
-
- // axis information
- double y_min, y_max;
-
- double y_major, y_axis;
-
- unsigned int y_major_length, y_minor_length,
- y_num_minor;
-
- bool use_y_label;
- bool use_y_major_labels;
-
-
- void _draw_y_minor_ticks(double j, path_element& tick_path,
- path_element& grid_path)
- {
- double y1(0.), x1(0.), x2(image.get_y_size());
-
- // draw the grid if needed
- if(use_y_minor_grid)
- {
- _transform_y(y1 = j);
-
- if(!use_plot_window)
- {
- // spacing for labels
- if(use_legend)
- {
- x1 -= 155;
- }
-
- if(use_y_label)
- {
- x2 -= 12 * 1.5;
- }
- }
-
- if(y1 < plot_y2 && y1 > plot_y1)
- {
- grid_path.M(x1, y1).L(x2, y1);
- }
- }
-
- double y_tick_length = y_minor_length / 2.;
-
- if(use_y_external_style)
- {
- x1 = plot_x1;
- x2 = plot_x1 - y_tick_length / 2.;
- }
-
- else
- {
- x1 = y_axis + y_tick_length / 2.;
- x2 = y_axis - y_tick_length / 2.;
- }
- y1=j;
-
- _transform_y(y1);
-
- //make sure that we are drawing inside of the allowed window
- if(y1 < plot_y2 && y1 > plot_y1)
- {
- tick_path.M(x1, y1).L(x2, y1);
- }
- }
-
- void _draw_y_major_ticks(double i, path_element& tick_path, path_element& grid_path)
- {
- double y1(i), x1(0.), x2(image.get_y_size());
-
- if(use_y_major_grid)
- {
- _transform_y(y1 = i);
-
- if(!use_plot_window)
- {
- if(use_title)
- {
- x1 += title_info.font_size() * 1.5;
- }
-
- if(use_y_label)
- {
- x2 -= 12 * 1.5;
- }
- }
-
- if(y1 < plot_y2 && y1 > plot_y1)
- {
- grid_path.M(x1, y1).L(x2, y1);
- }
- }
-
- //draw major tick
- y1=i;
-
- _transform_y(y1);
-
- //make sure that we are drawing inside of the allowed window
- if(y1 < plot_y2 && y1 > plot_y1)
- {
- double y_tick_length = y_major_length / 2.;
-
- if(use_y_external_style)
- {
- x1 = plot_x1;
- x2 = plot_x1 - y_tick_length/2.;
- }
-
- else
- {
- x1 = y_axis + y_tick_length/2.;
- x2 = y_axis - y_tick_length/2.;
- }
-
- tick_path.M(x1, y1).L(x2, y1);
-
- if(use_y_major_labels && i != 0)
- {
- std::stringstream fmt;
- fmt<<i;
-
- if(use_y_external_style)
- {
- x1 -= y_major_length;
- }
-
- else
- {
- x1 += (2 + y_major_length/2);
- }
-
- image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
- y1, fmt.str());
- }
- }
- }
-
- void _draw_y_axis()
- {
- double x1(0.);
-
- // draw the axis line
- _transform_x(x1);
- image.get_g_element(detail::PLOT_Y_AXIS).line(x1, plot_y1, x1, plot_y2);
-
- y_axis = x1;
-
- path_element& minor_tick_path =
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).path();
-
- path_element& major_tick_path =
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).path();
-
- path_element& minor_grid_path =
- image.get_g_element(detail::PLOT_Y_MINOR_GRID).path();
-
- path_element& major_grid_path =
- image.get_g_element(detail::PLOT_Y_MAJOR_GRID).path();
-
- if(show_y_axis_lines)
- {
- image.get_g_element(detail::PLOT_Y_AXIS).
- line(plot_y1, x_axis, plot_x2, x_axis);
- }
-
- // y_minor_jump is the interval between minor ticks.
- double y_minor_jump = y_major/((double)(y_num_minor + 1.) );
-
- // draw the ticks on the positive side
- for(double i = 0; i < y_max; i += y_major)
- {
- for(double j = i + y_minor_jump;
- j < i + y_major;
- j += y_minor_jump)
- {
- _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _draw_y_major_ticks(i, major_tick_path, major_grid_path);
- }
-
- // draw the ticks on the negative side
- for(double i = 0; i > y_min; i -= y_major)
- {
- // draw minor ticks
- for(double j=i; j>i-y_major; j-=y_major / (y_num_minor+1))
- {
- _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
- }
-
- _draw_y_major_ticks(i, major_tick_path, major_grid_path);
- }
- }
-
- void _draw_axis()
- {
- _draw_y_axis();
- _draw_x_axis();
- }
-
- void _draw_y_label()
- {
- /* text_element to_use((plot_x2 + plot_x1) / 2., image.get_y_size() - 8, x_label);
-
- to_use.font_size(12);
- to_use.alignment(center_align);
-
- image.get_g_element(PLOT_X_LABEL).stroke_color(white);
- image.get_g_element(PLOT_X_LABEL).fill_color(white);
-
-
- image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
- */
- }
-
-
- void _calculate_transform()
- {
- x_scale = (plot_x2 - plot_x1) / (x_max - x_min);
- x_shift = plot_x1 - x_min *(plot_x2-plot_x1)/(x_max-x_min);
-
- y_scale = -(plot_y2-plot_y1)/(y_max-y_min);
-
- y_shift = plot_y1 - (y_max *(plot_y1-plot_y2)/(y_max-y_min));
- }
-
- void _calculate_plot_window()
- {
- plot_x1 = plot_y1 = 0;
-
- plot_x2 = image.get_x_size();
- plot_y2 = image.get_y_size();
-
-
- if(use_x_label)
- {
- plot_y2 -= (int)(x_label_info.font_size() * 1.5);
- }
-
- if(use_y_label)
- {
- plot_x1 += 20;
- }
-
- if(use_title)
- {
- plot_y1 += (int)(title_info.font_size() * 1.5);
- }
-
- if(use_plot_window)
- {
- // give the plot window a natural bit of padding
- plot_x1+=5;
- plot_x2-=5;
- plot_y1+=5;
- plot_y2-=5;
-
-
- if(use_legend)
- {
- plot_x2 -= 155;
- }
-
- if(use_y_external_style)
- {
- plot_x1 +=
- y_major_length > y_minor_length ?
- y_major_length :
- y_minor_length ;
- }
-
- if(use_x_external_style)
- {
- plot_y2 -=
- x_major_length > x_minor_length ?
- x_major_length :
- x_minor_length ;
- }
-
- image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
- new rect_element(plot_x1, plot_y1,
- (plot_x2-plot_x1), plot_y2-plot_y1));
- }
- }
-
- void _draw_plot_lines()
- {
- double prev_x, prev_y, temp_x(0.), temp_y(0.);
-
- for(unsigned int i = 0; i < series.size(); ++i)
- {
- g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
-
- g_ptr.style().stroke_color(series[i].line_style.color);
-
- path_element& path = g_ptr.path();
-
- if(series[i].series.size() > 1)
- {
- std::multimap<double, double>::const_iterator j = series[i].series.begin();
- prev_x = (*j).first;
- prev_y = 0.;
-
- // If we have to fill the area under the plot, we first have to
- // move from the X-axis to the first point.
-
- _transform_point(prev_x, prev_y);
-
- if(series[i].line_style.area_fill != blank)
- {
- path.style().fill_color(series[i].line_style.area_fill);
- path.M(prev_x, prev_y);
- }
-
-
- _transform_y(prev_y = (*j).second);
-
- if(series[i].line_style.area_fill != blank)
- {
- path.style().fill_color(series[i].line_style.area_fill);
- path.L(prev_x, prev_y);
- }
-
- else
- {
- path.M(prev_x, prev_y);
- }
- ++j;
-
- for(; j != series[i].series.end(); ++j)
- {
- temp_x = (*j).first;
- temp_y = (*j).second;
-
- _transform_point(temp_x, temp_y);
-
- path.L(temp_x, temp_y);
-
- if(series[i].line_style.area_fill == blank)
- {
- path.M(temp_x, temp_y);
- }
-
- prev_x = temp_x;
- prev_y = temp_y;
- }
-
- if(series[i].line_style.area_fill != blank)
- {
- _transform_y(temp_y = 0.);
- path.L(temp_x, temp_y).z();
- }
- }
- }
- }
-
- void _update_image()
- {
- _clear_all();
-
- // draw background
- image.get_g_element(detail::PLOT_BACKGROUND).push_back(
- new rect_element(0, 0, image.get_x_size(),
- image.get_y_size()));
-
- _draw_title();
- _calculate_plot_window();
- _calculate_transform();
-
- if(use_axis)
- {
- _draw_y_axis();
- _draw_x_axis();
- }
-
- if(use_legend)
- {
- _draw_legend();
- }
-
- if(use_x_label)
- {
- _draw_x_label();
- }
-
- // draw lines
-
- _draw_plot_lines();
-
- // draw points
- double x(0.), y(0.);
- for(unsigned int i=0; i<series.size(); ++i)
- {
- g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
-
- g_ptr.style()
- .fill_color(series[i].point_style.fill_color)
- .stroke_color(series[i].point_style.stroke_color);
-
- for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
- j!=series[i].series.end(); ++j)
- {
- x = j->first;
- y = j->second;
-
- _transform_point(x, y);
-
- if(x > plot_x1 && x < plot_x2
- && y > plot_y1 && y < plot_y2)
- {
- _draw_plot_point(x, y, g_ptr, series[i].point_style);
- }
- }
- }
- }
-
-public:
-
-svg_2d_plot(): title_info(0, 0, "Plot of data", 30),
- x_label_info(0, 0, "X Axis", 12),
- x_min(-10), x_max(10),
- y_min(-10), y_max(10),
- x_major(3), x_num_minor(2),
- y_major(3), use_y_label(false),
- x_minor_length(10), x_major_length(20),
- x_major_width(2), x_minor_width(1),
- y_minor_length(10), y_num_minor(2),
- y_major_length(20), legend_title_size(12),
- use_x_major_labels(true), use_x_major_grid(false),
- use_x_minor_grid(false), use_x_label(false),
- use_title(true), use_legend(false), use_axis(true),
- use_plot_window(false), use_y_major_labels(false),
- use_x_external_style(false), use_y_external_style(false),
- show_x_axis_lines(true), show_y_axis_lines(true),
- use_y_major_grid(false), use_y_minor_grid(false)
-
-{
- image_size(500, 350);
-
- //build the document tree.. add children of the root node
- for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
- {
- image.add_g_element();
- }
-
- // set color defaults
- image.get_g_element(detail::PLOT_BACKGROUND)
- .style().fill_color(white);
-
- image.get_g_element(detail::PLOT_Y_AXIS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_X_AXIS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_X_MINOR_TICKS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
- .style().stroke_width(2);
-
- image.get_g_element(detail::PLOT_X_MINOR_TICKS)
- .style().stroke_width(1);
-
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
- .style().stroke_color(black);
-
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
- .style().stroke_width(2);
-
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
- .style().stroke_width(1);
-
- image.get_g_element(detail::PLOT_X_MAJOR_TICKS).style().stroke_width(2);
- image.get_g_element(detail::PLOT_X_MINOR_TICKS).style().stroke_width(1);
-}
-
-
-svg_2d_plot& write(const std::string& _str)
-{
- std::ofstream fout(_str.c_str());
-
- if(fout.fail())
- {
- throw std::runtime_error("Unable to open "+_str);
- }
-
- write(fout);
-
- return *this;
-}
-
-svg_2d_plot& write(std::ostream& s_out)
-{
- _update_image();
-
- image.write(s_out);
-
- return *this;
-}
-
-svg_2d_plot& y_name_on(bool _cmd)
-{
- use_y_label = _cmd;
- return *this;
-}
-
-svg_2d_plot& y_major_labels_on(bool _cmd)
-{
- use_y_major_labels = _cmd;
- return *this;
-}
-
-
-svg_2d_plot& y_axis_color(svg_color_constant _col)
-{
- y_axis_color(constant_to_rgb(_col));
-
- return (svg_2d_plot&)*this;
-}
-
-svg_2d_plot& y_axis_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_AXIS)
- .style().fill_color(_col);
-
- image.get_g_element(detail::PLOT_Y_AXIS)
- .style().stroke_color(_col);
-
- return *this;
-}
-
-svg_2d_plot& y_major_tick_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(_col);
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().fill_color(_col);
- return *this;
-}
-
-svg_2d_plot& y_major_tick_color(svg_color_constant _col)
-{
- y_major_tick_color(constant_to_rgb(_col));
- return *this;
-}
-
-svg_2d_plot& y_minor_tick_color(const svg_color& _col)
-{
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(_col);
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().fill_color(_col);
- return *this;
-}
-
-svg_2d_plot& y_minor_tick_color(svg_color_constant _col)
-{
- y_minor_tick_color(constant_to_rgb(_col));
- return *this;
-}
-
-svg_2d_plot& y_range(double y1, double y2)
-{
- y_min = y1;
- y_max = y2;
-
- if(y2 <= y1)
- {
- throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
- }
-
- return *this;
-}
-
-svg_2d_plot& y_axis_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(_width);
-
- return *this;
-}
-
-svg_2d_plot& y_major_interval(double _inter)
-{
- y_major = _inter;
-
- return *this;
-}
-
-svg_2d_plot& y_major_tick_length(unsigned int _length)
-{
- y_major_length = _length;
- return *this;
-}
-
-svg_2d_plot& y_minor_tick_length(unsigned int _length)
-{
- y_minor_length = _length;
- return *this;
-}
-
-svg_2d_plot& y_num_minor_ticks(unsigned int _num)
-{
- y_num_minor = _num;
- return *this;
-}
-
-svg_2d_plot& y_name(const std::string& _str)
-{
- y_label = _str;
- return *this;
-}
-
-svg_2d_plot& y_major_tick_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(_width);
-
- return *this;
-}
-
-svg_2d_plot& y_minor_tick_width(unsigned int _width)
-{
- image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(_width);
-
- return *this;
-}
-
-svg_2d_plot& axis_external_style(bool _is)
-{
- use_x_external_style = _is;
- use_y_external_style = _is;
- return *this;
-}
-
-svg_2d_plot& x_external_style_on(bool _is)
-{
- use_x_external_style = _is;
-
- return *this;
-}
-
-svg_2d_plot& y_external_style_on(bool _is)
-{
- use_y_external_style = _is;
- return *this;
-}
-
-#if defined (BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
-#endif
-
-BOOST_PARAMETER_MEMBER_FUNCTION
-(
- (void),
- plot_2d,
- tag,
- (required
- (container, *)
- (title, (const std::string&))
- )
- (optional
- (stroke_color, (const svg_color&), black)
- (point_style, (point_shape), circle)
- (size, (int), 10)
- (line_on, (bool), true)
- (line_color, (const svg_color&), black)
- (area_fill_color, (svg_color_constant), blank)
- )
- (deduced
- (optional
- (fill_color, (const svg_color&), white)
- (x_functor, *, boost_default_2d_convert())
- )
- )
-)
-{
- plot_line_style line_style(line_color, line_on);
-
- if(area_fill_color != none)
- {
- line_style.area_fill=area_fill_color;
- }
-
- series.push_back(
- svg_2d_plot_series(
- boost::make_transform_iterator(container.begin(), x_functor),
- boost::make_transform_iterator(container.end(), x_functor),
- title,
- plot_point_style(fill_color, stroke_color, size, point_style),
- line_style
- ));
-}
-};
-
-#if defined (BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-}
-}
-
-#endif
+// svg_1d_plot.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_SVG_2D_PLOT_HPP
+#define _BOOST_SVG_SVG_2D_PLOT_HPP
+
+#define BOOST_PARAMETER_MAX_ARITY 11
+
+#include <boost/bind.hpp>
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4512) // "assignment operator could not be generated."
+# pragma warning(disable: 4127) // "conditional expression is constant."
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+#include <boost/parameter/preprocessor.hpp>
+#include <boost/parameter/name.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+
+#include "svg_style.hpp"
+#include "detail/axis_plot_frame.hpp"
+#include "svg.hpp"
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+#include <map>
+#include <string>
+#include <sstream>
+#include <utility>
+#include <ostream>
+#include <iterator>
+#include <exception>
+
+
+namespace boost {
+namespace svg {
+
+
+#ifndef BOOST_SVG_BOOST_PARAMETER_NAMES
+#define BOOST_SVG_BOOST_PARAMETER_NAMES
+
+BOOST_PARAMETER_NAME(my_plot)
+BOOST_PARAMETER_NAME(container)
+BOOST_PARAMETER_NAME(title)
+BOOST_PARAMETER_NAME(stroke_color)
+BOOST_PARAMETER_NAME(fill_color)
+BOOST_PARAMETER_NAME(point_style)
+BOOST_PARAMETER_NAME(x_functor)
+BOOST_PARAMETER_NAME(size)
+#endif
+
+BOOST_PARAMETER_NAME(line_on)
+BOOST_PARAMETER_NAME(line_color)
+BOOST_PARAMETER_NAME(area_fill_color)
+
+class boost_default_2d_convert
+{
+public:
+ typedef std::pair<double, double> result_type;
+
+ template <class T, class U>
+ std::pair<double, double> operator()(const std::pair<T, U>& a) const
+ {
+ return std::pair<double, double>((double)(a.first), (double)(a.second));
+ }
+};
+
+struct svg_2d_plot_series
+{
+ std::multimap<double, double> series;
+ std::string title;
+ plot_point_style point_style;
+ plot_line_style line_style;
+
+ template <class T>
+ svg_2d_plot_series(T _begin,
+ T _end,
+ std::string _title,
+ const plot_point_style& _point,
+ const plot_line_style& _line):
+ series(_begin,_end),
+ title(_title),
+ point_style(_point),
+ line_style(_line)
+ {
+
+ }
+};
+
+class svg_2d_plot: public detail::axis_plot_frame<svg_2d_plot>
+{
+private:
+ friend class detail::axis_plot_frame<svg_2d_plot>;
+
+ double x_scale, x_shift;
+ double y_scale, y_shift;
+
+ // stored so as to avoid rewriting style information constantly
+ svg image;
+
+ text_element title_info;
+ text_element x_label_info;
+
+ // border information for the plot window. Initially will be set to the width
+ // and height of the graph
+ int plot_x1;
+ int plot_x2;
+ int plot_y1;
+ int plot_y2;
+
+ // axis information. y_axis stored as one point because this is a 1D graph
+ double x_min, x_max;
+ double x_axis;
+
+ double x_major;
+
+ unsigned int x_major_length, x_major_width,
+ x_minor_length, x_minor_width;
+ unsigned int x_num_minor;
+ unsigned int legend_title_size;
+
+ // Yes/no questions
+ bool use_x_major_labels;
+ bool use_x_major_grid;
+ bool use_x_minor_grid;
+ bool use_x_label;
+
+ bool use_title;
+ bool use_legend;
+ bool use_axis;
+ bool use_plot_window;
+ bool use_x_external_style;
+ bool use_y_external_style;
+ bool show_x_axis_lines;
+ bool show_y_axis_lines;
+ bool use_y_major_grid;
+ bool use_y_minor_grid;
+
+ // where we will be storing the data points for transformation
+ std::vector<svg_2d_plot_series> series;
+
+ // strings having to do with labels
+ std::string y_label;
+
+ // axis information
+ double y_min, y_max;
+
+ double y_major, y_axis;
+
+ unsigned int y_major_length, y_minor_length,
+ y_num_minor;
+
+ bool use_y_label;
+ bool use_y_major_labels;
+
+
+ void _draw_y_minor_ticks(double j, path_element& tick_path,
+ path_element& grid_path)
+ {
+ double y1(0.), x1(0.), x2(image.get_y_size());
+
+ // draw the grid if needed
+ if(use_y_minor_grid)
+ {
+ _transform_y(y1 = j);
+
+ if(!use_plot_window)
+ {
+ // spacing for labels
+ if(use_legend)
+ {
+ x1 -= 155;
+ }
+
+ if(use_y_label)
+ {
+ x2 -= 12 * 1.5;
+ }
+ }
+
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ grid_path.M(x1, y1).L(x2, y1);
+ }
+ }
+
+ double y_tick_length = y_minor_length / 2.;
+
+ if(use_y_external_style)
+ {
+ x1 = plot_x1;
+ x2 = plot_x1 - y_tick_length / 2.;
+ }
+
+ else
+ {
+ x1 = y_axis + y_tick_length / 2.;
+ x2 = y_axis - y_tick_length / 2.;
+ }
+ y1=j;
+
+ _transform_y(y1);
+
+ //make sure that we are drawing inside of the allowed window
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ tick_path.M(x1, y1).L(x2, y1);
+ }
+ }
+
+ void _draw_y_major_ticks(double i, path_element& tick_path, path_element& grid_path)
+ {
+ double y1(i), x1(0.), x2(image.get_y_size());
+
+ if(use_y_major_grid)
+ {
+ _transform_y(y1 = i);
+
+ if(!use_plot_window)
+ {
+ if(use_title)
+ {
+ x1 += title_info.font_size() * 1.5;
+ }
+
+ if(use_y_label)
+ {
+ x2 -= 12 * 1.5;
+ }
+ }
+
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ grid_path.M(x1, y1).L(x2, y1);
+ }
+ }
+
+ //draw major tick
+ y1=i;
+
+ _transform_y(y1);
+
+ //make sure that we are drawing inside of the allowed window
+ if(y1 < plot_y2 && y1 > plot_y1)
+ {
+ double y_tick_length = y_major_length / 2.;
+
+ if(use_y_external_style)
+ {
+ x1 = plot_x1;
+ x2 = plot_x1 - y_tick_length/2.;
+ }
+
+ else
+ {
+ x1 = y_axis + y_tick_length/2.;
+ x2 = y_axis - y_tick_length/2.;
+ }
+
+ tick_path.M(x1, y1).L(x2, y1);
+
+ if(use_y_major_labels && i != 0)
+ {
+ std::stringstream fmt;
+ fmt<<i;
+
+ if(use_y_external_style)
+ {
+ x1 -= y_major_length;
+ }
+
+ else
+ {
+ x1 += (2 + y_major_length/2);
+ }
+
+ image.get_g_element(detail::PLOT_PLOT_LABELS).text(x1,
+ y1, fmt.str());
+ }
+ }
+ }
+
+ void _draw_y_axis()
+ {
+ double x1(0.);
+
+ // draw the axis line
+ _transform_x(x1);
+ image.get_g_element(detail::PLOT_Y_AXIS).line(x1, plot_y1, x1, plot_y2);
+
+ y_axis = x1;
+
+ path_element& minor_tick_path =
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).path();
+
+ path_element& major_tick_path =
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).path();
+
+ path_element& minor_grid_path =
+ image.get_g_element(detail::PLOT_Y_MINOR_GRID).path();
+
+ path_element& major_grid_path =
+ image.get_g_element(detail::PLOT_Y_MAJOR_GRID).path();
+
+ if(show_y_axis_lines)
+ {
+ image.get_g_element(detail::PLOT_Y_AXIS).
+ line(plot_y1, x_axis, plot_x2, x_axis);
+ }
+
+ // y_minor_jump is the interval between minor ticks.
+ double y_minor_jump = y_major/((double)(y_num_minor + 1.) );
+
+ // draw the ticks on the positive side
+ for(double i = 0; i < y_max; i += y_major)
+ {
+ for(double j = i + y_minor_jump;
+ j < i + y_major;
+ j += y_minor_jump)
+ {
+ _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+
+ _draw_y_major_ticks(i, major_tick_path, major_grid_path);
+ }
+
+ // draw the ticks on the negative side
+ for(double i = 0; i > y_min; i -= y_major)
+ {
+ // draw minor ticks
+ for(double j=i; j>i-y_major; j-=y_major / (y_num_minor+1))
+ {
+ _draw_y_minor_ticks(j, minor_tick_path, minor_grid_path);
+ }
+
+ _draw_y_major_ticks(i, major_tick_path, major_grid_path);
+ }
+ }
+
+ void _draw_axis()
+ {
+ _draw_y_axis();
+ _draw_x_axis();
+ }
+
+ void _draw_y_label()
+ {
+ /* text_element to_use((plot_x2 + plot_x1) / 2., image.get_y_size() - 8, x_label);
+
+ to_use.font_size(12);
+ to_use.alignment(center_align);
+
+ image.get_g_element(PLOT_X_LABEL).stroke_color(white);
+ image.get_g_element(PLOT_X_LABEL).fill_color(white);
+
+
+ image.get_g_element(PLOT_X_LABEL).push_back(new text_element(to_use));
+ */
+ }
+
+
+ void _calculate_transform()
+ {
+ x_scale = (plot_x2 - plot_x1) / (x_max - x_min);
+ x_shift = plot_x1 - x_min *(plot_x2-plot_x1)/(x_max-x_min);
+
+ y_scale = -(plot_y2-plot_y1)/(y_max-y_min);
+
+ y_shift = plot_y1 - (y_max *(plot_y1-plot_y2)/(y_max-y_min));
+ }
+
+ void _calculate_plot_window()
+ {
+ plot_x1 = plot_y1 = 0;
+
+ plot_x2 = image.get_x_size();
+ plot_y2 = image.get_y_size();
+
+
+ if(use_x_label)
+ {
+ plot_y2 -= (int)(x_label_info.font_size() * 1.5);
+ }
+
+ if(use_y_label)
+ {
+ plot_x1 += 20;
+ }
+
+ if(use_title)
+ {
+ plot_y1 += (int)(title_info.font_size() * 1.5);
+ }
+
+ if(use_plot_window)
+ {
+ // give the plot window a natural bit of padding
+ plot_x1+=5;
+ plot_x2-=5;
+ plot_y1+=5;
+ plot_y2-=5;
+
+
+ if(use_legend)
+ {
+ plot_x2 -= 155;
+ }
+
+ if(use_y_external_style)
+ {
+ plot_x1 +=
+ y_major_length > y_minor_length ?
+ y_major_length :
+ y_minor_length ;
+ }
+
+ if(use_x_external_style)
+ {
+ plot_y2 -=
+ x_major_length > x_minor_length ?
+ x_major_length :
+ x_minor_length ;
+ }
+
+ image.get_g_element(detail::PLOT_PLOT_BACKGROUND).push_back(
+ new rect_element(plot_x1, plot_y1,
+ (plot_x2-plot_x1), plot_y2-plot_y1));
+ }
+ }
+
+ void _draw_plot_lines()
+ {
+ double prev_x, prev_y, temp_x(0.), temp_y(0.);
+
+ for(unsigned int i = 0; i < series.size(); ++i)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_LINES).add_g_element();
+
+ g_ptr.style().stroke_color(series[i].line_style.color);
+
+ path_element& path = g_ptr.path();
+
+ if(series[i].series.size() > 1)
+ {
+ std::multimap<double, double>::const_iterator j = series[i].series.begin();
+ prev_x = (*j).first;
+ prev_y = 0.;
+
+ // If we have to fill the area under the plot, we first have to
+ // move from the X-axis to the first point.
+
+ _transform_point(prev_x, prev_y);
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ path.style().fill_color(series[i].line_style.area_fill);
+ path.M(prev_x, prev_y);
+ }
+
+
+ _transform_y(prev_y = (*j).second);
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ path.style().fill_color(series[i].line_style.area_fill);
+ path.L(prev_x, prev_y);
+ }
+
+ else
+ {
+ path.M(prev_x, prev_y);
+ }
+ ++j;
+
+ for(; j != series[i].series.end(); ++j)
+ {
+ temp_x = (*j).first;
+ temp_y = (*j).second;
+
+ _transform_point(temp_x, temp_y);
+
+ path.L(temp_x, temp_y);
+
+ if(series[i].line_style.area_fill == blank)
+ {
+ path.M(temp_x, temp_y);
+ }
+
+ prev_x = temp_x;
+ prev_y = temp_y;
+ }
+
+ if(series[i].line_style.area_fill != blank)
+ {
+ _transform_y(temp_y = 0.);
+ path.L(temp_x, temp_y).z();
+ }
+ }
+ }
+ }
+
+ void _update_image()
+ {
+ _clear_all();
+
+ // draw background
+ image.get_g_element(detail::PLOT_BACKGROUND).push_back(
+ new rect_element(0, 0, image.get_x_size(),
+ image.get_y_size()));
+
+ _draw_title();
+ _calculate_plot_window();
+ _calculate_transform();
+
+ if(use_axis)
+ {
+ _draw_y_axis();
+ _draw_x_axis();
+ }
+
+ if(use_legend)
+ {
+ _draw_legend();
+ }
+
+ if(use_x_label)
+ {
+ _draw_x_label();
+ }
+
+ // draw lines
+
+ _draw_plot_lines();
+
+ // draw points
+ double x(0.), y(0.);
+ for(unsigned int i=0; i<series.size(); ++i)
+ {
+ g_element& g_ptr = image.get_g_element(detail::PLOT_PLOT_POINTS).add_g_element();
+
+ g_ptr.style()
+ .fill_color(series[i].point_style.fill_color)
+ .stroke_color(series[i].point_style.stroke_color);
+
+ for(std::multimap<double,double>::const_iterator j = series[i].series.begin();
+ j!=series[i].series.end(); ++j)
+ {
+ x = j->first;
+ y = j->second;
+
+ _transform_point(x, y);
+
+ if(x > plot_x1 && x < plot_x2
+ && y > plot_y1 && y < plot_y2)
+ {
+ _draw_plot_point(x, y, g_ptr, series[i].point_style);
+ }
+ }
+ }
+ }
+
+public:
+
+svg_2d_plot(): title_info(0, 0, "Plot of data", 30),
+ x_label_info(0, 0, "X Axis", 12),
+ x_min(-10), x_max(10),
+ y_min(-10), y_max(10),
+ x_major(3), x_num_minor(2),
+ y_major(3), use_y_label(false),
+ x_minor_length(10), x_major_length(20),
+ x_major_width(2), x_minor_width(1),
+ y_minor_length(10), y_num_minor(2),
+ y_major_length(20), legend_title_size(12),
+ use_x_major_labels(true), use_x_major_grid(false),
+ use_x_minor_grid(false), use_x_label(false),
+ use_title(true), use_legend(false), use_axis(true),
+ use_plot_window(false), use_y_major_labels(false),
+ use_x_external_style(false), use_y_external_style(false),
+ show_x_axis_lines(true), show_y_axis_lines(true),
+ use_y_major_grid(false), use_y_minor_grid(false)
+
+{
+ image_size(500, 350);
+
+ //build the document tree.. add children of the root node
+ for(int i=0; i<detail::SVG_PLOT_DOC_CHILDREN; ++i)
+ {
+ image.add_g_element();
+ }
+
+ // set color defaults
+ image.get_g_element(detail::PLOT_BACKGROUND)
+ .style().fill_color(white);
+
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_AXIS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS)
+ .style().stroke_width(2);
+
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS)
+ .style().stroke_width(1);
+
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
+ .style().stroke_color(black);
+
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS)
+ .style().stroke_width(2);
+
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS)
+ .style().stroke_width(1);
+
+ image.get_g_element(detail::PLOT_X_MAJOR_TICKS).style().stroke_width(2);
+ image.get_g_element(detail::PLOT_X_MINOR_TICKS).style().stroke_width(1);
+}
+
+
+svg_2d_plot& write(const std::string& _str)
+{
+ std::ofstream fout(_str.c_str());
+
+ if(fout.fail())
+ {
+ throw std::runtime_error("Unable to open "+_str);
+ }
+
+ write(fout);
+
+ return *this;
+}
+
+svg_2d_plot& write(std::ostream& s_out)
+{
+ _update_image();
+
+ image.write(s_out);
+
+ return *this;
+}
+
+svg_2d_plot& y_name_on(bool _cmd)
+{
+ use_y_label = _cmd;
+ return *this;
+}
+
+svg_2d_plot& y_major_labels_on(bool _cmd)
+{
+ use_y_major_labels = _cmd;
+ return *this;
+}
+
+
+svg_2d_plot& y_axis_color(svg_color_constant _col)
+{
+ y_axis_color(constant_to_rgb(_col));
+
+ return (svg_2d_plot&)*this;
+}
+
+svg_2d_plot& y_axis_color(const svg_color& _col)
+{
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().fill_color(_col);
+
+ image.get_g_element(detail::PLOT_Y_AXIS)
+ .style().stroke_color(_col);
+
+ return *this;
+}
+
+svg_2d_plot& y_major_tick_color(const svg_color& _col)
+{
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_color(_col);
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().fill_color(_col);
+ return *this;
+}
+
+svg_2d_plot& y_major_tick_color(svg_color_constant _col)
+{
+ y_major_tick_color(constant_to_rgb(_col));
+ return *this;
+}
+
+svg_2d_plot& y_minor_tick_color(const svg_color& _col)
+{
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_color(_col);
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().fill_color(_col);
+ return *this;
+}
+
+svg_2d_plot& y_minor_tick_color(svg_color_constant _col)
+{
+ y_minor_tick_color(constant_to_rgb(_col));
+ return *this;
+}
+
+svg_2d_plot& y_range(double y1, double y2)
+{
+ y_min = y1;
+ y_max = y2;
+
+ if(y2 <= y1)
+ {
+ throw std::runtime_error("Illegal Argument: X scale: x2 < x1");
+ }
+
+ return *this;
+}
+
+svg_2d_plot& y_axis_width(unsigned int _width)
+{
+ image.get_g_element(detail::PLOT_Y_AXIS).style().stroke_width(_width);
+
+ return *this;
+}
+
+svg_2d_plot& y_major_interval(double _inter)
+{
+ y_major = _inter;
+
+ return *this;
+}
+
+svg_2d_plot& y_major_tick_length(unsigned int _length)
+{
+ y_major_length = _length;
+ return *this;
+}
+
+svg_2d_plot& y_minor_tick_length(unsigned int _length)
+{
+ y_minor_length = _length;
+ return *this;
+}
+
+svg_2d_plot& y_num_minor_ticks(unsigned int _num)
+{
+ y_num_minor = _num;
+ return *this;
+}
+
+svg_2d_plot& y_name(const std::string& _str)
+{
+ y_label = _str;
+ return *this;
+}
+
+svg_2d_plot& y_major_tick_width(unsigned int _width)
+{
+ image.get_g_element(detail::PLOT_Y_MAJOR_TICKS).style().stroke_width(_width);
+
+ return *this;
+}
+
+svg_2d_plot& y_minor_tick_width(unsigned int _width)
+{
+ image.get_g_element(detail::PLOT_Y_MINOR_TICKS).style().stroke_width(_width);
+
+ return *this;
+}
+
+svg_2d_plot& axis_external_style(bool _is)
+{
+ use_x_external_style = _is;
+ use_y_external_style = _is;
+ return *this;
+}
+
+svg_2d_plot& x_external_style_on(bool _is)
+{
+ use_x_external_style = _is;
+
+ return *this;
+}
+
+svg_2d_plot& y_external_style_on(bool _is)
+{
+ use_y_external_style = _is;
+ return *this;
+}
+
+#if defined (BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4100) // "'boost_parameter_enabler_argument' : unreferenced formal parameter"
+#endif
+
+BOOST_PARAMETER_MEMBER_FUNCTION
+(
+ (void),
+ plot_2d,
+ tag,
+ (required
+ (container, *)
+ (title, (const std::string&))
+ )
+ (optional
+ (stroke_color, (const svg_color&), black)
+ (point_style, (point_shape), circle)
+ (size, (int), 10)
+ (line_on, (bool), true)
+ (line_color, (const svg_color&), black)
+ (area_fill_color, (svg_color_constant), blank)
+ )
+ (deduced
+ (optional
+ (fill_color, (const svg_color&), white)
+ (x_functor, *, boost_default_2d_convert())
+ )
+ )
+)
+{
+ plot_line_style line_style(line_color, line_on);
+
+ if(area_fill_color != none)
+ {
+ line_style.area_fill=area_fill_color;
+ }
+
+ series.push_back(
+ svg_2d_plot_series(
+ boost::make_transform_iterator(container.begin(), x_functor),
+ boost::make_transform_iterator(container.end(), x_functor),
+ title,
+ plot_point_style(fill_color, stroke_color, size, point_style),
+ line_style
+ ));
+}
+};
+
+#if defined (BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
+}
+}
+
+#endif

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_color.hpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,271 +1,271 @@
-// 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 _BOOST_SVG_SVG_COLOR_HPP
-#define _BOOST_SVG_SVG_COLOR_HPP
-
-#include <ostream>
-
-
-
-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, blank
-};
-
-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 << ")" ;
- }
-
- bool operator==(const svg_color& rhs)
- {
- return r == rhs.r && g == rhs.g && b == rhs.b;
- }
-};
-
-
-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
- 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, 112, 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)
-{
- svg_color temp(color_array[_c]);
-
- r = temp.r;
- g = temp.g;
- b = temp.b;
-}
-
-svg_color constant_to_rgb(svg_color_constant _c)
-{
- return color_array[_c];
-}
-
-}//svg
-}//boost
-
-
-#endif
+// 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 _BOOST_SVG_SVG_COLOR_HPP
+#define _BOOST_SVG_SVG_COLOR_HPP
+
+#include <ostream>
+
+
+
+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, blank
+};
+
+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 << ")" ;
+ }
+
+ bool operator==(const svg_color& rhs)
+ {
+ return r == rhs.r && g == rhs.g && b == rhs.b;
+ }
+};
+
+
+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
+ 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, 112, 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)
+{
+ svg_color temp(color_array[_c]);
+
+ r = temp.r;
+ g = temp.g;
+ b = temp.b;
+}
+
+svg_color constant_to_rgb(svg_color_constant _c)
+{
+ return color_array[_c];
+}
+
+}//svg
+}//boost
+
+
+#endif

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-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,139 +1,139 @@
-// 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 _BOOST_SVG_SVG_STYLE_HPP
-#define _BOOST_SVG_SVG_STYLE_HPP
-
-#include <ostream>
-#include "svg_color.hpp"
-#include "detail/svg_style_detail.hpp"
-
-namespace boost {
-namespace svg {
-
-enum point_shape{none, circle, square, point};
-
-struct plot_point_style
-{
- point_shape shape;
- svg_color stroke_color;
- svg_color fill_color;
- int size;
-
- plot_point_style(const svg_color& _fill,
- const svg_color& _stroke, int _size = 10, point_shape _shape = circle):
- fill_color(_fill), stroke_color(_stroke), size(_size), shape(_shape)
- {
-
- }
-};
-
-struct plot_line_style
-{
- svg_color color;
- svg_color_constant area_fill;
-
- bool line_on;
-
- plot_line_style(const svg_color& _col, bool _on):
- color(_col), line_on(_on), area_fill(blank)
- {
- }
-};
-
-// -----------------------------------------------------------------
-// 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_style
-{
-private:
- svg_color fill;
- svg_color stroke;
-
- unsigned int width;
-
- bool fill_on;
- bool stroke_on;
- bool width_on;
-
-public:
- svg_style():fill(svg_color(0, 0, 0)),
- stroke(svg_color(0, 0, 0)), width(0),
- fill_on(false), stroke_on(false), width_on(false)
- {
-
- }
-
- svg_style(const svg_color& _fill, const svg_color& _stroke,
- unsigned int _width = 0):
- fill(_fill), stroke(_stroke),
- width(_width), fill_on(false),
- stroke_on(false), width_on(false)
- {
-
- }
-
- // setters
- svg_style& fill_color(const svg_color& _col)
- {
- fill = _col;
- fill_on = true;
- return *this;
- }
-
- svg_style& stroke_color(const svg_color& _col)
- {
- stroke = _col;
- stroke_on = true;
- return *this;
- }
-
- svg_style& stroke_width(unsigned int _width)
- {
- width = _width;
- width_on = true;
- return *this;
- }
-
- // getters
- svg_color fill_color() { return svg_color(fill); }
- svg_color stroke_color() { return svg_color(stroke); }
- unsigned int stroke_width() { return width; }
-
-
- void write(std::ostream& rhs)
- {
- if(stroke_on)
- {
- rhs << "stroke=\"";
- stroke.write(rhs);
- rhs << "\" ";
- }
-
- if(fill_on)
- {
- rhs << "fill=\"";
- fill.write(rhs);
- rhs<<"\" ";
- }
- if(width_on)
- {
- rhs << "stroke-width=\""
- << width
- << "\" ";
- }
- }
-};
-
-}//svg
-}//boost
-
-
-#endif
+// 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 _BOOST_SVG_SVG_STYLE_HPP
+#define _BOOST_SVG_SVG_STYLE_HPP
+
+#include <ostream>
+#include "svg_color.hpp"
+#include "detail/svg_style_detail.hpp"
+
+namespace boost {
+namespace svg {
+
+enum point_shape{none, circle, square, point};
+
+struct plot_point_style
+{
+ point_shape shape;
+ svg_color stroke_color;
+ svg_color fill_color;
+ int size;
+
+ plot_point_style(const svg_color& _fill,
+ const svg_color& _stroke, int _size = 10, point_shape _shape = circle):
+ fill_color(_fill), stroke_color(_stroke), size(_size), shape(_shape)
+ {
+
+ }
+};
+
+struct plot_line_style
+{
+ svg_color color;
+ svg_color_constant area_fill;
+
+ bool line_on;
+
+ plot_line_style(const svg_color& _col, bool _on):
+ color(_col), line_on(_on), area_fill(blank)
+ {
+ }
+};
+
+// -----------------------------------------------------------------
+// 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_style
+{
+private:
+ svg_color fill;
+ svg_color stroke;
+
+ unsigned int width;
+
+ bool fill_on;
+ bool stroke_on;
+ bool width_on;
+
+public:
+ svg_style():fill(svg_color(0, 0, 0)),
+ stroke(svg_color(0, 0, 0)), width(0),
+ fill_on(false), stroke_on(false), width_on(false)
+ {
+
+ }
+
+ svg_style(const svg_color& _fill, const svg_color& _stroke,
+ unsigned int _width = 0):
+ fill(_fill), stroke(_stroke),
+ width(_width), fill_on(false),
+ stroke_on(false), width_on(false)
+ {
+
+ }
+
+ // setters
+ svg_style& fill_color(const svg_color& _col)
+ {
+ fill = _col;
+ fill_on = true;
+ return *this;
+ }
+
+ svg_style& stroke_color(const svg_color& _col)
+ {
+ stroke = _col;
+ stroke_on = true;
+ return *this;
+ }
+
+ svg_style& stroke_width(unsigned int _width)
+ {
+ width = _width;
+ width_on = true;
+ return *this;
+ }
+
+ // getters
+ svg_color fill_color() { return svg_color(fill); }
+ svg_color stroke_color() { return svg_color(stroke); }
+ unsigned int stroke_width() { return width; }
+
+
+ void write(std::ostream& rhs)
+ {
+ if(stroke_on)
+ {
+ rhs << "stroke=\"";
+ stroke.write(rhs);
+ rhs << "\" ";
+ }
+
+ if(fill_on)
+ {
+ rhs << "fill=\"";
+ fill.write(rhs);
+ rhs<<"\" ";
+ }
+ if(width_on)
+ {
+ rhs << "stroke-width=\""
+ << width
+ << "\" ";
+ }
+ }
+};
+
+}//svg
+}//boost
+
+
+#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-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,96 +1,96 @@
-#include "svg_1d_plot.hpp"
-#include "svg_2d_plot.hpp"
-
-#include <vector>
-#include <cmath>
-#include <map>
-
-using std::multimap;
-using std::vector;
-
-double f(double x)
-{
- return sqrt(x);
-}
-
-double g(double x)
-{
- return -2 + x*x;
-}
-
-double h(double x)
-{
- return 2*x;
-}
-
-
-class dConvert
-{
-public:
- typedef double result_type;
-
- double operator()(int a) const
- {
- return (double)a;
- }
-};
-
-int main()
-{
- using namespace boost::svg;
- std::map<double, double> data1;
- std::map<double, double> data2;
- std::vector<double> data3;
-
- svg_2d_plot my_2d_plot;
- svg_1d_plot my_1d_plot;
-
- for(double i=0; i<10; i+=1)
- {
- data1[i - 5.] = f(i);
- data2[i] = g(i);
- data3.push_back(h(i) - 10.);
- }
-
- // size/scale settings
- my_2d_plot.image_size(500, 350);
-
- my_2d_plot.title("Hello, operator")
- .plot_window_on(true)
- .legend_on(true);
-
- my_2d_plot.title_on(true)
- .x_label_on(true)
- .y_major_labels_on(true)
- .x_label("sqrt(x)")
- .x_major_grid_on(false);
-// .y_external_style_on(true)
-// .x_external_style_on(true);
-
- my_1d_plot.image_size(500, 350);
-
- my_1d_plot.title("Hello, operator")
- .plot_window_on(true)
- .legend_on(true);
-
- my_1d_plot.title_on(true)
- .x_label_on(true)
- .x_label("sqrt(x)");
-
- my_2d_plot.plot_2d(data1, "sqrt(x)");
-
- my_2d_plot.plot_2d(data2, "Not sqrt(x)",
- _size = 6,
- _point_style = square,
- _stroke_color = hotpink,
- _line_color = black,
- _fill_color = yellow,
- _area_fill_color = red);
-
- my_1d_plot.plot(data3, "1D Plot");
-
- my_1d_plot.write("./test1d.svg");
- my_2d_plot.write("./test2d.svg");
-
- return 0;
-}
+#include "svg_1d_plot.hpp"
+#include "svg_2d_plot.hpp"
+
+#include <vector>
+#include <cmath>
+#include <map>
+
+using std::multimap;
+using std::vector;
+
+double f(double x)
+{
+ return sqrt(x);
+}
+
+double g(double x)
+{
+ return -2 + x*x;
+}
+
+double h(double x)
+{
+ return 2*x;
+}
+
+
+class dConvert
+{
+public:
+ typedef double result_type;
+
+ double operator()(int a) const
+ {
+ return (double)a;
+ }
+};
+
+int main()
+{
+ using namespace boost::svg;
+ std::map<double, double> data1;
+ std::map<double, double> data2;
+ std::vector<double> data3;
+
+ svg_2d_plot my_2d_plot;
+ svg_1d_plot my_1d_plot;
+
+ for(double i=0; i<10; i+=1)
+ {
+ data1[i - 5.] = f(i);
+ data2[i] = g(i);
+ data3.push_back(h(i) - 10.);
+ }
+
+ // size/scale settings
+ my_2d_plot.image_size(500, 350);
+
+ my_2d_plot.title("Hello, operator")
+ .plot_window_on(true)
+ .legend_on(true);
+
+ my_2d_plot.title_on(true)
+ .x_label_on(true)
+ .y_major_labels_on(true)
+ .x_label("sqrt(x)")
+ .x_major_grid_on(false);
+// .y_external_style_on(true)
+// .x_external_style_on(true);
+
+ my_1d_plot.image_size(500, 350);
+
+ my_1d_plot.title("Hello, operator")
+ .plot_window_on(true)
+ .legend_on(true);
+
+ my_1d_plot.title_on(true)
+ .x_label_on(true)
+ .x_label("sqrt(x)");
+
+ my_2d_plot.plot_2d(data1, "sqrt(x)");
+
+ my_2d_plot.plot_2d(data2, "Not sqrt(x)",
+ _size = 6,
+ _point_style = square,
+ _stroke_color = hotpink,
+ _line_color = black,
+ _fill_color = yellow,
+ _area_fill_color = red);
+
+ my_1d_plot.plot(data3, "1D Plot");
+
+ my_1d_plot.write("./test1d.svg");
+ my_2d_plot.write("./test2d.svg");
+
+ return 0;
+}

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/doc/svg_plot.qbk 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,580 +1,580 @@
-[article SVG_Plot
- [quickbook 1.4]
- [authors [Voytko, Jake]]
- [copyright 2007 Jake Voytko]
- [purpose Plot STL containers onto graphs in SVG format]
- [license
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt or copy at
- [@http://www.boost.org/LICENSE_1_0.txt])
- ]
-]
-
-
-[section:preface Preface]
-Normally, the first task when dealing with numerical data is to plot it. Humans have a fantastic capacity for visual understanding, and merely looking at data oganized in one, two, or three dimensions allows us to see relations not otherwise visible in a list of numbers. Computers, however, deal with information numerically, and C++ and the STL do not offer a way to bridge that gap. This library allows the user to easily plot data stored in STL containers with (hopefully!) minimal intervention.
-[endsect]
-
-[section:intro Introduction]
-This project is focused on using STL containers in order to graph data on a one-dimensional and two-dimensional (and if time allows, 3D!) plot. The plot would be written in an svg image, compliant with the W3C standard. The goals of the project are as follows:
-
-* To provide an easy syntax for graphing data
-* To let users produce a simple plot with minimal intervention by using sane defaults
-* To demonstrate how to incorporate SVG images into Boost documentation
-* To allow users to easily customize graphs to their heart's content
-* To allow the user to talk with the svg_graph class using coordinate units instead of pixels or other arbitrary measures
-* To create the backbone of a svg class that will be extended to fully support storing the standard
-
-I have only a student's grasp of C++, so if you have a suggestion to help me with design or implementation, either leave them here or email me at jakevoytko (at) gmail (dot) com
-
-[endsect]
-
-[section:color Colors]
-[section:color_intro Introduction]
-
-The project supports any color definable by the RGB interface, as well as a number of constants that are named by the SVG standard.
-
-[@http://www.w3.org/TR/SVG/types.html#ColorKeywords Here] is a link to the SVG color constants that my program supports
-
-[endsect]
-
-[section:color_internals Internals and Rationale]
-
-All color information is stored in RGB format in a svg_struct. The rationale
-for storing information in RGB format is because it is precise and is always
-representable the exact same way. Storing as a floating point percentage
-introduces the possibility of rounding error, which I would like to avoid at
-all costs. The same image file will always display the same way on any system
-that correctly implements the SVG format.
-
-It is important to note that any integer value is accepted by the SVG standard, but negative values are rounded to 0, and positive values > 255 are rounded down to 255.
-
-Constants are defined in an enum, `svg_color_constant`, in alphabetical order.
-This facilitates quick lookup of their RGB values quickly in an array.
-
-[endsect]
-
-[section:color_usage Usage]
-
-To use an example, set_title_color(), here are the two different ways we could
- set the line color, one using RGB values, and the other using the constant.
-
-``
-// Using a new RGB value
-my_plot.set_title_color(svg_color(139, 69, 19));
-
-// Using an existing RGB value
-my_plot.set_title_color(my_color);
-
-// Using a color constant
-my_plot.set_title_color(saddlebrown);
-
-// Defining an RGB value from color constant. This is not required anywhere but in the plot() function
-my_plot.set_title_color(svg_color(saddle_brown));
-``
-
-[endsect]
-[endsect]
-
-
-[section:tutorial Tutorial]
-[section:tutorial_basic Basic Example]
-The minimal requirements for creating any image are as follows.
-
-* You need a one or two dimensional svg_plot
-* You need to call the write() command
-
-That's it! However, just doing this won't give you anything useful. The following can be considered a minimal example:
-
-[section:tutorial_code_simple Simple program]
-``
-#include <boost/svg_plot/svg_1d_plot.hpp>
-#include <vector>
-
-using std::vector;
-using namespace boost::svg_plot;
-
-int main()
-{
- // Snip
-
- vector<double> my_data;
-
- // initialize my_data here
-
- svg_1d_plot my_plot;
-
- my_plot.set_title("My Graph")
- .set_legend_on(true)
- .set_x_range(-1, 11);
-
- plot(my_plot, my_data, "Race times");
-
- my_plot.write("my_file.svg");
- return 0;
-}
-``
-
-[$my_file.svg]
-[endsect]
-[section:tutorial_simple_exam Basic Example Breakdown]
-Let's examine what this does.
-
-``
-svg_1d_plot my_plot;
-``
-initializes a new 1D plot. This also sets many of the values that the class keeps track of with reasonable defaults.
-
-``
-my_plot.set_title("My Graph")
- .set_legend_on(true)
- .set_x_range(-1, 11);
-``
-
-All of the set methods are fairly self explanatory. The title, which will appear at the top of the graph, will say "My Graph". `set_legend_on(true)` means that the legend will show up. `set_x_range(-1, 11)` means that the range of values that will be printed is between -1 and 11, as you can see in the above images.
-
-This syntax may be unfamiliar. However, it works on the same principle that the following code works:
-``
-a = b = c = d = 3;
-``
-
-You have also seen it used to print to the console:
-``
-std::cout << "Hello" << name << std::endl;
-``
-
-Within all of the plot classes, chaining works the same way. The equivalent code for the above is as follows:
-
-``
-my_plot.set_title("My Graph");
-my_plot.set_legend_on(true);
-my_plot.set_x_range(-1, 11);
-``
-
-In the long run, I think you will find that my choice helps organize the code a little better!
-
-
-``
-plot(my_plot, my_data, "Race times");
-``
-
-This draws `my_data` to `my_plot`. As many containers as you want can be drawn to my_plot. The name of the series is "Race times", and that text will show up in the legend. These are the three required parameters for this function call. There are optional parameters, as seen in the section Getting More Out Of The `plot()` Function, but most immediately beneficial would be the ability to specify a color for your data point:
-``
-plot(my_plot, my_data, "Race Times", blue);
-``
-
-is how you could accomplish this
-
-``
-my_plot.write("my_file.svg");
-``
-
-This writes our plot to the file "my_file.svg".
-[endsect]
-[endsect]
-
-[section:plot_window Using a Plot Window]
-If the legend or the title is obscuring data, or you would merely like a different choice for layout, you can opt to use a [^plot window]. To add it to a simple example:
-
-``
-#include <boost/svg_plot/svg_1d_plot.hpp>
-#include <vector>
-
-using std::vector;
-using namespace boost::svg_plot;
-
-// Snip
-
-vector<double> my_data;
-
-// initialize my_data here
-
-svg_1d_plot my_plot;
-
-my_plot.set_title("My Graph")
- .set_legend_on(true)
- .set_plot_window_on(true)
- .set_x_range(-1, 11);
-
-plot(my_plot, my_data, "Race times");
-
-my_plot.write("my_file.svg");
-``
-
-This produces the following image:
-(insert image)
-[endsect]
-[section:full_layout Full Layout Example]
-Boost.SVG_Plot is designed to avoid having to do much customization. However, it is by no means a "one size fits all" solution. As such, there is much that can be changed in the way of layout and design. An example follows:
-
-``
-svg_1d_plot my_plot;
-
-// misc data
-my_plot.set_image_size(500, 350)
- .set_title("Race Results")
- .set_title_font_size(20);
-
-// display commands
-my_plot.set_x_label_on(true)
- .set_x_major_labels_on(true)
- .set_x_major_grid_on(true)
- .set_x_minor_grid_on(true)
- .set_axis_on(true)
- .set_legend_on(true)
- .set_plot_window_on(true)
- .set_title_on(true);
-
-// axis information
-my_plot.set_x_axis_width(2)
- .set_x_label("Time in minutes")
- .set_x_major_tick(5)
- .set_x_num_minor_ticks(1)
- .set_x_scale(-5, 130);
-
-// plot the information
-plot(my_plot, ron_result, "Ron", orange);
-plot(my_plot, sally_result, "Sally", red);
-plot(my_plot, tim_result, "Tim", blue);
-
-my_plot.write("race_results.svg");
-``
-
-This produces the following image:
-(insert image)
-[endsect]
-
-[section:color Color Customization]
-The [^svg_plot] classes support two major ways to define colors. One is the use of colors in the RGB format. To specify a color in the RGB format, you can use the following: `svg_color(123, 73, 255)`, to pick a random example.
-
-The other way to define a color is to use the SVG standard's custom color definitions, as defined [@http://www.w3.org/TR/SVG/types.html#ColorKeywords here]
-
-Here is an example using color customization:
-
-``
- vector<double> data1;
- deque<double> data2;
- boost::array<double, 10> data3;
-
- svg_1d_plot my_plot;
-
- // 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_text("Time in Months");
-
- // command settings
- my_plot.set_axis(true)
- .set_legend(true)
- .set_plot_window(true)
- .set_x_label(true)
- .set_x_major_labels(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_range(my_plot, data2.begin(), data2.end(), "Lions", blue);
- plot_range(my_plot, data1.begin(), data1.end(), "Tigers", purple);
- plot_range(my_plot, data3.begin(), data3.end(), "Bears", red);
-
- my_plot.write("D:/1d_complex.svg");
-``
-This produces the following output:
-(Insert image)
-[endsect]
-[section:defaults `svg_1d_plot` Defaults]
-You may have noticed that there are certain defaults that are true at the beginning of the plotting. Here is a table of the defaults:
-
-[table Default Values]
- [[object] [Default value] [Rationale]]
- [[Axis] [On] [Most graphs include an axis of some kindl]]
- [[Distance between major X ticks] [`3 units`] [Reasonably fits into a plot window]]
- [[Font size of the legend title] [12] [Reasonable when paired with the image size]]
- [[Font size of the X Label] [12] [Reasonable when paired with the image size]]
- [[Font size of the title] [30] [Makes the title stand out]]
- [[Grid lines] [`All off`] [Grid lines are a user's personal choice, so I default with the simpler model]]
- [[Image background] [white] [K.I.S.S. Coloring will be highly dependent on user needs.]]
- [[Image size] [`500 by 350`] [Details discernable. The image is easily viewable by those using 800x600 monitors]]
- [[Legend] [`Off`] [The goal of the defaults is to provide the cleanest possible plot as a default. Not including the legend meets this goal. If there is a public outcry, I can change this.]]
- [[Major tick length] [20 pixels] [Tasteful default when paired with the window size. This also makes the major ticks easily distinguishable from the minor ticks]]
- [[Major tick width] [2 pixels] [Major ticks are more obvious than minor ticks]]
- [[Minor tick length] [10 pixels] [Tasteful default when compared with the size of the grid. This makes the minor ticks less obvious than the major ticks]]
- [[Minor tick width] [1 pixel] [This makes the minor tick less obvious than the major ticks]]
- [[Number of minor X ticks between each major X tick] [2] [This allows the minor ticks to appear on the integers]]
- [[Plot Window] [`Off`] [Initially off because it is the simplest case. I will change this if there is an outcry]]
- [[Title] [On, "Plot of data"] [The title is on because this is one of the most basic elements of a graph. The title is set to a default because when `title_on == true`, something should display]]
- [[X Axis Label] [`"X Axis", Off`] ["X Axis" is the label because something should display were the user to turn on the X axis label without setting text, and this is the most informative]]
- [[X Range] [`(-10, 10)`] [Traditional plot viewport]]
- [[Plot window background] [white] [K.I.S.S. Coloring will be highly dependent on user needs]]
- [[Legend background] [white] [K.I.S.S. Coloring will be highly dependent on user needs]]
- [[All other colors] [black] [K.I.S.S. Coloring will be highly dependent on user needs]]]
-
-[endsect]
-
-[section:plot_function Getting More Out Of The `plot()` Function]
-The `plot()` function is defined using Boost.Parameter. As such, it supports a few extra named parameters, as well as a deduced parameter.
-
-[table Deduced parameter
-[[ID] [Description] [Default]]
-[[_fill_color] [This is the color that shows up inside of the circle that is being drawn] [white] ]]
-
-[table Optional Parameters
-[[ID] [Description] [Default]]
-[[_stroke_color] [The outline of the circle that is being drawn] [black] ]
-[[_point_style] [This is the shape of the point. Options currently are between [^none], [^circle], and [^square].] [circle]]
-[[size] [This is the height/width of the circle and square.] [10]]
-[[_x_functor] [A pointer to a class that contains a conversion function. You will not have to worry about this, unless you are trying to accomplish stuff like plotting a vector of humans. For example:
-``
-class my_functor
-{
- typdef double result_type;
-
- double convert(const human& _hum)
- {
- return _hum.get_age();
- }
-}
-
-// snip
-
-plot(my_plot, my_data, "Lions", _x_functor = my_functor());
-``
-][
-`boost_default_convert` is sufficient in all cases where the data stored in the container can be directly casted to a double]]]
-
-Here are some examples of correct uses:
-[h3 Using fill and stroke colors]
-
-``
-plot(my_plot, my_data, "Lions", _fill_color = svg_color(red), _stroke_color = svg_color(black));
-``
-
-This has the same effect as the following:
-
-``
-plot(my_plot, my_data, "Lions", svg_color(red), svg_color(black));
-``
-
-and also the same effect as:
-``
-plot(my_plot, my_data, "Lions", _stroke_color = svg_color(black), _fill_color = svg_color(red));
-``
-
-Since _fill_color is a deduced parameter, when two svg_colors are used in the same function call, they are always inferred in the following order: (fill, stroke).
-
-[h3 Using all parameters]
-``
-plot(my_plot, my_data, "Lions",
- _fill_color = svg_color(red),
- _stroke_color = svg_color(black),
- _x_functor = my_functor());
-``
-
-[endsect]
-[endsect]
-
-[section:svg_interface SVG Public Interface]
-[table class svg
- [[Signature] [Description] [Notes]]
- [[`svg()`] [Constructor] [The default image size is (400, 400)]]
- [[`svg& image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels][]]
- [[`svg& get_x_size()`] [Returns the width of the image] []]
- [[`svg& get_y_size()`] [Returns the height of the image] []]
- [[`svg& write(const std::string&)`] [Writes the document to the file represented by the argument][Opens the file stream itself and tries to call `write(std::ostream&)`. Throws `std::runtime_exception` if it can not open the file.]]
- [[`svg& write(std::ostream&)`] [Writes the document to the stream represented by the argument][]]
- [[`svg& circle(double x, double y, unsigned int radius = 5)`] [Adds a point at (x,y) in the root level of the document][If the user is calling the circle method, odds are they would prefer a real circle instead of a degenerate circle (a point). 5 is as good a defaul as any other.]]
- [[`svg& line(double x1, double y1, double x2, double y2)`] [Adds a line from (x1,y1) to (x2,y2) in the root level of the document][]]
- [[`svg& text(double x, double y, std::string text)`] [Adds text `text` at (x,y) in the root level of the document][]]
- [[`svg& rect(double x1, double y1, double width, double height)`] [Adds a rectangle at point (x1, y1) that has width `width` and height `height`][]]
- [[`svg& clip_path(const rect_element&, g_element&, const std::string& id)`][Prevents the g_element in the argument from drawing outside of the rectangle in the argument. The string is provided to identify the clip.] [Currently unsupported]]
- [[`g_element& add_g_element()`] [Adds a g_element at the root of the document tree. Acts as a `push_back()`] [Returns the `g_element` that is pushed back. This allows you to do something like the following: `image.add_g_element().line(/**/).line(/**/).rect(/**/); `
-Which adds two lines and a rectangle to the g_element that was just created.]]
- [[`g_element& get_g_element(int)`] [Gets the g_element at the index specified] [Gives a runtime error if you specify an index that does not contain a `g_element`. This will be addressed]]
-]
-[endsect]
-
-[section:svg_1d_plot_interface `svg_1d_plot` Public Interface]
-[table Misc
- [[Signature] [Description]]
-[[ `void plot_range(std::vector<double>::const_iterator begin,
-std::vector<double>::const_iterator end, std::string text);`]
- [Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. If you are looking for the generic version, you can find it below.]]
- [[`void plot(const std::vector<double>& _ctr, const std::string&, const plot_point_style&)`]
- [Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. The point color for this series is going to be `col`. If you are looking for the generic version, you can find it below.]]
- [[`svg_1d_plot()`] [See the defaults section for further details]]
- [[`svg_1d_plot& set_image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels]]
- [[`svg_1d_plot& set_title(const std::string&)`] [Sets the string to be used for the title]]
- [[`svg_1d_plot& set_title_font_size(unsigned int)`] [Sets the font size for the title]]
- [[`svg_1d_plot& set_legend_title_font_size(unsigned int)`] [Sets the font size for the legend title]]
- [[`svg_1d_plot& write(const std::string&)`] [Writes the plot to the file passed as a parameter]]
- [[`svg_1d_plot& write(ostream&)`] [Writes the plot to a stream passed as a parameter]]]
-
-[table Commands
- [[Signature] [Description]]
- [[`svg_1d_plot& set_axis_on(bool)`] [Sets whether the axis is on or off]]
- [[`svg_1d_plot& set_legend_on(bool)`] [Sets whether the legend is on or off]]
- [[`svg_1d_plot& set_plot_window_on(bool)`] [Sets whether the plot will be displayed in its own window, or will be "full screen" in the image]]
- [[`svg_1d_plot& set_x_label_on(bool)`] [Sets whether or not the x axis label will show]]
- [[`svg_1d_plot& set_x_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the x axis]]
- [[`svg_1d_plot& set_title_on(bool)`] [Determines whether or not the image title is displayed]]
- [[`svg_1d_plot& set_x_major_grid_on(bool)`] [Determines whether or not the major grid on the X axis will be displayed]]
- [[`svg_1d_plot& set_x_minor_grid_on(bool)`] [Determines whether or not the minor grid on the X axis will be displayed]]]
-
-[table Color Information
- [[Signature] [Description]]
- [[`svg_1d_plot& set_title_color(svg_color_constant col)`] [Set the title color]]
- [[`svg_1d_plot& set_title_color(const svg_color &col)`] [Set the title color]]
- [[`svg_1d_plot& set_background_color(svg_color_constant col)`] [Set the background color for the whole image]]
- [[`svg_1d_plot& set_background_color(const svg_color &col)`] [Set the background color for the whole image]]
- [[`svg_1d_plot& set_legend_background_color(svg_color_constant col)`] [Set the background color for the legend as `col`, a SVG Color Constant]]
- [[`svg_1d_plot& set_legend_background_color(const svg_color &col)`] [Set the background color for the legend as `col`, an RGB color]]
- [[`svg_1d_plot& set_legend_border_color(svg_color_constant col)`] [Set the border color for the legend as `col`, a SVG Color Constant]]
- [[`svg_1d_plot& set_legend_border_color(const svg_color &col)`] [Set the border color for the legend as `col`, an RGB color]]
- [[`svg_1d_plot& set_background_border_color(svg_color_constant col)`] [Set the background border color for the legend as `col`, a SVG Color Constant]]
- [[`svg_1d_plot& set_background_border_color(const svg_color &col)`] [Set the background border color for the legend as `col`, an RGB color]]
- [[`svg_1d_plot& set_plot_background_color(svg_color_constant col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
- [[`svg_1d_plot& set_plot_background_color(const svg_color &col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
- [[`svg_1d_plot& set_x_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the axis]]
- [[`svg_1d_plot& set_x_axis_color(const svg_color &col)`] [Sets the color of the lines that form the axis]]
- [[`svg_1d_plot& set_x_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_1d_plot& set_x_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_1d_plot& set_x_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the x-axis]]
- [[`svg_1d_plot& set_x_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the x-axis]]
- [[`svg_1d_plot& set_x_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
- [[`svg_1d_plot& set_x_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
- [[`svg_1d_plot& set_x_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the x-axis]]
- [[`svg_1d_plot& set_x_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the x-axis]]
- ]
-
-[table Axis Information
- [[Signature] [Description]]
- [[`svg_1d_plot& set_x_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
- [[`svg_1d_plot& set_x_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
- [[`svg_1d_plot& set_x_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the x-axis] ]
- [[`svg_1d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis major ticks] ]
- [[`svg_1d_plot& set_x_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the x-axis] ]
- [[`svg_1d_plot& set_x_minor_tick(unsigned int)`] [Sets the length (in pixels) of the x-axis minor ticks] ]
- [[`svg_1d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis minor tick lengths] ]
- [[`svg_1d_plot& set_x_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the x-axis] ]
- [[`svg_1d_plot& set_x_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
- [[`svg_1d_plot& set_x_scale(double x1, double x2)`] [Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1 ] ]
-]
-
-(Note: Getters omitted for now)
-
-[endsect]
-[section:svg_2d_plot_interface `svg_2d_plot` Public Interface]
-[table Misc
- [[Signature] [Description]]
-[[` void plot_range(std::vector<double>::const_iterator begin,
-std::vector<double>::const_iterator end, std::string text)`]
-[Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. If you are looking for the generic version, you can find it below.]]
- [[` void plot_range(std::vector<double>::const_iterator begin, std::vector<double>::const_iterator end,
-std::string text, svg_color_constant col)`]
-[Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. The point color for this series is going to be `col`. If you are looking for the generic version, you can find it below.]]
- [[`svg_2d_plot()`] [See the defaults section for further details]]
- [[`svg_2d_plot& set_image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels]]
- [[`svg_2d_plot& set_title(const std::string&)`] [Sets the string to be used for the title]]
- [[`svg_2d_plot& set_title_font_size(unsigned int)`] [Sets the font size for the title]]
- [[`svg_2d_plot& set_legend_title_font_size(unsigned int)`] [Sets the font size for the legend title]]]
-
-[table Commands
- [[Signature] [Description]]
- [[`svg_2d_plot& set_axis_on(bool)`] [Sets whether the axis is on or off]]
- [[`svg_2d_plot& set_legend_on(bool)`] [Sets whether the legend is on or off]]
- [[`svg_2d_plot& set_plot_window_on(bool)`] [Sets whether the plot will be displayed in its own window, or will be "full screen" in the image]]
- [[`svg_2d_plot& set_title_on(bool)`] [Determines whether or not the image title is displayed]]
- [[`svg_2d_plot& set_x_label_on(bool)`] [Sets whether or not the X axis label will show]]
- [[`svg_2d_plot& set_x_major_grid_on(bool)`] [Determines whether or not the major grid on the X axis will be displayed]]
- [[`svg_2d_plot& set_x_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the x axis]]
- [[`svg_2d_plot& set_x_minor_grid_on(bool)`] [Determines whether or not the minor grid on the X axis will be displayed]]
- [[`svg_2d_plot& set_y_label_on(bool)`] [Sets whether or not the Y axis label will show]]
- [[`svg_2d_plot& set_y_major_grid_on(bool)`] [Determines whether or not the major grid on the Y axis will be displayed]]
- [[`svg_2d_plot& set_y_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the Y axis]]
- [[`svg_2d_plot& set_y_minor_grid_on(bool)`] [Determines whether or not the minor grid on the Y axis will be displayed]]]
-
-[table Color Information
- [[Signature] [Description]]
- [[`svg_2d_plot& set_title_color(svg_color_constant col)`] [Set the title color]]
- [[`svg_2d_plot& set_title_color(const svg_color &col)`] [Set the title color]]
- [[`svg_2d_plot& set_background_color(svg_color_constant col)`] [Set the background color for the whole image]]
- [[`svg_2d_plot& set_background_color(const svg_color &col)`] [Set the background color for the whole image]]
- [[`svg_2d_plot& set_legend_background_color(svg_color_constant col)`] [Set the background color for the legend as `col`, a SVG Color Constant]]
- [[`svg_2d_plot& set_legend_background_color(const svg_color &col)`] [Set the background color for the legend as `col`, an RGB color]]
- [[`svg_2d_plot& set_legend_border_color(svg_color_constant col)`] [Set the border color for the legend as `col`, a SVG Color Constant]]
- [[`svg_2d_plot& set_legend_border_color(const svg_color &col)`] [Set the border color for the legend as `col`, an RGB color]]
- [[`svg_2d_plot& set_background_border_color(svg_color_constant col)`] [Set the background border color for the legend as `col`, a SVG Color Constant]]
- [[`svg_2d_plot& set_background_border_color(const svg_color &col)`] [Set the background border color for the legend as `col`, an RGB color]]
- [[`svg_2d_plot& set_plot_background_color(svg_color_constant col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
- [[`svg_2d_plot& set_plot_background_color(const svg_color &col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
- [[`svg_2d_plot& set_x_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the axis]]
- [[`svg_2d_plot& set_x_axis_color(const svg_color &col)`] [Sets the color of the lines that form the axis]]
- [[`svg_2d_plot& set_x_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_2d_plot& set_x_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_2d_plot& set_x_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the x-axis]]
- [[`svg_2d_plot& set_x_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the x-axis]]
- [[`svg_2d_plot& set_x_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
- [[`svg_2d_plot& set_x_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
- [[`svg_2d_plot& set_x_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the x-axis]]
- [[`svg_2d_plot& set_x_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the x-axis]]
- [[`svg_2d_plot& set_y_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the Y axis]]
- [[`svg_2d_plot& set_y_axis_color(const svg_color &col)`] [Sets the color of the lines that form the Y axis]]
- [[`svg_2d_plot& set_y_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_2d_plot& set_y_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
- [[`svg_2d_plot& set_y_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the Y-axis]]
- [[`svg_2d_plot& set_y_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the Y-axis]]
- [[`svg_2d_plot& set_y_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the Y axis]]
- [[`svg_2d_plot& set_y_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the Y axis]]
- [[`svg_2d_plot& set_y_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the Y-axis]]
- [[`svg_2d_plot& set_y_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the Y-axis]]
- ]
-
-[table Axis Information
- [[Signature] [Description]]
- [[`svg_2d_plot& set_x_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
- [[`svg_2d_plot& set_x_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
- [[`svg_2d_plot& set_x_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the x-axis] ]
- [[`svg_2d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis major ticks] ]
- [[`svg_2d_plot& set_x_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the x-axis] ]
- [[`svg_2d_plot& set_x_minor_tick(unsigned int)`] [Sets the length (in pixels) of the x-axis minor ticks] ]
- [[`svg_2d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis minor tick lengths] ]
- [[`svg_2d_plot& set_x_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the x-axis] ]
- [[`svg_2d_plot& set_x_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
- [[`svg_2d_plot& set_x_scale(double x1, double x2)`] [Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1 ] ]
- [[`svg_2d_plot& set_y_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
- [[`svg_2d_plot& set_y_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
- [[`svg_2d_plot& set_y_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the Y axis] ]
- [[`svg_2d_plot& set_y_major_tick_length(int)`] [Sets the length (in pixels) of the Y axis major ticks] ]
- [[`svg_2d_plot& set_y_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the Y axis] ]
- [[`svg_2d_plot& set_y_minor_tick(unsigned int)`] [Sets the length (in pixels) of the Y axis minor ticks] ]
- [[`svg_2d_plot& set_y_major_tick_length(int)`] [Sets the length (in pixels) of the Y axis minor tick lengths] ]
- [[`svg_2d_plot& set_y_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the Y axis] ]
- [[`svg_2d_plot& set_y_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
- [[`svg_2d_plot& set_y_scale(double y1, double y2)`] [Sets the scale of the Y axis from y1 to y2. Throws an exception if y2<=y1 ] ]
-]
-
-(Note: Getters omitted for now)
-
-[endsect]
+[article SVG_Plot
+ [quickbook 1.4]
+ [authors [Voytko, Jake]]
+ [copyright 2007 Jake Voytko]
+ [purpose Plot STL containers onto graphs in SVG format]
+ [license
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+ ]
+]
+
+
+[section:preface Preface]
+Normally, the first task when dealing with numerical data is to plot it. Humans have a fantastic capacity for visual understanding, and merely looking at data oganized in one, two, or three dimensions allows us to see relations not otherwise visible in a list of numbers. Computers, however, deal with information numerically, and C++ and the STL do not offer a way to bridge that gap. This library allows the user to easily plot data stored in STL containers with (hopefully!) minimal intervention.
+[endsect]
+
+[section:intro Introduction]
+This project is focused on using STL containers in order to graph data on a one-dimensional and two-dimensional (and if time allows, 3D!) plot. The plot would be written in an svg image, compliant with the W3C standard. The goals of the project are as follows:
+
+* To provide an easy syntax for graphing data
+* To let users produce a simple plot with minimal intervention by using sane defaults
+* To demonstrate how to incorporate SVG images into Boost documentation
+* To allow users to easily customize graphs to their heart's content
+* To allow the user to talk with the svg_graph class using coordinate units instead of pixels or other arbitrary measures
+* To create the backbone of a svg class that will be extended to fully support storing the standard
+
+I have only a student's grasp of C++, so if you have a suggestion to help me with design or implementation, either leave them here or email me at jakevoytko (at) gmail (dot) com
+
+[endsect]
+
+[section:color Colors]
+[section:color_intro Introduction]
+
+The project supports any color definable by the RGB interface, as well as a number of constants that are named by the SVG standard.
+
+[@http://www.w3.org/TR/SVG/types.html#ColorKeywords Here] is a link to the SVG color constants that my program supports
+
+[endsect]
+
+[section:color_internals Internals and Rationale]
+
+All color information is stored in RGB format in a svg_struct. The rationale
+for storing information in RGB format is because it is precise and is always
+representable the exact same way. Storing as a floating point percentage
+introduces the possibility of rounding error, which I would like to avoid at
+all costs. The same image file will always display the same way on any system
+that correctly implements the SVG format.
+
+It is important to note that any integer value is accepted by the SVG standard, but negative values are rounded to 0, and positive values > 255 are rounded down to 255.
+
+Constants are defined in an enum, `svg_color_constant`, in alphabetical order.
+This facilitates quick lookup of their RGB values quickly in an array.
+
+[endsect]
+
+[section:color_usage Usage]
+
+To use an example, set_title_color(), here are the two different ways we could
+ set the line color, one using RGB values, and the other using the constant.
+
+``
+// Using a new RGB value
+my_plot.set_title_color(svg_color(139, 69, 19));
+
+// Using an existing RGB value
+my_plot.set_title_color(my_color);
+
+// Using a color constant
+my_plot.set_title_color(saddlebrown);
+
+// Defining an RGB value from color constant. This is not required anywhere but in the plot() function
+my_plot.set_title_color(svg_color(saddle_brown));
+``
+
+[endsect]
+[endsect]
+
+
+[section:tutorial Tutorial]
+[section:tutorial_basic Basic Example]
+The minimal requirements for creating any image are as follows.
+
+* You need a one or two dimensional svg_plot
+* You need to call the write() command
+
+That's it! However, just doing this won't give you anything useful. The following can be considered a minimal example:
+
+[section:tutorial_code_simple Simple program]
+``
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+
+using std::vector;
+using namespace boost::svg_plot;
+
+int main()
+{
+ // Snip
+
+ vector<double> my_data;
+
+ // initialize my_data here
+
+ svg_1d_plot my_plot;
+
+ my_plot.set_title("My Graph")
+ .set_legend_on(true)
+ .set_x_range(-1, 11);
+
+ plot(my_plot, my_data, "Race times");
+
+ my_plot.write("my_file.svg");
+ return 0;
+}
+``
+
+[$my_file.svg]
+[endsect]
+[section:tutorial_simple_exam Basic Example Breakdown]
+Let's examine what this does.
+
+``
+svg_1d_plot my_plot;
+``
+initializes a new 1D plot. This also sets many of the values that the class keeps track of with reasonable defaults.
+
+``
+my_plot.set_title("My Graph")
+ .set_legend_on(true)
+ .set_x_range(-1, 11);
+``
+
+All of the set methods are fairly self explanatory. The title, which will appear at the top of the graph, will say "My Graph". `set_legend_on(true)` means that the legend will show up. `set_x_range(-1, 11)` means that the range of values that will be printed is between -1 and 11, as you can see in the above images.
+
+This syntax may be unfamiliar. However, it works on the same principle that the following code works:
+``
+a = b = c = d = 3;
+``
+
+You have also seen it used to print to the console:
+``
+std::cout << "Hello" << name << std::endl;
+``
+
+Within all of the plot classes, chaining works the same way. The equivalent code for the above is as follows:
+
+``
+my_plot.set_title("My Graph");
+my_plot.set_legend_on(true);
+my_plot.set_x_range(-1, 11);
+``
+
+In the long run, I think you will find that my choice helps organize the code a little better!
+
+
+``
+plot(my_plot, my_data, "Race times");
+``
+
+This draws `my_data` to `my_plot`. As many containers as you want can be drawn to my_plot. The name of the series is "Race times", and that text will show up in the legend. These are the three required parameters for this function call. There are optional parameters, as seen in the section Getting More Out Of The `plot()` Function, but most immediately beneficial would be the ability to specify a color for your data point:
+``
+plot(my_plot, my_data, "Race Times", blue);
+``
+
+is how you could accomplish this
+
+``
+my_plot.write("my_file.svg");
+``
+
+This writes our plot to the file "my_file.svg".
+[endsect]
+[endsect]
+
+[section:plot_window Using a Plot Window]
+If the legend or the title is obscuring data, or you would merely like a different choice for layout, you can opt to use a [^plot window]. To add it to a simple example:
+
+``
+#include <boost/svg_plot/svg_1d_plot.hpp>
+#include <vector>
+
+using std::vector;
+using namespace boost::svg_plot;
+
+// Snip
+
+vector<double> my_data;
+
+// initialize my_data here
+
+svg_1d_plot my_plot;
+
+my_plot.set_title("My Graph")
+ .set_legend_on(true)
+ .set_plot_window_on(true)
+ .set_x_range(-1, 11);
+
+plot(my_plot, my_data, "Race times");
+
+my_plot.write("my_file.svg");
+``
+
+This produces the following image:
+(insert image)
+[endsect]
+[section:full_layout Full Layout Example]
+Boost.SVG_Plot is designed to avoid having to do much customization. However, it is by no means a "one size fits all" solution. As such, there is much that can be changed in the way of layout and design. An example follows:
+
+``
+svg_1d_plot my_plot;
+
+// misc data
+my_plot.set_image_size(500, 350)
+ .set_title("Race Results")
+ .set_title_font_size(20);
+
+// display commands
+my_plot.set_x_label_on(true)
+ .set_x_major_labels_on(true)
+ .set_x_major_grid_on(true)
+ .set_x_minor_grid_on(true)
+ .set_axis_on(true)
+ .set_legend_on(true)
+ .set_plot_window_on(true)
+ .set_title_on(true);
+
+// axis information
+my_plot.set_x_axis_width(2)
+ .set_x_label("Time in minutes")
+ .set_x_major_tick(5)
+ .set_x_num_minor_ticks(1)
+ .set_x_scale(-5, 130);
+
+// plot the information
+plot(my_plot, ron_result, "Ron", orange);
+plot(my_plot, sally_result, "Sally", red);
+plot(my_plot, tim_result, "Tim", blue);
+
+my_plot.write("race_results.svg");
+``
+
+This produces the following image:
+(insert image)
+[endsect]
+
+[section:color Color Customization]
+The [^svg_plot] classes support two major ways to define colors. One is the use of colors in the RGB format. To specify a color in the RGB format, you can use the following: `svg_color(123, 73, 255)`, to pick a random example.
+
+The other way to define a color is to use the SVG standard's custom color definitions, as defined [@http://www.w3.org/TR/SVG/types.html#ColorKeywords here]
+
+Here is an example using color customization:
+
+``
+ vector<double> data1;
+ deque<double> data2;
+ boost::array<double, 10> data3;
+
+ svg_1d_plot my_plot;
+
+ // 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_text("Time in Months");
+
+ // command settings
+ my_plot.set_axis(true)
+ .set_legend(true)
+ .set_plot_window(true)
+ .set_x_label(true)
+ .set_x_major_labels(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_range(my_plot, data2.begin(), data2.end(), "Lions", blue);
+ plot_range(my_plot, data1.begin(), data1.end(), "Tigers", purple);
+ plot_range(my_plot, data3.begin(), data3.end(), "Bears", red);
+
+ my_plot.write("D:/1d_complex.svg");
+``
+This produces the following output:
+(Insert image)
+[endsect]
+[section:defaults `svg_1d_plot` Defaults]
+You may have noticed that there are certain defaults that are true at the beginning of the plotting. Here is a table of the defaults:
+
+[table Default Values]
+ [[object] [Default value] [Rationale]]
+ [[Axis] [On] [Most graphs include an axis of some kindl]]
+ [[Distance between major X ticks] [`3 units`] [Reasonably fits into a plot window]]
+ [[Font size of the legend title] [12] [Reasonable when paired with the image size]]
+ [[Font size of the X Label] [12] [Reasonable when paired with the image size]]
+ [[Font size of the title] [30] [Makes the title stand out]]
+ [[Grid lines] [`All off`] [Grid lines are a user's personal choice, so I default with the simpler model]]
+ [[Image background] [white] [K.I.S.S. Coloring will be highly dependent on user needs.]]
+ [[Image size] [`500 by 350`] [Details discernable. The image is easily viewable by those using 800x600 monitors]]
+ [[Legend] [`Off`] [The goal of the defaults is to provide the cleanest possible plot as a default. Not including the legend meets this goal. If there is a public outcry, I can change this.]]
+ [[Major tick length] [20 pixels] [Tasteful default when paired with the window size. This also makes the major ticks easily distinguishable from the minor ticks]]
+ [[Major tick width] [2 pixels] [Major ticks are more obvious than minor ticks]]
+ [[Minor tick length] [10 pixels] [Tasteful default when compared with the size of the grid. This makes the minor ticks less obvious than the major ticks]]
+ [[Minor tick width] [1 pixel] [This makes the minor tick less obvious than the major ticks]]
+ [[Number of minor X ticks between each major X tick] [2] [This allows the minor ticks to appear on the integers]]
+ [[Plot Window] [`Off`] [Initially off because it is the simplest case. I will change this if there is an outcry]]
+ [[Title] [On, "Plot of data"] [The title is on because this is one of the most basic elements of a graph. The title is set to a default because when `title_on == true`, something should display]]
+ [[X Axis Label] [`"X Axis", Off`] ["X Axis" is the label because something should display were the user to turn on the X axis label without setting text, and this is the most informative]]
+ [[X Range] [`(-10, 10)`] [Traditional plot viewport]]
+ [[Plot window background] [white] [K.I.S.S. Coloring will be highly dependent on user needs]]
+ [[Legend background] [white] [K.I.S.S. Coloring will be highly dependent on user needs]]
+ [[All other colors] [black] [K.I.S.S. Coloring will be highly dependent on user needs]]]
+
+[endsect]
+
+[section:plot_function Getting More Out Of The `plot()` Function]
+The `plot()` function is defined using Boost.Parameter. As such, it supports a few extra named parameters, as well as a deduced parameter.
+
+[table Deduced parameter
+[[ID] [Description] [Default]]
+[[_fill_color] [This is the color that shows up inside of the circle that is being drawn] [white] ]]
+
+[table Optional Parameters
+[[ID] [Description] [Default]]
+[[_stroke_color] [The outline of the circle that is being drawn] [black] ]
+[[_point_style] [This is the shape of the point. Options currently are between [^none], [^circle], and [^square].] [circle]]
+[[size] [This is the height/width of the circle and square.] [10]]
+[[_x_functor] [A pointer to a class that contains a conversion function. You will not have to worry about this, unless you are trying to accomplish stuff like plotting a vector of humans. For example:
+``
+class my_functor
+{
+ typdef double result_type;
+
+ double convert(const human& _hum)
+ {
+ return _hum.get_age();
+ }
+}
+
+// snip
+
+plot(my_plot, my_data, "Lions", _x_functor = my_functor());
+``
+][
+`boost_default_convert` is sufficient in all cases where the data stored in the container can be directly casted to a double]]]
+
+Here are some examples of correct uses:
+[h3 Using fill and stroke colors]
+
+``
+plot(my_plot, my_data, "Lions", _fill_color = svg_color(red), _stroke_color = svg_color(black));
+``
+
+This has the same effect as the following:
+
+``
+plot(my_plot, my_data, "Lions", svg_color(red), svg_color(black));
+``
+
+and also the same effect as:
+``
+plot(my_plot, my_data, "Lions", _stroke_color = svg_color(black), _fill_color = svg_color(red));
+``
+
+Since _fill_color is a deduced parameter, when two svg_colors are used in the same function call, they are always inferred in the following order: (fill, stroke).
+
+[h3 Using all parameters]
+``
+plot(my_plot, my_data, "Lions",
+ _fill_color = svg_color(red),
+ _stroke_color = svg_color(black),
+ _x_functor = my_functor());
+``
+
+[endsect]
+[endsect]
+
+[section:svg_interface SVG Public Interface]
+[table class svg
+ [[Signature] [Description] [Notes]]
+ [[`svg()`] [Constructor] [The default image size is (400, 400)]]
+ [[`svg& image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels][]]
+ [[`svg& get_x_size()`] [Returns the width of the image] []]
+ [[`svg& get_y_size()`] [Returns the height of the image] []]
+ [[`svg& write(const std::string&)`] [Writes the document to the file represented by the argument][Opens the file stream itself and tries to call `write(std::ostream&)`. Throws `std::runtime_exception` if it can not open the file.]]
+ [[`svg& write(std::ostream&)`] [Writes the document to the stream represented by the argument][]]
+ [[`svg& circle(double x, double y, unsigned int radius = 5)`] [Adds a point at (x,y) in the root level of the document][If the user is calling the circle method, odds are they would prefer a real circle instead of a degenerate circle (a point). 5 is as good a defaul as any other.]]
+ [[`svg& line(double x1, double y1, double x2, double y2)`] [Adds a line from (x1,y1) to (x2,y2) in the root level of the document][]]
+ [[`svg& text(double x, double y, std::string text)`] [Adds text `text` at (x,y) in the root level of the document][]]
+ [[`svg& rect(double x1, double y1, double width, double height)`] [Adds a rectangle at point (x1, y1) that has width `width` and height `height`][]]
+ [[`svg& clip_path(const rect_element&, g_element&, const std::string& id)`][Prevents the g_element in the argument from drawing outside of the rectangle in the argument. The string is provided to identify the clip.] [Currently unsupported]]
+ [[`g_element& add_g_element()`] [Adds a g_element at the root of the document tree. Acts as a `push_back()`] [Returns the `g_element` that is pushed back. This allows you to do something like the following: `image.add_g_element().line(/**/).line(/**/).rect(/**/); `
+Which adds two lines and a rectangle to the g_element that was just created.]]
+ [[`g_element& get_g_element(int)`] [Gets the g_element at the index specified] [Gives a runtime error if you specify an index that does not contain a `g_element`. This will be addressed]]
+]
+[endsect]
+
+[section:svg_1d_plot_interface `svg_1d_plot` Public Interface]
+[table Misc
+ [[Signature] [Description]]
+[[ `void plot_range(std::vector<double>::const_iterator begin,
+std::vector<double>::const_iterator end, std::string text);`]
+ [Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. If you are looking for the generic version, you can find it below.]]
+ [[`void plot(const std::vector<double>& _ctr, const std::string&, const plot_point_style&)`]
+ [Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. The point color for this series is going to be `col`. If you are looking for the generic version, you can find it below.]]
+ [[`svg_1d_plot()`] [See the defaults section for further details]]
+ [[`svg_1d_plot& set_image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels]]
+ [[`svg_1d_plot& set_title(const std::string&)`] [Sets the string to be used for the title]]
+ [[`svg_1d_plot& set_title_font_size(unsigned int)`] [Sets the font size for the title]]
+ [[`svg_1d_plot& set_legend_title_font_size(unsigned int)`] [Sets the font size for the legend title]]
+ [[`svg_1d_plot& write(const std::string&)`] [Writes the plot to the file passed as a parameter]]
+ [[`svg_1d_plot& write(ostream&)`] [Writes the plot to a stream passed as a parameter]]]
+
+[table Commands
+ [[Signature] [Description]]
+ [[`svg_1d_plot& set_axis_on(bool)`] [Sets whether the axis is on or off]]
+ [[`svg_1d_plot& set_legend_on(bool)`] [Sets whether the legend is on or off]]
+ [[`svg_1d_plot& set_plot_window_on(bool)`] [Sets whether the plot will be displayed in its own window, or will be "full screen" in the image]]
+ [[`svg_1d_plot& set_x_label_on(bool)`] [Sets whether or not the x axis label will show]]
+ [[`svg_1d_plot& set_x_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the x axis]]
+ [[`svg_1d_plot& set_title_on(bool)`] [Determines whether or not the image title is displayed]]
+ [[`svg_1d_plot& set_x_major_grid_on(bool)`] [Determines whether or not the major grid on the X axis will be displayed]]
+ [[`svg_1d_plot& set_x_minor_grid_on(bool)`] [Determines whether or not the minor grid on the X axis will be displayed]]]
+
+[table Color Information
+ [[Signature] [Description]]
+ [[`svg_1d_plot& set_title_color(svg_color_constant col)`] [Set the title color]]
+ [[`svg_1d_plot& set_title_color(const svg_color &col)`] [Set the title color]]
+ [[`svg_1d_plot& set_background_color(svg_color_constant col)`] [Set the background color for the whole image]]
+ [[`svg_1d_plot& set_background_color(const svg_color &col)`] [Set the background color for the whole image]]
+ [[`svg_1d_plot& set_legend_background_color(svg_color_constant col)`] [Set the background color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_1d_plot& set_legend_background_color(const svg_color &col)`] [Set the background color for the legend as `col`, an RGB color]]
+ [[`svg_1d_plot& set_legend_border_color(svg_color_constant col)`] [Set the border color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_1d_plot& set_legend_border_color(const svg_color &col)`] [Set the border color for the legend as `col`, an RGB color]]
+ [[`svg_1d_plot& set_background_border_color(svg_color_constant col)`] [Set the background border color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_1d_plot& set_background_border_color(const svg_color &col)`] [Set the background border color for the legend as `col`, an RGB color]]
+ [[`svg_1d_plot& set_plot_background_color(svg_color_constant col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
+ [[`svg_1d_plot& set_plot_background_color(const svg_color &col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
+ [[`svg_1d_plot& set_x_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the axis]]
+ [[`svg_1d_plot& set_x_axis_color(const svg_color &col)`] [Sets the color of the lines that form the axis]]
+ [[`svg_1d_plot& set_x_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_1d_plot& set_x_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_1d_plot& set_x_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the x-axis]]
+ [[`svg_1d_plot& set_x_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the x-axis]]
+ [[`svg_1d_plot& set_x_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
+ [[`svg_1d_plot& set_x_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
+ [[`svg_1d_plot& set_x_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the x-axis]]
+ [[`svg_1d_plot& set_x_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the x-axis]]
+ ]
+
+[table Axis Information
+ [[Signature] [Description]]
+ [[`svg_1d_plot& set_x_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
+ [[`svg_1d_plot& set_x_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
+ [[`svg_1d_plot& set_x_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the x-axis] ]
+ [[`svg_1d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis major ticks] ]
+ [[`svg_1d_plot& set_x_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the x-axis] ]
+ [[`svg_1d_plot& set_x_minor_tick(unsigned int)`] [Sets the length (in pixels) of the x-axis minor ticks] ]
+ [[`svg_1d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis minor tick lengths] ]
+ [[`svg_1d_plot& set_x_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the x-axis] ]
+ [[`svg_1d_plot& set_x_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
+ [[`svg_1d_plot& set_x_scale(double x1, double x2)`] [Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1 ] ]
+]
+
+(Note: Getters omitted for now)
+
+[endsect]
+[section:svg_2d_plot_interface `svg_2d_plot` Public Interface]
+[table Misc
+ [[Signature] [Description]]
+[[` void plot_range(std::vector<double>::const_iterator begin,
+std::vector<double>::const_iterator end, std::string text)`]
+[Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. If you are looking for the generic version, you can find it below.]]
+ [[` void plot_range(std::vector<double>::const_iterator begin, std::vector<double>::const_iterator end,
+std::string text, svg_color_constant col)`]
+[Plots a vector<double> from begin() to end(). It adds the text `text` to the legend. The point color for this series is going to be `col`. If you are looking for the generic version, you can find it below.]]
+ [[`svg_2d_plot()`] [See the defaults section for further details]]
+ [[`svg_2d_plot& set_image_size(unsigned int, unsigned int)`] [Sets the size of the image produced, in pixels]]
+ [[`svg_2d_plot& set_title(const std::string&)`] [Sets the string to be used for the title]]
+ [[`svg_2d_plot& set_title_font_size(unsigned int)`] [Sets the font size for the title]]
+ [[`svg_2d_plot& set_legend_title_font_size(unsigned int)`] [Sets the font size for the legend title]]]
+
+[table Commands
+ [[Signature] [Description]]
+ [[`svg_2d_plot& set_axis_on(bool)`] [Sets whether the axis is on or off]]
+ [[`svg_2d_plot& set_legend_on(bool)`] [Sets whether the legend is on or off]]
+ [[`svg_2d_plot& set_plot_window_on(bool)`] [Sets whether the plot will be displayed in its own window, or will be "full screen" in the image]]
+ [[`svg_2d_plot& set_title_on(bool)`] [Determines whether or not the image title is displayed]]
+ [[`svg_2d_plot& set_x_label_on(bool)`] [Sets whether or not the X axis label will show]]
+ [[`svg_2d_plot& set_x_major_grid_on(bool)`] [Determines whether or not the major grid on the X axis will be displayed]]
+ [[`svg_2d_plot& set_x_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the x axis]]
+ [[`svg_2d_plot& set_x_minor_grid_on(bool)`] [Determines whether or not the minor grid on the X axis will be displayed]]
+ [[`svg_2d_plot& set_y_label_on(bool)`] [Sets whether or not the Y axis label will show]]
+ [[`svg_2d_plot& set_y_major_grid_on(bool)`] [Determines whether or not the major grid on the Y axis will be displayed]]
+ [[`svg_2d_plot& set_y_major_labels_on(bool)`] [sets whether or not the major ticks will be labelled on the Y axis]]
+ [[`svg_2d_plot& set_y_minor_grid_on(bool)`] [Determines whether or not the minor grid on the Y axis will be displayed]]]
+
+[table Color Information
+ [[Signature] [Description]]
+ [[`svg_2d_plot& set_title_color(svg_color_constant col)`] [Set the title color]]
+ [[`svg_2d_plot& set_title_color(const svg_color &col)`] [Set the title color]]
+ [[`svg_2d_plot& set_background_color(svg_color_constant col)`] [Set the background color for the whole image]]
+ [[`svg_2d_plot& set_background_color(const svg_color &col)`] [Set the background color for the whole image]]
+ [[`svg_2d_plot& set_legend_background_color(svg_color_constant col)`] [Set the background color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_2d_plot& set_legend_background_color(const svg_color &col)`] [Set the background color for the legend as `col`, an RGB color]]
+ [[`svg_2d_plot& set_legend_border_color(svg_color_constant col)`] [Set the border color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_2d_plot& set_legend_border_color(const svg_color &col)`] [Set the border color for the legend as `col`, an RGB color]]
+ [[`svg_2d_plot& set_background_border_color(svg_color_constant col)`] [Set the background border color for the legend as `col`, a SVG Color Constant]]
+ [[`svg_2d_plot& set_background_border_color(const svg_color &col)`] [Set the background border color for the legend as `col`, an RGB color]]
+ [[`svg_2d_plot& set_plot_background_color(svg_color_constant col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
+ [[`svg_2d_plot& set_plot_background_color(const svg_color &col)`] [Set the color of the plot area. Note: this only goes into effect if set_plot_area(true) has been called]]
+ [[`svg_2d_plot& set_x_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the axis]]
+ [[`svg_2d_plot& set_x_axis_color(const svg_color &col)`] [Sets the color of the lines that form the axis]]
+ [[`svg_2d_plot& set_x_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_2d_plot& set_x_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_2d_plot& set_x_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the x-axis]]
+ [[`svg_2d_plot& set_x_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the x-axis]]
+ [[`svg_2d_plot& set_x_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
+ [[`svg_2d_plot& set_x_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the X axis]]
+ [[`svg_2d_plot& set_x_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the x-axis]]
+ [[`svg_2d_plot& set_x_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the x-axis]]
+ [[`svg_2d_plot& set_y_axis_color(svg_color_constant col)`] [Sets the color of the lines that form the Y axis]]
+ [[`svg_2d_plot& set_y_axis_color(const svg_color &col)`] [Sets the color of the lines that form the Y axis]]
+ [[`svg_2d_plot& set_y_label_color(const svg_color &col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_2d_plot& set_y_label_color(svg_color_constant col)`] [Sets the color of the labels that go along the X axis]]
+ [[`svg_2d_plot& set_y_major_tick_color(svg_color_constant col)`] [Sets the color of the major ticks of the Y-axis]]
+ [[`svg_2d_plot& set_y_major_tick_color(const svg_color &col)`] [Sets the color of the major ticks of the Y-axis]]
+ [[`svg_2d_plot& set_y_major_grid_color(svg_color_constant col)`] [Sets the color of the grid that runs perpindicular to the Y axis]]
+ [[`svg_2d_plot& set_y_major_grid_color(const svg_color &col)`] [Sets the color of the grid that runs perpindicular to the Y axis]]
+ [[`svg_2d_plot& set_y_minor_tick_color(svg_color_constant col)`] [Sets the color of the minor ticks of the Y-axis]]
+ [[`svg_2d_plot& set_y_minor_tick_color(const svg_color &col)`] [Sets the color of the minor ticks of the Y-axis]]
+ ]
+
+[table Axis Information
+ [[Signature] [Description]]
+ [[`svg_2d_plot& set_x_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
+ [[`svg_2d_plot& set_x_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
+ [[`svg_2d_plot& set_x_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the x-axis] ]
+ [[`svg_2d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis major ticks] ]
+ [[`svg_2d_plot& set_x_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the x-axis] ]
+ [[`svg_2d_plot& set_x_minor_tick(unsigned int)`] [Sets the length (in pixels) of the x-axis minor ticks] ]
+ [[`svg_2d_plot& set_x_major_tick_length(int)`] [Sets the length (in pixels) of the x-axis minor tick lengths] ]
+ [[`svg_2d_plot& set_x_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the x-axis] ]
+ [[`svg_2d_plot& set_x_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
+ [[`svg_2d_plot& set_x_scale(double x1, double x2)`] [Sets the scale of the x axis from x1 to x2. Throws an exception if x2<=x1 ] ]
+ [[`svg_2d_plot& set_y_axis_width(unsigned int)`] [Sets the stroke width of the x-axis] ]
+ [[`svg_2d_plot& set_y_label(const std::string&)`] [Sets the label of the x-axis. This does not guarantee that it will be shown. You must run `set_x_label(true)` for that guarantee] ]
+ [[`svg_2d_plot& set_y_major_tick(double)`] [Sets the distance (in Cartesian units) between ticks on the Y axis] ]
+ [[`svg_2d_plot& set_y_major_tick_length(int)`] [Sets the length (in pixels) of the Y axis major ticks] ]
+ [[`svg_2d_plot& set_y_major_tick_width(unsigned int)`] [Sets the width (in pixels) of the major ticks on the Y axis] ]
+ [[`svg_2d_plot& set_y_minor_tick(unsigned int)`] [Sets the length (in pixels) of the Y axis minor ticks] ]
+ [[`svg_2d_plot& set_y_major_tick_length(int)`] [Sets the length (in pixels) of the Y axis minor tick lengths] ]
+ [[`svg_2d_plot& set_y_minor_tick_width(unsigned int)`] [Sets the width (in pixels) of the minor ticks on the Y axis] ]
+ [[`svg_2d_plot& set_y_num_minor_ticks(int)`] [Sets the number of minor ticks between each major tick] ]
+ [[`svg_2d_plot& set_y_scale(double y1, double y2)`] [Sets the scale of the Y axis from y1 to y2. Throws an exception if y2<=y1 ] ]
+]
+
+(Note: Getters omitted for now)
+
+[endsect]

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/Jamfile.v2 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,15 +1,15 @@
-# Copyright 2007 Stjepan Rajko.
-# Distributed under the Boost Software License, Version 1.0. (See
-# accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-import testing ;
-
-project
- : requirements
- <include>../../..
- ;
-
-run test_color_constant.cpp ;
-run test_color_persistance.cpp ;
-run test_color_consistency.cpp ;
+# Copyright 2007 Stjepan Rajko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import testing ;
+
+project
+ : requirements
+ <include>../../..
+ ;
+
+run test_color_constant.cpp ;
+run test_color_persistance.cpp ;
+run test_color_consistency.cpp ;

Modified: 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 (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/test_2d_color_persistance.cpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,92 +1,92 @@
-#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;
-}
+#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;
+}

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/test_color_persistance.cpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,70 +1,70 @@
-#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;
-}
+#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;
+}

Modified: sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp (original)
+++ sandbox/SOC/2007/visualization/libs/svg_plot/test/test_output_consistency.cpp 2007-07-26 19:57:18 EDT (Thu, 26 Jul 2007)
@@ -1,90 +1,90 @@
-#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;
-}
+#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