inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/sg/cloud2plot
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file exlib.license for terms.
00003 
00004 #ifndef inlib_sg_cloud2plot
00005 #define inlib_sg_cloud2plot
00006 
00007 // Inheritance :
00008 #include <inlib/sg/plottable>
00009 
00010 #include <inlib/smanip>
00011 
00012 #include "../histo/c2d"
00013 
00014 namespace inlib {
00015 namespace sg {
00016 
00017 class c2d2plot : public virtual inlib::sg::points2D {
00018 public: //plottable
00019   virtual plottable* copy() const {return new c2d2plot(*this);}
00020   virtual bool is_valid() const {return true;}
00021   virtual std::string name(){return m_name;}
00022   virtual void set_name(const std::string& a_s) {m_name = a_s;}
00023   virtual std::string title(){return "";}
00024   virtual std::string legend(){return m_legend;}
00025   virtual void set_legend(const std::string& a_s) {m_legend = a_s;}
00026 
00027   virtual std::string infos(const std::string& a_opts){
00028     std::string f_lf("\n");
00029     std::string sinfos;
00030     std::vector<std::string> words;
00031     inlib::words(a_opts," ",false,words);
00032     std::vector<std::string>::const_iterator it;
00033   
00034     for(it=words.begin();it!=words.end();++it) {
00035       if(((*it)=="name") && m_name.size()) {
00036         if(sinfos.size()) sinfos += f_lf;
00037         sinfos += "Name\n";
00038         sinfos += m_name;
00039   
00040       } else if((*it)=="entries") {
00041         if(sinfos.size()) sinfos += f_lf;
00042         sinfos += "Entries\n";
00043         sinfos += inlib::to<int>(m_data.entries());
00044   
00045       } else if((*it)=="mean") {
00046         if(sinfos.size()) sinfos += f_lf;
00047         sinfos += "MeanX\n";
00048         sinfos += inlib::to<double>(m_data.mean_x());
00049         sinfos += f_lf;
00050         sinfos += "MeanY\n";
00051         sinfos += inlib::to<double>(m_data.mean_y());
00052 
00053       } else if((*it)=="rms") {
00054         if(sinfos.size()) sinfos += f_lf;
00055         sinfos += "RMS X\n";
00056         sinfos += inlib::to<double>(m_data.rms_x());
00057         sinfos += f_lf;
00058         sinfos += "RMS Y\n";
00059         sinfos += inlib::to<double>(m_data.rms_y());
00060   
00061       }
00062     }
00063   
00064     return sinfos;
00065   }  
00066 public: //points2D
00067   virtual float x_axis_min() const {return m_data.lower_edge_x();}
00068   virtual float x_axis_max() const {return m_data.upper_edge_x();}
00069   virtual float y_axis_min() const {return m_data.lower_edge_y();}
00070   virtual float y_axis_max() const {return m_data.upper_edge_y();}
00071 
00072   virtual unsigned int points() const {return m_data.entries();}
00073   virtual bool ith_point(unsigned int a_index,float& a_x,float& a_y) const {
00074     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;return false;}
00075     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;return false;}
00076     a_x = m_data.value_x(a_index);
00077     a_y = m_data.value_y(a_index);
00078     return true;
00079   }
00080 public:
00081   c2d2plot(const histo::c2d& a_data)
00082   :m_data(a_data)
00083   {}
00084   virtual ~c2d2plot(){}
00085 protected:
00086   c2d2plot(const c2d2plot& a_from)
00087   :inlib::sg::plottable(a_from)
00088   ,inlib::sg::points2D(a_from)
00089   ,m_data(a_from.m_data)
00090   ,m_name(a_from.m_name)
00091   ,m_legend(a_from.m_legend)
00092   {}  
00093 private:
00094   c2d2plot& operator=(const c2d2plot&){return *this;}
00095 private:
00096   const histo::c2d& m_data;
00097   std::string m_name;
00098   std::string m_legend;
00099 };
00100 
00101 }}
00102 
00103 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines