Logo ROOT  
Reference Guide
graph_edit_playback.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// This macro plays a recorded ROOT session showing how to perform various
4/// interactive graphical editing operations. The initial graphics setup
5/// was created using the following root commands:
6/// ~~~{.cpp}
7/// TRecorder *t = new TRecorder();
8/// t->Start("graphedit_playback.root");
9/// gStyle->SetPalette(1);
10/// TCanvas *c2 = new TCanvas("c2","c2",0,0,700,500);
11/// TH2F* h2 = new TH2F("h2","Random 2D Gaussian",40,-4,4,40,-4,4);
12/// h2->SetDirectory(0);
13/// TRandom r;
14/// for (int i=0;i<50000;i++) h2->Fill(r.Gaus(),r.Gaus());
15/// h2->Draw();
16/// gPad->Update();
17/// TCanvas *c1 = new TCanvas("c1","c1",0,0,700,500);
18/// TH1F* h1 = new TH1F("h1","Random 1D Gaussian",100,-4,4);
19/// h1->SetDirectory(0);
20/// h1->FillRandom("gaus",10000);
21/// h1->Draw();
22/// gPad->Update();
23///
24/// // Here the following "sketch" was done.
25///
26/// t->Stop();
27/// ~~~
28/// Note: The previous commands should be copy/pasted into a ROOT session, not
29/// executed as a macro.
30///
31/// ### The interactive editing shows
32/// - Object editing using object editors
33/// - Direct editing on the graphics canvas
34/// - Saving PS and bitmap files.
35/// - Saving as a .C file: C++ code corresponding to the modifications is saved.
36///
37/// ### The sketch of the recorded actions is
38///
39/// #### On the canvas c1
40/// - Open View/Editor
41/// - Select histogram
42/// - Change fill style
43/// - Change fill color
44/// - Move stat box
45/// - Change fill color
46/// - Move title
47/// - Change fill color using wheel color
48/// - Select Y axis
49/// - Change axis title
50/// - Select X axis
51/// - Change axis title
52/// - Select histogram
53/// - Go in binning
54/// - Change range
55/// - Move range
56/// - On the canvas menu set grid Y
57/// - On the canvas menu set grid X
58/// - On the canvas menu set log Y
59/// - Increase the range
60/// - Close View/Editor
61/// - Open the Tool Bar
62/// - Create a text "Comment"
63/// - Create an arrow
64/// - Change the arrow size
65/// - Close the Tool Bar
66/// - Save as PS file
67/// - Save as C file
68/// - Close c1
69/// #### On the canvas c2
70/// - Open View/Editor
71/// - Select histogram
72/// - Select COL
73/// - Select Palette
74/// - Move Stats
75/// - Select Overflows
76/// - Select histogram
77/// - Select 3D
78/// - Select SURF1
79/// - Rotate Surface
80/// - Go in binning
81/// - Change X range
82/// - Change Y range
83/// - Close View/Editor
84/// - Save as GIF file
85/// - Save as C file
86/// - Close c2
87/// \author Olivier Couet
88
89Int_t file_size(const char *filename)
90{
91 FileStat_t fs;
92 gSystem->GetPathInfo(filename, fs);
93 return (Int_t)fs.fSize;
94}
95
96void graph_edit_playback()
97{
98 TRecorder *r = new TRecorder();
99 r->Replay("http://root.cern.ch/files/graphedit_playback.root");
100
101 // wait for the recorder to finish the replay
102 while (r->GetState() == TRecorder::kReplaying) {
104 gSystem->Sleep(1);
105 }
106
107 Int_t c1_ps_Ref = 11592 , c1_ps_Err = 600;
108 Int_t c1_C_Ref = 4729 , c1_C_Err = 200;
109 Int_t c2_gif_Ref = 21184 , c2_gif_Err = 500;
110 Int_t c2_C_Ref = 35471 , c2_C_Err = 1500;
111
112 Int_t c1_ps = file_size("c1.ps");
113 Int_t c1_C = file_size("c1.C");
114 Int_t c2_gif = file_size("c2.gif");
115 Int_t c2_C = file_size("c2.C");
116
117 cout << "**********************************************************************" <<endl;
118 cout << "* Report of graph_edit_playback.C *" <<endl;
119 cout << "**********************************************************************" <<endl;
120
121 if (TMath::Abs(c1_ps_Ref-c1_ps) <= c1_ps_Err) {
122 cout << "Canvas c1: PS output............................................... OK" <<endl;
123 } else {
124 cout << "Canvas c1: PS output........................................... FAILED" <<endl;
125 }
126 if (TMath::Abs(c1_C_Ref-c1_C) <= c1_C_Err) {
127 cout << " C output................................................ OK" <<endl;
128 } else {
129 cout << " C output............................................ FAILED" <<endl;
130 }
131 if (TMath::Abs(c2_gif_Ref-c2_gif) <= c2_gif_Err) {
132 cout << "Canvas c2: GIF output.............................................. OK" <<endl;
133 } else {
134 cout << "Canvas c2: GIF output.......................................... FAILED" <<endl;
135 }
136 if (TMath::Abs(c2_C_Ref-c2_C) <= c2_C_Err) {
137 cout << " C output................................................ OK" <<endl;
138 } else {
139 cout << " C output............................................ FAILED" <<endl;
140 }
141 cout << "**********************************************************************" <<endl;
142
143}
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:45
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
Class provides direct recorder/replayer interface for a user.
Definition: TRecorder.h:266
@ kReplaying
Definition: TRecorder.h:296
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition: TSystem.cxx:1398
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:440
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:419
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Long64_t fSize
Definition: TSystem.h:130