Changeset 4071 in Sophya for trunk/SophyaPI/PIext/pintuple.cc


Ignore:
Timestamp:
May 9, 2012, 11:36:04 PM (13 years ago)
Author:
ansari
Message:

Trace en coordonnees polaires (2D avec barres d'erreur) classe PINTuple

et introduction des attributs graphiques polarplot, polaraxes ...

Reza, 9 Mai 2012

File:
1 edited

Legend:

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

    r3559 r4071  
    6060  SelectColorByName(NULL);
    6161  SelectColorByIndex(NULL);
     62  SelectPolar(NULL,NULL);
    6263  SetName("NTupleDrw");
    63   NptDraw = 0;
    64 
     64  NptDraw=0;
     65  polarPlot=false;
    6566}
    6667
     
    8586// void  SelectLabel(const char* plabel=NULL)
    8687//      Choix du nom de colonne correspondant à l'étiquette.
     88// void  SelectPolar(const char* pradius, const char* pangle, double angconv=1., double angoffser=0.)
     89//      Choix des noms de colonnes rayon/angle pour un trace en coordonnees polaires
    8790//--
    8891
     
    9699if (py == NULL) yK = -1;
    97100else { name = py; yK = mNT->ColumnIndex(name); }
     101polarPlot=false;
    98102}
    99103
     
    143147}
    144148
     149/* --Methode-- */
     150void  PINTuple::SelectPolar(const char* pangle, const char* pradius, double angconv, double angoff)
     151{
     152string name;
     153if (mNT == NULL)  xK = yK = -1;
     154if (pangle == NULL) xK = -1;
     155else { name = pangle; xK = mNT->ColumnIndex(name); }
     156if (pradius == NULL) yK = -1;
     157else { name = pradius; yK = mNT->ColumnIndex(name); }
     158polarPlot=true;
     159angConvFactor=angconv;
     160angOffset=angoff;
     161}
    145162
    146163/* --Methode-- */
     
    153170  // Commencer par trouver nos limites
    154171  double xmin, xmax, ymin, ymax;
    155   xmin = ymin = 9.e19;
    156   xmax = ymax = -9.e19;
    157   mNT->GetMinMax(xK, xmin, xmax);
    158   mNT->GetMinMax(yK, ymin, ymax);
    159   PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax);
    160   PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax);
     172  if (polarPlot) {
     173    double rmin,rmax;
     174    mNT->GetMinMax(yK, rmin, rmax);
     175    if (rmax<=0.)  rmax=1.;
     176    xmin=ymin=-rmax;
     177    xmax=ymax=rmax;
     178  }
     179  else {
     180    xmin = ymin = 9.e19;
     181    xmax = ymax = -9.e19;
     182    mNT->GetMinMax(xK, xmin, xmax);
     183    mNT->GetMinMax(yK, ymin, ymax);
     184    PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax);
     185    PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax);
     186  }
    161187  SetLimits(xmin,xmax,ymin,ymax);
    162188//  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);  Ne pas faire - Reza 11/99
     
    169195{
    170196double xp,yp,xer,yer,wp;
     197double ray,ang;
    171198double xl,yl;
    172199long nok;
     
    228255for (long i=0; i<(long)mNT->NbLines(); i++) {
    229256  xl = xp;  yl = yp; fgoklastpt = fgokcurpt;
    230 
    231   xp = mNT->GetCell(i, xK);
    232   yp = mNT->GetCell(i, yK);
    233 
     257  if (polarPlot) {
     258    ang = mNT->GetCell(i, xK)*angConvFactor+angOffset;
     259    ray = mNT->GetCell(i, yK);
     260    xp=cos(ang)*ray;
     261    yp=sin(ang)*ray;
     262  }
     263  else {
     264    xp = mNT->GetCell(i, xK);
     265    yp = mNT->GetCell(i, yK);
     266  }
    234267  // Comptage du nombre de pts dans la zone graphique du widget
    235268  if ( !((xp < xmin2) || (xp > xmax2) || (yp < ymin2) || (yp > ymax2)) )  nok++;
     
    287320  if (xebK >= 0) {
    288321    xer = mNT->GetCell(i, xebK);
    289     if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
     322    if(xer>0.) {
     323      if (polarPlot) {
     324        g->DrawLine(xp,yp,ray*cos(ang-yer*angConvFactor),ray*sin(ang-yer*angConvFactor));
     325        g->DrawLine(xp,yp,ray*cos(ang+yer*angConvFactor),ray*sin(ang+yer*angConvFactor));
     326      }
     327      else g->DrawLine(xp-xer, yp, xp+xer, yp);
     328    }
    290329  }
    291330  if (yebK >= 0) {
    292331    yer = mNT->GetCell(i, yebK);
    293     if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
     332    if(yer>0.) {
     333      if (polarPlot) {
     334        double ray1=ray-xer;  if (ray1<0.) ray1=0.;
     335        double ray2=ray+xer;  if (ray2<0.) ray2=0.;
     336        g->DrawLine(ray1*cos(ang), ray1*sin(ang), ray2*cos(ang), ray2*sin(ang));
     337      }
     338      else g->DrawLine(xp, yp-yer, xp, yp+yer);
     339    }
    294340  }
    295341
     
    418464      UseSizeScale(true, nbn);
    419465    }
    420 
     466    // gestion trace en coordonnees polaires
     467    else if (opts == "polarplot") { polarPlot=true; }
     468    else if (opts == "polarangledeg") { angConvFactor=M_PI/180.; } 
     469    else if (opts.substr(0,11) == "polarangle=") {
     470      double aconv=1., aoff=0.;
     471      sscanf(opts.substr(11).c_str(),"%lf,%lf",&aconv, &aoff);
     472      angConvFactor=aconv; angOffset=aoff;
     473    }
    421474    else {
    422475      // Si option non decode
     
    453506 } else opt.push_back("nosizescale");
    454507
     508 if (polarPlot) {
     509   sprintf(str,"polarplot polarangle==%g,%g",angConvFactor,angOffset); opt.push_back(str);
     510 }
     511
    455512 return 1;
    456513}
     
    474531info += "  colorscale/nocolorscale (Use color scale for weight) \n";
    475532info += "  sizescale/sizescale=nbins/nosizescale (Use marker size for weight) \n";
     533info += "  polarplot: select plot in polar coordinates \n";
     534info += "  polarangle=ConvFactorToRadian,AngOffsetinRadian Polar angle conversion \n";
     535info += "  polarangledeg: set ConvFactorToRadian for input angles in degree \n";
    476536info += "   (and usual color/line/marker/... attribute decoding)  \n";
    477537// On recupere ensuite la chaine info de la classe de base
Note: See TracChangeset for help on using the changeset viewer.