Re: embedding ROOT

Rene Brun (Rene.Brun@cern.ch)
Fri, 26 Sep 1997 08:10:52 +0200


Pasha Murat wrote:
>
> This is kind of issue which people will never agree upon...
> I'm trying to write a prototype of event display code
> based on ROOT graphics classes. By design this shoudn't be a
> standalone application, instead it should be called by another routine:
> I need main to be loaded statically because otherwise there is no
> way to debug the whole system. This is nothing but embedding ROOT
> into another application. Having started from test/hworld.cxx
> I've been trying to make the code reentrant: after the event display
> routine is executed, all the windows should be closed. The example below
> bombs. I guess that this is happening because TCanvas::Close() does
> much more than just closing the window on the screen.
>
> Is it possible to modify the example below so it would close a canvas after
> the first call to TApplication::Run() and reopen it at the second call?
>
> I'd appreciate any hints on this subject.
> Thanks, Pasha.
>

I have modified your example below to use the delete operator

Rene Brun

--------------------------------------------------------------------------------
> #include "TROOT.h"
> #include "TApplication.h"
> #include "TCanvas.h"
> #include "TLine.h"
> #include "TPaveLabel.h"
>
> extern void InitGui();
> VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
> int Error;
> TROOT root("hello","Hello World", initfuncs);
> TApplication* theApp;
>
> main(int argc, char **argv) {
> TApplication theApp("App", &argc, argv);
> TCanvas *c = new TCanvas("c", "The Hello Canvas", 400, 400);
> c->Update();
> theApp.Run(kTRUE);
> delete c;

.....
> c = new TCanvas(........;
> theApp.Run(kTRUE);
> }
> --------------------------------------------------------------------------------