Re: Question about option "EventStatus"

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Apr 15 1998 - 18:13:12 MEST


Patrice Lebrun wrote:
> 
> Hi,
> 
>    It seems that we have a particular case in Root about the option
> EventStatus. Why the EventStatus display is not a TObject ?
> In other hand, is there an object which contains informations displayed
> by the EventStatus ?
> 

The EventStatus facility invokes the member function GetObjectInfo
for the object identified with the mouse.
Root provides a default TObject::GetObjectInfo (see below).
This method can be redefined by all classes derived from TObject.

Rene Brun



//_______________________________________________________________
Text_t *TObject::GetObjectInfo(Int_t px, Int_t py)
{
   // Returns string containing info about the object at (px,py).
   // This method is typically overridden by classes of which the
objects
   // can report peculiarities for different positions.

   if (!gPad) return "";
   static char info[64];
   Float_t x = gPad->AbsPixeltoX(px);
   Float_t y = gPad->AbsPixeltoY(py);
   sprintf(info,"x=%.3g, y=%.3g",gPad->PadtoX(x),gPad->PadtoY(y));
   return info;
}


Another example:

//______________________________________________________________
Text_t *TH1::GetObjectInfo(Int_t px, Int_t py)
{
//   Redefines TObject::GetObjectInfo.
//   Displays the histogram info (bin number, contents, integral 
//   corresponding to cursor position px,py
//
   if (!gPad) return "";
   static char info[64];
   Float_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
   Float_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
   Int_t binx,biny;
   binx = fXaxis.FindBin(x);
   if (GetDimension() == 1) {
      Double_t integ = 0;
      for (Int_t bin=0;bin<binx;bin++) {integ += GetBinContent(bin+1);}
      sprintf(info,"(x=%g, y=%g, binx=%d, binc=%g,
Sum=%g)",x,y,binx,GetBinContent(binx),integ);
   } else {
      biny = fYaxis.FindBin(y);
      sprintf(info,"(x=%g, y=%g, binx=%d, biny=%d,
binc=%g)",x,y,binx,biny,GetCellContent(binx,biny));
   }
   return info;
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET