Changeset 3125 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jan 11, 2007, 7:02:52 PM (19 years ago)
Author:
ansari
Message:

1/ Introduction d'une classe P1DHistoWrapper (fichier phistwrapper.h) pour rendre PIHisto independant de SOPHYA et des objets Histo, HistErr, HProf ...
2/ Ecriture du wrapper/adaptateur pour SOPHYA::Histo,HProf,HistErr
3/ mise en conformite des ObjAdapter piapp pour Histo,HistErr, chgt numero de version

Reza 11/01/2007

Location:
trunk/SophyaPI/PIext
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/nomherradapter.cc

    r3123 r3125  
    88#include "nomherradapter.h"
    99#include "servnobjm.h"
    10 /*  A_FAIRE_REZA      #include "pihisterr.h" */
    11 /*  A_FAIRE_REZA      #include "pihist2err.h" */
     10
     11#include "pihisto.h"   /* Wrapper pour HistoErr */
     12#include "sohiswrap.h"   /* Wrapper pour HistoErr */
     13
    1214
    1315#include "objfitter.h"
     
    100102PIDrawer* NOMAdapter_HistoErr::GetDrawer(string & dopt)
    101103{
    102   /*  A_FAIRE_REZA    -> + des options pour choisir val / err2 / nb
    103 if (typeid(*mHerr) == typeid(HProf))  dopt = "fcirclemarker5 " + dopt;
    104 else dopt = "thinline " + dopt;
    105 PIHistoErr * pih = new PIHistoErr(mHerr, false);
     104  /*  A_FAIRE_CMV    -> + des options pour choisir val / err2 / nb
     105      pour les options, il faut rajouter des arguments ou methodes a
     106      la classe HistoErrWrapper() et modifier la methode  operator()(int_4 i) Error()
     107
     108      Si besoin, modifier dopt apres... dopt = "fcirclemarker5 " + dopt;
     109  */
     110HistoErrWrapper* hw = new HistoErrWrapper(mHerr, false); // false: le Wrapper ne delete pas l'objet mHerr
     111PIHisto * pih = new PIHisto(hw, true); // true: PIHisto delete l'objet HistoErrWrapper hw
    106112return( pih );
    107   */
    108   return NULL;
    109113}
    110114
  • trunk/SophyaPI/PIext/nomherradapter.h

    r3123 r3125  
    11// This may look like C code, but it is really -*- C++ -*-
    2 // Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
    3 //                                    Reza 05/99
    4 // LAL-IN2P3/CNRS               CEA-DAPNIA     
     2// Adaptateur d objets (pour NamedObjMgr) pour HistoErr
     3//             C. Magneville                    2007
     4// (C) LAL-IN2P3/CNRS               CEA-DAPNIA     
    55 
    66#ifndef NOMHERRADAPTER_H_SEEN
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r3123 r3125  
    88#include "nomhistadapter.h"
    99#include "pihisto.h"
     10#include "sohiswrap.h"
     11
    1012#include "pihisto2d.h"
    1113#include "pipodrw.h"
     
    153155if (typeid(*mHis) == typeid(HProf))  dopt = "fcirclemarker5 " + dopt;
    154156else dopt = "thinline " + dopt;
    155 PIHisto * pih = new PIHisto(mHis, false);
     157HistoWrapper* hw = new HistoWrapper(mHis, false); // false: le Wrapper ne delete pas l'objet Histo mHis
     158PIHisto * pih = new PIHisto(hw, true); // true: PIHisto delete l'objet HistoWrapper hw
    156159return( pih );
    157160}
  • trunk/SophyaPI/PIext/pawexecut.cc

    r3123 r3125  
    475475              PIHisto* pih = NULL;
    476476              if( (pih = dynamic_cast<PIHisto *>(pidwr))==NULL ) continue;
    477               Histo* h = pih->Histogram();
     477              P1DHistoWrapper* h = pih->HistoWrapper();
    478478              if(h==NULL) continue;
    479479              if(h->NBins()<1) continue;
  • trunk/SophyaPI/PIext/piaversion.h

    r3024 r3125  
    22#define PIAPPVERSION_H_SEEN
    33
    4 #define PIAPP_VERSIONNUMBER  4.0
     4#define PIAPP_VERSIONNUMBER  4.1
    55
    66#endif
  • trunk/SophyaPI/PIext/pihisto.cc

    r3055 r3125  
    11// Classe traceur d histogramme                 96-99
    2 // CEA-DAPNIA      LAL-IN2P3/CNRS
     2//  C. Magneville , R. Ansari               2000-2007
     3// (C)  CEA-DAPNIA          LAL-IN2P3/CNRS
    34
    45#include <stdio.h>
     
    89#include <typeinfo>
    910
    10 #include "sopnamsp.h"
     11//RZDEL #include "sopnamsp.h"
    1112#include "pihisto.h"
    12 #include "hisprof.h"
    1313
    1414//++
     
    1717// include      pihisto.h
    1818//
    19 //      Classe traceur d'objet histogramme (classe *Histo*)
     19//      Classe traceur d'objet histogramme (classe *P1DHistoWrapper*)
    2020//--
    2121//++
     
    2727//--
    2828//++
    29 // PIHisto(Histo* histo, bool ad=false)
     29// PIHisto(P1DHistoWrapper* histo, bool ad=false)
    3030//      Constructeur. Si "ad == true", l'objet "histo" est détruit par
    3131//      le destructeur de l'objet "PIHisto"
     
    3737
    3838
    39 PIHisto::PIHisto(Histo* histo, bool ad)
     39PIHisto::PIHisto(P1DHistoWrapper* histo, bool ad)
    4040: PIDrawer(), mHisto(histo)
    4141{
     
    5757{
    5858  if (!mHisto)  return;
    59   float hmin = mHisto->VMin();
    60   float hmax = mHisto->VMax()+0.2*(mHisto->VMax()-mHisto->VMin());
    61   // si HBProf min,max calcules en tenant compte des erreurs
    62   if( typeid(*mHisto) == typeid(HProf) ) {
    63     float v1,v2;
    64     for (int i=1; i<mHisto->NBins(); i++) {
    65       v1 = (*mHisto)(i) - mHisto->Error(i);
    66       v2 = (*mHisto)(i) + mHisto->Error(i);
    67       if(v1<hmin) hmin = v1;
    68       if(v2>hmax) hmax = v2;
    69     }
    70     v1 = 0.1*(hmax-hmin);
    71     hmin -= v1;   hmax += v1;
    72   }
     59  double v1,v2,hmin,hmax;
     60  hmin = 9.e39;
     61  hmax = -9.e39;
     62  for (int i=1; i<mHisto->NBins(); i++) {
     63    v1 = (*mHisto)(i); //DEL  - mHisto->Error(i);
     64    v2 = (*mHisto)(i); //DEL  + mHisto->Error(i);
     65    if(v1<hmin) hmin = v1;
     66    if(v2>hmax) hmax = v2;
     67  }
     68  // REZA$CHECK : Modifier pour tenir compte si axe (Y) en log
     69  v1 = 0.1*(hmax-hmin);
     70  hmin -= v1;   hmax += v1;
     71
    7372  if(hmax<=hmin) hmax = hmin+1.;
    7473  SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax);
     
    8382  if (mHisto->NBins()<=0) return;
    8483 
    85   if( typeid(*mHisto)==typeid(HProf) ) mHisto->UpdateHisto();
     84  mHisto->Update();
    8685
    8786  bool oktrace=false;
     
    9190  // Tracer des marqueurs si demande ou si HProf
    9291  bool drawmarker=false;
    93   if( (GetGraphicAtt().GetMarker() != PI_NotDefMarker) || 
    94       (typeid(*mHisto) == typeid(HProf)) ) drawmarker = true;
     92  if (GetGraphicAtt().GetMarker() != PI_NotDefMarker) drawmarker = true;
     93//RZDEL   ||  (typeid(*mHisto) == typeid(HProf)) ) drawmarker = true;
    9594  // Tracer des erreurs ?
    9695  bool drawerr=false;
    9796  if(error==0) {  // Gestion automatique des erreurs
    98     // Tracer les erreurs si HProf
    99     if( typeid(*mHisto)==typeid(HProf) ) drawerr=true;
     97    //RZDEL Tracer les erreurs si HProf
     98//RZDEL    if( typeid(*mHisto)==typeid(HProf) ) drawerr=true;
    10099    // Trace les erreurs si marqueurs demandes
    101100    if(drawmarker) drawerr=true;
     
    263262  PIGrCoord a, d;
    264263  double cH = (double)g->GetFontHeight(a,d);
    265   double cellHeight = 3.6 * cH;
    266 
    267   // Les labels et leurs longueurs -> largeur de la cellule
    268   char *label, label1[64], label2[64], label3[64];
    269   sprintf(label1, "N= %-g",mHisto->NData());
    270   sprintf(label2, "m= %-g",mHisto->Mean());
    271   sprintf(label3, "s= %-g",mHisto->Sigma());
    272   label = label1;
    273   if(strlen(label)<strlen(label2)) label = label2;
    274   if(strlen(label)<strlen(label3)) label = label3;
    275   double cellWidth =  1.1 * (double)g->CalcStringWidth(label);
     264  vector<string> lines;
     265  int nlig = mHisto->GetStatInfoAsText(lines);
     266  if (nlig < 1) return;
     267
     268  double cellHeight = (nlig+0.6) * cH;
     269
     270  int idxll = 0;
     271 
     272  int kl;
     273  // on recherche la ligne la plus longue
     274  for(kl=1; kl<nlig; kl++)
     275    if ( lines[kl].length() > lines[idxll].length() )  idxll = kl;
     276
     277  double cellWidth =  1.1 * (double)g->CalcStringWidth(lines[idxll].c_str());
    276278
    277279  double ofpx = spoX*(XMax()-XMin());
     
    294296  yu = g->DeltaUCY(YMax(),cw);
    295297  xu += ofpx;  yu += ofpy;
    296   g->DrawString(xu, yu,label1);
    297   cw +=  -1.15*cH;
    298   yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
    299   g->DrawString(xu, yu,label2);
    300   cw +=  -1.15*cH;
    301   yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
    302   g->DrawString(xu, yu,label3);
     298
     299  for(kl=0; kl<nlig; kl++) {
     300    g->DrawString(xu, yu, lines[kl].c_str() );
     301    cw +=  -1.15*cH;
     302    yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
     303  }
    303304                       
    304305}
  • trunk/SophyaPI/PIext/pihisto.h

    r2523 r3125  
    11// This may look like C code, but it is really -*- C++ -*-
    22// Classe traceur d histogramme                 96-99
     3//            C. Magneville / R. Ansari       2000-2007
    34// CEA-DAPNIA      LAL-IN2P3/CNRS
     5
    46#ifndef PIHISTO_H
    57#define PIHISTO_H
    68
    7 #include "histos.h"
    89#include "pidrawer.h"
     10#include "phistwrapper.h"
     11
    912
    1013class PIHisto : public PIDrawer {
    1114public:
    12                      PIHisto(Histo* histo, bool ad=false);
     15                     PIHisto(P1DHistoWrapper* histo, bool ad=true);
    1316  virtual           ~PIHisto();
    1417  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
     
    2124  inline  void       SetError(short fg=0) {error=fg;}
    2225  inline  void       SetFilled(bool fg=false) {filled=fg;}
    23   inline  Histo*     Histogram() {return(mHisto);}
     26  inline  P1DHistoWrapper*     HistoWrapper() {return(mHisto);}
    2427
    2528//   Methode de decodage des options
     
    3336protected:
    3437  virtual void       DrawStats(PIGraphicUC* g);
    35   Histo* mHisto;
     38  P1DHistoWrapper*  mHisto;
    3639  bool mAdDO;
    3740  bool stats,filled;
Note: See TracChangeset for help on using the changeset viewer.