Boost logo

Boost-Commit :

From: JakeVoytko_at_[hidden]
Date: 2007-08-03 17:14:35


Author: jakevoytko
Date: 2007-08-03 17:14:32 EDT (Fri, 03 Aug 2007)
New Revision: 38428
URL: http://svn.boost.org/trac/boost/changeset/38428

Log:
Changes to clipping
Text files modified:
   sandbox/SOC/2007/visualization/boost/svg_plot/detail/svg_tag.hpp | 77 ++++++++++++++++++---------------------
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp | 3 +
   sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp | 5 --
   3 files changed, 39 insertions(+), 46 deletions(-)

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-08-03 17:14:32 EDT (Fri, 03 Aug 2007)
@@ -46,8 +46,20 @@
 protected:
     svg_style style_info;
     std::string id_name;
- std::string class_name;
- std::string clip_name;
+ std::string clip_name;
+
+ void write_attributes(std::ostream& s_out)
+ {
+ if(id_name.size())
+ {
+ s_out << " id=\"" << id_name << "\"";
+ }
+
+ if(clip_name.size())
+ {
+ s_out << " clip-path=\"url(#" << id_name << ")\"";
+ }
+ }
 
 public:
     virtual void write(std::ostream& rhs) = 0;
@@ -57,35 +69,14 @@
 
     }
 
- void write_elements(std::ostream& rhs)
- {
- if(id_name.size())
- {
- rhs << " id=\"" << id_name << "\"";
- }
-
- if(class_name.size())
- {
- rhs << " class=\"" << class_name << "\"";
- }
-
- if(clip_name.size())
- {
- rhs << " clip-path=\"" << id_name << "\" ";
- }
- }
-
    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 id_name; }
 
- void clip(const std::string& _name){ clip_name = _name; }
- std::string clip( ) { return clip_name; }
-
- void xml_class(const std::string& _class) { class_name = _class; }
- std::string xml_class() { return class_name; }
+ void clip_id(const std::string& _id) { id_name = _id; }
+ std::string clip_id() { return clip_name; }
 };
 
 // -----------------------------------------------------------------
@@ -106,9 +97,9 @@
 
     void write(std::ostream& rhs)
     {
- rhs<<"<rect";
- write_elements(rhs);
- rhs<<"x=\""<<x<<"\""
+ rhs << "<rect ";
+ write_attributes(rhs);
+ rhs << " x=\""<<x<<"\""
                     <<" y=\""<<y<<"\" "
                     <<" width=\""<<width<<"\" "
                     <<" height=\""<<height<<"\"/>"
@@ -134,8 +125,8 @@
     void write(std::ostream& rhs)
     {
         rhs<<"<circle";
- write_elements(rhs);
- rhs<<"cx=\""
+ write_attributes(rhs);
+ rhs<<" cx=\""
            <<x<<"\" cy=\""
            <<y<<"\" r=\""
            <<radius<<"\"/>";
@@ -160,9 +151,7 @@
 
     void write(std::ostream& rhs)
     {
- rhs<<"<line ";
- write_elements(rhs);
- rhs<<"x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
+ rhs<<"<line x1=\""<<x1<<"\" y1=\""<<y1<<"\" x2=\""<<x2<<"\" y2=\""
             <<y2<<"\"/>";
     }
 };
@@ -231,9 +220,7 @@
             break;
         }
 
- rhs << "<text ";
- write_elements(rhs);
- rhs<<"x=\"" << x_coord << "\""
+ rhs << "<text x=\"" << x_coord << "\""
             <<" y=\"" << y_coord << "\" ";
         
         if(output != "")
@@ -277,7 +264,6 @@
     clip_path_element(const std::string& _id, const rect_element& _rect):
             element_id(_id), rect(_rect)
     {
-
     }
 
     void write(std::ostream& rhs)
@@ -536,7 +522,7 @@
 public:
     bool _fill;
 
- path_element(const path_element& rhs)//:path(rhs.path.release())
+ path_element(const path_element& rhs)
     {
         path = (const_cast<path_element&>(rhs)).path.release();
     }
@@ -647,9 +633,7 @@
 
     void write(std::ostream& o_str)
     {
- o_str<<"<path ";
- write_elements(o_str);
- o_str<<"d=\"";
+ o_str<<"<path d=\"";
            
         for(ptr_vector<path_point>::iterator i = path.begin();
             i!=path.end();
@@ -659,6 +643,7 @@
         }
         o_str<<"\" ";
         
+ write_attributes(o_str);
         style_info.write(o_str);
 
         if(!_fill)
@@ -678,9 +663,17 @@
 {
 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];
@@ -695,8 +688,8 @@
     {
         rhs << "<g ";
 
- write_elements(rhs);
         style_info.write(rhs);
+ write_attributes(rhs);
 
         rhs<< " >" << std::endl;
         

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_2d_plot.hpp 2007-08-03 17:14:32 EDT (Fri, 03 Aug 2007)
@@ -166,6 +166,8 @@
     // strings having to do with labels
     std::string y_label;
 
+ std::string plot_window_clip;
+
     // axis information
     double y_min, y_max;
 
@@ -669,6 +671,7 @@
                       x_major_width(2), x_minor_width(1),
                       y_minor_length(10), y_num_minor(2),
                       y_major_length(20), legend_title_size(12),
+ plot_window_clip("__clip_window"),
                       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),

Modified: sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp
==============================================================================
--- sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp (original)
+++ sandbox/SOC/2007/visualization/boost/svg_plot/svg_test.cpp 2007-08-03 17:14:32 EDT (Fri, 03 Aug 2007)
@@ -17,7 +17,7 @@
 
 double g(double x)
 {
- return cos(x);
+ return 2*cos(x);
 }
 
 double h(double x)
@@ -51,12 +51,9 @@
 
     double pi = 3.1415926535;
   
- data2[1.5] = std::numeric_limits<double>::infinity();
     for(double i=0; i<10; i+=pi/8.)
     {
- //data1[i] = f(i);
         data2[i] = g(i);
- //data3.push_back(h(i));
     }
 
     cout<<"Done with first part"<<endl;


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