TEllipse as a TGButton

Hi,

I’m making a gui for visualizing data, and I want to represent an array of pmt’s in the detector as TEllipses. When a user would click on one of the TEllipse, it send a signal to draw the data waveform of that pmt to a canvas. How do I do that?

May be something like that:

#include <TEllipse.h>
#include <TCanvas.h>
#include <TQObject.h>

void exec2()
{
   // Example of using signal/slot in TCanvas/TPad to get feedback
   // about mouse-click events.
   //Author: Ilka Antcheva
   
   TCanvas *c1=new TCanvas("c1");
   c1->Range(-10,-10,10,10);
   
   TEllipse *e = new TEllipse();

   e->DrawEllipse(0.,0.,1.,2.,0.,360.,0.);
   e->DrawEllipse(3.,0.,1.,2.,0.,360.,0.);
   e->DrawEllipse(-3.,0.,1.,2.,0.,360.,0.);
   e->DrawEllipse(0.,5.,1.,2.,0.,360.,0.);
   e->DrawEllipse(0.,-5.,1.,2.,0.,360.,0.);

   c1->Update();
   c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0,
               "exec2event(Int_t,Int_t,Int_t,TObject*)");
}

void exec2event(Int_t event, Int_t x, Int_t y, TObject *selected)
{
   TCanvas *c = (TCanvas *) gTQSender;

   if (event == kButton1Down) // mouse click
      printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n", c->GetName(),
             event, x, y, selected->IsA()->GetName());
}

Thank you couet for the reply. Do you know a way I can pass the UniqueID as well? I tried to set the unique id in the exec2() and then recover it in exec2event() but it gives me junk.

Surge

You mean unique ID to each Ellipse ?
TEllipse is very basic and does not inherit from TNamed … So that a bit difficult to set a unique ID…
May be retrieving the ellipse position can be a solution ?

I was afraid of that. Thanks for your help.

Surge