The "intercoms" category provides an expandable command interpreter. It is the key mechanism of Geant4 to realize secure user interactions in all categories without being annoyed by the dependencies among categories. The Geant4 commands can be used both in a interactive terminal session and in a batch mode with a maco file or a direct C++ call.
Geant4 can be controllled by a seriese of Geant4 UI commands. The "intercoms" category provides the abstract class G4UIsession that processes interactive commands. The concrete implementation of (graphical) user interfaceis is located in the "interfaces" category. This interfacing strategy opens an important door towards various user interface tools, and allows Geant4 to utilize the state-of-the-art GUI tools such as Motif, Qt, and Java etc. The richness of the collaboration realizes various user interfaces to the Geant4 command system. The following interfaces is currently available;
Character terminal (dumb terminal and tcsh-like terminal), that is the default user interface of Geant4
Xm, Win32, Qt variations of the above terminal by using a Motif, Qt or Windows widget
GAG, a fully graphical user interface and its network extension GainServer of the client/server type.
Implementation of the user sesssions (1 and 2) is included
in the source/interfaces/basic
directory.
As for GAG, the front-end class is included
in the source/interfaces/GAG directory,
while its partner GUI package MOMO.jar is available
under the environments/MOMO
directory.
MOMO.jar, Java archive file, contains
not only GAG, but also GGE and other helper packages.
Supplementary information is available
from the author's web page (see URL below).
GAG, GainServer's client GUI Gain: http://www-geant4.kek.jp/~yoshidah
These interfaces open a session on the character terminal. G4UIterminal runs on all platforms supported by Geant4, including cygwin on Windows. The following built-in commands are available in G4UIterminal;
G4UItcsh supports user-friendly key bindings a-la-tcsh. G4UItcsh runs on Solaris and Linux. The following keybindings are supported;
The example below shows how to set a user's prompt.
G4UItcsh* tcsh = new G4UItcsh(); tcsh-> SetPrompt("%s>");
The following strings are supported as substitutions in a prompt string.
Command history in a user's session is saved
in a file $(HOME)/.g4_hist
that is automatically read at the next session,
so that command history is available across sessions.
These interfaces are versions of G4UIterminal implemented over libraries Motif, Qt and WIN32 respectively. G4UIXm uses the Motif XmCommand widget, G4UIQt the Qt dialog widget, and G4UIWin32 the Windows "edit" component to do the command capturing. These interfaces are useful if working in conjunction with visualization drivers that use the Xt library, Qt library or the WIN32 one.
A command box is at disposal for entering or recalling Geant4 commands. Command completion by typing "TAB" key is available in the command box. The shell commands "exit, cont, help, ls, cd..." are also supported. A menu bar can be customized through the AddMenu and AddButton method. Ex:
G4UIXm runs on Unix/Linux with Motif. G4UIQt run everywhere with Qt. G4UIWin32 runs on Windows.
They are the front-end classes of Geant4 which make connection with their respective graphical user interfaces, GAG (Geant4 Adaptive GUI) via pipe, and Gain (Geant4 adaptive interface for network) via sockets. While GAG must run on the same system (Windows or Unixen) as a Geant4 application, Gain can run on a remote system (Windows, Linux, etc.) in which JRE (Java Runtime Environment) is installed. A Geant4 application is invoked on a Unix (Linux) system and behaves as a network server. It opens a port, waiting the connection from the Gain. Gain is capable to connect to multiple Geant4 "servers" on Unixen systems at different institutes.
Client GUIs, GAG and Gain have almost similar look-and-feel. So, GAG's functionalities are briefly explained here. Please refer to the URL previously mentioned for details.
Using GAG, user can select a command, set its parameters and execute it. It is adaptive, in the sense that it reflects the internal states of Geant4 that is a state machine. So, GAG always provides users with the Geant4 commands which may be added, deleted, enabled or disabled during a session. GAG does nothing by itself but to play an intermediate between user and an executable simulation program via pipes. Geant4's front-end class G4UIGAG must be instantiated to communicate with GAG. GAG runs on Linux and Windows. MOMO.jar can be run by a command;
%java -jar $G4INSTALL/environments/MOMO/MOMO.jar
GAG has following functions.
The libraries that do not depend on external packages are created by default, using Geant4 configure scripts. They include G4UIterminal, G4UItcsh and G4UIGAG in libraries libG4UIbasic.a/so and libG4UIGAG.a/so. G4UIGainServer.o is packed in the libG4UIGAG.
To make the libraries of G4UIXm and G4UIWin32 , respective environment variables G4UI_BUILD_XM_SESSION, G4UI_BUILD_QT_SESSION and G4UI_BUILD_WIN32_SESSION must be set explicitly before creating libraries.
If the environment variable G4UI_NONE is set, no interface libraries are built at all.
The scheme of building the user interface libraries is specified in "$G4INSTALL/config/G4UI_BUILD.gmk" makefile and the dependencies on the external packages are specified in "$G4INSTALL/config/interactivity.gmk".
To use a given interface
(G4UIxxx
where xxx = terminal,Xm, Win32, Qt,
GAG, GainServer
) in your program, there are two ways.
#include "G4Uixxx.hh" // to instantiate a session of your choice and start the session G4UIsession* session = new G4UIxxx; session->SessionStart(); // the line next to the "SessionStart" is necessary to finish the session delete session;
// to include the class definition in the main program: #if defined(G4UI_USE_TCSH) #include "G4UIterminal.hh" #include "G4UItcsh.hh" #elif defined(G4UI_USE_XM) #include "G4UIXm.hh" .... #endif #if defined(G4UI_USE_TCSH) session = new G4UITerminal(new G4UItcsh); #elif defined(G4UI_USE_XM) session = new G4UIXm(argc,argv); #elif ...
G4UIsession* session = new G4UIterminal(new G4UItcsh);
G4UIsession* session = new G4UIterminal(new G4UItcsh, false).
// to include the class definition in the main program: #ifdef G4UI_USE #include "G4UIExecutive.hh" #endif // to instantiate a session of your choice and start the session #ifdef G4UI_USE G4UIExecutive* ui = new G4UIExecutive(argc,argv); ui->SessionStart(); // the line next to the "SessionStart" is necessary to finish the session delete ui; #endif
A corresponding environment variable must be preset to select a given interface. But some of them are set by defaults for your convenience.
G4UIterminal, G4UItcsh, G4UIGAG and G4UIGainServer can be used without setting any environment variables. Sessions not needing external packages or libraries are always built (see "G4UI_BUILD.gmk") and linked, so the user can instantiate one of these sessions without rebuilding the libraries and without setting any environment variables.
The environment variable G4UI_USE_XM, G4UI_USE_QT or G4UI_USE_WIN32 must be set to use the respective interface. The file "$G4INSTALL/config/G4UI_USE.gmk" resolves their dependencies on external packages.
If the environment variable G4UI_NONE is set, no external libraries are selected. Also, for your convenience, if any G4UI_USE_XXX environment variable is set, then the corresponding C-pre-processor flag is also set. However, if the environment variable G4UI_NONE is set, no C-pre-processor flags are set.