Re: Sliding graph

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Sat, 15 Dec 2007 09:28:07 +0100


Emanuel,

You can try something teh example below.

Rene

{

   Int_t n=0,N=0, ndrop = 100, nmax = 1000;    TGraph *g = new TGraph(0);
   TCanvas c1;
   c1.SetGrid();
   g->Draw("alp");
   TRandom r;
   while(1) {

      if (n ==nmax-1) {
         TGraph *gtemp = new 
TGraph(nmax-ndrop,g->GetX()+ndrop,g->GetY()+ndrop);
         delete g;
         g=gtemp;
         n -=ndrop;
         g->Draw("alp");
      }
      g->SetPoint(n,N,0.5*r.Rndm()+5*TMath::Sin(N/200.)+5.5);
      n++;N++;
      if (n%5 == 0) {
         g->SetMarkerStyle(21);
         g->SetMarkerSize(.1);
         g->SetMinimum(0);
         g->SetMaximum(12);
         c1->Modified();
         c1->Update();
         gSystem->ProcessEvents();
      }

   }
}         

Emanuel Machado wrote:
> Hi,
>
> We're trying to use a graph-like display that accumulates data all the time
> but after a certain number of points it starts to dump the old ones.
> Something like
>
> TGraph *p = new TGraph(n, x, y)
> x = ...
> y = ...
> p->Draw()
>
> Int i = 0;
> While (1) {
> // my hardware acquisition
> AcquirePoint (i &yp)
>
> // place point in graph
> if (i <n) {
> p->SetPoint(i,yp);
> } else {
> // remove first point
> p->RemovePoint(0);
> // insert point at the end
> p->InsertPoint(n-1,yp);
> }
> P->Modified();
> p->Update();
> }
>
> Unfortunately, of course, this does not work since InsertPoint is meant for
> mouse access. Is there a way (perhaps more obvious) to achieve this effect?
>
> Many thanks,
>
> Emanuel
>
> ----
> Emanuel Machado, PhD.
> Senior Engineer, Project Leader
>
>
>
> Cytonome, Inc.
> 27 Drydock Ave
> Boston, MA 02210
> Voice: (617) 330-5030 ext. 237
> Fax: (617) 330-5031
> Website: www.cytonome.com
>
> Email: Emanuel-Machado_at_cytonome.com
>
>
>> -----Original Message-----
>> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
>> Behalf Of Rene Brun
>> Sent: Friday, December 14, 2007 4:47 AM
>> To: roottalk; project-lcg-peb-apps_at_cern.ch; project-lcg-af_at_cern.ch
>> Subject: [ROOT] Pre-Production release 5.17/08 is now available
>>
>> The pre-production release of ROOT 5.17/08 is now available.
>> This will be the last development version for 5.17. We release it before
>> Christmas to give a
>> chance to the major collaborations to test their frameworks in the
>> coming few weeks. Our plan is to make a production release 5.18 on
>> January 16.
>> Between now and the production release in January, no new developments
>> will be introduced, only possible bug fixes. We encourage the maximum
>> number of people to test this version 5.17/08 and report potential
>> problems to us as soon as possible . In case you are upgrading from
>> version 5.14, please read the releases notes of version 5.16 in addition
>> to the release notes of this new version.
>> For more details, see http://root.cern.ch
>>
>> Rene Brun, on behalf of the ROOT team
>>
>
>
>
Received on Sat Dec 15 2007 - 09:28:19 CET

This archive was generated by hypermail 2.2.0 : Mon Dec 17 2007 - 05:50:02 CET