Zoom in TGLEmbeddedViewer

Hi everybody,
I created a MainFrame that contains a toolbar and a TGLEmbeddedViewer, I created also 2 buttons to generate zoom-in and zoom-out of my glviewer, but I don’t know how to create this command. I tried the code below, without success. So, if someone have a suggestion, please help me :slight_smile:. Thank you very much.

[code]//ev is a TGLEmbeddedViewer

void MyMainFrame::DoZoomIn(){
ev->GetOrthoXOYCamera()->ZoomIn();
gEve->Redraw3D(kTRUE);
}
void MyMainFrame::DoZoomOut(){
ev->GetOrthoXOYCamera()->ZoomOut();
gEve->Redraw3D(kTRUE);
}[/code]

Hi,

Can you try this way:

[code]
void MyMainFrame::DoZoomIn() {
ev->CurrentCamera().Zoom(-50, kFALSE, kFALSE));
gEve->Redraw3D(kTRUE);
}

void MyMainFrame::DoZoomOut() {
ev->CurrentCamera().Zoom(50, kFALSE, kFALSE));
gEve->Redraw3D(kTRUE);
}[/code]
And let me know, please?

Cheers, Bertrand.

Hi Bertrand,
Thank you very much for your help!
I found a little problem with this code, the first time when I click in the button i.e. ZoomIn() the zoom is produced instantly, but if I press another time, etc… it doesn’t work. I must have to click and move the mouse in the GLViewer to produce the “refresh” image. Probably it’s releated with the gEve->Redraw3D(kTRUE).
Thank you again,
Cheers

Hi,

You can try to add: ev->RequestDraw(); after ev->CurrentCamera().Zoom()

Cheers,
Bertrand.

Hi Bertrand,
Absolutely perfect!!!
Thank you very very much!
Cheers

You’re welcome!
And BTW, sorry for the late reply, but you posted on the wrong forum (this is not relaed to “Stat and Math Tools”)… :wink:
Best regards,
Bertrand.