gtime.C

Go to the documentation of this file.
00001 // Example of a graph of data moving in time
00002 // Use the canvas "File/Quit" to exit from this example
00003 //Author: Olivier Couet
00004 void gtime() {
00005    TCanvas *c1 = new TCanvas("c1");
00006    const Int_t ng = 100;
00007    const Int_t kNMAX = 10000;
00008    Double_t *X = new Double_t[kNMAX];
00009    Double_t *Y = new Double_t[kNMAX];
00010    Int_t cursor = kNMAX;
00011    TGraph *g = new TGraph(ng);
00012    g->SetMarkerStyle(21);
00013    g->SetMarkerColor(kBlue);
00014    Double_t x = 0;
00015          
00016    while (1) {
00017       c1->Clear();
00018       if (cursor > kNMAX-ng) {
00019          for (Int_t i=0;i<ng;i++) {
00020             X[i] = x;
00021             Y[i] = sin(x);
00022             x   += 0.1;
00023          }
00024          g->Draw("alp");
00025          cursor = 0;
00026       } else {
00027          x + = 0.1;
00028          X[cursor+ng] = x;
00029          Y[cursor+ng] = sin(x);
00030          cursor++;
00031          g->DrawGraph(ng,&X[cursor],&Y[cursor],"alp");
00032       }
00033       c1->Update();
00034       gSystem->ProcessEvents();
00035       gSystem->Sleep(10);
00036    }
00037 }         
00038       

Generated on Tue Jul 5 15:44:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1