Re: [ROOT] TCanvas problem with TRootEmbeddedCanvas

From: H.-Gerd Rosarius (rosarius@getit.de)
Date: Thu Jun 05 2003 - 11:42:45 MEST


I make up the solution by my own. Reading the list and guitest.C
as well as puzzeling things together did help. 
For the people who are faced with the same problem here's a 
(hopefully) working solution.

// --- Code start -----------------------------------------
// Importing canvas with name "c1" from root-file
TFile* f = new TFile("/home/xxxxx/root-files/demo.root");
TCanvas* c = (TCanvas*) f->Get("c1");

// Define a layout
TGLayoutHints* layoutTV = new TGLayoutHints(kLHintsTop | kLHintsLeft | 
kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5);

// Frame to display the histogram
TGCompositeFrame* frameTV = new TGCompositeFrame(this, 60, 60, 
kHorizontalFrame);
// The embbeded canvas for the display frame
TRootEmbeddedCanvas* canvasEmbedded = new TRootEmbeddedCanvas("Histo_canvas", 
frameTV, 100, 100);
//Add embedded canvas to display frame
frameTV->AddFrame(canvasEmbedded, layoutTV);

// Get pointer to "normal" canvas
TCanvas* display = canvasEmbedded->GetCanvas();
display->cd();

// Get primitives from imported canvas ...
TList* list = c->GetListOfPrimitives();

// ... and draw each single object.
for (Int_t i = 0; i < list->GetSize(); i++) {
  list->At(i)->Draw();
}

display->Modified();
display->Update();

// --- Code end -------------------------------------------

In my case this works like a charm.

Happy rooting

   H.-Gerd Rosarius



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET