Hi Rene, > Simply derive your painter from the existing painter > and redefine only one or a few functions. yes, but then you change behaviour of ALL histograms. But what to do if you want to change it only for one? When Painter is a separate class, it is very natural to allow to Paint different histograms by different painters. Victor Rene Brun wrote: > > Hi Victor, > You do not need to reimplement a complete painter. > Simply derive your painter from the existing painter > and redefine only one or a few functions. > In a separate mail from Fons (that did not reach roottalk), he says: > > 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. > > > > > Rene Brun > > On Thu, 21 Oct 1999, Victor Perevoztchikov wrote: > > > Hi Rene, > > > > > Once this is called (once per job), TH1::Paint will automatically > > > invoke your painter. > > > > no, it is good only if user does not want standard Painter at all. > > But usually standard painter is good enough, but for very special > > histograms, user wants provide modified painter do NOT AFFECTING all others histograms. > > For this case method SetPainter() is very usefull and safe. > > And it is very easy to implement, just 3 lines of code and no more discussion > > > > Victor > > > > > > Rene Brun wrote: > > > > > > Hi Victor, Damir, > > > There is no need for TH1::SetPainter > > > You can directly use the static function > > > TVirtualHistPainter::SetPainter(const char* myPainterClassname) > > > Once this is called (once per job), TH1::Paint will automatically > > > invoke your painter. > > > Note that each histogram has its own painter instance in such a way > > > that the system can work in a multithreaded environment. > > > > > > Rene Brun > > > > > > On Thu, 21 Oct 1999, Victor Perevoztchikov wrote: > > > > > > > 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 > > > > > > > > -- > > 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 > > -- 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
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET