Changeset 3125 in Sophya for trunk/SophyaPI/PIext/pihisto.cc
- Timestamp:
- Jan 11, 2007, 7:02:52 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/pihisto.cc
r3055 r3125 1 1 // 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 3 4 4 5 #include <stdio.h> … … 8 9 #include <typeinfo> 9 10 10 #include "sopnamsp.h"11 //RZDEL #include "sopnamsp.h" 11 12 #include "pihisto.h" 12 #include "hisprof.h"13 13 14 14 //++ … … 17 17 // include pihisto.h 18 18 // 19 // Classe traceur d'objet histogramme (classe * Histo*)19 // Classe traceur d'objet histogramme (classe *P1DHistoWrapper*) 20 20 //-- 21 21 //++ … … 27 27 //-- 28 28 //++ 29 // PIHisto( Histo* histo, bool ad=false)29 // PIHisto(P1DHistoWrapper* histo, bool ad=false) 30 30 // Constructeur. Si "ad == true", l'objet "histo" est détruit par 31 31 // le destructeur de l'objet "PIHisto" … … 37 37 38 38 39 PIHisto::PIHisto( Histo* histo, bool ad)39 PIHisto::PIHisto(P1DHistoWrapper* histo, bool ad) 40 40 : PIDrawer(), mHisto(histo) 41 41 { … … 57 57 { 58 58 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 73 72 if(hmax<=hmin) hmax = hmin+1.; 74 73 SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax); … … 83 82 if (mHisto->NBins()<=0) return; 84 83 85 if( typeid(*mHisto)==typeid(HProf) ) mHisto->UpdateHisto();84 mHisto->Update(); 86 85 87 86 bool oktrace=false; … … 91 90 // Tracer des marqueurs si demande ou si HProf 92 91 bool drawmarker=false; 93 if ( (GetGraphicAtt().GetMarker() != PI_NotDefMarker) ||94 92 if (GetGraphicAtt().GetMarker() != PI_NotDefMarker) drawmarker = true; 93 //RZDEL || (typeid(*mHisto) == typeid(HProf)) ) drawmarker = true; 95 94 // Tracer des erreurs ? 96 95 bool drawerr=false; 97 96 if(error==0) { // Gestion automatique des erreurs 98 // Tracer les erreurs si HProf99 if( typeid(*mHisto)==typeid(HProf) ) drawerr=true;97 //RZDEL Tracer les erreurs si HProf 98 //RZDEL if( typeid(*mHisto)==typeid(HProf) ) drawerr=true; 100 99 // Trace les erreurs si marqueurs demandes 101 100 if(drawmarker) drawerr=true; … … 263 262 PIGrCoord a, d; 264 263 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()); 276 278 277 279 double ofpx = spoX*(XMax()-XMin()); … … 294 296 yu = g->DeltaUCY(YMax(),cw); 295 297 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 } 303 304 304 305 }
Note:
See TracChangeset
for help on using the changeset viewer.