Re: mouse button: 2 questions

From: Alexis Cothenet <cothenet_at_cppm.in2p3.fr>
Date: Thu, 14 Apr 2005 09:06:56 +0200 (CEST)

Hi Rene,

Thank you. You were right now it works for both cases. So, in the macro i do:
void exectest(){

  int event = gPad->GetEvent();
  float iix = gPad->GetEventX();
  float iiy = gPad->GetEventY();

  float roix = gPad->AbsPixeltoX(iix);
  float roiy = gPad->AbsPixeltoY(iiy);

  if (event == 1){ //button down

    TMarker *m = new TMarker(roix, roiy, 800) ;

    m->SetMarkerStyle(3);
    m->SetMarkerColor(2);
    m->Draw("SAME");

}
}

but i'd like also to be able that if i click on a marker with the mouse button, i could move it at another place. I have no idea how to do that, i checked the functions in Tpad but didn't see what could help... Would you have a such example ?
Thank you,

Alexis

On Thu, 14 Apr 2005, Rene Brun wrote:

> When you run the script test.C, the function exectest is known to CINT.
> If you type the commands without telling CINT where to find
> the function, it is clear that it cannot work.
> I suggest adding the following line
> gROOT->ProcessLine(".L exectest.C")
> before executing:
> c1->AddExec("test","exectest()");
>
> where exectest.C is a file containing only the function exectest
>
> Rene Brun
>
> On
> Wed, 13 Apr 2005 alexis.cothenet_at_free.fr wrote:
>
> > Hi all,
> >
> > I have two questions about the macro that i put in attachment.
> >
> > 1) If i run it like this, it works well.
> > But if i prefer to do in root:
> > TFile * f = new TFile("test.root","RECREATE");
> > TH1F * hALL = new TH1F("hALL","hALL",100,-3,3);
> > hALL->FillRandom("gaus",1000);
> > f->Write();
> > and then to change test() like this:
> > //TH1F * hALL = new TH1F("hALL","hALL",100,-3,3);
> > TFile f("test.root","READ") ;
> > // hALL->FillRandom("gaus",1000);
> > TCanvas * c1 = new TCanvas("c1");
> > hALL->Draw();
> > c1->Update();
> > c1->AddExec("test","exectest()");
> >
> >
> > I cannot see any more the hitogramm hALL...it seems to be masked by something
> > empty...do you understand my problem ?
> >
> > 2) once i clicked on the canvas with the mouse and that some markers appeared,
> > i'd like to be able to move some of them at another place in the canvas by the
> > way of the mouse.
> > Could you explain me how to do that ?
> >
> > Thank you a lot by advance!
> >
> > Regards,
> > Alexis
> >
> >
>
>
Received on Thu Apr 14 2005 - 09:07:05 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:06 MET