ROOT
CLING_PROFILE
Reference Guide
Loading...
Searching...
No Matches
gtime.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphics
3
/// Example of a graph of data moving in time.
4
/// Use the canvas "File/Quit ROOT" to exit from this example
5
///
6
/// \macro_code
7
///
8
/// \author Olivier Couet
9
10
void
gtime()
11
{
12
auto
c1
= (
TCanvas
*)
gROOT
->FindObject(
"c1"
);
13
if
(
c1
)
14
delete
c1
;
15
16
c1
=
new
TCanvas
(
"c1"
);
17
const
Int_t
ng = 100;
18
const
Int_t
kNMAX = 10000;
19
std::vector<Double_t>
X
(kNMAX), Y(kNMAX);
20
Int_t
cursor
= kNMAX;
21
Double_t
x
= 0, stepx = 0.1;
22
23
while
(!
gSystem
->ProcessEvents()) {
24
if
(
cursor
+ ng >= kNMAX) {
25
cursor
= 0;
26
for
(
Int_t
i = 0; i < ng; i++) {
27
X
[i] =
x
;
28
Y[i] =
TMath::Sin
(
x
);
29
x
+= stepx;
30
}
31
}
else
{
32
X
[
cursor
+ ng] =
x
;
33
Y[
cursor
+ ng] =
TMath::Sin
(
x
);
34
x
+= stepx;
35
cursor
++;
36
}
37
38
TGraph
*
g
=
new
TGraph
(ng,
X
.data() +
cursor
, Y.data() +
cursor
);
39
g
->SetMarkerStyle(21);
40
g
->SetMarkerColor(
kBlue
);
41
g
->SetLineColor(
kGreen
);
42
g
->SetBit(
kCanDelete
);
// let canvas delete graph when call TCanvas::Clear()
43
44
c1
->Clear();
45
g
->Draw(
"alp"
);
46
c1
->Update();
47
48
gSystem
->Sleep(10);
49
}
50
}
g
#define g(i)
Definition
RSha256.hxx:105
Int_t
int Int_t
Signed integer 4 bytes (int).
Definition
RtypesCore.h:59
Double_t
double Double_t
Double 8 bytes.
Definition
RtypesCore.h:73
kGreen
@ kGreen
Definition
Rtypes.h:67
kBlue
@ kBlue
Definition
Rtypes.h:67
X
#define X(type, name)
cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Definition
TGWin32VirtualXProxy.cxx:160
kCanDelete
@ kCanDelete
Definition
TObject.h:375
gROOT
#define gROOT
Definition
TROOT.h:417
gSystem
externTSystem * gSystem
Definition
TSystem.h:582
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TGraph
Definition
TGraph.h:41
c1
return c1
Definition
legend1.C:41
x
Double_t x[n]
Definition
legend1.C:17
TMath::Sin
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition
TMath.h:599
tutorials
visualisation
graphics
gtime.C
ROOTCLING_PROFILE - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1