Re: [ROOT] picking an object on a pad

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 09 2001 - 10:25:45 MET


Hi Pasha,
As you say, there are several cases where it is not convenient to store
each object in the list of pad primitives. Very often, a supervisor object
takes care of painting its contained objects. 
Picking these objects not in the pad list of primitives is easy.
In your supervisor object function DistancetoPrimitive, you simply have to
   gPad->SetSelected(foundObject);
When clicking with the right button, you will automatically get
the context menu of the class corresponding to foundObject.
We have many examples. See, eg:

1- the histogram picking function. a TH1 objects does not store its sub-objects
(such as the TAxis objects) in the pad primitives.

http://root.cern.ch/root/htmldoc/src/THistPainter.cxx.html#THistPainter:DistancetoPrimitive


2- Example of an Event Display supervisor
http://root.cern.ch/root/html224/atlfast/src/ATLFDisplay.cxx.html#ATLFDisplay:DistancetoPrimitive


Rene Brun


Pasha Murat (630)840-8237@169G wrote:
> 
> Dear ROOTers,
> 
> having spent some time working with ROOT graphics I came across the following
> issue. I'm drawing various primitives, typical for high-energy physics:
> tracks, track segments, hits, detectors etc. In order to optimize certain
> operations like disabling drawing all the tracks or MC particles, the
> objects included into TCanvas's list of primitives are not the hits and the
> tracks themselves, but the lists of those. This way one can avoid having
> very long and hard to handle lists of primitives.
> 
> The thing I'd like to be able to do is to locate a Track with a mouse and to
> popup a context menu for this Track, provided not a Track, but a list of Tracks
> is included into the current pad's list of primitives.
> 
> In principle, this is possible. One of the solutions, which comes to mind
> right away, would be to have
> 
> TObject::DistancetoPrimitive
> 
> returning not only a distance to the primitive, but also a pointer to
> WHAT IT AND NOT A TPad believes to be the object, closest to the
> cursor, because not all the information is available for TPad.
> I'm wondering if a call signature like
> 
>  void TObject::DistancetoPrimitive(Int_t px, Int_t px, TObject*& closest_object);
> 
> or
> 
> TObject* TObject::DistancetoPrimitive(Int_t px, Int_t px)
> 
> can be considered? Or is there a more elegant solution, which doesn't require
> changing the interfaces?
>                                                 thanks a lot, Pasha



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET