The "intercoms" category provides an expandable command interpreter. It is the key mechanism of Geant4 to realize user interactions of all categories without being annoyed by the dependencies among categories. The direct use of Geant4 classes in a C++ program offers a first ground level of interactivity, i.e., the batch session. As seen in the examples/novice/N01, Geant4 commands and macros are to be hard-coded in the program.
To avoid too much programming, the "intercoms" category provides the abstract class G4UIsession that captures interactive commands . The concrete implementation of the user interface and Graphical User Interfaces (GUI) is left to 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 and Java, etc..The richness of the collaboration has permitted for different groups to offer various user interfaces to the Geant4 command system. Currently available are the following;
Character terminal (dumb terminal and tcsh(bash)-like terminal), the default user interface of Geant4,
Xm, Xaw, Win32, variations of the upper terminal by using a Motif, Athena or Windows widget to retrieve commands, and
GAG, a fully Graphical User Interface and its extension GainServer of the client/server type.
Full implementation of the character
terminals (1 and 2) is included in the standard Geant4 distribution
in the source/interfaces/basic
directory. As for GAG
with rich GUI functionalities, its front-end classes are included
in the Geant4 distribution in the source/interfaces/GAG directory.
The corresponding GUI package is available either from the author's
Web pages (see URL below) or in the distributed package under the
environments/MOMO
directory.
GAG, GainServer's client GUI Gain: http://erpc1.naruto-u.ac.jp/~geant4
These interfaces open a session on the character terminal. G4UIterminal runs on all platform supported by Geant4, including cygwin on Windows, while G4UItcsh runs on Solaris and Linux. G4UItcsh supports user-friendly key bindings a-la-tcsh (or bash);
In addition, the following string substitutions are supported;
These interfaces are versions of G4UIterminal implemented over libraries Motif, Athena and WIN32 respectively. G4UIXm uses the Motif XmCommand widget, G4UIXaw the Athena 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 or the WIN32 one.
A command box is at disposal for entering or recalling Geant4 commands. Command completion by typing “TAB” key is available on the command line. The shellcommands "exit, cont, help, ls, cd..." are also supported. A menu bar could be customized through the AddMenu and AddButton method. Ex:
G4UIXm runs on Unix/Linux with Motif. G4UIXaw, less user friendly, runs on Unix with Athena widgets. G4UIWin32 runs on Windows.
They are the front-end classes of Geant4 which interface with their respective graphical user interfaces, GAG (Geant4 Adaptive GUI) and Gain (Geant4 adaptive interface for network). 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.) to which JVM (Java Virtual Machine) 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 GUI, GAG and Gain have almost similar look-and-feel. So, GAG's functionalities are briefly introduced here. Please refer to the above URL for details and to download the client GUIs.
GAG is a Graphical User Interface tool with which user can set parameters and execute commands. It is adaptive, since GAG reflects the internal states of Geant4 that is a state machine. GAG is based on the server-client model; GAG is the server, while Geant4 executables are clients. Hence, GAG does nothing by itself and it must invoke an executable simulation program. Geant4's front-end class G4UIGAG must be instantiated to communicate with GAG. This runs on Linux and Windows 2000. GAG is written in Java and its Jar (Java Archive) file is available from the above URL. See the same pages to know how to install and run Java programs.
GAG has following functions.
The libraries that don't depend on external packages are made by default. 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, G4UIXaw and G4UIWin32 , respective environment variables G4UI_BUILD_XM_SESSION, G4UI_BUILD_XAW_SESSION or G4UI_BUILD_WIN32_SESSION must be set explicitly.
However, if the environment variable G4UI_NONE is set, no interface libraries are built at all.
Build scheme of 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, Xaw, Win32,
GAG, GainServer
) in a user's program, he has the following
lines in his main program;
// to include the class definition in his main program: #include "G4Uixxx.hh" // to instantiate a session of his choice and start the session G4UIsession* session = new G4UIxxx; session->SessionStart(); // the line next to the "SessionStart" is usually to finish the session delete session;
For a tcsh session, the second line must be :
G4UIsession* session = new G4UIterminal(new G4UItcsh);
See the examples in "examples/novice/N0x" in which the terminal session is used.
If the user wants to deactivate the default signal handler (soft abort) raised by "Ctr-C", the false flag can be set in the second argument of the G4UIterminal constructor like;
G4UIsession* session = new G4UIterminal(new G4UItcsh, false).
Again, environment variable selects a given interface. But for your convenience, some of them are set defaults.
G4UIterminal, G4UItcsh, G4UIGAG and G4UIGainServer can be used without 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. For backwards compatibility with user code, as typified by geant4/examples main programs, the C-pre-processor variables corresponding to the original environment variables for the above three (i.e., G4UI_USE_TERMINAL, G4UI_USE_TCSH and G4UI_USE_GAG ) are set. However, if he/she sets no environment variables, then the C-pre-processor variable G4UI_USE_TERMINAL is set by default, although there is no need to use it.
The environment variable G4UI_USE_XM, G4UI_USE_XAW or G4UI_USE_WIN32 must be set to use the respective interface. The file "$G4INSTALL/config/interactivity.gmk" resolves their dependencies on external packages.
If the environment variable G4UI_NONE is set, no externa ibraries 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.