Changeset 2383 in Sophya


Ignore:
Timestamp:
May 16, 2003, 5:15:55 PM (22 years ago)
Author:
ansari
Message:

Ajout methode GetInfoString() aux ObjAdapter + attributs de gestion de position de stat pour PINtuple/PIHisto + positionnement par defaut de stat (statposoff=) lors de disp same - Reza 16/5/2003

Location:
trunk/SophyaPI/PIext
Files:
11 edited

Legend:

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

    r2322 r2383  
    6666cout << "NObjMgrAdapter::FillFromString() - Error : Not supported for " << s << endl;
    6767 return;
     68}
     69
     70/* --Methode-- */
     71string NObjMgrAdapter::GetInfoString(int /*lev*/)
     72{
     73char buff[128];
     74sprintf("Type: %s @ %lx", typeid(*mObj).name(), (long)mObj);
     75return(buff);
    6876}
    6977
  • trunk/SophyaPI/PIext/nomgadapter.h

    r1315 r2383  
    4343  virtual void                  FillFromString();
    4444
     45// Returns a string with synthetic information about the object (lev-> Level of details)
     46  virtual string                GetInfoString(int lev=0);
     47
    4548  virtual void                  ReadFits(string const & flnm);
    4649  virtual void                  SaveFits(string const & flnm);
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r2322 r2383  
    4646HProf * hp = dynamic_cast<HProf *>(mHis);
    4747if(hp) return("HProf "); else return("Histo ");
     48}
     49
     50/* --Methode-- */
     51string NOMAdapter_Histo::GetInfoString(int lev)
     52{
     53  char buff[128];
     54  string rs;
     55  if (lev > 2) {
     56    sprintf(buff, "Histo: NBin=%d XMin=%lg XMax=%lg\n", mHis->NBins(),
     57          mHis->XMin(), mHis->XMax());
     58    rs += buff;
     59  }
     60  sprintf(buff, "Entries= %lg \n", mHis->NEntries());
     61  rs += buff;
     62  if (lev > 0) {
     63    sprintf(buff, "Overflow= %lg \n", mHis->NOver());
     64    rs += buff;
     65    sprintf(buff, "Underflow= %lg \n", mHis->NUnder());
     66    rs += buff;
     67  }
     68  sprintf(buff, "Mean= %lg \n", mHis->Mean());
     69  rs += buff;
     70  sprintf(buff, "Sigma= %lg \n", mHis->Sigma());
     71  rs += buff;
     72  return rs;
    4873}
    4974
  • trunk/SophyaPI/PIext/nomhistadapter.h

    r1321 r2383  
    3232  //  virtual void                      SaveFits(string const & flnm);
    3333  virtual void                  SavePPF(POutPersist& s, string const & nom);
     34
     35// Returns a string with synthetic information about the object
     36  virtual string                GetInfoString(int lev=0);
    3437
    3538  virtual void                  Print(ostream& os);
  • trunk/SophyaPI/PIext/pihisto.cc

    r2232 r2383  
    3939  SetStats();
    4040  SetError();
     41  SetStatPosOffset();
    4142  SetName("HistoDrw");
    4243}
     
    173174    else if(opts=="noerr")    SetError(-1);
    174175    else if(opts=="autoerr")  SetError(0);
     176    else if(opts.substr(0,11) == "statposoff=") {
     177      float xo=0., yo=0.;
     178      sscanf(opts.substr(11).c_str(),"%g,%g",&xo, &yo);
     179      SetStatPosOffset(xo, yo);
     180    }
    175181    else {
    176182      ndec--;
     
    191197PIDrawer::GetOptionsHelpInfo(info);
    192198info += " ---- PIHisto options help info : \n" ;
    193 info += "- sta,stat,stats:            activate   statistic display\n";
     199info += "  sta,stat,stats:            activate   statistic display\n";
    194200info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
    195 info += "- err / nerr : draw, do not draw error bars\n";
     201info += "  err / nerr : draw, do not draw error bars\n";
    196202info += "  autoerr : draw error bars if Marker drawing requested OR Profile histo\n";
     203info += "  statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
     204info += "       as a fraction of total size \n";
    197205return;
    198206}
     
    221229  double cellWidth =  1.1 * (double)g->CalcStringWidth(label);
    222230
     231  double ofpx = spoX*(XMax()-XMin());
     232  double ofpy = spoY*(YMax()-YMin());
     233 
    223234  double xu, yu, cw;
    224235  // Les limites du cadre
    225236  xu = g->DeltaUCX(XMax(), -cellWidth);
    226237  yu = g->DeltaUCY(YMax(), -cellHeight);
    227   g->DrawLine(xu,YMax(),xu,yu);
    228   g->DrawLine(xu,yu,XMax(),yu);
     238  double recw = XMax()-xu;
     239  double rech = YMax()-yu;
     240  xu += ofpx;  yu += ofpy;
     241  g->DrawBox(xu, yu, recw, rech);
    229242
    230243  // L'ecriture des labels (attention aux inversions possibles des axes!)
     
    234247  cw = (g->isAxeYDirUpDown()) ? -0.15*cH : -1.15*cH;
    235248  yu = g->DeltaUCY(YMax(),cw);
     249  xu += ofpx;  yu += ofpy;
    236250  g->DrawString(xu, yu,label1);
    237     cw +=  -1.15*cH;
    238     yu = g->DeltaUCY(YMax(),cw);
    239     g->DrawString(xu, yu,label2);
    240       cw +=  -1.15*cH;
    241       yu = g->DeltaUCY(YMax(),cw);
    242       g->DrawString(xu, yu,label3);
     251  cw +=  -1.15*cH;
     252  yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
     253  g->DrawString(xu, yu,label2);
     254  cw +=  -1.15*cH;
     255  yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
     256  g->DrawString(xu, yu,label3);
    243257                       
    244258}
  • trunk/SophyaPI/PIext/pihisto.h

    r2229 r2383  
    1515  virtual void       UpdateLimits();
    1616  inline  void       SetStats(bool fg=true) {stats=fg;}
     17  inline  void       SetStatPosOffset(float ofx=-0.01, float ofy=-0.01)
     18          {spoX=ofx; spoY=ofy; }
    1719  // fg=-1 pas de barre d'erreur, 1=barres d'erreurs,
    1820  // 0=barres d'erreurs automatiques: trace si HProf ou markeur demande
     
    2931  bool mAdDO;
    3032  bool stats,error;
     33  float spoX, spoY; // Stat pos offset par rapport a position defaut
    3134};
    3235
  • trunk/SophyaPI/PIext/pihisto2d.cc

    r2380 r2383  
    4242UseFrac();
    4343SetStats();
     44 SetStatPosOffset();
    4445SetName("Histo2DDrw");
    4546// PIHisto2D has specific control tools
     
    427428  double cellWidth =  1.1 * (double)g->CalcStringWidth(label);
    428429
     430  double ofpx = spoX*(XMax()-XMin());
     431  double ofpy = spoY*(YMax()-YMin());
     432
    429433  double xu, yu, cw;
    430434  // Les limites du cadre
    431435  xu = g->DeltaUCX(XMax(), -cellWidth);
    432436  yu = g->DeltaUCY(YMax(), -cellHeight);
    433   g->DrawLine(xu,YMax(),xu,yu);
    434   g->DrawLine(xu,yu,XMax(),yu);
     437  double recw = XMax()-xu;
     438  double rech = YMax()-yu;
     439  xu += ofpx;  yu += ofpy;
     440  g->DrawBox(xu, yu, recw, rech);
    435441
    436442  // L'ecriture des labels
     
    439445  cw = (g->isAxeYDirUpDown()) ? -0.1*cH : -1.1*cH;
    440446  yu = g->DeltaUCY(YMax(),cw);
     447  xu += ofpx;  yu += ofpy;
    441448  g->DrawString(xu,yu,label);
    442449
     
    524531             || opts=="nostat" || opts=="nostats") {
    525532      SetStats(false);
     533    } else  if(opts.substr(0,11) == "statposoff=") {
     534      float xo=0., yo=0.;
     535      sscanf(opts.substr(11).c_str(),"%g,%g",&xo, &yo);
     536      SetStatPosOffset(xo, yo);
    526537    } else if(opts.substr(0,8)=="h2scale=") {
    527538      unsigned short t=TypScale(); float ls=LogScale();
  • trunk/SophyaPI/PIext/pihisto2d.h

    r2380 r2383  
    4242  virtual void DrawStats(PIGraphicUC* g);
    4343  inline  void SetStats(bool fg=true) {stats=fg;}
     44  inline  void SetStatPosOffset(float ofx=-0.01, float ofy=-0.01)
     45          {spoX=ofx; spoY=ofy; }
    4446
    4547  //  Methode permettant l'affichage d'une fenetre de controle specialisee
     
    7779  float mHMin,mHMax;
    7880  float mFracMin,mFracMax;
     81  float spoX, spoY; // Stat pos offset par rapport a position defaut
    7982};
    8083
  • trunk/SophyaPI/PIext/pintuple.cc

    r2373 r2383  
    4646  mAdDO = ad;
    4747  SetStats(true);
     48  SetStatPosOffset();
    4849  ConnectPoints(false);
    4950  UseSizeScale(true, 5);
     
    237238  // Les labels et leurs longueurs -> largeur de la cellule
    238239  char label[64];
    239   sprintf(label, "Nd= %d / Ntot= %d", nok, mNT->NbLines());
     240  sprintf(label, "N=%d (/%d)", nok, mNT->NbLines());
    240241  double cellWidth =   1.1 * (double)g->CalcStringWidth(label);
    241242  double xu, yu, cw;
     243  double ofpx = spoX*(XMax()-XMin());
     244  double ofpy = spoY*(YMax()-YMin());
    242245  // Les limites du cadre
    243246  xu = g->DeltaUCX(XMax(), - cellWidth);
    244247  yu = g->DeltaUCY(YMax(), - cellHeight);
    245   g->DrawLine(xu, YMax(), xu, yu);
    246   g->DrawLine(xu, yu, XMax(), yu);
     248  double recw = XMax()-xu;
     249  double rech = YMax()-yu;
     250  xu += ofpx;  yu += ofpy;
     251  g->DrawBox(xu, yu, recw, rech);
    247252  // L'ecriture des labels (attention aux inversions possibles des axes!)
    248253  cw = (g->isAxeXDirRtoL()) ? -0.05*cellWidth : -0.95*cellWidth;
     
    250255  cw = (g->isAxeYDirUpDown()) ? -0.1*cH : -1.1*cH;
    251256  yu = g->DeltaUCY(YMax(),cw);
     257  xu += ofpx;  yu += ofpy;
    252258  g->DrawString(xu,yu,label);
    253259}
     
    313319    else if(  opts=="nsta"   || opts=="nstat"
    314320           || opts=="nostat" || opts=="nostats") SetStats(false);
     321    else if(opts.substr(0,11) == "statposoff=") {
     322      float xo=0., yo=0.;
     323      sscanf(opts.substr(11).c_str(),"%g,%g",&xo, &yo);
     324      SetStatPosOffset(xo, yo);
     325    }
    315326    else if (opts == "connectpoints") ConnectPoints(true);
    316327    else if (opts == "noconnectpoints") ConnectPoints(false);
     
    323334      UseSizeScale(true, nbn);
    324335    }
     336
    325337    else {
    326338      // Si option non decode
     
    350362info += "  sta,stat,stats:            activate   statistic display\n";
    351363info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
     364info += "  statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
     365info += "      as a fraction of total size \n";
    352366info += "  connectpoints: The points are connected by a line \n";
    353367info += "  noconnectpoints (this is the default) \n";
    354368info += "  colorscale/nocolorscale (Use color scale for weight) \n";
    355369info += "  sizescale/sizescale=nbins/nosizescale (Use marker size for weight) \n";
    356 info += "  and usual color/line/marker/... attribute decoding  \n";
     370info += "   (and usual color/line/marker/... attribute decoding)  \n";
    357371return;
    358372}
  • trunk/SophyaPI/PIext/pintuple.h

    r2373 r2383  
    3535
    3636  inline  void       SetStats(bool fg=true) { stats = fg; }
     37  inline  void       SetStatPosOffset(float ofx=-0.01, float ofy=-0.01)
     38          {spoX=ofx; spoY=ofy; }
    3739
    3840  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
     
    5658  bool stats;               // true -> indication du nb de points
    5759  bool connectPts;          // true -> les points sont relies par une ligne
     60  float spoX, spoY; // Stat pos offset par rapport a position defaut
    5861};
    5962
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2350 r2383  
    4444static void hideInfoWindow(PIStdImgApp* app);
    4545
     46// Pour compter le nombre de display same a la suite
     47static int nb_disp_same = 0;
    4648
    4749/* ........................................................... */
     
    628630  // Les options
    629631  scd->DecodeOptionString(mDefaultAtt, false);
     632  if (nb_disp_same > 0) {
     633    vector<string> ostatpos;
     634    int spo = nb_disp_same%4;
     635    if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26");
     636    else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01");
     637    else  ostatpos.push_back("statposoff=-0.36,-0.26");
     638    scd->DecodeOptionString(ostatpos, true);
     639  }
    630640  scd->DecodeOptionString(opts, true);
    631641
     
    720730  // Les options
    721731  dr3->DecodeOptionString(mDefaultAtt, false);
     732  if (nb_disp_same > 1) {
     733    vector<string> ostatpos;
     734    int spo = nb_disp_same%4;
     735    if (spo == 1) ostatpos.push_back("statposoff=-0.01,-0.26");
     736    else if (spo == 2)  ostatpos.push_back("statposoff=-0.36,-0.01");
     737    else  ostatpos.push_back("statposoff=-0.36,-0.26");
     738    dr3->DecodeOptionString(ostatpos, true);
     739  }
     740
    722741  dr3->DecodeOptionString(opts, true);
    723742
     
    14441463
    14451464  //DBG  cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
     1465  if (rc == Disp_Same) nb_disp_same++;
     1466  else nb_disp_same = 0;
    14461467  return (rc);
    14471468}
Note: See TracChangeset for help on using the changeset viewer.