Re: painting an object derived from TH1

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Oct 21 1999 - 16:21:05 MEST


Hi Damir,
I describe here a simple and powerful solution to add any TObject*
to be painted together with an histogram.
A TH1 has a TList member normally supporting the associated functions.
You can add to this list any TObject*. When the histogram is drawn,
all the objects in this list are drawn in the order found in the list.
Note that this list is also persistent with the histogram.
Suppose you want to add one or more annotation objects to an histogram
h,
for example a TPaveText, you can do:

  TPaveText *pt = new TPaveText(x1,y1,x2,y2);
  h->GetListOfFunctions()->Add(pt);

where x1,y1,x2,y2 are given in histogram coordinates.
When doing h->Draw, the PaveText pt will also be drawn.
In your case, you can use this technique, to fill the pt object
with your own statistics. You can create this PaveText in your derived
TH1 class
myTH1::Paint function.

Rene Brun

Damir Buskulic wrote:
> 
> Hi,
> 
> with the new library scheme of ROOT, the Painter and Hist are separated.
> I have a class that derives from TH1F, but I would like to paint some
> parts differently, namely the stat box. Before, I was just overloading
> the TH1::PaintStats method.
> How can I do it now ? Do I have to specify a completely different
> painter that I have to rewrite ? I looked a little bit at the code and
> found that the static member fgPainter was holding the class description
> of the current Painter. Since it is static, I cannot change it without
> changing also the painter for regular TH1.
> I suppose I'll just put regular stats off and overlay my own stat box.
> 
> Any other ideas ?
> 
> Damir
> --
> =====================================================================
> | Damir Buskulic                  | Universite de Savoie/LAPP       |
> |                                 | Chemin de Bellevue, B.P. 110    |
> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> =====================================================================
> mailto:buskulic@lapp.in2p3.fr



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