GLViewer - set camera to static zoom

I have a scene that generates many TGeoVolumes (little boxes) that appear and disappear. The camera generally adapts to the number of boxes I have, so that when there’s only one box it fills up the whole screen, or two boxes, etc. But this doesn’t work for me - I’d like to view the boxes from a fixed distance. Currently my solution is to make some fixed “borders”:

TGeoBBox *bigBox = new TGeoBBox(“bigBox”,51,51,51);
TGeoBBox *smallBox1 = new TGeoBBox(“smallBox1”,55,50.9,50.9);
TGeoBBox *smallBox2 = new TGeoBBox(“smallBox2”,50.9,55,50.9);
TGeoBBox *smallBox3 = new TGeoBBox(“smallBox3”,50.9,50.9,55);

TGeoCompositeShape *cs1=new TGeoCompositeShape(“cs1”,“bigBox-(smallBox1+smallBox2)”);
TGeoCompositeShape *cs2=new TGeoCompositeShape(“cs2”,“cs1-smallBox3”);
TGeoVolume * comp = new TGeoVolume(“COMP”,cs2);


This is the biggest box and thus the camera stays fixed while I draw things inside it. But, basically, this feels like kind of a hack and I’d prefer not to see the borders. Is it possible to make a large invisible box that the camera adjusts to? When I just make a simple box and SetInvisibility(kFALSE) the camera totally ignores it, so that doesn’t work.


Maybe un-ticking “Reset on update” check-box in “Style” tab could help?

If you have pointer to TGLViewer, you can also call v->SetResetCamerasOnUpdate(kFALSE).