Dynamic linkage of object's member function to a Pad

Hi ROOTers

I am trying to add an executable function to the current selected canvas. because I am divided my canvas into some n number of pads, I end up adding the function to every single pad in the following form:

//[LINE#1] gPad->AddExec("dynamic","GetCoordinates()");

which I find to be the same as doing the following declaration:

//[LINE#2] gPad->AddExec("dynamic","APIanalyzer::GetCoordinates()");

Now it happens that GetCoordenates is a memeber function of my APIanalyzer class:

When I run this program in ROOT v5.19, my program works fine. However when I run my program in v5.22 or v5.24 I get the following errors:

If I run with LINE#1:

[quote]
*** Interpreter error recovered ***
Error: Function GetCoordinates() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
Error: Function GetCoordinates() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
Error: Function GetCoordinates() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
Error: Function GetCoordinates() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***[/quote]

If I run with LINE#2:

[quote]
*** Interpreter error recovered ***
Error: cannot call member function without object (tmpfile):1:
(compiled) 0 void APIanalyzer::GetCoordinates();
Calling : APIanalyzer::GetCoordinates();
Match rank: file line signature

  •    0 (compiled)   0 void APIanalyzer::GetCoordinates();
    

*** Interpreter error recovered ***
Error: cannot call member function without object (tmpfile):1:
(compiled) 0 void APIanalyzer::GetCoordinates();
Calling : APIanalyzer::GetCoordinates();
Match rank: file line signature

  •    0 (compiled)   0 void APIanalyzer::GetCoordinates();
    

*** Interpreter error recovered ***
Error: cannot call member function without object (tmpfile):1:
(compiled) 0 void APIanalyzer::GetCoordinates();
Calling : APIanalyzer::GetCoordinates();
Match rank: file line signature

  •    0 (compiled)   0 void APIanalyzer::GetCoordinates();
    

*** Interpreter error recovered ***[/quote]

Those errors are print out as soon as a mouse action is detected in any of my pads. I was able to figure out (based on the error description) that the AddExec is adding a function which is linked to an object. Because I do not specified the object, hence I get the error. I was able to solve the problem by declaring my function static:

This indeed solve the problem however it does not work with my current program architecture. Is there a way to do the proper linkage of an executable function (aka member function to an object) to a Pad?

I try the following but it did not work:

Thanks for your comments…
Kris

Instead of

gPad->AddExec("dynamic","this->GetCoordinates()"); you can do

Rene

Hi Rene

Your suggestions works fine for v5.19 but it does not work for v5.22. I got the following error:

[quote]Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
Error: unexpected character in expression 0xbfbfa34c->GetCoordinates() (tmpfile):1:
(long long)1012184072096636928
*** Interpreter error recovered ***
[/quote]

Suggestions? I will try v5.24 and I get back to you soon…
Kris

About the sane error in v5.24…

Kris

instead of

gPad->AddExec("dynamic",Form("(APIanalyzer*)0x%x->GetCoordinates()",this)); try

gPad->AddExec("dynamic",Form("((APIanalyzer*)0x%x)->GetCoordinates()",this));
I had a missing parenthesis

Rene

Rene… You are a genius. It worked. Thxs,
Kris