Changeset 144 in Sophya for trunk/SophyaPI
- Timestamp:
- Sep 18, 1998, 10:37:09 AM (27 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pihisto.cc
r136 r144 1 1 #include <stdio.h> 2 2 #include "pihisto.h" 3 #include "hisprof.h" 3 4 4 5 PIHisto::PIHisto(Histo* histo, bool ad) … … 10 11 PIHisto::~PIHisto() 11 12 { 12 if (mAdDO) 13 delete mHisto; 13 if (mAdDO) delete mHisto; 14 14 } 15 16 17 15 18 16 void 19 17 PIHisto::UpdateLimits() 20 18 { 21 if (!mHisto) return; 22 SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->VMin(), mHisto->VMax()*1.2); 19 if (!mHisto) return; 20 float hmin = mHisto->VMin(); 21 float hmax = mHisto->VMax()+0.2*(mHisto->VMax()-mHisto->VMin()); 22 // si HBProf min,max calcules en tenant compte des erreurs 23 if( mHisto->ClassId() == HProf::classId ) { 24 float v1,v2; 25 for (int i=1; i<mHisto->NBins(); i++) { 26 v1 = (*mHisto)(i) - mHisto->Error(i); 27 v2 = (*mHisto)(i) + mHisto->Error(i); 28 if(v1<hmin) hmin = v1; 29 if(v2>hmax) hmax = v2; 30 } 31 v1 = 0.1*(hmax-hmin); 32 hmin -= v1; hmax += v1; 33 } 34 SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax); 23 35 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 24 36 } 25 26 37 27 38 void 28 39 PIHisto::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 29 40 { 41 bool oktrace = false; 30 42 if (!mHisto) return; 43 if (mMrk != PI_NotDefMarker || mHisto->ClassId() == HProf::classId ) { 44 // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a 45 float x1,y1, x2,y2; 46 float bw = mHisto->BinWidth(); 47 for (int i=0; i<mHisto->NBins(); i++) { 48 // barres d'erreur verticales 49 x1 = x2 = mHisto->BinCenter(i); 50 y1 = (*mHisto)(i) - mHisto->Error(i); 51 y2 = (*mHisto)(i) + mHisto->Error(i); 52 g->DrawLine(x1,y1, x1, y2); 53 // limites de barres d'erreurs (horizontales) 54 x1 -= bw/3.; x2 += bw/3.; 55 g->DrawLine(x1,y1, x2, y1); 56 g->DrawLine(x1,y2, x2, y2); 57 // le marqueur 58 x1 = mHisto->BinCenter(i); 59 y1 = (*mHisto)(i); 60 g->DrawMarker(x1,y1); 61 } 62 oktrace = true; 63 } 31 64 if (mLAtt != PI_NotDefLineAtt) { 32 65 float x1,y1, x2, y2; 33 66 x1 = mHisto->BinLowEdge(0); 34 y1 = 0; 67 y1 = 0; 35 68 for (int i=0; i<mHisto->NBins(); i++) { 36 x2 = x1; 69 x2 = x1; 37 70 y2 = (*mHisto)(i); 38 71 g->DrawLine(x1,y1, x2, y2); 39 y1 = y2; 72 y1 = y2; 40 73 x2 = mHisto->BinHighEdge(i); 41 74 g->DrawLine(x1,y1, x2, y2); 42 x1 = x2; 43 } 44 y2 = 0; g->DrawLine(x1,y1, x2, y2); 75 x1 = x2; 45 76 } 46 else for (int i=0; i<mHisto->NBins(); i++) { 47 float left = mHisto->BinLowEdge(i); 48 float width = mHisto->BinWidth(); 49 float bottom = 0; 50 float height = (*mHisto)(i); 51 g->DrawFBox(left,bottom,width,height); 52 g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne... 53 } 77 y2 = 0; g->DrawLine(x1,y1, x2, y2); 78 oktrace = true; 79 } 80 if( !oktrace ) { 81 for(int i=0; i<mHisto->NBins(); i++) { 82 float left = mHisto->BinLowEdge(i); 83 float width = mHisto->BinWidth(); 84 float bottom = 0; 85 float height = (*mHisto)(i); 86 g->DrawFBox(left,bottom,width,height); 87 g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne... 88 } 89 } 54 90 DrawStats(g); 55 91 } … … 72 108 73 109 } 110
Note:
See TracChangeset
for help on using the changeset viewer.