Re: executing a Method for an object stored in TObjArray

From: Fons Rademakers (rdm@pcsalo.cern.ch)
Date: Wed Sep 02 1998 - 17:54:55 MEST


Hi Frederic,

   this should work correctly because the TPolyMarker will be called via
the virtual Draw() function in TObject. Make sure that you set the right range
in the TCanvas (default 0..1,0..1). See small example below.

Cheers, Fons.


{
    gROOT->Reset();

    TObjArray a;

    for (int i = 1; i < 6; i++) {
       float x[2];
       float y[2];

       x[0] = i*0.1;
       x[1] = i*0.15;
       y[0] = i*0.1;
       y[1] = i*0.15;

       TPolyMarker *p = new TPolyMarker(2,x,y);

       a.Add(p);
    }

    a[0]->Draw();   // draw first polymarker
    //a.Draw();       // draw all polymarkers
}

> 
> Hello,
>  I stored many objects( of class TPolyMarker) in a Array A(of class TObjArray)
> with the command A.AddLast().
>   Then i would like to Draw all these objects, 
> but  i don't know how to do, because, the command A[0]->Draw()  seems not to 
> call the
> Method Draw() of TPolymarker, but the Method of TObject.
> Thank you in advance,
> 
>   
> -- 
> Frederic Faure
> LPMMC (Maison des Magisteres Jean Perrin, CNRS)
> BP 166 38042 Grenoble Cedex 9 France
> email: faure@labs.polycnrs-gre.fr
> tel: 04 76 88 74 98
> fax: 04 76 88 79 81
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



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