Re: TObject derivatives : clarification needed

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Oct 07 1997 - 16:38:48 MEST


Hi Laurent,

   the two main sets of TObject member functions that can be 
overridden are the ones to draw your object and to sort your 
object in a collection. Most others don't need to be overridden
since they are general. For example to make your object drawable
you would have to implement the members: Draw() and Paint().
Draw() in general is very simple and only calls AppendPad()
(see example TLine::Draw()). AppendPad() adds an object to
a TPad's display list. In Paint() you actually paint the
object using TPad paint primitives, like TPad::PaintLine(),
etc., see TLine::Paint()). To interact with you object on the
screen you also would need to implement ExecuteEvent() (see
again TLine::ExecuteEvent()).

In case your objects are sortable or hashable you should 
override the members: IsSortable(), Compare(), Hash() and 
IsEqual(). See for example the small class in 
$ROOTSYS/test/tcollex.cxx.

See also page 33 (part 2, page 3) and further (on collections)
in the just published ROOT course (see ROOT News on web).

Cheers, Fons.


Laurent Aphecetche wrote:
> 
> Hi,
> 
> I would like to have some clarification on which member functions
> must/can be overloaded when one derives a class from TObject, and
> what exactly do these function. Also, are there other rules (than
> making a default ctor and a virtual destructor) to add personal
> classes into Root ?
> 
> Thanks a lot.
> --
> APHECETCHE Laurent (mailto:aphecetche@ganil.fr)
> GANIL, B.P. 5027, 14076, Caen Cedex 5, France
> Vox: +33 (0)2 31 45 45 85 - Fax: +33 (0)2 31 45 46 65
> WWW: http://ganp03.in2p3.fr/nof/ & (perso.)
> http://www.mygale.org/~p0mp0n

-- 
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:26:21 MET