Hi, I've been writing a macro that saves the canvas pointed to by gPad and all objects on it. I've run into two problems. 1. When histogram color is changed through hist->SetLineColor(kRed) this change isn't saved when you do hist->Write(); Are there any ways to get around this? 2. The draw options for histograms (like col or lego) as well as the canvas options (like logy) are not saved either when you use Write(). How would one extract and save this information? I'm running v.3.02/07 on red hat 6.2. The code I've been using is pasted below: Thanks, Rajat Bhatnagar #include <iostream.h> #include "TH1.h" #include "TPaveLabel.h" #include "TCanvas.h" #include "TFile.h" #include "TKey.h" #include "TROOT.h" #include "TStyle.h" void SaveCanvas(TFile* f) { TList* t0 = gPad->GetListOfPrimitives(); TObject* obj; if (!f->IsWritable()) cout << "Error: file not writeable.\n"; if (t0) { TListIter next(t0); while ((obj=next())) { cout << "Saving: " << obj->GetName() << endl; obj->Write(); } } } void ReadCanvas(TFile* f) { TList* t0 = f->GetListOfKeys(); TObject *key, *obj; int firsttime = 1; if (t0) { TListIter next(t0); while ((key=next())) { obj = ((TKey*) key)->ReadObj(); cout << "Reading: " << obj->GetName() << endl; if (obj->InheritsFrom("TH1") && firsttime) { obj->Draw(); firsttime = 0; } else if (obj->InheritsFrom("TH1")) obj->Draw("same"); else obj->Draw(); } } }
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:02 MET