I would like to be able to define a graphical cut on a histogram drawn in an embedded canvas, which is part of a GUI I’m writing.
On a standard canvas, this is done by clicking the ‘Graphical Cut’ button on the toolbar. Is there a way to access this same tool from a menu or with a button in my own GUI ? In other words, what function in what class/object should I call in order to start the graphical cut definition tool ?
I’ve been going through the code for TCanvas, TRootCanvas and TGToolbar to get some ideas, but I’m a bit lost here …
There is no way to show up the canvas tool bar when using an embedded canvas for that moment. I will include your request in our todo list and we will provide this feature.
Thanks for your quick reply and the kind offer. At the moment, however, I would be happy if I could just access the graphical cut tool, not the complete toolbar.
In the mean time I did some further digging in the old RootTalk archives and apparently
does the trick for CINT.
If I try to include this in a function or program, I run into the same problem as mentioned in http://root.cern.ch/root/roottalk/roottalk00/0477.html, being that the program moves on before I finish defining the cut. So, I tried the sollution suggested by Rene in his reply to the original question and came up with this function :
Please find an example in the attached macro. I tried to create it as simple as possible. You have an embedded canvas, status bar and 3 buttons: Draw, CutG and Exit. The signals/slots communication mechanism is used in this example. To draw a histogram click the Draw button; to create a graphical cut - on the CutG button; Exit - will terminate it.
You have to set a name to the TCutG object any time you want to keep it. Use the context menu and SetName command for that. Otherwise, any new TCutG object will replace the old one because they have the same name CUTG.
In addition, you can see how to make available the status bar for an embedded canvas in case you need it.
I explained the way you can change the TCutG name and it works fine. There should be some reasons (not in my knowledge) which require the same name of any new TCutG object.
OK, in addition I found that the name is set this way in TCreatePrimitives::PolyLine method where the object is created.
[quote]There should be some reasons (not in my knowledge) which require the same name of any new TCutG object.[/quote]We use a default name so that the graphically created graphic cut can easily (and predicably) be recovered from the command line.