Changeset 4071 in Sophya


Ignore:
Timestamp:
May 9, 2012, 11:36:04 PM (12 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

Location:
trunk/SophyaPI/PIext
Files:
4 edited

Legend:

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

    r3720 r4071  
    467467usage += ">> cdreal,cdimag,cdphase,cdmod,cdmod2 (default=cdmod): Displayed value\n";
    468468usage += "     for complex arrays (real/imaginary part, phase, module, module^2)\n";
     469usage += ">> polarplot polarangle=ConvFactorToRadian,AngOffsetinRadian polarangledeg\n";
     470usage += "     for 2D plots in polar coordinates (PINTuple)\n";
    469471usage += "--- General purpose options:\n";
    470472usage += ">> stat,stats / nsta,nstat,nostat,nostats : Toggle statistic display\n";
     
    489491usage += "         nbticks=X_NTicks,Y_NTicks  \n";
    490492usage += "         tickslen=MajTickLenFrac,MinTickLenFrac \n";
     493usage += "         polaraxes or polaraxes=NbCircles,NbCteTheta,ThetaOffdeg";
    491494usage += ">> Axe labels font size: fixedfontsize/autofontsize=fszf \n";
    492495usage += "         autofontsize=fsizef: Font size computed automatically \n";
     
    755758usage = "Displays Points (X-Y) [with error-bar / Weight / Label ] from an NTuple ";
    756759usage += "\n Usage : nt2d nameobj varx vary [errx erry wt label graphic_attributes]";
     760usage += "\n  For plots in polar coordinates, specify polarplot graphic_att";
    757761usage += "\n  Related commands: disp surf nt2dcn nt2dci nt3d  gfd2d vecplot"; 
    758762mpiac->RegisterCommand(kw, usage, this, grp);
  • 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
  • trunk/SophyaPI/PIext/pintuple.h

    r3269 r4071  
    2424  virtual void       SelectColorByName(const char* pcolnm=NULL);
    2525  virtual void       SelectColorByIndex(const char* pcolidx=NULL);
     26  virtual void       SelectPolar(const char* pangle, const char* pradius, double angconv=1., double angoff=0.);
    2627
    2728  inline  void       ConnectPoints(bool fg=false) { connectPts = fg; }
     
    5455  NTupleInterface* mNT;
    5556  bool mAdDO;
    56   int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
     57  int xK, yK;          // Index du nom de variable en X/Y (ou rayon/angle) ds le ntuple
    5758  int xebK, yebK;      // Index du nom de variable en ErrBarX/Y ds le ntuple
    5859  int wK;              // Index du nom de variable poids
     
    6465  int nWbins;          // Nombre de bins taille de marker variable
    6566  bool colorScale;     // true -> Couleur de marker variable suivant poids
     67  bool polarPlot;      // true -> polar plot
     68  double angConvFactor;  // Facteur de conversion de l'angle en radian
     69  double angOffset;      // Offset de l'angle (en radian) apres conversion
    6670  bool stats;               // true -> indication du nb de points
    6771  bool connectPts;          // true -> les points sont relies par une ligne
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r3572 r4071  
    17941794{
    17951795  DispWinEnum rc = Disp_Next;
    1796   //DBG cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl;
     1796  // cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl;
    17971797  if (opts.size() > 0)  opts.erase(opts.begin(), opts.end());
    17981798  if (sop.length() < 1) return(rc);
     
    18331833      wname=token.substr(6);
    18341834    }
    1835     // Option a etre decode par les drawers, etc ...
     1835    // Gestion specifique des options concernant les traces en coord. polaires
     1836    else if (token == "polarplot")  {
     1837      opts.push_back("polaraxes");
     1838      opts.push_back(token);
     1839    }
     1840    else if ((token == "polaraxes")||(token.substr(0,10) == "polaraxes=")) {
     1841      opts.push_back("polarplot");
     1842      opts.push_back(token);
     1843    }
     1844    //--- Option a etre decode par les drawers, etc ...
    18361845    else  opts.push_back(token);
    18371846  }
    18381847
    1839   //DBG cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
     1848  // cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
    18401849  if (rc == Disp_Same) nb_disp_same++;
    18411850  else nb_disp_same = 0;
Note: See TracChangeset for help on using the changeset viewer.