> Hi Rooters, > > we clearly did not describe clearly enough how to derive from > TVirtualHistPainter or from THistPainter and how to make your new > painter the default painter. > > Assume you want to modify the existing default THistPainter: > > - class TMyHistPainter : public THistPainter { ... }; > override only the few paint methods you want to change > > - compile into a shared lib libMyHistPainter.so > > - in rootlogon.C add the following: > > > // make sure the base class is loaded > > gROOT->LoadClass("THistPainter","HistPainter"); > > gROOT->LoadClass("TMyHistPainter", MyHistPainter"); > > TVirtualHistPainter::SetPainter("TMyHistPainter"); > > > > - from now on all histograms will be painted using the new TMyHistPainter. > > Hello, Fons, I understood the original problem / question slightly different. One complained: > > > > Since it is static, I cannot change it without > > > > changing also the painter for regular TH1. Sounds like the user does want to use very standard "painter" to all histograms excluding a few of them. Those he wants to paint with his/her own painter. To achieve this goal he is to be provided with one extra method TH1::Painter() described below. Cheers, Valery > > Cheers, Fons. > > > > > > > > > > > > > > Hi Damir, > > > in new TH1 class no method SetPainter(TVirtualHistPainter *userPainter); > > > If Rene & Fons will add it, then you can create your painter > > > object derived from TVirtualHistPainter and set it to histogram. > > > > > > As a temporary solution you can use the following "barbaric" function > > > to add your method to histogram. When rene will add SetPainter to TH1 > > > then you can remove it. > > > > > > void SetPainter(TH1 *h,TVirtualHistPainter *p) > > > { > > > TVirtualHistPainter **s = (TVirtualHistPainter **)((int*)h+117); > > > p->SetHistogram(h); > > > *s = p; > > > } > > > > > > Victor > > > > > > "Valeri Fine (Faine)" wrote: > > > > > > > > ----- Original Message ----- > > > > From: Valeri Fine (Faine) <fine@bnl.gov> > > > > To: Damir Buskulic <buskulic@lapp.in2p3.fr>; ROOT mailing list <roottalk@hpsalo.cern.ch> > > > > Subject: Re: painting an object derived from TH1 > > > > > > > > ----- Original Message ----- > > > > From: Damir Buskulic <buskulic@lapp.in2p3.fr> > > > > To: ROOT mailing list <roottalk@hpsalo.cern.ch> > > > > Subject: painting an object derived from TH1 > > > > > > > > > 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 ? > > > > > > > > I missed one essential point, one has to add > > > > fPainter->StHistogram(this) ; > > > > statement to get: > > > > > > > > > > > > class TMyHist : public TH1 { > > > > public: > > > > TVirtualHistPainter * Painter(TVirtualHistPainter *myPainter) { > > > > TVirtualHistPainter * old = fPainter; > > > > fPainter = myPainter; > > > > if (fPainter) fPainter->SetHistogram(this) ; > > > > return old; > > > > } > > > > } > > > > > > > > Afterwards you can define your own painter and attach it to your particular > > > > histogram. This way you may use either standard or your own Painter with each > > > > other Update step or for different TPads. > > > > > > > > Another solution: > > > > > > > > class TMyHist : public TH1 { > > > > public: > > > > TVirtualHistPainter * Painter(TVirtualHistPainter *myPainter) { > > > > delete fPainter; fPainter = 0; > > > > if (myPainter) { > > > > fPainter = myPainter; > > > > fPainter->SetHistogram(this) ; > > > > } > > > > return fPainter ; > > > > } > > > > } > > > > > > > > Valery > > > > > > -- > > > Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch > > > Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 > > > tel office : 516-344-7894; fax 516-344-4206; home 516-345-2690 > > > > > > > > > -- > > Org: CERN, European Laboratory for Particle Physics. > > Mail: 1211 Geneve 23, Switzerland > > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 > > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910 > > > > >
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET