Changeset 2229 in Sophya


Ignore:
Timestamp:
Oct 24, 2002, 11:17:29 PM (23 years ago)
Author:
cmv
Message:

Gestion des options graph. cmv 24/10/02

Location:
trunk/SophyaPI/PIext
Files:
3 edited

Legend:

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

    r1971 r2229  
    3838  mAdDO = ad;     // Flag pour suppression automatique de mHisto
    3939  SetStats(true);
     40  SetError(0);
    4041  SetName("HistoDrw");
    4142}
     
    4344PIHisto::~PIHisto()
    4445{
    45   if (mAdDO) delete mHisto;
     46  if(mAdDO) delete mHisto;
    4647}
    4748
     
    6465    hmin -= v1;   hmax += v1;
    6566  }
    66   if(hmax<=hmin) hmax += 1.;
     67  if(hmax<=hmin) hmax = hmin+1.;
    6768  SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax);
    68 //  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);   NE PAS faire Reza 11/99
    6969}
    7070
     
    7474  if (axesFlags != kAxesNone) DrawAxes(g);
    7575
    76   bool oktrace = false;
    77   if (!mHisto)  return; 
    78 
    79   if((GetGraphicAtt().GetMarker() != PI_NotDefMarker) || 
    80      (typeid(*mHisto) == typeid(HProf)) ) {
    81     // Marqeurs definis OU HProf => marqueurs+Erreurs si il y en a
    82     mHisto->UpdateHisto(); // pour le cas ou c'est un HProf
    83     if(GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
    84     double x1,y1, x2,y2;
     76  if (!mHisto)  return;
     77 
     78  if( typeid(*mHisto)==typeid(HProf) ) mHisto->UpdateHisto();
     79
     80  bool drawmarker=false, drawerr=false, oktrace=false;
     81  // Tracer les marqueurs si demande ou si HProf
     82  if( (GetGraphicAtt().GetMarker() != PI_NotDefMarker) || 
     83      (typeid(*mHisto) == typeid(HProf)) ) drawmarker = true;
     84  if(error==0) {  // Gestion automatique des erreurs
     85    // Tracer les erreurs si HProf
     86    if( typeid(*mHisto)==typeid(HProf) ) drawerr=true;
     87    // Trace les erreurs si marqueurs demandes
     88    if(drawmarker) drawerr=true;
     89  } else if(error>0) drawerr=true;
     90
     91  // Trace des marqeurs
     92  if(drawmarker) {
     93    double x1,y1; oktrace = true;
     94    for(int i=0; i<mHisto->NBins(); i++) {
     95      x1 = mHisto->BinCenter(i);
     96      y1 = (*mHisto)(i);
     97      g->DrawMarker(x1,y1);
     98    }
     99  }
     100
     101  // Trace des erreurs
     102  // Si Marqeurs definis OU HProf => marqueurs+Erreurs si il y en a
     103  if(drawerr) {
     104    if(GetGraphicAtt().GetLineAtt()==PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
     105    double x1,x2,y1,y2;  oktrace = true;
    85106    double bw = mHisto->BinWidth();
    86107    for(int i=0; i<mHisto->NBins(); i++) {
     
    96117        g->DrawLine(x1,y2, x2, y2);
    97118      }
    98       // le marqueur
    99       x1 = mHisto->BinCenter(i);
    100       y1 = (*mHisto)(i);
    101       g->DrawMarker(x1,y1);
    102     }
    103     oktrace = true;
    104   }
     119    }
     120  }
     121
     122  // Trace de la ligne continue
    105123  if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) {
    106     double x1,y1, x2, y2;
     124    double x1,y1, x2, y2; oktrace = true;
    107125    x1 = mHisto->BinLowEdge(0);
    108126    y1 = 0;
     
    117135    }
    118136    y2 = 0; g->DrawLine(x1,y1, x2, y2);
    119     oktrace = true;
    120   }
     137  }
     138
     139  // Si rien n'a ete trace
    121140  if( !oktrace ) {
    122141    for(int i=0; i<mHisto->NBins(); i++) {
     
    126145      double height = (*mHisto)(i);
    127146      g->DrawFBox(left,bottom,width,height);
    128       g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
    129     }
    130   }
     147      g->DrawLine(left, bottom, left, bottom+height); // Au moins une ligne...
     148    }
     149  }
     150
     151  // Trace/Ecriture des statistiques
    131152  // A faire a la fin - DrawStats change l'attribut de ligne
    132153  if(stats) DrawStats(g);
     
    136157PIHisto::DecodeOptionString(vector<string> & opt, bool rmdecopt)
    137158{
    138   if (opt.size() < 1)  return(0); 
     159  int optsz1 = opt.size();
     160  if(optsz1<1) return(0);
    139161  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
    140   if ((opt.size() - ndec1) < 1) return(ndec1);  // si tout a ete decode
     162  if(optsz1-ndec1<1) return(ndec1);  // si tout a ete decode
    141163
    142164  vector<string> udopt;  // On gardera ici les options non decodees
     
    145167  for( k=0; k<opt.size(); k++ ) {
    146168    string opts = opt[k];
    147     if (opts == "stat")  SetStats(true);
    148     else if (opts == "nostat")  SetStats(false);
     169    if(opts=="sta" || opts=="stat" || opts=="stats") SetStats(true);
     170    else if(  opts=="nsta"   || opts=="nstat"
     171           || opts=="nostat" || opts=="nostats") SetStats(false);
     172    else if(opts=="err")      SetError(1);
     173    else if(opts=="noerr")    SetError(-1);
     174    else if(opts=="autoerr")  SetError(0);
    149175    else {
    150176      ndec--;
     
    152178      if (rmdecopt)  udopt.push_back(opts);
    153179    }
    154   } 
     180  }
    155181  // S'il faut supprimer les options decodees, on remplace l'argument opt
    156182  // par le vecteur des options non decodees.
    157183  if (rmdecopt)  opt = udopt;
    158   return(ndec+ndec1); 
     184  return(ndec+ndec1);
     185}
     186
     187void
     188PIHisto::GetOptionsHelpInfo(string& info)
     189{
     190// On recupere d'abord la chaine info de la classe de base
     191PIDrawer::GetOptionsHelpInfo(info);
     192info += " ---- PIHisto options help info : \n" ;
     193info += "- sta,stat,stats:            activate   statistic display\n";
     194info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
     195info += "- err / nerr : draw, do not draw error bars\n";
     196info += "  autoerr : draw error bars if Marker drawing requested OR Profile histo\n";
     197return;
    159198}
    160199
  • trunk/SophyaPI/PIext/pihisto.h

    r1971 r2229  
    1414  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
    1515  virtual void       UpdateLimits();
    16   inline  void       SetStats(bool fg=true) { stats = fg; }
    17   inline  Histo*     Histogram() { return(mHisto); }
     16  inline  void       SetStats(bool fg=true) {stats=fg;}
     17  // fg=-1 pas de barre d'erreur, 1=barres d'erreurs,
     18  // 0=barres d'erreurs automatiques: trace si HProf ou markeur demande
     19  inline  void       SetError(unsigned short fg=0) {error=fg;}
     20  inline  Histo*     Histogram() {return(mHisto);}
    1821
    1922//   Methode de decodage des options
    2023  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     24  virtual void       GetOptionsHelpInfo(string& info);
    2125
    2226protected:
     
    2428  Histo* mHisto;
    2529  bool mAdDO;
    26   bool stats;        // true -> indication des stats d'histo
     30  bool stats,error;
    2731};
    2832
  • trunk/SophyaPI/PIext/pintuple.cc

    r2115 r2229  
    270270int PINTuple::DecodeOptionString(vector<string> & opt, bool rmdecopt)
    271271{
    272   if (opt.size() < 1)  return(0); 
     272  int optsz1 = opt.size();
     273  if(optsz1<1)  return(0); 
    273274  // On appelle d'abord le decodage de la classe PIDrawer de laquelle
    274275  // on herite. (Pas obligatoire) on decode donc ici les attributs de
    275276  // couleur, fontes ...
    276277  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
    277   if ((opt.size() - ndec1) < 1) return(ndec1);  // si tout a ete decode
     278  if(optsz1-ndec1<1) return(ndec1);  // si tout a ete decode
    278279
    279280  vector<string> udopt;  // On gardera ici les options non decodees
     
    282283  for( k=0; k<opt.size(); k++ ) {
    283284    string opts = opt[k];
    284     if (opts == "stat")  SetStats(true);
    285     else if (opts == "nostat")  SetStats(false);
     285    if(opts=="sta" || opts=="stat" || opts=="stats") SetStats(true);
     286    else if(  opts=="nsta"   || opts=="nstat"
     287           || opts=="nostat" || opts=="nostats") SetStats(false);
    286288    else {
    287289      // Si option non decode
     
    306308void PINTuple::GetOptionsHelpInfo(string& info)
    307309{
    308   // On recupere d'abord la chaine info de la classe de base
    309   PIDrawer::GetOptionsHelpInfo(info);
    310   info += " ---- PINTuple options help info : \n" ;
    311   info += "    stat / nostat : activate/deactivate statistic information display \n";
    312   return;
    313 }
     310// On recupere d'abord la chaine info de la classe de base
     311PIDrawer::GetOptionsHelpInfo(info);
     312info += " ---- PINTuple options help info : \n" ;
     313info += "- sta,stat,stats:            activate   statistic display\n";
     314info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
     315return;
     316}
Note: See TracChangeset for help on using the changeset viewer.