ROOT logo

From $ROOTSYS/tutorials/graphics/graph_edit_playback.C

// This macro plays a recorded ROOT session showing how to perform various
// interactive graphical editing operations. The initial graphics setup 
// was created using the following root commands: 
/*
     t = new TRecorder();
     t->Start("graphedit_playback.root");
     gStyle->SetPalette(1);
     TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
     TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
     h2->SetDirectory(0);
     TRandom r;
     for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
     h2->Draw();
     gPad->Update();
     TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
     TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
     h1->SetDirectory(0);
     h1->FillRandom("gaus",10000);
     h1->Draw();
     gPad->Update();
    
     // Here the following "sketch" was done.
    
     t->Stop();
*/
// Note: The previous commands should be copy/pasted into a ROOT session, not
// executed as a macro.
//
// The interactive editing shows:
//     - Object editing using object editors
//     - Direct editing on the graphics canvas
//     - Saving PS and bitmap files.
//     - Saving as a .C file: C++ code corresponding to the modifications
//       is saved.
//
// The sketch of the recorded actions is:
//
//    On the canvas c1:
//       Open View/Editor
//       Select histogram
//       Change fill style
//       Change fill color
//       Move stat box
//       Change fill color
//       Move title 
//       Change fill color using wheel color
//       Select Y axis
//       Change axis title
//       Select X axis
//       Change axis title
//       Select histogram
//       Go in binning
//       Change range
//       Move range
//       On the canvas menu set grid Y
//       On the canvas menu set grid X
//       On the canvas menu set log Y
//       Increase the range
//       Close View/Editor
//       Open the Tool Bar
//       Create a text "Comment"
//       Create an arrow
//       Change the arrow size
//       Close the Tool Bar
//       Save as PS file
//       Save as C file
//       Close c1
//    On the canvas c2:
//       Open View/Editor
//       Select histogram
//       Select COL
//       Select Palette
//       Move Stats
//       Select Overflows
//       Select histogram
//       Select 3D
//       Select SURF1
//       Rotate Surface
//       Go in binning
//       Change X range
//       Change Y range
//       Close View/Editor
//       Save as GIF file
//       Save as C file
//       Close c2

Int_t file_size(char *filename)
{
   FileStat_t fs;
   gSystem->GetPathInfo(filename, fs);
   return (Int_t)fs.fSize;
}

void graph_edit_playback()
{
   r = new TRecorder();
   r->Replay("http://root.cern.ch/files/graphedit_playback.root");

   // wait for the recorder to finish the replay
   while (r->GetState() == TRecorder::kReplaying) {
      gSystem->ProcessEvents();
      gSystem->Sleep(1);
   }

   Int_t c1_ps_Ref  = 11592 , c1_ps_Err  = 600;
   Int_t c1_C_Ref   =  4729 , c1_C_Err   = 200;
   Int_t c2_gif_Ref = 21184 , c2_gif_Err = 500;
   Int_t c2_C_Ref   = 35471 , c2_C_Err   = 1500;

   Int_t c1_ps  = file_size("c1.ps");
   Int_t c1_C   = file_size("c1.C");
   Int_t c2_gif = file_size("c2.gif");
   Int_t c2_C   = file_size("c2.C");

   cout << "**********************************************************************" <<endl;
   cout << "*  Report of graph_edit_playback.C                                   *" <<endl;
   cout << "**********************************************************************" <<endl;

   if (TMath::Abs(c1_ps_Ref-c1_ps) <= c1_ps_Err) {
      cout << "Canvas c1: PS output............................................... OK" <<endl;
   } else {
      cout << "Canvas c1: PS output........................................... FAILED" <<endl;
   }
   if (TMath::Abs(c1_C_Ref-c1_C) <= c1_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   if (TMath::Abs(c2_gif_Ref-c2_gif) <= c2_gif_Err) {
      cout << "Canvas c2: GIF output.............................................. OK" <<endl;
   } else {
      cout << "Canvas c2: GIF output.......................................... FAILED" <<endl;
   }
   if (TMath::Abs(c2_C_Ref-c2_C) <= c2_C_Err) {
      cout << "           C output................................................ OK" <<endl;
   } else {
      cout << "           C output............................................ FAILED" <<endl;
   }
   cout << "**********************************************************************" <<endl;

}
 graph_edit_playback.C:1
 graph_edit_playback.C:2
 graph_edit_playback.C:3
 graph_edit_playback.C:4
 graph_edit_playback.C:5
 graph_edit_playback.C:6
 graph_edit_playback.C:7
 graph_edit_playback.C:8
 graph_edit_playback.C:9
 graph_edit_playback.C:10
 graph_edit_playback.C:11
 graph_edit_playback.C:12
 graph_edit_playback.C:13
 graph_edit_playback.C:14
 graph_edit_playback.C:15
 graph_edit_playback.C:16
 graph_edit_playback.C:17
 graph_edit_playback.C:18
 graph_edit_playback.C:19
 graph_edit_playback.C:20
 graph_edit_playback.C:21
 graph_edit_playback.C:22
 graph_edit_playback.C:23
 graph_edit_playback.C:24
 graph_edit_playback.C:25
 graph_edit_playback.C:26
 graph_edit_playback.C:27
 graph_edit_playback.C:28
 graph_edit_playback.C:29
 graph_edit_playback.C:30
 graph_edit_playback.C:31
 graph_edit_playback.C:32
 graph_edit_playback.C:33
 graph_edit_playback.C:34
 graph_edit_playback.C:35
 graph_edit_playback.C:36
 graph_edit_playback.C:37
 graph_edit_playback.C:38
 graph_edit_playback.C:39
 graph_edit_playback.C:40
 graph_edit_playback.C:41
 graph_edit_playback.C:42
 graph_edit_playback.C:43
 graph_edit_playback.C:44
 graph_edit_playback.C:45
 graph_edit_playback.C:46
 graph_edit_playback.C:47
 graph_edit_playback.C:48
 graph_edit_playback.C:49
 graph_edit_playback.C:50
 graph_edit_playback.C:51
 graph_edit_playback.C:52
 graph_edit_playback.C:53
 graph_edit_playback.C:54
 graph_edit_playback.C:55
 graph_edit_playback.C:56
 graph_edit_playback.C:57
 graph_edit_playback.C:58
 graph_edit_playback.C:59
 graph_edit_playback.C:60
 graph_edit_playback.C:61
 graph_edit_playback.C:62
 graph_edit_playback.C:63
 graph_edit_playback.C:64
 graph_edit_playback.C:65
 graph_edit_playback.C:66
 graph_edit_playback.C:67
 graph_edit_playback.C:68
 graph_edit_playback.C:69
 graph_edit_playback.C:70
 graph_edit_playback.C:71
 graph_edit_playback.C:72
 graph_edit_playback.C:73
 graph_edit_playback.C:74
 graph_edit_playback.C:75
 graph_edit_playback.C:76
 graph_edit_playback.C:77
 graph_edit_playback.C:78
 graph_edit_playback.C:79
 graph_edit_playback.C:80
 graph_edit_playback.C:81
 graph_edit_playback.C:82
 graph_edit_playback.C:83
 graph_edit_playback.C:84
 graph_edit_playback.C:85
 graph_edit_playback.C:86
 graph_edit_playback.C:87
 graph_edit_playback.C:88
 graph_edit_playback.C:89
 graph_edit_playback.C:90
 graph_edit_playback.C:91
 graph_edit_playback.C:92
 graph_edit_playback.C:93
 graph_edit_playback.C:94
 graph_edit_playback.C:95
 graph_edit_playback.C:96
 graph_edit_playback.C:97
 graph_edit_playback.C:98
 graph_edit_playback.C:99
 graph_edit_playback.C:100
 graph_edit_playback.C:101
 graph_edit_playback.C:102
 graph_edit_playback.C:103
 graph_edit_playback.C:104
 graph_edit_playback.C:105
 graph_edit_playback.C:106
 graph_edit_playback.C:107
 graph_edit_playback.C:108
 graph_edit_playback.C:109
 graph_edit_playback.C:110
 graph_edit_playback.C:111
 graph_edit_playback.C:112
 graph_edit_playback.C:113
 graph_edit_playback.C:114
 graph_edit_playback.C:115
 graph_edit_playback.C:116
 graph_edit_playback.C:117
 graph_edit_playback.C:118
 graph_edit_playback.C:119
 graph_edit_playback.C:120
 graph_edit_playback.C:121
 graph_edit_playback.C:122
 graph_edit_playback.C:123
 graph_edit_playback.C:124
 graph_edit_playback.C:125
 graph_edit_playback.C:126
 graph_edit_playback.C:127
 graph_edit_playback.C:128
 graph_edit_playback.C:129
 graph_edit_playback.C:130
 graph_edit_playback.C:131
 graph_edit_playback.C:132
 graph_edit_playback.C:133
 graph_edit_playback.C:134
 graph_edit_playback.C:135
 graph_edit_playback.C:136
 graph_edit_playback.C:137
 graph_edit_playback.C:138
 graph_edit_playback.C:139
 graph_edit_playback.C:140
 graph_edit_playback.C:141
 graph_edit_playback.C:142