How to update the openGL-viewer?

hello;

i’m a ROOT-newbie, and i’ve written a script, which simulates a tube-detector with several tubes. they are displayed in the openGL-viewer via top.Draw(“ogl”).
in my script, i open a datafile and set the color of each tube according to the value of the tube in the datafile. everything workes fine so far.

what i’ve tried to do now, is to display several datasamples, one after the other.
i think i have to use the “update”-funktion, but i didn’t succeed, yet.

the last lines of my script are the following:
(they’re inside a while loop, where “ii” is the number of the sample)

while(ii…)
{

geom->CloseGeometry();
geom->SetVisLevel(3);

if(ii==0)
top.Draw(“ogl”);
else
{gPad->WaitPrimitive;
gpad->Update(“ogl”);} /// syntax error, i’m afraid

}

as you can see, i’ve also tried to build in a halt, so that the next sample won’t be displayed until the user presses any key.

what’s the syntax i have to use, to make these two points work ?

cheers;
asim.

p.s.:
i’m running my script in the interpreter-mode, because i haven’t written a makefile, yet.

You forgot to post your script

Rene

Sorry,

i thought those few lines would be wrong enough :wink:
here’s the script (i don’t want to post the whole thing, but i think, these are the essential parts). since i’m running the interpreter mode, there are no functions in it (afaik there mustn’t be any functions in scripts which are to be run in the interpreter mode?).

thanks for the fast reply;
asim.

Could you post the 2 data files required to run your script?
What is the value to be entered at:

cout<<"Wie viele Events sollen displayed werden ?"<<endl; cin>>eventzahl;

Rene

hi rene,

i’ve done a short version of the script, so you don’t have to read all the stuff.
here it is:

thanks,
asim.
ampli.txt (60 Bytes)
eventm.C (2.08 KB)

[quote]hello;

i’m a ROOT-newbie, and i’ve written a script, which simulates a tube-detector with several tubes. they are displayed in the openGL-viewer via top.Draw(“ogl”).
in my script, i open a datafile and set the color of each tube according to the value of the tube in the datafile. everything workes fine so far.

what i’ve tried to do now, is to display several datasamples, one after the other.
i think i have to use the “update”-funktion, but i didn’t succeed, yet.

[/quote]
Hello.

from your macros it’s not easy to understand, what you want. Do you want to make an animation?

If you want an animation, what shoud be the time interval between frames?

I’ve modified your script and reused sample code from my answer somewhere in this forum
eventm.C (3.05 KB)
TGLViewer.cxx (72.8 KB)
TGLViewer.h (15.6 KB)

Hi tpochep;

thanks for your answers.
My intention was to display ONE event (datalines 1-10 in the datafile);
if the user presses a key (for example “space”), the next event (datalines 11-20) should be displayed.

Tanks again;
Asim.

Hello everybody,

Is it possible to make this kind of loop with Pgon and Pcon ?

[code]TGeoVolume *tub[10];

for (Int_t tnr=0; tnr<10; tnr++)
{
tub[tnr] = geom->MakeBox(“tub”, Al, 2, 2, 200);

top->AddNode(tub[tnr],tnr, new TGeoTranslation(6*tnr, 0, 0));
} [/code]

I tried this:

[code]TGeoVolume *tub[10];

for (Int_t tnr=0; tnr<10; tnr++)
{
tub[tnr] = geom->MakePgon(“tub”, Al, 0, 360, 6,2);
tub[tnr]->DefineSection(0,-200/2, 12, 12) ;
tub[tnr]->DefineSection(1,20/2, 12, 12) ;
tub[tnr]->SetLineColor(kGreen) ;
world->AddNode(tub[tnr],tnr, new TGeoTranslation(6*tnr, 0, 0));
} [/code]

But i have an Error: Can’t call TGeoVolume::DefineSection(0,-200/2,12,12) in current scope
Possible candidates are…
(in TGeoVolume)
(in TGeoAtt)
*** Interpreter error recovered ***

[quote=“ThomasF”]Hello everybody,

Is it possible to make this kind of loop with Pgon and Pcon ?
But i have an Error: Can’t call TGeoVolume::DefineSection(0,-200/2,12,12) in current scope
*** Interpreter error recovered ***[/quote]

Your question is not about OpenGL viewer, it’s about TGeo classes.
TGeoVolume does not have member DefineSection (and it can not have such a member).
TGeoPgon has, but TGeoVolume is not a TGeoPgon. Probably, Andrei or somebody, who knows
geom module of ROOT will correct me, if I’m wrong, but you can do:

arr[idx] = geom->MakePgon(.....
//Now, you can ask your volume to give you a shape:
//arr[idx]->GetShape() - this will give you TGeoShape, indirect base class for TGeoPgon, you need a cast:
TGeoPgon *pgonShape = (TGeoPgon *)arr[idx]->GetShape();
pgonShape->DefineSection(.....

I think it can be good to read docs about ROOT’s geometry.