Logo ROOT  
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" to exit from this example
5///
6/// \macro_code
7///
8/// \author Olivier Couet
9
10void gtime() {
11 TCanvas *c1 = new TCanvas("c1");
12 const Int_t ng = 100;
13 const Int_t kNMAX = 10000;
14 Double_t *X = new Double_t[kNMAX];
15 Double_t *Y = new Double_t[kNMAX];
16 Int_t cursor = kNMAX;
17 TGraph *g = new TGraph(ng);
18 g->SetMarkerStyle(21);
19 g->SetMarkerColor(kBlue);
20 Double_t x = 0;
21
22 while (1) {
23 c1->Clear();
24 if (cursor > kNMAX-ng) {
25 for (Int_t i=0;i<ng;i++) {
26 X[i] = x;
27 Y[i] = sin(x);
28 x += 0.1;
29 }
30 g->Draw("alp");
31 cursor = 0;
32 } else {
33 x += 0.1;
34 X[cursor+ng] = x;
35 Y[cursor+ng] = sin(x);
36 cursor++;
37 g->DrawGraph(ng,&X[cursor],&Y[cursor],"alp");
38 }
39 c1->Update();
41 gSystem->Sleep(10);
42 }
43}
44
#define g(i)
Definition RSha256.hxx:105
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
@ kBlue
Definition Rtypes.h:66
const Int_t kNMAX
double sin(double)
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
The Canvas class.
Definition TCanvas.h:23
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:438
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:417
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17