Writing TCanvas to Screen (X11) from compiled code

Hi,

I am trying to do the following. I wrote a class, which creates a TCanvas and plots some histogram on it. I can print the TCanvas to file, and it all looks fine. I call the class from a simple C++ executable.

I compiled everything under MacOs 10.4, using gcc 4.0.1, linking against the root 5.20 libraries.

Now I want the class to print the TCanvas to screen instead of to file, like you can do in a CINT session for instance. Is this possible? I found the ROOT X11 interface, but I have no idea how to use this to reach my goal.

Hope you can help.

Folkert

Should work when executed from the proper shell.
e.g.
When I run root interactively in a non-x11 terminal shell I get an error
When I do the same in an x11 shell I get plots.
OSX should handle this automatically in the proper shell.

I’m in the process of attempting the same thing.

osx user

When I run interactively in a xterm on MacOsX, it works fine like you said.

It’s when I try to show a canvas in stand-alone compiled code that I get problems. There are no errors, and the canvas is created ok (I can print it to file), but I cannot show it on the screen. Did you manage to get this working?

Could you post the shortest possible running code explaining/showing the problem?

Rene

These are the three files. There is the header and source for the class, and there is the source for the small binary used to create an instance of the class. Hope this helps clarify.

If I add a line in the doPlot() method of the class:
c1->Print(“c1.eps”);

Then I get the canvas in the ps file. But it is not shown on screen, whether I run in an xterm or not.
Plotter_short.h (1.28 KB)
plot_short.cxx (404 Bytes)
Plotter_short.cxx (355 Bytes)