Updating TGeo geometry drawn on a canvas

Hello again,

I’m working on a ROOT-based event browser-like application using TGeo to represent geometry of the apparatus. Most of the geometry is static so we just load a TGeoManager streamed earlier into a ROOT file, adjust some visibility flags as per user preferences, then display the top volume on a TCanvas we prepared for that purpose. This works fine. However, if we add additional, dynamically built volumes to the hierarchy we cannot get them to appear on the same canvas. TGeo itself seems to have no trouble with additional volumes, as they are clearly visible if I query the TGeoManager, stream it to a ROOT file or export its geometry to GDML. Even during the same program session I can get the new volumes to appear if I create a new TCanvas and draw the top volume again or if I just draw it in OpenGL mode. On the same canvas however - no dice. I tried invoking Modified() and Update() on the canvas, to no avail. Redrawing the top volume on the same canvas causes some display settings, zoom level for instance, to be reset but the new volumes still do not appear. Explicitly invoking Voxelize() or SetVisibility(kTRUE) on new volumes appears has no effect either. Could you help me figure out what the problem is?

Unfortunately I cannot post the code in question here for others to try running themselves, as is a part of a much larger whole. Still, it looks roughly as follows:

  1. create the canvas, connect it to the rest of the GUI and cd to it;
  2. stream in a TGeoManager;
  3. switch visibility off for components the config file specifies should be invisible;
  4. get the top volume and draw it;
  5. having started the event loop, read in parameters of dynamically-built volumes;
  6. build appropriate material, shape, volume and position objects;
  7. use these objects to add new nodes to the top volume;
  8. either:
  • cd to the canvas again just in case and attempt to re-draw the top volume - new volumes not visible;
  • draw the top volume in OpenGL mode - new volumes visible; or
  • create a new canvas, cd to it and draw the top volume in default mode - new volumes visible.

Please let me know if you’d like to know anything more.