graph_edit_playback.C

Go to the documentation of this file.
00001 // This macro plays a recorded ROOT session showing how to perform various
00002 // interactive graphical editing operations. The initial graphics setup 
00003 // was created using the following root commands: 
00004 /*
00005      t = new TRecorder();
00006      t->Start("graphedit_playback.root");
00007      gStyle->SetPalette(1);
00008      TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
00009      TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
00010      h2->SetDirectory(0);
00011      TRandom r;
00012      for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
00013      h2->Draw();
00014      gPad->Update();
00015      TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
00016      TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
00017      h1->SetDirectory(0);
00018      h1->FillRandom("gaus",10000);
00019      h1->Draw();
00020      gPad->Update();
00021     
00022      // Here the following "sketch" was done.
00023     
00024      t->Stop();
00025 */
00026 // Note: The previous commands should be copy/pasted into a ROOT session, not
00027 // executed as a macro.
00028 //
00029 // The interactive editing shows:
00030 //     - Object editing using object editors
00031 //     - Direct editing on the graphics canvas
00032 //     - Saving PS and bitmap files.
00033 //     - Saving as a .C file: C++ code corresponding to the modifications
00034 //       is saved.
00035 //
00036 // The sketch of the recorded actions is:
00037 //
00038 //    On the canvas c1:
00039 //       Open View/Editor
00040 //       Select histogram
00041 //       Change fill style
00042 //       Change fill color
00043 //       Move stat box
00044 //       Change fill color
00045 //       Move title 
00046 //       Change fill color using wheel color
00047 //       Select Y axis
00048 //       Change axis title
00049 //       Select X axis
00050 //       Change axis title
00051 //       Select histogram
00052 //       Go in binning
00053 //       Change range
00054 //       Move range
00055 //       On the canvas menu set grid Y
00056 //       On the canvas menu set grid X
00057 //       On the canvas menu set log Y
00058 //       Increase the range
00059 //       Close View/Editor
00060 //       Open the Tool Bar
00061 //       Create a text "Comment"
00062 //       Create an arrow
00063 //       Change the arrow size
00064 //       Close the Tool Bar
00065 //       Save as PS file
00066 //       Save as C file
00067 //       Close c1
00068 //    On the canvas c2:
00069 //       Open View/Editor
00070 //       Select histogram
00071 //       Select COL
00072 //       Select Palette
00073 //       Move Stats
00074 //       Select Overflows
00075 //       Select histogram
00076 //       Select 3D
00077 //       Select SURF1
00078 //       Rotate Surface
00079 //       Go in binning
00080 //       Change X range
00081 //       Change Y range
00082 //       Close View/Editor
00083 //       Save as GIF file
00084 //       Save as C file
00085 //       Close c2
00086 
00087 Int_t file_size(char *filename)
00088 {
00089    FileStat_t fs;
00090    gSystem->GetPathInfo(filename, fs);
00091    return (Int_t)fs.fSize;
00092 }
00093 
00094 void graph_edit_playback()
00095 {
00096    r = new TRecorder();
00097    r->Replay("http://root.cern.ch/files/graphedit_playback.root");
00098 
00099    // wait for the recorder to finish the replay
00100    while (r->GetState() == TRecorder::kReplaying) {
00101       gSystem->ProcessEvents();
00102       gSystem->Sleep(1);
00103    }
00104 
00105    Int_t c1_ps_Ref  = 11592 , c1_ps_Err  = 600;
00106    Int_t c1_C_Ref   =  4729 , c1_C_Err   = 200;
00107    Int_t c2_gif_Ref = 21184 , c2_gif_Err = 500;
00108    Int_t c2_C_Ref   = 35471 , c2_C_Err   = 1500;
00109 
00110    Int_t c1_ps  = file_size("c1.ps");
00111    Int_t c1_C   = file_size("c1.C");
00112    Int_t c2_gif = file_size("c2.gif");
00113    Int_t c2_C   = file_size("c2.C");
00114 
00115    cout << "**********************************************************************" <<endl;
00116    cout << "*  Report of graph_edit_playback.C                                   *" <<endl;
00117    cout << "**********************************************************************" <<endl;
00118 
00119    if (TMath::Abs(c1_ps_Ref-c1_ps) <= c1_ps_Err) {
00120       cout << "Canvas c1: PS output............................................... OK" <<endl;
00121    } else {
00122       cout << "Canvas c1: PS output........................................... FAILED" <<endl;
00123    }
00124    if (TMath::Abs(c1_C_Ref-c1_C) <= c1_C_Err) {
00125       cout << "           C output................................................ OK" <<endl;
00126    } else {
00127       cout << "           C output............................................ FAILED" <<endl;
00128    }
00129    if (TMath::Abs(c2_gif_Ref-c2_gif) <= c2_gif_Err) {
00130       cout << "Canvas c2: GIF output.............................................. OK" <<endl;
00131    } else {
00132       cout << "Canvas c2: GIF output.......................................... FAILED" <<endl;
00133    }
00134    if (TMath::Abs(c2_C_Ref-c2_C) <= c2_C_Err) {
00135       cout << "           C output................................................ OK" <<endl;
00136    } else {
00137       cout << "           C output............................................ FAILED" <<endl;
00138    }
00139    cout << "**********************************************************************" <<endl;
00140 
00141 }

Generated on Tue Jul 5 15:44:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1