Redrawing 3D objects

Hellow,

When using the geometry package, I would like to change the visibility of the some volumes and draw the scene again.
But when I call the TopVolume->Draw(“gl”) method one more time, I got the error: “Error in : expected scene to be in mode modified locked”

It seems Root wants to add more objects in the scene, while what I want is just to redraw the scene with the volumes that are visibles.

What is the correct way to do that?

Thanks,
Luciano

[quote]Hellow,

When using the geometry package, I would like to change the visibility of the some volumes and draw the scene again.
But when I call the TopVolume->Draw(“gl”) method one more time, I got the error: "Error in : expected scene to be in mode modified locked"
Thanks,
Luciano[/quote]

With ROOT’s TBrowser you can modify properties of geometry and these canges will be visible in gl-viewer.

And you can set visibility of some object directly in a viewer - select it (right mouse button click with shift pressed) and unset “SetVisibility” in a context menu.

I am working with a detector peace with more than 1000 channels.

How can I do this by code?

Hi,

Do the settings in a loop, then call Draw(“gl”) only once at the end.

Andrei

hi agheata.

maybe a little late, but
i had the same problem a few days ago.
imagine several data-samples which shall be shown in the openGL-viewer, one by one.
if he puts the (different) settings for the different samples in a loop and calls “draw(“ogl”)” only once at the end, only the last sample will be displayed,
or am i wrong ?

asim.

Hi Akrasim,

I am not the author of the GL viewer implementation, but as far as I know it cannot support this mode:

Timur, correct me if I am wrong.
Cheers,

Hello,

Call gPad->Update(); inside the loop, instead of Draw(“gl”)

cheers,
Luciano

I forgot to say: you must call Draw(“ogl”) before the loop :slight_smile:

Hi Luciano.

It seems to work - thank you very much.
(I put

gPad->Modified();
gPad->Update();
getchar();
// the next sample shall not be shown until the user presses any key

at the end of my loop.)

unfortunately, i can rotate, zoom, etc. only the last update. the others are shown at least.
Since I haven’t compiled my script, it might also be a problem of the Interpreter. We’ll see.

Thanks again;
Asim.

[quote]
I am not the author of the GL viewer implementation, but as far as I know it cannot support this mode:

Timur, correct me if I am wrong.
Cheers,[/quote]
Yes Andrei, you are right. This can be done with “hacks” I’ve shown, but the problem is - he wants to use interpreter and
pad, but I do not know, how to intercept keyboard events in this case (he wants to press key or something like this to show next sample)

the easiest way will be to learn how to create makefiles, i think :smiley:
so that’s what i’m gonna do.

asim.

[quote]the easiest way will be to learn how to create makefiles, i think :smiley:
so that’s what i’m gonna do.
asim.[/quote]

Lol :slight_smile:)))
You do not need makefile, you must only specify root’s libs in g++ command line :slight_smile:

I’m afraid, it will not help you, unless you’re going to write you own gl-render yourself :slight_smile:))

In principle, I can tell you, how to solve your problem - you can have gl-viewer with
your tubes and separate gui with a button “NEXT” :slight_smile:)
and when you press this button, you can change the color and transparency (as in my previous macro) and ask viewer to redraw - so, instead of timer event you’ll process button press.
And, may be, instead of TGeo and my hacked version of gl-viewer, you can try approach Matevz Tadel recommended in this forum (I do not know where exactly).

You can not rotate, zooming, etc becouse you are using getchar().
This command locks the loop of messages so the root can not receive any message coming from the mouse.
This will not work even if you compile, unless you do a multithread application.
I think you should create a function to update your geometry and call it with the interpreter every time you want update.
For instance, you can create a function called “next()” and put there the commands to update your geometry. Just type next() in the interpreter to see the next event.
In this way you do not need to use the getchar and you keep the loop of message free to rotate and stuffs.

cheers,
Luciano