> > 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