Changeset 2115 in Sophya


Ignore:
Timestamp:
Jul 17, 2002, 11:59:50 PM (23 years ago)
Author:
cmv
Message:

ResizeMinMax: cmv 17/07/2002

Location:
trunk/SophyaPI
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/piaxes.cc

    r2113 r2115  
    1010#include <math.h>
    1111#include "piaxes.h"
    12 
    13 #define PERC_GARDE 0.02
    1412
    1513inline void dble_SWAP(double& a,double& b) {double tmp=a; a=b; b=tmp;}
     
    317315////////////////////////////////////////////////////////////////////////
    318316/* --Methode-Static-- */
     317void 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-- */
    319348void PIAxes::BestTicks(double xmin,double xmax,int nticks
    320349                      ,vector<double>& majticks,vector<double>& minticks)
     
    366395// *** Calcul des ticks pour un axe logarithmique
    367396{
     397 long i;
    368398 if(nticks<=0) nticks = 1;
    369399 //cout<<"BestTicksLog: xmin="<<xmin<<" xmax="<<xmax<<" nticks="<<nticks<<endl;
    370400
    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;
    387404   BestTicks(xmin,xmax,nticks,majticks,minticks);
    388405   return;
    389406 }
    390407
    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 }
    393420 if(dmax==dmin) dmax++; else if(dmax<dmin) dmax=dmin+1;
    394421 int inc = (dmax-dmin+1)/nticks; if(inc<1) inc=1;
     
    396423
    397424 majticks.resize(0);
    398  int i;
    399425 for(i=dmin;i<=dmax;i+=inc) {
    400426   double x = pow(10.,(double)i);
     
    404430 //cout<<"majticks.size()="<<majticks.size()<<endl;
    405431
    406  // Pas de puissance de 10 dans l'intervalle
     432 // Pas de puissance de 10 dans l'intervalle on garde BestTicks
    407433 if(majticks.size()==0) {
    408434   BestTicks(xmin,xmax,nticks,majticks,minticks);
     
    424450   if(nins>4) nins=4;
    425451   vector<double> tmp;
    426    for(i=0;i<=majticks.size();i++) {
     452   for(i=0;i<=(long)majticks.size();i++) {
    427453     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];
    430456     for(int n=0;n<nins;n++) {
    431457       double xins = seqmaj[nins-1][n]*xt;
     
    433459       tmp.push_back(xins);
    434460     }
    435      if(i<majticks.size()) tmp.push_back(majticks[i]);
     461     if(i<(long)majticks.size()) tmp.push_back(majticks[i]);
    436462   }
    437463   majticks = tmp;
     
    439465 //cout<<"...majticks.size()="<<majticks.size()<<endl;
    440466
    441  // Les ticks mimneurs
     467 // Les ticks mineurs
    442468 minticks.resize(0);
    443  for(i=0;i<majticks.size()-1;i++) {
     469 for(i=0;i<(long)majticks.size()-1;i++) {
    444470   double dx = (majticks[i+1]-majticks[i])/10.;
    445471   minticks.push_back(majticks[i]);
     
    452478 minticks.push_back(majticks[majticks.size()-1]);
    453479 //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 }
    454488
    455489}
  • trunk/SophyaPI/PI/piaxes.h

    r2091 r2115  
    4242  //  virtual void      DrawHorizontalAxe(double xmin, double xmax, double y,
    4343
    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)
    4547  static void BestTicks(double xmin,double xmax,int nticks
    46                         ,vector<double>& majticks,vector<double>& minticks);
     48                       ,vector<double>& majticks,vector<double>& minticks);
    4749  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)
    5152  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)
    5555  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)
    5857  static void Arrange_Label(char *label);
    5958
  • trunk/SophyaPI/PI/piyfxdrw.cc

    r2092 r2115  
    77#include "piyfxdrw.h"
    88#include "parradapter.h"
    9 
    10 #define PERC_GARDE 0.02
    119
    1210// --------------------------------------------------------------------------
     
    102100    }
    103101
    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);
    108105  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    109106}
  • trunk/SophyaPI/PIext/pigfd1.cc

    r2092 r2115  
    33#include <stdio.h>
    44#include "pigfd1.h"
    5 
    6 #define PERC_GARDE 0.02
    75 
    86/* --Methode-- */
     
    4240if(mGFD->NData()<=0) return;
    4341if(VarX<0) return;
    44 double dx, dy;
    4542double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19;
    4643mGFD->GetMnMx(10*VarX+2,xmin,xmax);
     
    4845if(xmax<=xmin) xmax = xmin+1.;
    4946if(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);
     47PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax);
     48PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax);
     49SetLimits(xmin,xmax,ymin,ymax);
    5350SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    5451}
  • trunk/SophyaPI/PIext/pintuple.cc

    r2092 r2115  
    55#include <stdio.h>
    66#include "pintuple.h"
    7 
    8 #define PERC_GARDE 0.02
    97
    108//++
     
    126124
    127125  // Commencer par trouver nos limites
    128   double dx, dy;
    129126  double xmin, xmax, ymin, ymax;
    130127  xmin = ymin = 9.e19;
     
    132129  mNT->GetMinMax(xK, xmin, xmax);
    133130  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);
    139134//  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);  Ne pas faire - Reza 11/99
    140135}
     
    175170nok = 0; 
    176171xp = yp = xl = yl = 0;
    177 for (int i=0; i<mNT->NbLines(); i++) {
     172for (long i=0; i<(long)mNT->NbLines(); i++) {
    178173  xl = xp;  yl = yp;
    179174  xp = mNT->GetCell(i, xK);
     
    247242info += buff;
    248243info += mNT->LineHeaderToString();
    249 for (int i=0; i<mNT->NbLines(); i++) {
     244for(long i=0; i<(long)mNT->NbLines(); i++) {
    250245  xp = mNT->GetCell(i, xK);
    251246  yp = mNT->GetCell(i, yK);
  • trunk/SophyaPI/PIext/pistlist.cc

    r2092 r2115  
    44#include <stdio.h>
    55#include "pistlist.h"
    6 
    7 #define PERC_GARDE 0.02
    86
    97//++
     
    8482
    8583  // Commencer par trouver nos limites
    86   double dx, dy;
    87   double x1, x2, y1, y2;
     84  double x1,x2,y1,y2;
    8885  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);
    9489  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    9590}
Note: See TracChangeset for help on using the changeset viewer.