Possible communication between browser and cint

Hello all:

When you make a action in GUI, it corresponding to a command line in cint window.
I am wondering whether it is possible or not to show this command line in cint window. If possible, people can easily find the command they want, and programing will be much easier.

Best wishes
xiaojing

Hi xiaojing,

Well, first of all, this statement:

Is not true. The gui events (most of them) are not processed by CINT, but by internal event loop…
But you can use signal/slots to display the processed events (event if it doesn’t really help). For example:[code]#include “Riostream.h”
#include “TGClient.h”

void EventProcessed(Event_t *ev, Window_t)
{
TString evType;
switch (ev->fType) {
case kMapNotify:
evType.Form(“kMapNotify”);
break;
case kUnmapNotify:
evType.Form(“kUnmapNotify”);
break;
case kDestroyNotify:
evType.Form(“kDestroyNotify”);
break;
case kExpose:
evType.Form(“kExpose”);
break;
case kConfigureNotify:
evType.Form(“kConfigureNotify”);
break;
case kGKeyPress:
evType.Form(“kGKeyPress”);
break;
case kKeyRelease:
evType.Form(“kKeyRelease”);
break;
case kFocusIn:
evType.Form(“kFocusIn”);
break;
case kFocusOut:
evType.Form(“kFocusOut”);
break;
case kButtonPress:
evType.Form(“kButtonPress”);
break;
case kButtonDoubleClick:
evType.Form(“kButtonDoubleClick”);
break;
case kButtonRelease:
evType.Form(“kButtonRelease”);
break;
case kEnterNotify:
evType.Form(“kEnterNotify”);
break;
case kLeaveNotify:
evType.Form(“kLeaveNotify”);
break;
case kMotionNotify:
evType.Form(“kMotionNotify”);
break;
case kClientMessage:
evType.Form(“kClientMessage”);
break;
case kSelectionNotify:
evType.Form(“kSelectionNotify”);
break;
case kSelectionRequest:
evType.Form(“kSelectionRequest”);
break;
case kSelectionClear:
evType.Form(“kSelectionClear”);
break;
case kColormapNotify:
evType.Form(“kColormapNotify”);
break;
case kOtherEvent:
evType.Form(“kOtherEvent”);
break;
default:
evType.Form(“Unknown”);
break;
}
cout << “Processed " << evType << " event” << endl;
}

void SpyGUI()
{
if (gClient) {
gClient->Connect(“ProcessedEvent(Event_t *, Window_t)”, 0, 0,
“EventProcessed(Event_t *, Window_t)”);
}
}

[/code]
You can also select what you want to print, since you have access to the full Event_t structure.

Cheers, Bertrand.

Hello bellenot:

Thanks for the instant reply.
Of course you are perfectly correct that the action made in GUI is not processed in CINT window.
However, is it true or not that this action can be translated to a command in CINT?
As far as this command can be printed out in CINT window, then the life of users will be easier.
Because users might not do programing all the time and remember all the commands.
Although the reference of ROOT is very good and helpful, it also takes time read through.

What I understand is that the printout in CINT window can be controlled, but it might not be helpful because
the information is not directly reusable as a executable command. So we need something more, as usual.

Best wishes
Xiaojing

Dear Xiaojing,

Well, not really… CINT is not processing every event and doesn’t know most of them. But what would be your goal? You can already save the GUI in a macro by pressing “ctrl+s” in any TGMainFrame, you can also record a whole session, including the GUI events in a root file (using TRecorder), using signal/slot allows to view almost every possible GUI event… So what is missing?

Cheers, Bertrand.

I think what is desired here is a way to answer the question “How do I do X in CINT or in a macro when I know how to do it with the GUI?” So if you have a histogram showing, and you use the mouse to set a new x range, then it would print something like

h1->GetXaxis()->SetRange(foo,bar);

And if you open the FitPanel and do a Gaussian fit, it would print something like

h1->Fit(“gaus”);

A problem is that there are often many ways to accomplish the same thing, for example SetRange and SetRangeUser, which of those corresponds to zooming with the mouse? What about SetMaximum and SetMinimum?

Jean-François

Jean-François says what I means in his post.

Of course the command may not be unique, but it will be enough if you have one of them.
For example, you want to display several spectra in the same style. You want to show them in beautiful way, but you do not want to repeat the procedure for each spectrum.
Then what you need to do it is to find a macro that display the first one correctly, and the others can be done easily by copy/paste/replace.

When you do that interactively on screen, CINT is not invoked. The method (SetRange in that case) of the class (TAxis in that case) is called directly. What you can do is to save the final state of the editing you did by simply saving the TCanvas in a .C file.