Changeset 2115 in Sophya
- Timestamp:
- Jul 17, 2002, 11:59:50 PM (23 years ago)
- Location:
- trunk/SophyaPI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/piaxes.cc
r2113 r2115 10 10 #include <math.h> 11 11 #include "piaxes.h" 12 13 #define PERC_GARDE 0.0214 12 15 13 inline void dble_SWAP(double& a,double& b) {double tmp=a; a=b; b=tmp;} … … 317 315 //////////////////////////////////////////////////////////////////////// 318 316 /* --Methode-Static-- */ 317 void PIAxes::ReSizeMinMax(bool axelog,double& vmin,double& vmax,double garde) 318 // Calcul du min et du max du display a partir des valeurs min et max a plotter 319 { 320 if(garde<0. || garde>=1.) garde = 0.025; 321 cout<<"ReSizeMinMax[log="<<axelog<<",garde="<<garde<<"] vmin="<<vmin<<" vmax="<<vmax<<endl; 322 // Cas d'une echelle lineaire 323 if(!axelog || vmax<=0.) { 324 double dv = garde*(vmax-vmin); 325 vmin -= dv; 326 vmax += dv; 327 } 328 329 // Cas d'une echelle log avec un range raisonnable 330 else if(vmin>0.) { 331 double dv = pow(vmax/vmin,garde); 332 vmin /= dv; 333 vmax *= dv; 334 } 335 336 // Cas d'une echelle log avec un range de-raisonnable 337 else if(vmin<=0.) { 338 if(vmin<0.) vmin += garde*vmin; 339 if(vmax==1.) vmax = 1.+garde; 340 if(vmax>1.) vmax = pow(vmax,1.+garde); 341 else vmax = pow(vmax,1.-garde); 342 } 343 344 cout<<" vmin="<<vmin<<" vmax="<<vmax<<endl; 345 } 346 347 /* --Methode-Static-- */ 319 348 void PIAxes::BestTicks(double xmin,double xmax,int nticks 320 349 ,vector<double>& majticks,vector<double>& minticks) … … 366 395 // *** Calcul des ticks pour un axe logarithmique 367 396 { 397 long i; 368 398 if(nticks<=0) nticks = 1; 369 399 //cout<<"BestTicksLog: xmin="<<xmin<<" xmax="<<xmax<<" nticks="<<nticks<<endl; 370 400 371 // CMV_BUG: quand on fait func x 1 100 ..., Reza renvoit xmin=-0.9602 !!! 372 // Ceci est un bricolo qui permet d'obtenir un resultat moyen. 373 // A CORRIGER: pour Reza, ne pas surdimensionner la fenetre 374 // vers les xmin,ymin SI on demande une echelle log 375 // pour etre sur que xmin,ymin sera bien ce qui est demande. 376 if(xmin<=0.) { 377 cout<<"Error_BestTicksLog: xmin="<<xmin; 378 // On suppose que: xmin = xmin0 - PERC_GARDE*(xmax0-xmin0) 379 xmin = fabs((xmin+PERC_GARDE*xmax)/(1.+PERC_GARDE)); 380 cout<<" corrected to xmin="<<xmin<<endl 381 <<" ===> First labels may be WRONG"<<endl; 382 } 383 384 // Si xmax<=0 ou si dynamique trop faible on garde BestTicks 385 if(xmax<=0. || xmax/xmin<5.) { 386 //cout<<"Choix de BestTicks xmax="<<xmax<<" xmax/xmin="<<xmax/xmin<<" <5"<<endl;; 401 // Si xmax<=0, on garde BestTicks 402 if(xmax<=0. ) { 403 //cout<<"Choix de BestTicks car xmax="<<xmax<<endl; 387 404 BestTicks(xmin,xmax,nticks,majticks,minticks); 388 405 return; 389 406 } 390 407 391 int dmin=int(floor(log10(xmin))); 392 int dmax=int(floor(log10(xmax))); 408 int dmin, dmax=int(floor(log10(xmax))); 409 if(xmin>0.) { 410 // Dynamique trop faible, on garde BestTicks 411 if(xmax/xmin<5.) { 412 //cout<<"Choix de BestTicks car xmax/xmin="<<xmax/xmin<<" <5"<<endl; 413 return; 414 } 415 dmin=int(floor(log10(xmin))); 416 } else { 417 if(dmax>3) dmin = dmax/3; 418 else dmin = dmax-1; 419 } 393 420 if(dmax==dmin) dmax++; else if(dmax<dmin) dmax=dmin+1; 394 421 int inc = (dmax-dmin+1)/nticks; if(inc<1) inc=1; … … 396 423 397 424 majticks.resize(0); 398 int i;399 425 for(i=dmin;i<=dmax;i+=inc) { 400 426 double x = pow(10.,(double)i); … … 404 430 //cout<<"majticks.size()="<<majticks.size()<<endl; 405 431 406 // Pas de puissance de 10 dans l'intervalle 432 // Pas de puissance de 10 dans l'intervalle on garde BestTicks 407 433 if(majticks.size()==0) { 408 434 BestTicks(xmin,xmax,nticks,majticks,minticks); … … 424 450 if(nins>4) nins=4; 425 451 vector<double> tmp; 426 for(i=0;i<= majticks.size();i++) {452 for(i=0;i<=(long)majticks.size();i++) { 427 453 double xt; 428 if(i< majticks.size()) xt = majticks[i]/10.;429 else xt = majticks[i-1];454 if(i<(long)majticks.size()) xt = majticks[i]/10.; 455 else xt = majticks[i-1]; 430 456 for(int n=0;n<nins;n++) { 431 457 double xins = seqmaj[nins-1][n]*xt; … … 433 459 tmp.push_back(xins); 434 460 } 435 if(i< majticks.size()) tmp.push_back(majticks[i]);461 if(i<(long)majticks.size()) tmp.push_back(majticks[i]); 436 462 } 437 463 majticks = tmp; … … 439 465 //cout<<"...majticks.size()="<<majticks.size()<<endl; 440 466 441 // Les ticks mi mneurs467 // Les ticks mineurs 442 468 minticks.resize(0); 443 for(i=0;i< majticks.size()-1;i++) {469 for(i=0;i<(long)majticks.size()-1;i++) { 444 470 double dx = (majticks[i+1]-majticks[i])/10.; 445 471 minticks.push_back(majticks[i]); … … 452 478 minticks.push_back(majticks[majticks.size()-1]); 453 479 //cout<<"...minticks.size()="<<minticks.size()<<endl; 480 481 // Si on a xmin<=0., on insere zero dans les ticks majeurs 482 if(xmin<=0.) { 483 vector<double> tmp = majticks; 484 majticks.resize(0); majticks.push_back(0.); 485 for(i=0;i<(long)tmp.size();i++) majticks.push_back(tmp[i]); 486 //cout<<"...xmin="<<xmin<<"<=0. add majticks[0]="<<majticks[0]<<endl; 487 } 454 488 455 489 } -
trunk/SophyaPI/PI/piaxes.h
r2091 r2115 42 42 // virtual void DrawHorizontalAxe(double xmin, double xmax, double y, 43 43 44 // Calcul des Distances optimales des subdivisions (STATIC) 44 // Calcul du min et du max du display a partir des valeurs min et max a plotter 45 static void ReSizeMinMax(bool axelog,double& vmin,double& vmax,double garde=0.025); 46 // Calcul des Distances optimales des subdivisions (STATIC) 45 47 static void BestTicks(double xmin,double xmax,int nticks 46 48 ,vector<double>& majticks,vector<double>& minticks); 47 49 static void BestTicksLog(double xmin,double xmax,int nticks 48 ,vector<double>& majticks,vector<double>& minticks); 49 50 // Calcul du format optimal (STATIC) 50 ,vector<double>& majticks,vector<double>& minticks); 51 // Calcul du format optimal (STATIC) 51 52 static int BonFormatAxes(double xmin,double xmax,double xstep 52 ,string& format,int typf=0,int add_digit=0); 53 54 // Decision du format optimal pour les axes (STATIC) 53 ,string& format,int typf=0,int add_digit=0); 54 // Decision du format optimal pour les axes (STATIC) 55 55 static int Le_Bon_Format(vector<double>& xticks,string& format,double& xstep); 56 57 // Mise en forme optimale du label numerique (STATIC) 56 // Mise en forme optimale du label numerique (STATIC) 58 57 static void Arrange_Label(char *label); 59 58 -
trunk/SophyaPI/PI/piyfxdrw.cc
r2092 r2115 7 7 #include "piyfxdrw.h" 8 8 #include "parradapter.h" 9 10 #define PERC_GARDE 0.0211 9 12 10 // -------------------------------------------------------------------------- … … 102 100 } 103 101 104 double dx, dy; 105 dx = PERC_GARDE*(xmax-xmin); 106 dy = PERC_GARDE*(ymax-ymin); 107 SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy); 102 PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax); 103 PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax); 104 SetLimits(xmin,xmax,ymin,ymax); 108 105 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 109 106 } -
trunk/SophyaPI/PIext/pigfd1.cc
r2092 r2115 3 3 #include <stdio.h> 4 4 #include "pigfd1.h" 5 6 #define PERC_GARDE 0.027 5 8 6 /* --Methode-- */ … … 42 40 if(mGFD->NData()<=0) return; 43 41 if(VarX<0) return; 44 double dx, dy;45 42 double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19; 46 43 mGFD->GetMnMx(10*VarX+2,xmin,xmax); … … 48 45 if(xmax<=xmin) xmax = xmin+1.; 49 46 if(ymax<=ymin) ymax = ymin+1.; 50 dx = PERC_GARDE*(xmax-xmin);51 dy = PERC_GARDE*(ymax-ymin);52 SetLimits( (double)xmin-dx,(double)xmax+dx,(double)ymin-dy,(double)ymax+dy);47 PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax); 48 PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax); 49 SetLimits(xmin,xmax,ymin,ymax); 53 50 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 54 51 } -
trunk/SophyaPI/PIext/pintuple.cc
r2092 r2115 5 5 #include <stdio.h> 6 6 #include "pintuple.h" 7 8 #define PERC_GARDE 0.029 7 10 8 //++ … … 126 124 127 125 // Commencer par trouver nos limites 128 double dx, dy;129 126 double xmin, xmax, ymin, ymax; 130 127 xmin = ymin = 9.e19; … … 132 129 mNT->GetMinMax(xK, xmin, xmax); 133 130 mNT->GetMinMax(yK, ymin, ymax); 134 135 dx = PERC_GARDE*(xmax-xmin); 136 dy = PERC_GARDE*(ymax-ymin); 137 138 SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy); 131 PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax); 132 PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax); 133 SetLimits(xmin,xmax,ymin,ymax); 139 134 // SetAxesFlags(kBoxAxes | kExtTicks | kLabels); Ne pas faire - Reza 11/99 140 135 } … … 175 170 nok = 0; 176 171 xp = yp = xl = yl = 0; 177 for ( int i=0; i<mNT->NbLines(); i++) {172 for (long i=0; i<(long)mNT->NbLines(); i++) { 178 173 xl = xp; yl = yp; 179 174 xp = mNT->GetCell(i, xK); … … 247 242 info += buff; 248 243 info += mNT->LineHeaderToString(); 249 for (int i=0; i<mNT->NbLines(); i++) {244 for(long i=0; i<(long)mNT->NbLines(); i++) { 250 245 xp = mNT->GetCell(i, xK); 251 246 yp = mNT->GetCell(i, yK); -
trunk/SophyaPI/PIext/pistlist.cc
r2092 r2115 4 4 #include <stdio.h> 5 5 #include "pistlist.h" 6 7 #define PERC_GARDE 0.028 6 9 7 //++ … … 84 82 85 83 // Commencer par trouver nos limites 86 double dx, dy; 87 double x1, x2, y1, y2; 84 double x1,x2,y1,y2; 88 85 mStL->CalcXYLimits(x1, x2, y1, y2); 89 90 dx = PERC_GARDE*(x2-x1); 91 dy = PERC_GARDE*(y2-y1); 92 93 SetLimits(x1-dx, x2+dx, y1-dy, y2+dy); 86 PIAxes::ReSizeMinMax(isLogScaleX(),x1,x2); 87 PIAxes::ReSizeMinMax(isLogScaleY(),y1,y2); 88 SetLimits(x1,x2,y1,y2); 94 89 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 95 90 }
Note:
See TracChangeset
for help on using the changeset viewer.