Logo ROOT   6.12/06
Reference Guide
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 
10 void 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 
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:424
return c1
Definition: legend1.C:41
int Int_t
Definition: RtypesCore.h:41
Double_t x[n]
Definition: legend1.C:17
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:445
double sin(double)
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
The Canvas class.
Definition: TCanvas.h:31
double Double_t
Definition: RtypesCore.h:55
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
Definition: Rtypes.h:59
const Int_t kNMAX
static constexpr double g