I am finishing up a GUI app and I wanted to know how to perform this operation in a compiled code (C++).
With Cint we can do:
TH1D *h1 = new TH1D("name","name", 10, 0 , 1);
This of course gives us a pretty plot.
Then we can return the list of objects on that pad/canvas in a few ways, one being below
This returns a variety of things including the histogram primitive.
Now in compiled code, at the moment, all it seems like I can do is search for:
Is there any way to return a list in C++ of objects in a pad currently? I want to try to avoid calling FindObject too often.
Personally I do not see any problem of calling FindObject() many times.
Maybe you are thinking in a way to handle an object after you found it?
TH1D *h1_handle = (TH1D*) gPad->FindObject("name");
h1_handle ->SetTitle("Notice h1 is own by the current directory");
Anyways, you can also try
In return a TList, something you can handle as a list.
I hope this helps.
Thank you, I will check out this function. This is what I was looking for.
For posterities sake, a little bit of C++ implementation:
TList *MyList = EmpeddedCanvasObject->GetCanvas()->GetListOfPrimitives();
std::cout << "object class name " << obj1->ClassName() << std::endl;