Hello,
I have a problem I don’t understand. I would like to put two markers on a TH1F (when I press a button) and so I’ve written the following code:
TMarker *mark[3]; //global variable
void MyMainFrame::DoModify()
{
TCanvas *fCanvas=fEcanvas->GetCanvas();
fCanvas->cd();
ica=0;
nmarker=0;
gPad->SetFillColor(0); //why the code needs this line to works good?
fCanvas->Connect(“ProcessedEvent(Int_t,Int_t,Int_t,TObject*)”, 0, 0,“mettimarker(Int_t,Int_t,Int_t,TObject*)”);
while(ica!=1)
{
usleep(100);
gClient->HandleInput();
}
fCanvas->Disconnect(“ProcessedEvent(Int_t,Int_t,Int_t,TObject*)”);
}
void mettimarker(Int_t event,Int_t x,Int_t y,TObject* selected)
{
TCanvas *fCanvas = (TCanvas *) gTQSender;
fCanvas->cd();
if(event==61 && ica!=1 &&nmarker<2>SetX(gPad->AbsPixeltoX(x));
mark[nmarker]->SetY(gPad->AbsPixeltoY(y));
mark[nmarker]->SetMarkerStyle(23);
mark[nmarker]->SetMarkerColor(2);
mark[nmarker]->Draw();
gPad->Modified();
gPad->Update();
nmarker++;
}
}
where fCanvas is defined as:
private:
TRootEmbeddedCanvas *fEcanvas;
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
{
fMain=new TGMainFrame(p,w,h);
fEcanvas= new TRootEmbeddedCanvas(“Ecanvas”,fMain,200,200);
fMain->AddFrame(fEcanvas,new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,10,10,10,1));
}
The code works well only if I write the command line (that I don’t need)
gPad->SetFillColor(0);
while, if I don’t do this, I get the error messagg:
Error: non class,struct,union object $gPad used with . or ->
when I move on the pad?
Thanks for your help!
Regards
paola