Draw a volume as solid and wireframe at the same time

I’d need to draw one volume (a box) as a solid volume filled in cyan with a wireframe in dark blue (to highlight the volume borders when placed nearby other identical elements). Right now I can only set one style (e.g.solid or wireframe) with G4VisAttributes but not both styles at the same time. Is it possible? If yes, how can I set it?


Vis attributes are attached to the logical volume. If your volumes have the same logical volume then you cannot differentiate between different instances of the same volume using vis attributes.

But…you can set the drawing style of individual “touchable” as follows, even if they have the same logical volume.

A “touchable” is a volume at the end of the hierarchy, a “leaf” in the parlance of hierarchies. You can find the leaf parameters with

/vis/ASCIITree/verbose 11

For example, B2a

“World”:0 / “World”
“Target”:0 / “Target”
“Tracker”:0 / “Tracker”
“Chamber_PV”:0 / “Chamber_LV” (SD=“TrackerChamberSD”)
“Chamber_PV”:1 / “Chamber_LV” (SD=“TrackerChamberSD”)
“Chamber_PV”:2 / “Chamber_LV” (SD=“TrackerChamberSD”)
“Chamber_PV”:3 / “Chamber_LV” (SD=“TrackerChamberSD”)
“Chamber_PV”:4 / “Chamber_LV” (SD=“TrackerChamberSD”)

So, for example

/vis/set/touchable World 0 Tracker 0 Chamber_PV 2

(The opposite of what you want but you get the idea?)

Hope this helps


Hi John, thanks for your reply. Maybe I didn’t explain well what I want to do: I don’t want to draw the different physical volumes belonging to the same logical in different ways. I just want to draw all of them using both the solid and wireframe drawing, using a darker color for the wireframe to highlight the borders. Is this feasible?

Mmm. You’re right. This does not seem possible. As things stand the vis attributes (see G4VisAttributes.hh) are limited to:

  void SetVisibility          (G4bool = true);
  void SetDaughtersInvisible  (G4bool = true);
  void SetColour              (const G4Colour&);
  void SetColor               (const G4Color&);
  void SetColour              (G4double red, G4double green, G4double blue,
                               G4double alpha = 1.);
  void SetColor               (G4double red, G4double green, G4double blue,
                               G4double alpha = 1.);
  void SetLineStyle           (LineStyle);
  void SetLineWidth           (G4double);
  void SetForceWireframe      (G4bool = true);
  void SetForceSolid          (G4bool = true);
  void SetForceCloud          (G4bool = true);
  void SetForceNumberOfCloudPoints (G4int nPoints);
  // nPoints <= 0 means under control of viewer
  void SetForceAuxEdgeVisible (G4bool = true);
  void SetForceLineSegmentsPerCircle (G4int nSegments);
  // Allows choice of circle approximation.  A circle of 360 degrees
  // will be composed of nSegments line segments.  If your solid has
  // curves of D degrees that you need to divide into N segments,
  // specify nSegments = N * 360 / D.
  void SetStartTime           (G4double);
  void SetEndTime             (G4double);
  void SetAttValues           (const std::vector<G4AttValue>*);
  void SetAttDefs             (const std::map<G4String,G4AttDef>*);

and these can be set for individual logical volumes in your detector construction or, I think most of them, afterwards by /vis/geometry/set commands.

When it comes to drawing, the G4 vis system, at least with OpenGL drivers, offers additional and more sophisticated styles - though perhaps not as sophisticated as you desire - but only on a global scale. You can set both surface and edge drawing. For example, in B2a:

/vis/geometry/set/visibility World ! false
/vis/geometry/set/visibility Target ! false
/vis/geometry/set/visibility Tracker ! false
/vis/viewer/set/style surface
/vis/viewer/set/edge true

shows chambers in surface mode with edges highlighted, but you have no control over the colour of the edges - see image.

To do what I think you wish to do I think we would need to add

  void SetForceEdge       (G4bool = true);
  void SetForceColour     (const G4Color&);
  void SetForceEdgeColour (const G4Color&);

and program the drivers to respect this - quite a big job.

Have I understood?


Hi John, yes you’ve understood. It is not a blocker for me right now, I just wanted to produce nice pictures of the detector to show to colleagues. I’ll play with B2a to see if it can help with this.
Thanks again,