Changeset 3149 in Sophya for trunk/SophyaPI/PIext/pihisto2d.cc


Ignore:
Timestamp:
Jan 18, 2007, 7:21:49 PM (19 years ago)
Author:
cmv
Message:

suite adaptation travail reza 2D et adapteur + adaptation aux modifs HistoErr cmv 18/01/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pihisto2d.cc

    r3145 r3149  
    5151      mRetFg = 0;
    5252    }   
    53     else if(opts.substr(0,8) == "hbinerr") {
     53    else if(opts.substr(0,7) == "hbinerr") {
    5454      mRetFg = 1;
    5555    }   
    56     else if(opts.substr(0,8) == "hbinent") {
     56    else if(opts.substr(0,7) == "hbinent") {
    5757      mRetFg = 2;
    5858    }   
     
    157157
    158158//++
    159 void PIHisto2D::UseScale(unsigned short type,float logscale)
     159void PIHisto2D::UseScale(unsigned short type,double logscale)
    160160//
    161161//      Pour changer les echelles (lineaire ou logarithmique)
     
    184184
    185185//++
    186 void PIHisto2D::UseDisplay(unsigned short type,float fnpt)
     186void PIHisto2D::UseDisplay(unsigned short type,double fnpt)
    187187//
    188188//      Type de Display
     
    212212
    213213//++
    214 void PIHisto2D::UseDyn(float fmin,float fmax)
     214void PIHisto2D::UseDyn(double fmin,double fmax)
    215215//
    216216//      Gestion de la dynamique a representer:
     
    224224//--
    225225{
    226   if( (mHistoWp) && (mHistoWp->NBinX()>0) && (mHistoWp->NBinY()>0) && (fmin>=fmax) ) {
    227     double v,hmin,hmax;
    228     hmin = hmax = (*mHistoWp)(0,0);
    229     for (int_4 i=0; i<mHistoWp->NBinX(); i++)
    230       for (int_4 j=0; j<mHistoWp->NBinY(); j++) {
    231         v = (*mHistoWp)(i, j);
    232         if(v<hmin) hmin = v;
    233         if(v>hmax) hmax = v;
    234       }
    235     fmin = hmin;  fmax = hmax;   // $CHECK$ CMV : attention, double vers float !!
    236   }
    237 
    238 // $CHECK$ CMV : Ne faut-il pas passer les attributs de la classe en double ??
     226if( (mHistoWp) && (mHistoWp->NBinX()>0) && (mHistoWp->NBinY()>0) && (fmin>=fmax) ) {
     227  double v,hmin,hmax;
     228  hmin = hmax = (*mHistoWp)(0,0);
     229  for (int_4 i=0; i<mHistoWp->NBinX(); i++)
     230    for (int_4 j=0; j<mHistoWp->NBinY(); j++) {
     231      v = (*mHistoWp)(i, j);
     232      if(v<hmin) hmin = v;
     233      if(v>hmax) hmax = v;
     234    }
     235  fmin = hmin;  fmax = hmax;
     236}
     237
    239238if(fmin>=fmax) fmax = fmin+1.;
    240239mHMin = fmin; mHMax = fmax;
     
    242241
    243242//++
    244 void PIHisto2D::UseFrac(float frmin,float frmax)
     243void PIHisto2D::UseFrac(double frmin,double frmax)
    245244//
    246245//      Pour definir la fraction de la dynamique a dessiner:
     
    274273printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%p\n"
    275274      ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,mHistoWp);
    276 // if(lp>=1) mHistoWp->PrintStatus();  $CHECK$ CMV : que faut-il faire ?
    277275fflush(stdout);
    278276}
     
    352350
    353351// Gamme a representer entre [0,1] mais >=fracmin et scale fracmax
    354 float fracmin=FMin(), fracmax=FMax();
    355 float llscale = (float) log10((double)LogScale());
     352double fracmin=FMin(), fracmax=FMax();
     353double llscale = log10(LogScale());
    356354
    357355// gestion Couleurs.
     
    377375if(mTypDisp==1) {
    378376  g->SelMarker(1,PI_DotMarker);
    379   npt = (int) ((float)NPixBin(g)*FPoints()); if(npt<=0) npt = 2;
     377  npt = (int)(NPixBin(g)*FPoints()); if(npt<=0) npt = 2;
    380378}
    381379
     
    400398
    401399  // Gestion de la dynamique a dessiner
    402   float frac = ((*mHistoWp)(i,j)-HMin())/(HMax()-HMin());
     400  double frac = ((*mHistoWp)(i,j)-HMin())/(HMax()-HMin());
    403401  if(frac<0.) continue;
    404402  if(mTypScal==1) {              // echelle log10
     
    408406  if(frac<=fracmin) continue;
    409407  if(frac>1.) frac = 1.;
    410   float fracred = frac * fracmax;
     408  double fracred = frac * fracmax;
    411409
    412410  // Gestion de la couleur
    413411  int icol = 0;
    414412  if (cmap) {
    415     icol = int( (float) ncol*frac );
     413    icol = int(ncol*frac);
    416414    if(icol>=ncol) icol = ncol-1; else if(icol<0) icol=0;
    417415    g->SelForeground(*cmap,icol);
     
    431429  } else if(mTypDisp==1) {
    432430    //..... nuage de points .....
    433     int ipt  = int( (float) npt *frac );
     431    int ipt  = int(npt *frac);
    434432    for(int k=0;k<ipt;k++) {
    435433      double x = left0 + frand01()*dx;
     
    559557
    560558//++
    561 char PIHisto2D::HPrint2(float f)
     559char PIHisto2D::HPrint2(double f)
    562560//
    563561//      Codage des valeurs en caracteres (fct privee).
     
    638636      SetStats(false);
    639637    } else  if(opts.substr(0,11) == "statposoff=") {
    640       float xo=0., yo=0.;
    641       sscanf(opts.substr(11).c_str(),"%g,%g",&xo, &yo);
     638      double xo=0., yo=0.;
     639      sscanf(opts.substr(11).c_str(),"%lf,%lf",&xo, &yo);
    642640      SetStatPosOffset(xo, yo);
    643641    } else if(opts.substr(0,8)=="h2scale=") {
    644       unsigned short t=TypScale(); float ls=LogScale();
     642      unsigned short t=TypScale(); double ls=LogScale();
    645643      if(opts.substr(8,3)=="lin") t=0;
    646644      else if(opts.substr(8,3)=="log")
    647         {t=1; sscanf(opts.c_str(),"h2scale=log,%g",&ls);}
     645        {t=1; sscanf(opts.c_str(),"h2scale=log,%lf",&ls);}
    648646      UseScale(t,ls);
    649647    } else if(opts.substr(0,7)=="h2disp=") {
    650       unsigned short t=TypDisplay(); float fpts=FPoints();
     648      unsigned short t=TypDisplay(); double fpts=FPoints();
    651649      if(opts.substr(7,3)=="var") t=0;
    652650      else if(opts.substr(7,3)=="hbk") t=2;
    653651      else if(opts.substr(7,3)=="img") t=3;
    654652      else if(opts.substr(7,3)=="pts")
    655         {t=1; sscanf(opts.c_str(),"h2disp=pts,%g",&fpts);}
     653        {t=1; sscanf(opts.c_str(),"h2disp=pts,%lf",&fpts);}
    656654      UseDisplay(t,fpts);
    657655    } else if(opts.substr(0,6)=="h2dyn=") {
    658       float hmin=HMin(),hmax=HMax(); size_t q = opts.find(',');
    659       sscanf(opts.c_str(),"h2dyn=%g",&hmin);
    660       if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%g",&hmax);
     656      double hmin=HMin(),hmax=HMax(); size_t q = opts.find(',');
     657      sscanf(opts.c_str(),"h2dyn=%lf",&hmin);
     658      if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%lf",&hmax);
    661659      UseDyn(hmin,hmax);
    662660    } else if(opts.substr(0,7)=="h2frac=") {
    663       float fmin=FMin(),fmax=FMax(); size_t q = opts.find(',');
    664       sscanf(opts.c_str(),"h2frac=%g",&fmin);
    665       if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%g",&fmax);
     661      double fmin=FMin(),fmax=FMax(); size_t q = opts.find(',');
     662      sscanf(opts.c_str(),"h2frac=%lf",&fmin);
     663      if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%lf",&fmax);
    666664      UseFrac(fmin,fmax);
    667665   } else {
     
    10771075
    10781076else if(opt==6001) {
    1079   sscanf(mText[0]->GetText().c_str(),"%g %g",&mHMin,&mHMax);
    1080   sscanf(mText[1]->GetText().c_str(),"%g %g",&mFracMin,&mFracMax);
    1081   sscanf(mText[2]->GetText().c_str(),"%g",&mLogScale);
     1077  sscanf(mText[0]->GetText().c_str(),"%lf %lf",&mHMin,&mHMax);
     1078  sscanf(mText[1]->GetText().c_str(),"%lf %lf",&mFracMin,&mFracMax);
     1079  sscanf(mText[2]->GetText().c_str(),"%lf",&mLogScale);
    10821080  mpih->UseColors(mFgCol,mCmap,mRevCmap);
    10831081  mpih->UseScale(mTypScal,mLogScale);
Note: See TracChangeset for help on using the changeset viewer.