Re: TH->Draw() Draw options question.

From: Anton Fokin (kosu_fokin@garbo.lucas.lu.se)
Date: Wed Mar 17 1999 - 21:50:12 MET


Hi Valery and Rene,

I think I've sent a message with an example where I need to have one TPad
(TCanvas) and then draw different histograms in this pad. Unfortunately I
couldn't find my message in the roottalk. Perhaps it has a limitation on
the message size (I have attached a jpg image). Well anyway the example is
very simple. Just imagine you have a list of different histograms in a
dialog window and when you click on a histogram's name the histogram
appears in TCanvas which is also inside this dialog window. I think the
example is not too much "artificial". Of course all the histograms are
different from LOG, DrawOptions, etc. point of view. What to do in this
case? I would also like to store these options when I write histos in a
file ... It means that in this case these options should be properties of
histograms but not of canvas or pads ...

PS. What I meant by the "main line" of OOP is that in any introductory
course about OOP (and in ROOT intro as well) one may find somewhat like
"shapes" example where Line or Circle or whatever knows how to draw itself,
i.e. a color of a line belongs to the line but not to the TCanvas or TPad
or TMy14"Monitor :))

Regards,


Dr. Anton Fokin

Division of Cosmic and Subatomic Physics
Lund University
Sweden

----------
> From: Valery Fine (Faine) <fine@bnl.gov>
> To: Anton Fokin <kosu_fokin@garbo.lucas.lu.se>; Rene Brun
<Rene.Brun@cern.ch>
> Cc: roottalk@hpsalo.cern.ch
> Subject: RE: TH->Draw() Draw options question.
> Date:  den 17 March 1999 20:29
> 
> >
> > Hi Rene,
> >
> > I think I got it. But ... but ... Isn't it in the line of OOP that
every
> > object knows how to draw itself? Well, anyway my problem is that I have
an
> > array of histograms, let's say TH *hist[2], then I define TH1F *H1F =
new
> > TH1F() and TH2F *H2F = new TH2F() and finally hist[0]=H1F; hist[1]=H2F;
> > Then somewhere in my program I write
> >
> >
> 
>   In C++ the property the object can be taken from the class inheritance
> list.
>   ROOT TH1 class is defined on http://root.cern.ch/root/html/TH1.html as
> follows:
> 
>   class TH1 : public TNamed, public TAttLine, public TAttFill, public
> TAttMarker
> 
>   One can "click" the "inheritance tree" get
> http://root.cern.ch/root/html/TH_Tree.ps
>   to get just all methods of that class for a glance.
> 
>    Actually this means the ROOT objects like "TH1" have something like
> "private per
> object properties" ( . . . Colors/Pattters/Makers per objects . . .) and
> there are others
> "collective properties" like the scale (because for example one needs  a
> scale to
> compare two objects). This involves some assumptions ("model") of the way
> the objects
> of some particular class will be used. Anyway I don't think  OO  has a
> single and only
> true "OO line" if any.
> 
> > for(int i=0;i<2;i++) {
> >   hist[i]->Draw();
> > }
> 
>   What about "Draw" method. This method looks as follows:
> (see: http://root.cern.ch/root/html/TObject.html#TObject:Draw )
> 
> //_________________________________
>  void TObject::Draw(Option_t *option){
>    // Default Draw method for all objects
>    AppendPad(option);
> }
> 
> see: http://root.cern.ch/root/html/src/TObject.cxx.html#TObject:AppendPad
> 
> //_________________________________
>  void TObject::AppendPad(Option_t *option)
> {
>    // Append graphics object to current pad. In case no current pad is
set
>    // yet, create a default canvas with the name "c1".
>    if (!gPad) {
>       if (!gROOT->GetMakeDefCanvas()) return;
>       (gROOT->GetMakeDefCanvas())();
>    }
>    SetBit(kObjInCanvas);
>    gPad->GetListOfPrimitives()->Add(this,option);
>    gPad->Modified(kTRUE);
> }
> 
>   Namely it just "fills" the list of objects the TPad object will paint
> later.
> 
>   Hope this helps,
>                                               Valery



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