Hello Rooters,
currently I'm going to program a small GUI application which
imports a canvas with a histogram on it from a root-file and
displays it on the screen.
For this purpose I use the following code:
// --- Code start ----------------------------------------------------
// Do stuff like initialising TGMainFrame object etc.
// Import canvas from root-file
TFile* f = new TFile("/home/xxxxxx/root-files/demo.root");
TCanvas* c = (TCanvas*) f->Get("c1");
// Define a base canvas
TGCanvas* canvas = new TGCanvas( this, 1280, 1024, kHorizontalFrame |
kSunkenFrame);
// Create embedded canvas and create root-canvas
TRootEmbeddedCanvas* rootCanvas = new TRootEmbeddedCanvas(0,
canvas->GetViewPort(), 800, 400, kHorizontalFrame);
TCanvas* myRootCanvas = new TCanvas("Empty", 800, 400,
rootCanvas->GetCanvasWindowId());
// Add imported canvas to empty canvas
myRootCanvas->SetCanvas( c );
myRootCanvas->cd();
myRootCanvas->Update();
// Adopt canvas and set the container
rootCanvas->AdoptCanvas( myRootCanvas );
canvas->SetContainer( rootCanvas );
// --- Code snippet end ---------------------------------------------
Unfortunately not the imported canvas c is displayed in the application.
The (or an) empty canvas myRootCanvas is displayed instead.
Maybe it's just a beginners mistake...
Any hints?
Grettings
H.-Gerd
P. S.: Using Root 3.05 built from source on a Debian Linux box.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET