Changeset 2517 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Mar 17, 2004, 7:04:57 PM (22 years ago)
Author:
cmv
Message:

GetDistanceToPoint cmv 17/03/04

Location:
trunk/SophyaPI/PIext
Files:
10 edited

Legend:

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

    r2494 r2517  
    11761176usage += ">> Axes:  axesnone stdaxes=defaxes=boxaxes boxaxesgrid \n";
    11771177usage += "          fineaxes fineaxesgrid centeredaxes finecenteredaxes \n";
    1178 usage += "          centeredaxesgrid finecenteredaxesgrid \n";
     1178usage += "          centeredaxesgrid finecenteredaxesgrid\n";
     1179usage += "          axescenter=x0,y0 (for default axescenter=)\n";
    11791180usage += "          grid nogrid labels nolabels  \n";
    11801181usage += "          ticks noticks minorticks nominorticks \n";
  • trunk/SophyaPI/PIext/pi2dvec.cc

    r2322 r2517  
    169169}
    170170
     171
     172
     173/* --Methode-- */
     174double PI2dVecDrawer::GetDistanceToPoint(double x, double y)
     175{
     176 if(_nti==NULL) return 1.e+9;
     177 if( xK<0 || yK<0 ) return 1.e+9;
     178 if( vK<0 || wK<0 ) return 1.e+9;
     179
     180 double dist = -1.e+18;
     181 for(int i=0; i<_nti->NbLines(); i++) {
     182   double xp=_nti->GetCell(i,xK);
     183   double yp=_nti->GetCell(i,yK);
     184   xp = (xp-x)/(XMax()-XMin())/0.5;
     185   yp = (yp-y)/(YMax()-YMin())/0.5;
     186   xp = xp*xp+yp*yp;
     187   if(dist<0. || xp<dist) dist = xp;
     188 }
     189 dist=sqrt(fabs(dist));
     190 cout<<dist<<"PI2dVecDrawer: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
     191     <<" NbLines="<<_nti->NbLines()<<endl;
     192 cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<endl;
     193 cout<<"****** NON teste (CMV) ******"<<endl;
     194
     195 return dist;
     196}
  • trunk/SophyaPI/PIext/pi2dvec.h

    r2161 r2517  
    2222  virtual int       SelectVW(const char* px, const char* py);
    2323
     24// Renvoie une distance au point x,y
     25  virtual double     GetDistanceToPoint(double x, double y);
    2426 
    2527protected:
  • trunk/SophyaPI/PIext/pigfd1.cc

    r2115 r2517  
    1010SelectX(0);
    1111SelectErrBar(false,false);
     12NptDraw = 0;
    1213}
    1314
     
    6061if(GetGraphicAtt().GetLineAtt()!=PI_NotDefLineAtt) SelectErrBar(true,true);
    6162double xp,yp,er;
     63NptDraw = 0;
    6264for (int i=0; i<mGFD->NData(); i++) {
    6365  xp = mGFD->Absc(VarX,i);
    6466  yp = mGFD->Val(i);
    6567  if(xp<xmin || xp>xmax || yp<ymin || yp>ymax)  continue;
     68  NptDraw++;
    6669  if(ErrX) {
    6770    er = mGFD->EAbsc(VarX,i);
     
    7679return;
    7780}
     81
     82/* --Methode-- */
     83double PIGenFitDat::GetDistanceToPoint(double x, double y)
     84{
     85 if(!mGFD) return 1.e+9;
     86 if(mGFD->NData()<=0) return 1.e+9;
     87 if(VarX<0) return 1.e+9;
     88
     89 const int nessai = 100;
     90 long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
     91
     92 double dist = -1.e+18;
     93 long n = 0;
     94 for(long i=0; i<mGFD->NData(); i++) {
     95   double xp=mGFD->Absc(VarX,i);
     96   if(xp<XMin() || xp>XMax()) continue;
     97   double yp=mGFD->Val(i);
     98   if(yp<YMin() || yp>YMax()) continue;
     99   if(n%inc==0) {
     100     xp = (xp-x)/(XMax()-XMin())/0.5;
     101     yp = (yp-y)/(YMax()-YMin())/0.5;
     102     xp = xp*xp+yp*yp;
     103     if(dist<0. || xp<dist) dist = xp;
     104   }
     105   n++;
     106 }
     107 dist=sqrt(fabs(dist));
     108 //cout<<"PIGenFitDat: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
     109 //    <<" NData="<<mGFD->NData()<<" inc="<<inc<<endl;
     110 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
     111
     112 return dist;
     113}
  • trunk/SophyaPI/PIext/pigfd1.h

    r339 r2517  
    1717          void       SelectX(int varx);
    1818          void       SelectErrBar(bool erbx,bool erby);
     19
     20// Renvoie une distance au point x,y
     21  virtual double     GetDistanceToPoint(double x, double y);
    1922       
    2023protected:
     
    2326  int VarX;          // numero de variable X ds le GeneralFitData
    2427  bool ErrX,ErrY;    // Erreur en X et Y ?
     28  long NptDraw; // nombre de points effectivement dessines dans la fenetre
    2529};
    2630
  • trunk/SophyaPI/PIext/pigfd2.h

    r339 r2517  
    1717          void       SelectXY(int varx,int vary);
    1818          void       SelectErrBar(bool erbx,bool erby,bool erbz);
    19 
    2019       
    2120protected:
  • trunk/SophyaPI/PIext/pihisto.cc

    r2469 r2517  
    33
    44#include <stdio.h>
     5#include <stdlib.h>
     6#include <iostream>
     7#include <math.h>
    58#include <typeinfo>
    69
     
    3942  SetStats();
    4043  SetError();
     44  SetFilled();
    4145  SetStatPosOffset();
    4246  SetName("HistoDrw");
     
    8084
    8185  bool oktrace=false;
     86  // Tracer d'une polyline si demandee
     87  bool drawpline=false;
     88  if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) drawpline=true;
    8289  // Tracer des marqueurs si demande ou si HProf
    8390  bool drawmarker=false;
     
    94101  else if(error>0) drawerr=true;
    95102  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  }
    96120
    97121  // Trace des marqeurs
     
    125149  }
    126150
    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) {
    131153    PIGrCoord* x1 = new PIGrCoord[2*mHisto->NBins()+2];
    132154    PIGrCoord* y1 = new PIGrCoord[2*mHisto->NBins()+2];
     
    147169    y1[npt] = 0;
    148170    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;
    155174  }
    156175
     
    179198    else if(opts=="noerr")    SetError(-1);
    180199    else if(opts=="autoerr")  SetError(0);
     200    else if(opts=="fill")     SetFilled(true);
     201    else if(opts=="nofill")   SetFilled(false);
    181202    else if(opts.substr(0,11) == "statposoff=") {
    182203      float xo=0., yo=0.;
     
    204225info += "  err / nerr : draw, do not draw error bars\n";
    205226info += "  autoerr : draw error bars if Marker drawing requested OR Profile histo\n";
     227info += "  fill / nofill : fill, do not fill bars with selected color\n";
    206228info += "  statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
    207229info += "       as a fraction of total size \n";
     
    262284                       
    263285}
     286
     287
     288
     289/* --Methode-- */
     290double 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}
  • trunk/SophyaPI/PIext/pihisto.h

    r2469 r2517  
    2020  // 0=barres d'erreurs automatiques: trace si HProf ou markeur demande
    2121  inline  void       SetError(short fg=0) {error=fg;}
     22  inline  void       SetFilled(bool fg=false) {filled=fg;}
    2223  inline  Histo*     Histogram() {return(mHisto);}
    2324
     
    2627  virtual void       GetOptionsHelpInfo(string& info);
    2728
     29// Renvoie une distance au point x,y
     30  virtual double     GetDistanceToPoint(double x, double y);
     31
    2832protected:
    2933  virtual void       DrawStats(PIGraphicUC* g);
    3034  Histo* mHisto;
    3135  bool mAdDO;
    32   bool stats;
     36  bool stats,filled;
    3337  short error;
    3438  float spoX, spoY; // Stat pos offset par rapport a position defaut
  • trunk/SophyaPI/PIext/pintuple.cc

    r2469 r2517  
    44
    55#include <stdio.h>
     6#include <stdlib.h>
     7#include <iostream>
     8#include <math.h>
    69#include "pintuple.h"
    710
     
    5558  SelectLabel(NULL);
    5659  SetName("NTupleDrw");
     60  NptDraw = 0;
     61
    5762}
    5863
     
    189194xp = yp = xl = yl = 0;
    190195PIGrCoord xpolyg[NMXMULTP_LOCAL], ypolyg[NMXMULTP_LOCAL];
    191 npolyg = 0; 
     196npolyg = 0;
     197NptDraw = 0;
    192198for (long i=0; i<(long)mNT->NbLines(); i++) {
    193199  xl = xp;  yl = yp;
     
    198204  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
    199205
     206  NptDraw++;
    200207// Taille - couleur de marker en fonction du poids
    201208  if (wK >= 0) wp = mNT->GetCell(i, wK);
     
    391398
    392399
    393 
     400/* --Methode-- */
     401double PINTuple::GetDistanceToPoint(double x, double y)
     402{
     403 if(!mNT) return 1.e+9;
     404 if( xK<0 || yK<0 ) return 1.e+9;
     405
     406 const int nessai = 100;
     407 long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
     408
     409 double dist = -1.e+18;
     410 long n = 0;
     411 for(long i=0; i<(long)mNT->NbLines(); i++) {
     412   double xp=mNT->GetCell(i,xK);
     413   if(xp<XMin() || xp>XMax()) continue;
     414   double yp=mNT->GetCell(i,yK);
     415   if(yp<YMin() || yp>YMax()) continue;
     416   if(n%inc==0) {
     417     xp = (xp-x)/(XMax()-XMin())/0.5;
     418     yp = (yp-y)/(YMax()-YMin())/0.5;
     419     xp = xp*xp+yp*yp;
     420     if(dist<0. || xp<dist) dist = xp;
     421   }
     422   n++;
     423 }
     424 dist=sqrt(fabs(dist));
     425 //cout<<"PINTuple: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
     426 //    <<" NbLines="<<mNT->NbLines()<<" inc="<<inc<<endl;
     427 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
     428
     429 return dist;
     430}
  • trunk/SophyaPI/PIext/pintuple.h

    r2383 r2517  
    4444//   Texte d'aide des options disponibles
    4545  virtual void       GetOptionsHelpInfo(string& info);
     46
     47// Renvoie une distance au point x,y
     48  virtual double     GetDistanceToPoint(double x, double y);
    4649       
    4750protected:
     
    5962  bool connectPts;          // true -> les points sont relies par une ligne
    6063  float spoX, spoY; // Stat pos offset par rapport a position defaut
     64  long NptDraw; // nombre de points effectivement dessines dans la fenetre
    6165};
    6266
Note: See TracChangeset for help on using the changeset viewer.