The "intercoms" category provides an expandable command interpreter. It is the key mechanism of Geant4 to realize secure user interactions across categories without being annoyed by dependencies among categories. Geant4 commands can be used in an interactive session, a batch mode with a macro 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 implementations of (graphical) user interface are provided
in the "interfaces" category. The strategy realize to adopt various user
interface tools, and allows Geant4 to utilize the state-of-the-art GUI tools
such as Motif, Qt, and Java etc.
The following interfaces is currently available;
Implementation of the user sesssions (1 and 2) is included
As for GAG, the front-end class is included
while its partner GUI package MOMO.jar is available
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/
This interface opens a session on a command-line terminal.
G4UIterminal runs on all supported platforms.
There are two kinds of shells,
tcsh-like readline features (cursor and command completion)
and works on Linux on Mac, while
G4UIcsh is a
plain standard input (cin) shell that works on all platforms.
The following built-in commands are available in
G4UItcsh supports user-friendly key bindings a-la-tcsh.
G4UItcsh runs on Linux and Mac.
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
that is automatically read at the next session,
so that command history is available across sessions.
These interfaces are versions of
implemented over libraries Motif, Qt and WIN32 respectively.
G4UIXm uses the Motif XmCommand widget,
G4UIQt the Qt dialog widget,
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 front-end classes of Geant4 which make connections 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 has capability to connect to multiple Geant4 "servers" on Unixen systems at different hosts.
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 is supplied in the Geant4 source distribution and can be run by
%java -jar /path/to/geant4.10.00/environments/MOMO/MOMO.jar
GAG has following functions.
To choose an interface
xxx = terminal,Xm, Win32, Qt,
GAG, GainServer) in your programs, there are two ways.
#include "G4Uixxx.hh" G4UIsession* session = new G4UIxxx; session-> SessionStart(); delete session;
G4UIterminalis instantiated like:
G4UIsession* session = new G4UIterminal(new G4UItcsh);
G4UIsession* session = new G4UIterminal(new G4UItcsh, false).
G4UIExecutiveThis is more convenient way for choosing a session type, that can select a session at run-time according to a rule described below.
#include "G4UIExecutive.hh" G4UIExecutive* ui = new G4UIExecutive(argc, argv); ui->SessionStart(); delete ui;
G4UIExecutive has several ways to choose a session type.
A session is selected in the following rule.
Note that session types are identified by a case-insensitive characters
("qt", "xm", "win32", "gag", "tcsh", "csh").
new G4UIExecutive(argc, argv, "qt");
G4UI_USE_XX (XX= QT, XM, WIN32, GAG, TCSH). Select a session if the corresponding environment variable is defined. Variables are checked in the order of QT, XM, WIN32, GAG, TCSH if multiple variables are set.
~/.g4sesion. You can specify the default session type and a session type by each application in that file. The below shows a sample of
tcsh # default session exampleN03 Qt # (application name / session type) myapp tcsh hoge csh
In any cases,
G4UIExecutive checks if a specified
session is build or not. If not, it goes the next step. A terminal session
with csh is the fallback session. If none of specified session is available,
then it will be selected.