Re: [ROOT] how to handle mouse events in root

From: Jo Schambach (jschamba@physics.utexas.edu)
Date: Wed Jul 31 2002 - 18:01:42 MEST


Hi again,
I am sorry to bother you again, but I am somewhat lost. I tried to follow the
example given in the link that you send me, but I am not successful with this.
Let me try to give you some more detail:

I am using QtRoot from GSI to build an application that has a Root Canvas with
two pads (containing histos) as part of the GUI. In the implementation of the
constructor (which calls the function "init()" below), I did the following (as
shown in your example):

void exec4event(Int_t event, Int_t x, Int_t y, TObject *selected)
{
   TCanvas *c = (TCanvas *) gTQSender;
   printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n",
          c->GetName(), event, x, y, selected->IsA()->GetName());
}

void QtRoot::init() // the constructor of QtRoot calls this function
{
    if (c1->getCanvas()) { // c1 is the TQRootCanvas
	rc1 = c1->getCanvas();
	pad1 = new TPad("pad1", "2d Histo", 0.01, 0.01, 0.55, 0.99, 10);
	rc1->cd();  
	pad2 = new TPad("pad2", "1d Histo",  0.555,  0.01,  0.99,  0.99,  10);
	pad1->SetCanvas(  rc1 );
	pad1->Draw(); 
	pad1->cd();
 	histo2d = new TH2F("hybrid", 
			   "Barrel 3, Ladder 1, Wafer 1, Hybrid 2 ", 
			   240, -0.5, 239.5, 128, -0.5, 127.5);
	histo2d->Draw();
     
	rc1->cd();  
	pad2->SetCanvas(  rc1 );
	pad2->Draw();
	pad2->cd();
	histo = new TH1F("hppx", "Gaussian Distribution", 100, -4, 4);
	histo->Draw();
	rc1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0,
		     "exec4event(Int_t,Int_t,Int_t,TObject*)");
    }
}


This code compiles correctly, but when I run the application, I get the
following message:

Error in <TQObject::CheckConnectArgs>: slot exec4event(int,int,int,TObject*)
does not exist


What am i missing here?

Cheers,		Jo

Fons Rademakers wrote:
> 
> Sorry forgot to paste the link:
> 
> http://root.cern.ch/root/roottalk/roottalk02/2914.html
> 
> Cheers, Fons.
> 
> On Tue, 2002-07-30 at 23:13, Jo Schambach wrote:
> > I am sorry, Fons, I am a little confused: which message and which thread are
> > you talking about?
> >
> > Cheers,               Jo
> >
> > Fons Rademakers wrote:
> > >
> > > Hi Jo,
> > >
> > >   see this message and the associated thread.
> > >
> > > Cheers, Fons.
> > >
> > > On Tue, 2002-07-30 at 21:31, Jo Schambach wrote:
> > > > Forgive me if this question is a FAQ or has been answered before:
> > > >
> > > > How does one handle mouse events in a custom root application?
> > > > Specifically, here is what I would like to do:
> > > > I have a canvas with 2 pads, one pad containing a 2d histo, the other a 1d
> > > > histo. When the user left clicks (or shift clicks, if left click is already
> > > > used) on the 2d histo, I would like to display the projection of the 2d histo
> > > > at the mouse location in the 1d histo. So I need a way of getting notified
> > > > about the fact and the location of the "left-mouse-click".
> > > > Thanks for any help in advance.
> > > >
> > > > Regards,
> > > >
> > > > Jo
> > > > --
> > > > *******************************************************
> > > > Dr Joachim Schambach
> > > > Physics Department, RLM 5.208 -C1600
> > > > University of Texas
> > > > Austin, TX 78712, USA
> > > > Phone: (512) 471-1303; FAX: (781) 998-5513
> > > > e-mail: jschamba@physics.utexas.edu
> > > --
> > > Org:    CERN, European Laboratory for Particle Physics.
> > > Mail:   1211 Geneve 23, Switzerland
> > > E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> > > WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480
> >
> > --
> > *******************************************************
> > Dr Joachim Schambach
> > Physics Department, RLM 5.208 -C1600
> > University of Texas
> > Austin, TX 78712, USA
> > Phone: (512) 471-1303; FAX: (781) 998-5513
> > e-mail: jschamba@physics.utexas.edu
> --
> Org:    CERN, European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23, Switzerland
> E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480

-- 
*******************************************************
Dr Joachim Schambach
Physics Department, RLM 5.208 -C1600
University of Texas
Austin, TX 78712, USA
Phone: (512) 471-1303; FAX: (781) 998-5513
e-mail: jschamba@physics.utexas.edu



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:02 MET