Changeset 2517 in Sophya for trunk/SophyaPI/PIext/pihisto.cc
- Timestamp:
- Mar 17, 2004, 7:04:57 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/pihisto.cc
r2469 r2517 3 3 4 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include <iostream> 7 #include <math.h> 5 8 #include <typeinfo> 6 9 … … 39 42 SetStats(); 40 43 SetError(); 44 SetFilled(); 41 45 SetStatPosOffset(); 42 46 SetName("HistoDrw"); … … 80 84 81 85 bool oktrace=false; 86 // Tracer d'une polyline si demandee 87 bool drawpline=false; 88 if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) drawpline=true; 82 89 // Tracer des marqueurs si demande ou si HProf 83 90 bool drawmarker=false; … … 94 101 else if(error>0) drawerr=true; 95 102 else if(error<0) drawerr=false; 103 // Fill de l'histo ? 104 bool drawfill=false; 105 if(filled) drawfill=true; else drawfill=false; 106 // Et aussi si on ne demande ni ligne ni marqueur ? 107 if( !drawmarker && !drawpline && !drawerr ) drawfill=true; 108 109 // Remplissage des bins avec la couleur courante (trace en premier) 110 if(drawfill) { 111 oktrace = true; 112 for(int i=0; i<mHisto->NBins(); i++) { 113 double left = mHisto->BinLowEdge(i); 114 double width = mHisto->BinWidth(); 115 double bottom = 0; 116 double height = (*mHisto)(i); 117 g->DrawFBox(left,bottom,width,height); 118 } 119 } 96 120 97 121 // Trace des marqeurs … … 125 149 } 126 150 127 // Trace de la ligne continue 128 // Si on ne demande pas de ligne (PI_NotDefLineAtt) 129 // et que l'on a rien trace auparavent, on trace un FPolygon 130 if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt || !oktrace) { 151 // Trace de la ligne continue si demandee 152 if(drawpline) { 131 153 PIGrCoord* x1 = new PIGrCoord[2*mHisto->NBins()+2]; 132 154 PIGrCoord* y1 = new PIGrCoord[2*mHisto->NBins()+2]; … … 147 169 y1[npt] = 0; 148 170 npt++; 149 if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) { 150 g->DrawPolygon(x1,y1,npt,false); 151 oktrace = true; 152 } 153 if(!oktrace) g->DrawFPolygon(x1,y1,npt,false); 154 delete[] x1; delete[] y1; 171 g->DrawPolygon(x1,y1,npt,false); 172 delete [] x1; delete [] y1; 173 oktrace = true; 155 174 } 156 175 … … 179 198 else if(opts=="noerr") SetError(-1); 180 199 else if(opts=="autoerr") SetError(0); 200 else if(opts=="fill") SetFilled(true); 201 else if(opts=="nofill") SetFilled(false); 181 202 else if(opts.substr(0,11) == "statposoff=") { 182 203 float xo=0., yo=0.; … … 204 225 info += " err / nerr : draw, do not draw error bars\n"; 205 226 info += " autoerr : draw error bars if Marker drawing requested OR Profile histo\n"; 227 info += " fill / nofill : fill, do not fill bars with selected color\n"; 206 228 info += " statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n"; 207 229 info += " as a fraction of total size \n"; … … 262 284 263 285 } 286 287 288 289 /* --Methode-- */ 290 double PIHisto::GetDistanceToPoint(double x, double y) 291 { 292 if (!mHisto) return 1.e+9; 293 294 double dist = -1.e+18; 295 for(int i=0; i<mHisto->NBins(); i++) { 296 double xp=mHisto->BinCenter(i); 297 double yp=(*mHisto)(i); 298 xp = (xp-x)/(XMax()-XMin())/0.5; 299 yp = (yp-y)/(YMax()-YMin())/0.5; 300 xp = xp*xp+yp*yp; 301 if(dist<0. || xp<dist) dist = xp; 302 } 303 dist=sqrt(fabs(dist)); 304 //cout<<dist<<"PIHisto: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax() 305 // <<" NBins="<<mHisto->NBins()<<endl; 306 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<endl; 307 308 return dist; 309 }
Note:
See TracChangeset
for help on using the changeset viewer.