[ROOT] Q: copy canvas into pad

From: Ingolf Martin (martin@pit.physik.uni-tuebingen.de)
Date: Wed Jul 12 2000 - 08:59:40 MEST


Hi Rooters,

I would like to copy a canvas into a little pad in another canvas,
something like

  // create two canvases (and one pad in second canvas)
  .x $ROOTSYS/tutorials/graph.C;
  TCanvas *canv1 = (TCanvas*)gROOT->GetListOfCanvases()->First();
  TCanvas *canv2 = new TCanvas("canv2", "canv2", 1);
  TPad *pad2 = new TPad("subpad","subpad", 0.3, 0.3, 0.7, 0.7);
  canv2->cd();
  pad2->Range(canv1->GetX1(), canv1->GetY1(), canv1->GetX2(), canv1->GetY2());
  pad2->Draw();

But if I do

  //first try
  TCanvas *clone1 = (TCanvas*)canv1->Clone();
  pad2->cd();
  clone1->Draw();

all that appears on pad2 is a frame and the title of canv1's graph.
If one decides to manually loop through all graphics objects

  //second try
  pad2->Clear();
  TIter next(canv1->GetListOfPrimitives());
  TObject *obj;
  while (obj = next()) obj->Clone()->Draw();

the copy is still incomplete (apart from the obvious fact that this doesn't
duplicate pad attributes like color and grid).
On the other hand, the second approach works fine on the output of

  .x $ROOTSYS/tutorials/archi.C

which contains mainly TBoxes.

What is wrong with these examples? 
(ROOT 2.25/00 on Linux) - any comments would be greatly
appreciated.

Ingolf 

------------------------------------------------

Ingolf Martin
Physikalisches Institut,  Universität Tübingen
Auf der Morgenstelle 14, 72076 Tübingen, Germany
Tel: 07071/2976311   Fax: /295373



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:29 MET