Changeset 3132 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Jan 12, 2007, 2:26:57 PM (19 years ago)
Author:
ansari
Message:

introduction methode P1DHistoWrapper::DecodeOptionString et son implementation par defaut, Reza 12/01/2007

Location:
trunk/SophyaPI/PIext
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/phistwrapper.h

    r3125 r3132  
    1212
    1313//! Wrapper class interface for 1d-histogram like objects , used by PIHisto
     14// methodes par defaut dans pihisto.cc
    1415class P1DHistoWrapper
    1516{
    1617public:
    17   virtual ~P1DHistoWrapper() { }
     18  P1DHistoWrapper();
     19  virtual ~P1DHistoWrapper();
    1820
    1921  virtual int_4 NBins() = 0;
     
    2729
    2830  // Renvoie contenu du bin i
    29   virtual r_8 operator()(int_4 i) = 0;
     31  virtual r_8 Value(int_4 i) = 0;
    3032  virtual r_8 Error(int_4 i) = 0;
    3133
     34  inline  r_8 operator()(int_4 i) { return ( Value(i)*mScale+mOff ); }
    3235  // Methode de mise a jour du contenu
    3336  // avec implementation par defaut - ne faisant rien
     
    3639  // ajoute des lignes de texte avec les infos statistiques (dans text)
    3740  // renvoie le nombre de lignes ajoutees - avec implementation par defaut
    38   virtual int GetStatInfoAsText(vector<string> & /* text */ ) { return 0; }
     41  virtual int GetStatInfoAsText(vector<string> &  text );
     42
     43//   Methode de decodage des options - avec implementation par defaut
     44//   l'implementation par defaut ds le fichier pihisto.cc
     45  virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     46
     47protected:
     48  r_8 mScale, mOff;   // scaling coefficient, offset coefficient
    3949
    4050};
  • trunk/SophyaPI/PIext/pihisto.cc

    r3125 r3132  
    99#include <typeinfo>
    1010
    11 //RZDEL #include "sopnamsp.h"
    1211#include "pihisto.h"
     12
     13//------ Implementation classe P1DHistoWrapper
     14P1DHistoWrapper::P1DHistoWrapper()
     15: mScale(1.) , mOff(0.)
     16{
     17}
     18
     19P1DHistoWrapper::~P1DHistoWrapper()
     20{
     21}
     22
     23int P1DHistoWrapper::GetStatInfoAsText(vector<string> & /* text */ )
     24{
     25  return 0;
     26}
     27
     28int P1DHistoWrapper::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     29{
     30  if(opt.size() < 1) return(0);
     31
     32  vector<string> udopt;  // On gardera ici les options non decodees
     33  unsigned int k = 0;
     34  int ndec = opt.size();
     35  for( k=0; k<opt.size(); k++ ) {
     36    string & opts = opt[k];
     37    if(opts.substr(0,7) == "hs1") {
     38      mScale = 1.;  mOff = 0.;
     39    }
     40    else if(opts.substr(0,7) == "hscale=") {
     41      mScale = atof(opts.substr(7).c_str());
     42    }
     43    else if(opt[k].substr(0,8) == "hoffset=") {
     44      mOff = atof(opts.substr(8).c_str());
     45    }
     46    else {
     47      ndec--;
     48      // S'il faut supprimer les options decodees
     49      if (rmdecopt)  udopt.push_back(opts);
     50    }
     51  }
     52  // S'il faut supprimer les options decodees, on remplace l'argument opt
     53  // par le vecteur des options non decodees.
     54  if (rmdecopt)  opt = udopt;
     55  return(ndec);
     56}
     57
    1358
    1459//++
     
    212257    }
    213258  }
     259
    214260  // S'il faut supprimer les options decodees, on remplace l'argument opt
    215261  // par le vecteur des options non decodees.
    216262  if (rmdecopt)  opt = udopt;
    217   return(ndec+ndec1);
     263
     264  // Decodage des options par le histo-wrapper
     265  int ndec2 = 0;
     266  if ( ( optsz1-ndec1-ndec > 0) && (mHisto) ) {
     267    ndec2 = mHisto->DecodeOptionString(opt, rmdecopt);
     268  }
     269  return(ndec+ndec1+ndec2);
    218270}
    219271
     
    246298info += "  statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
    247299info += "       as a fraction of total size \n";
     300info += " ---- HistoWrapper options : \n" ;
     301info += "  hscale=value  : multiplicative factor (in Y) \n" ;
     302info += "  hoffset=value : additive coefficient  (in Y) \n" ;
     303info += "  hs1 : set hscale=1 hoffset=0  (default) \n" ;
    248304// On recupere ensuite la chaine info de la classe de base
    249305PIDrawer::GetOptionsHelpInfo(info);
  • trunk/SophyaPI/PIext/sohiswrap.h

    r3125 r3132  
    3838  virtual r_8 BinHighEdge(int_4 i) { return mHis->BinHighEdge(i) ; }
    3939
    40   virtual r_8 operator()(int_4 i) { return (*mHis)(i) ; }
     40  virtual r_8 Value(int_4 i) { return (*mHis)(i) ; }
    4141  virtual r_8 Error(int_4 i) { return mHis->Error(i) ; }
    4242
     
    8585  virtual r_8 BinHighEdge(int_4 i) { return mHis->BinHighEdge(i) ; }
    8686
    87   virtual r_8 operator()(int_4 i) { return (*mHis)(i) ; }
     87  virtual r_8 Value(int_4 i) { return (*mHis)(i) ; }
    8888  virtual r_8 Error(int_4 i) { return mHis->Error(i) ; }
    8989
Note: See TracChangeset for help on using the changeset viewer.