Problem with TRootEmbeddedCanvas


I have a standalone gui program, using TRootEmbeddedCanvas, and i can’t do wat i want.
I would like to display Root Tracks with TGeoManager in a TRootEmbeddedCanvas.

#include "MdiTrackAnimation.hxx"
#include <TCanvas.h>
#include <TGeoManager.h>
#include <TFile.h>
#include <TKey.h>
#include <iostream>
using namespace std;


MdiTrackAnimation::MdiTrackAnimation(TGMdiMainFrame *p) : TGMdiFrame(p, 600, 500)

//     ec1_ = new TRootEmbeddedCanvas("ec1",this,100,100);
//     this->AddFrame(ec1_, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
//     ec1_->GetCanvas()->cd();

    TGeoManager * geom_;

    TFile * f = new TFile("./myfile.root");
    Bool_t fin = kFALSE;
    TKey *key = 0;
    TIter* objIter = new TIter(f->GetListOfKeys());
    while (!fin && (key=(TKey*) objIter->Next()))
        if (strcmp(key->GetClassName(),"TGeoManager") == 0 )
            geom_ = (TGeoManager * )(key->ReadObj());
            fin = kTRUE;

    geom_->SetTminTmax(9e-9, 1e-8);

    this->SetWindowName("Track Animation");

This code works fine and open the tracks in a new TCanvas

But if i uncomment the 3 lines at the beginning, it doesn’t work, and i don’t understand why.
The TRootEmbeddedCanvas is diplayed, but empty (white).

Any idea?


Hi Laurent,

Please make your .root file available for testing (attach it to your post if it is small, or copy it in a public place from where I can download it). I see no problem creating a TRootEmbeddedCanvas in a TGMdiFrame frame and drawing something there.

Thank you, Ilka

Here is my root file with tracks included. But i’m not sure the problem come from the root file.

When I just wan’t to display the TGeoManager with

    TGeoManager * geom = new TGeoManager("MyGeom", "MyGeom");

If a Root embedded Canvas is opened, it doesn’t work
But if not, it open a new TCanvas, and it works.
I don’t understand why.

The Root file:


Here is a simple test

precision: i’m under Linux Mandriva 2006 with root 5.15
test.tar (30 KB)

Hi Laurent,

Thank you for providing the file. I will investigate what happens and will let you know.

Best regards, Ilka

Hi Laurent,

What you have observed comes from the hard coded behavior in TGeoXXX classes. I have informed the authors.

Cheers, Ilka


Thank you for your reply.
I have to find an other solution :frowning:


Hi Laurent,

What you want should be possible and I hope a solution will be found soon. We will keep you informed.

Best regards, Ilka