Changeset 2234 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Oct 28, 2002, 6:53:22 PM (23 years ago)
Author:
cmv
Message:
  • Gestion des options ligne de commande pour Histo@d (PIHisto2D) cmv 28/10/2002
Location:
trunk/SophyaPI/PIext
Files:
2 edited

Legend:

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

    r2231 r2234  
    4141UseDyn();
    4242UseFrac();
     43SetStats();
    4344SetName("Histo2DDrw");
    4445// PIHisto2D has specific control tools
     
    187188printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%p\n"
    188189      ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,mHisto);
    189 if(lp<1) return;
    190 mHisto->PrintStatus();
     190if(lp>=1) mHisto->PrintStatus();
     191fflush(stdout);
    191192}
    192193
     
    278279
    279280// gestion epaisseur de ligne
    280 if (GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
     281PILineAtt LineAtt = GetGraphicAtt().GetLineAtt();
     282if(LineAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
    281283
    282284// gestion Markers ou plot avec des points.
     
    369371g->SelForeground(coul);
    370372g->SelFontSzPt(FontSize,FontAtt);
     373g->SelLine(LineAtt);
    371374if (cmap) delete cmap;
    372375
    373376// Fin du dessin, ecriture de la statistique.
    374 DrawStats(g);
     377if(stats) DrawStats(g);
    375378}
    376379
     
    457460//|         .   ==> 0<valeur<1
    458461//|------------------------------------------
    459 //|            C1111111111222222222233333333
    460 //|  C01234567890123456789012345678901234567
     462//|             1111111111222222222233333333
     463//|   01234567890123456789012345678901234567
    461464//| " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"
    462465//|------------------------------------------
     
    486489//      ,dx,dy,dxg,dyg,np);
    487490return np;
     491}
     492
     493//++
     494int PIHisto2D::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     495//
     496//      Decodage des options
     497//--
     498{
     499  int optsz1 = opt.size();
     500  if(optsz1<1) return(0);
     501  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     502  if(optsz1-ndec1<1) return(ndec1);  // si tout a ete decode
     503
     504  vector<string> udopt;  // On gardera ici les options non decodees
     505  unsigned int k = 0;
     506  int ndec = opt.size();
     507  bool listopt=false;
     508  for( k=0; k<opt.size(); k++ ) {
     509    string opts = opt[k];
     510    if(opts=="h2help") {
     511      string info; GetOptionsHelpInfo(info);
     512      size_t q = info.find("PIHisto2D");
     513      if(q<info.length()-1) cout<<info.substr(q)<<endl;
     514    } else if(opts=="h2list") {
     515      listopt=true;
     516    } else if(opts=="sta" || opts=="stat" || opts=="stats") {
     517      SetStats(true);
     518    } else if(  opts=="nsta"   || opts=="nstat"
     519             || opts=="nostat" || opts=="nostats") {
     520      SetStats(false);
     521    } else if(opts.substr(0,8)=="h2scale=") {
     522      unsigned short t=TypScale(); float ls=LogScale();
     523      if(opts.substr(8,3)=="lin") t=0;
     524      else if(opts.substr(8,3)=="log")
     525        {t=1; sscanf(opts.c_str(),"h2scale=log,%g",&ls);}
     526      UseScale(t,ls);
     527    } else if(opts.substr(0,7)=="h2disp=") {
     528      unsigned short t=TypDisplay(); float fpts=FPoints();
     529      if(opts.substr(7,3)=="var") t=0;
     530      else if(opts.substr(7,3)=="hbk") t=2;
     531      else if(opts.substr(7,3)=="img") t=3;
     532      else if(opts.substr(7,3)=="pts")
     533        {t=1; sscanf(opts.c_str(),"h2disp=pts,%g",&fpts);}
     534      UseDisplay(t,fpts);
     535    } else if(opts.substr(0,6)=="h2dyn=") {
     536      float hmin=HMin(),hmax=HMax(); size_t q = opts.find(',');
     537      sscanf(opts.c_str(),"h2dyn=%g",&hmin);
     538      if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%g",&hmax);
     539      UseDyn(hmin,hmax);
     540    } else if(opts.substr(0,7)=="h2frac=") {
     541      float fmin=FMin(),fmax=FMax(); size_t q = opts.find(',');
     542      sscanf(opts.c_str(),"h2frac=%g",&fmin);
     543      if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%g",&fmax);
     544      UseFrac(fmin,fmax);
     545    } else if(opts.substr(0,6)=="h2col=") {
     546      bool fcol=Color(); CMapId cmid=ColMap(); bool rmap=IsColMapRev();
     547      if(opts.find(",rev")<opts.length()-1) rmap=true;
     548      if(opts.find(",nor")<opts.length()-1) rmap=false;
     549      for(int k=0; k<PIColorMap::NumberStandardColorMaps(); k++) {
     550        string cn=PIColorMap::GetStandardColorMapName(k);
     551        for(unsigned int j=0; j<cn.length(); j++) cn[j]=tolower(cn[j]);
     552        if(opts.find(cn)<opts.length()-1)
     553          {fcol=true; cmid=PIColorMap::GetStandardColorMapId(k); break;}
     554      }
     555      UseColors(fcol,cmid,rmap);
     556   } else {
     557      ndec--;
     558      // S'il faut supprimer les options decodees
     559      if (rmdecopt)  udopt.push_back(opts);
     560    }
     561  }
     562  // S'il faut supprimer les options decodees, on remplace l'argument opt
     563  // par le vecteur des options non decodees.
     564  if (rmdecopt)  opt = udopt;
     565  // Liste des options si demande
     566  if(listopt) Print();
     567  return(ndec+ndec1);
     568}
     569
     570//++
     571void PIHisto2D::GetOptionsHelpInfo(string& info)
     572//
     573//      Help relatif au options
     574//--
     575{
     576// On recupere d'abord la chaine info de la classe de base
     577PIDrawer::GetOptionsHelpInfo(info);
     578info += " ---- PIHisto2D options help info (see also ALT-O): \n" ;
     579info += "- h2help: get this help text\n";
     580info += "- h2list: list choosen options\n";
     581info += "- sta,stat,stats:            activate   statistic display\n";
     582info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
     583info += "- h2disp=typ[,fracpts]: choose display type\n";
     584info += "    typ=var: variable size boxes\n";
     585info += "    typ=hbk: \"a la hbook2\"\n";
     586info += "    typ=img: image like (use \"h2col\" for color map)\n";
     587info += "    typ=pts: point clouds (fracpts=max possible fraction\n";
     588info += "             of used pixels per bin [0,1])\n";
     589info += "- h2scale=lin/log[,logscale]: choose linear or logarithmic scale\n";
     590info += "- h2dyn=[hmin][,hmax]: choose histogramme range for display\n";
     591info += "- h2col=[colname][,colsigne] : color table\n";
     592info += "    colname: name of color table (ex: grey32,midas_heat,...)\n";
     593info += "             (see general graphicatt description)\n";
     594info += "    colsigne: reverse (\"rev\") or normal (\"nor\") color table\n";
     595info += "- h2frac=[fmin][,fmax]: choose sub-range display [0,1]\n";
     596return;
    488597}
    489598
     
    625734mOPop[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    626735
    627 // Menu du choix des couleurs
     736// Menu du choix de la table des couleurs
    628737  cpy += bsy+spy;
    629738mOPop[2] = new PIOptMenu(this,"optmen-h2d-3",2*bsx,bsy,cpx,cpy);
  • trunk/SophyaPI/PIext/pihisto2d.h

    r2231 r2234  
    1313
    1414#include "histos2.h"
     15#include "pidrawer.h"
    1516#include "piscdrawwdg.h"
    1617
     
    3031  virtual void Draw(PIGraphicUC* g,double xmin,double ymin,double xmax,double ymax);
    3132
    32   //   AppendTextInfo a faire un jour - Reza 21/01/2002
    33   //  virtual void AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
     33  //AppendTextInfo a faire un jour - Reza 21/01/2002
     34  //virtual void AppendTextInfo(string& info,double xmin,double ymin
     35  //                           ,double xmax,double ymax);
    3436
     37  // Ce que fait l'action de clic avec la souris
    3538  virtual void GetClickInfo(string& info, double x, double y
    3639                           ,double x0=0.,double y0=0.,bool fgdiff=false);
     
    3841  virtual void UpdateLimits();
    3942  virtual void DrawStats(PIGraphicUC* g);
     43  inline  void SetStats(bool fg=true) {stats=fg;}
    4044
    41 //  Methode permettant l'affichage d'une fenetre de controle specialisee
     45  //  Methode permettant l'affichage d'une fenetre de controle specialisee
    4246  virtual void ShowControlWindow(PIBaseWdgGen* wdg);
    43 //  Desactivation de la fenetre de controle specialisee
     47  //  Desactivation de la fenetre de controle specialisee
    4448  virtual void DeactivateControlWindow(PIBaseWdgGen* wdg);
    4549
     50  //   Methode de decodage des options
     51  virtual int  DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     52  virtual void GetOptionsHelpInfo(string& info);
     53
     54  // Methodes inline
    4655  inline Histo2D*       Histogram()   {return(mHisto);}
    4756  inline bool           Color()       {return(mFgCol);}
     
    6271
    6372  Histo2D* mHisto;
    64   bool mAdDO;
     73  bool mAdDO; bool stats;
    6574  bool mFgCol; CMapId mCmap; bool mRevCmap;
    6675  unsigned short mTypScal; float mLogScale;
Note: See TracChangeset for help on using the changeset viewer.