Geant4 Visualization Tutorial using the OpenGL Event Display with Qt Toolkit

 

Introduction

This tutorial is designed for anyone who wants to learn OpenGL Visualization for Geant4 with Qt powerfull toolkit.

This tutorial can be used on its own, but gives the most comprehensive introduction to Geant4 visualization when used as part of the following full set of documents:

While some Geant4 visualization drivers are always included by default in your Geant4 build (because they require no external libraries), Qt is not part of the default set. You have to specifically ask to include Qt.

If you followed the Geant4 Installation Guides referenced above, you used the Geant4 Configuration script and said "yes" to including Qt. Qt version should be Qt3 are above (Qt 4.4 is current version)

If you are following some other set of build instructions, refer to them for how to include Qt driver. This may involve explicitly setting environment variables.

 

Main features

 

Running Geant4 with Qt driver

Since OpenGL runs directly from Geant4, you just start Geant4 and then issue a few visualization commands. The Installation Guides listed above already showed you how to start Geant4 with OpenGL Qt driver included. They then showed you how to use a few simple commands to do the most minimal visualization of some detector geometry and some event data. This guide will show you some additional commands.

Building User interface driver

Set the following variables acording to your shell, then recompile sources/interfaces

Building visualization driver

Set the following variables acording to your shell, then recompile sources/visualization

Note : Remember to do the appropriate setup commands before you start Geant4 from a new windows (see the installation guides for details).

 

User Interface

User Interface

As others Graphic User Interfaces (Xm,Win32), Qt User Interface have the same look & feel. A output area, history area, command area, menu are available.

Building the menu is available by executing set of commands defined in a macro file or entering thoses commands in the User Interface (as other Graphics User Interfaces). For example :

/gui/addMenu run Run
/gui/addButton run "beamOn 1" "/run/beamOn 1"
                
Theses command will build a new menu "Run" with a sub-menu "beamOn 1" calling /run/beamOn command
G4UIQt

Help widget

A New command "help" has been set specialy for Qt. Invoke it, it will display the help tree widget. This help widget will display all commands already loaded from Geant4 and all your personnels commands if Geant4 already knows them.

This widget is very useful to find quicly a command in the geant4 set of commands. Moreover, you could ouble-click on the command you have find to set it in User Interface command area.

This help widget is composed of :

  • A search area: Look in command definition the string you look for
  • A command tree browser
  • A command definition outup zone
Helper 1

 

Helper2
 

Visualization driver

Controlling visualization

As OpenInventor driver, Qt driver is a real-time display.
There is three control modes availables thanks to context-menu (right mouse button) :

As default, control is set to rotate mode.
If you release mouse press when moving mouse press (in rotate/move mode), you will set the scene in an auto rotate/move mode. Press mouse will stop this auto move/rotate mode. The speed of this auto rotation/move is control by the speed of your mouse move when releasing mouse press.

In addition controling visualization is alo available by keybord :

Context menu options

ContextMenu

A context menu is available on right mouse button, it is a quick mean to set somes geant4 main options and some Qt specific ones :

  • Mouse actions
    • Rotate
    • Move
    • Pick
    • Show shortcuts
  • Styles
    • Representation
      • Polyhedron
      • NURBS
    • Projections
      • Orthographic
      • Perspective
    • Drawing
      • Wireframe
      • Hidden line removal
      • Hidden line and surface removal
    • Background
      • White
      • Black
  • Actions
    • Save as...
    • Movies parameters...
  • Special
    • Transparency (On/Off)
    • Antialiasing (On/Off)
    • Haloing (On/Off)
    • Auxiliairy edges (On/Off)
    • Full screen (On/Off)

A underline item is set by default by Geant4.

A word about Qt specific options.
These new options introduced by Qt driver are Actions-<Save as..., Movies parameters..., and full screen mode.

Saving file

Thanks to Qt, a lot of export formats are available :

  • bmp
  • jpeg
  • jpg
  • png
  • ppm
  • tif
  • tiff
  • xbm
  • xpm (Qt4 only)
  • eps (Vectorial and non-vectorial)
  • ps
  • pdf

Making movies

A important feature of Qt driver is avaibility to make movies. To do this Qt driver rely on an free external software call mpeg_encode. It is available here: http://bmrc.berkeley.edu/frame/research/mpeg/.

How does it works ?

  1. Qt driver record each frame on OpenGL scene
  2. mpeg_encode will merge all picture in one movie file

Caution : This is not a time based saving, but a frame based !

What do I have to do ?

  1. Download mpeg_encoder
  2. Fill parameters in movie dialog box :

    First of all, you have to set where is install mpeg_encoder

     

     

     

    Then, set the temp folder (by default Qt should find the good one)

     

     

     

    Set the name of the movie file that will be created

     

     

     

    Then press Start/Pause/Stop to record/pause/stop movie
    When press Save, the movie will be created, it could take a while depending of frame number.

MovieDialog
 

Further Resources

Documents in this Visualization Tutorial Set:

Other Resources:


Laurent Garnier
Last modified: Tue Jan 6 12:18:15 CET 2009