source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/GettingStarted/graphicalUserInterface.xml @ 904

Last change on this file since 904 was 904, checked in by garnier, 16 years ago

ajout de la doc

File size: 16.2 KB
Line 
1<!-- ******************************************************** -->
2<!--                                                          -->
3<!--  [History]                                               -->
4<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
5<!--                                                          -->
6<!-- ******************************************************** -->
7
8
9<!-- ******************* Section (Level#1) ****************** -->
10<sect1 id="sect.HowToSetUpInter">
11<title>
12How to Set Up an Interactive Session
13</title>
14
15
16<!-- ******************* Section (Level#2) ****************** -->
17<sect2 id="sect.HowToSetUpInter.Intro">
18<title>
19Introduction
20</title>
21
22<!-- ******************* Section (Level#3) ****************** -->
23<sect3 id="sect.HowToSetUpInter.Intro.RolesIntercoms">
24<title>
25Roles of the "intercoms" category
26</title>
27
28<para>
29The "intercoms" category
30provides an expandable command interpreter. It is the key mechanism
31of Geant4 to realize user interactions of all categories without
32being annoyed by the dependencies among categories. The direct use
33of Geant4 classes in a C++ program offers a first ground level of
34interactivity, i.e., the batch session. As seen in the
35examples/novice/N01, Geant4 commands and macros are to be
36hard-coded in the program.
37</para>
38
39</sect3>
40
41<!-- ******************* Section (Level#3) ****************** -->
42<sect3 id="sect.HowToSetUpInter.Intro.UserInterfaces">
43<title>
44User Interfaces to steer the simulation
45</title>
46
47<para>
48To avoid too much programming, the
49"intercoms" category provides the abstract class <emphasis>G4UIsession</emphasis>
50that captures interactive commands . The concrete implementation of
51the user interface and Graphical User Interfaces (GUI) is left to
52the interfaces category. This interfacing strategy opens an
53important door towards various user interface tools and allows
54Geant4 to utilize the state-of-the-art GUI tools such as Motif and
55Java, etc..The richness of the collaboration has permitted for
56different groups to offer various user interfaces to the Geant4
57command system. Currently available are the following;
58
59<orderedlist spacing="compact">
60  <listitem><para>
61  Character terminal (dumb terminal and tcsh(bash)-like terminal),
62  the default user interface of Geant4,
63  </para></listitem>
64  <listitem><para>
65  Xm, Xaw, Win32, variations of the upper terminal by using a
66  Motif, Athena or Windows widget to retrieve commands, and
67  </para></listitem>
68  <listitem><para>
69  GAG, a fully Graphical User Interface and its extension
70  GainServer of the client/server type.
71  </para></listitem>
72</orderedlist>
73</para>
74
75<para>
76Full implementation of the character
77terminals (1 and 2) is included in the standard Geant4 distribution
78in the <literal>source/interfaces/basic</literal> directory. As for GAG
79with rich GUI functionalities, its front-end classes are included
80in the Geant4 distribution in the source/interfaces/GAG directory.
81The corresponding GUI package is available either from the author's
82Web pages (see URL below) or in the distributed package under the
83<literal>environments/MOMO</literal> directory.
84</para>
85
86<para>
87GAG, GainServer's client GUI Gain:
88<ulink url="http://erpc1.naruto-u.ac.jp/~geant4">
89http://erpc1.naruto-u.ac.jp/~geant4
90</ulink>
91</para>
92
93</sect3>
94</sect2>
95
96<!-- ******************* Section (Level#2) ****************** -->
97<sect2 id="sect.HowToSetUpInter.DescInter">
98<title>
99A Short Description of Available Interface Classes
100</title>
101
102<!-- ******************* Section (Level#3) ****************** -->
103<sect3 id="sect.HowToSetUpInter.DescInter.G4UI">
104<title>
105<emphasis>G4UIterminal</emphasis> and <emphasis>G4UItcsh</emphasis> classes
106</title>
107
108<para>
109These interfaces open a session on the character terminal.
110<emphasis>G4UIterminal</emphasis> runs on all platform supported by Geant4,
111including <emphasis>cygwin</emphasis> on Windows,
112while <emphasis>G4UItcsh</emphasis> runs on Solaris and Linux. G4UItcsh
113supports user-friendly key bindings a-la-tcsh (or bash);
114
115<variablelist>
116  <varlistentry>
117    <term>^A</term>
118    <listitem>
119    move cursor to the top
120    </listitem>
121  </varlistentry>
122  <varlistentry>
123    <term>^B</term>
124    <listitem>
125    backward cursor ([LEFT] cursor)
126    </listitem>
127  </varlistentry>
128  <varlistentry>
129    <term>^C (except Windows terminal)</term>
130    <listitem>
131    abort a run (<emphasis>soft abort</emphasis>) during event processing.
132    A program will be terminated while accepting a user command.
133    </listitem>
134  </varlistentry>
135  <varlistentry>
136    <term>^D</term>
137    <listitem>
138    delete/exit/show matched list
139    </listitem>
140  </varlistentry>
141  <varlistentry>
142    <term>^E</term>
143    <listitem>
144    move cursor to the end
145    </listitem>
146  </varlistentry>
147  <varlistentry>
148    <term>^F</term>
149    <listitem>
150    forward cursor ([RIGHT] cursor)
151    </listitem>
152  </varlistentry>
153  <varlistentry>
154    <term>^K</term>
155    <listitem>
156    clear after the cursor
157    </listitem>
158  </varlistentry>
159  <varlistentry>
160    <term>^N</term>
161    <listitem>
162    next command ([DOWN] cursor)
163    </listitem>
164  </varlistentry>
165  <varlistentry>
166    <term>^P</term>
167    <listitem>
168    previous command ([UP] cursor)
169    </listitem>
170  </varlistentry>
171  <varlistentry>
172    <term>TAB</term>
173    <listitem>
174    command completion
175    </listitem>
176  </varlistentry>
177  <varlistentry>
178    <term>DEL</term>
179    <listitem>
180    backspace
181    </listitem>
182  </varlistentry>
183  <varlistentry>
184    <term>BS</term>
185    <listitem>
186    backspace
187    </listitem>
188  </varlistentry>
189</variablelist>
190</para>
191
192<para>
193In addition, the following string substitutions are supported;
194
195<variablelist>
196  <varlistentry>
197    <term>%s</term>
198    <listitem>
199    current application status
200    </listitem>
201  </varlistentry>
202  <varlistentry>
203    <term>%/</term>
204    <listitem>
205    current working directory
206    </listitem>
207  </varlistentry>
208  <varlistentry>
209    <term>%h</term>
210    <listitem>
211    history number
212    </listitem>
213  </varlistentry>
214</variablelist>
215</para>
216
217</sect3>
218
219<!-- ******************* Section (Level#3) ****************** -->
220<sect3 id="sect.HowToSetUpInter.DescInter.G4UIXm">
221<title>
222<emphasis>G4UIXm</emphasis>, <emphasis>G4UIXaw</emphasis> and
223<emphasis>G4UIWin32</emphasis> classes
224</title>
225
226<para>
227These interfaces are versions of <emphasis>G4UIterminal</emphasis> 
228implemented over libraries Motif, Athena and WIN32 respectively.
229<emphasis>G4UIXm</emphasis> uses the Motif XmCommand widget,
230<emphasis>G4UIXaw</emphasis> the Athena dialog
231widget, and <emphasis>G4UIWin32</emphasis> the Windows "edit" component to do the
232command capturing. These interfaces are useful if working in
233conjunction with visualization drivers that use the Xt library or
234the WIN32 one.
235</para>
236
237<para>
238A command box is at disposal for entering or recalling Geant4 commands.
239Command completion by typing &amp;ldquo;TAB&amp;rdquo; key is
240available on the command line. The shellcommands "exit, cont,
241help, ls, cd..." are also supported. A menu bar could be customized
242through the <emphasis>AddMenu</emphasis> and
243<emphasis>AddButton</emphasis> method. Ex:
244
245<variablelist>
246  <varlistentry>
247    <term>/gui/addMenu</term>
248    <listitem>
249    test Test
250    </listitem>
251  </varlistentry>
252  <varlistentry>
253    <term>/gui/addButton</term>
254    <listitem>
255    test Init /run/initialize
256    </listitem>
257  </varlistentry>
258  <varlistentry>
259    <term>/gui/addButton</term>
260    <listitem>
261    test "Set gun" "/control/execute gun.g4m"
262    </listitem>
263  </varlistentry>
264  <varlistentry>
265    <term>/gui/addButton</term>
266    <listitem>
267    test "Run one event" "/run/beamOn 1"
268    </listitem>
269  </varlistentry>
270</variablelist>
271</para>
272
273<para>
274<emphasis>G4UIXm</emphasis> runs on Unix/Linux with Motif. <emphasis>G4UIXaw</emphasis>,
275less user friendly, runs on Unix with Athena widgets.
276<emphasis>G4UIWin32</emphasis> runs on Windows.
277</para>
278
279</sect3>
280
281
282<!-- ******************* Section (Level#3) ****************** -->
283<sect3 id="sect.HowToSetUpInter.DescInter.G4UIGAG">
284<title>
285<emphasis>G4UIGAG</emphasis> and <emphasis>G4UIGainServer</emphasis> classes
286</title>
287
288<para>
289They are the front-end classes of Geant4 which interface with their
290respective graphical user interfaces, GAG (Geant4 Adaptive GUI) and Gain
291(Geant4 adaptive interface for network). While GAG must run on the same
292system (Windows or Unixen) as a Geant4 application, Gain can run on a
293remote system (Windows, Linux, etc.) to which JVM (Java Virtual
294Machine) is installed. A Geant4 application is invoked on a Unix
295(Linux) system and behaves as a network server. It opens a port,
296waiting the connection from the Gain. Gain is capable to connect to
297multiple Geant4 "servers" on Unixen systems at different
298institutes.
299</para>
300
301<para>
302Client GUI, GAG and Gain have almost similar look-and-feel. So,
303GAG's functionalities are briefly introduced here. Please refer to
304the above URL for details and to download the client GUIs.
305</para>
306
307<para>
308GAG is a Graphical User Interface tool with which user
309can set parameters and execute commands. It is adaptive, since GAG
310reflects the internal states of Geant4 that is a state machine. GAG
311is based on the server-client model; GAG is the server, while
312Geant4 executables are clients. Hence, GAG does nothing by itself
313and it must invoke an executable simulation program. Geant4's
314front-end class <emphasis>G4UIGAG</emphasis> must be instantiated to
315communicate with GAG. This runs on Linux and Windows 2000.
316GAG is written in Java and
317its Jar (Java Archive) file is available from the above URL. See
318the same pages to know how to install and run Java programs.
319</para>
320
321<para>
322GAG has following functions.
323
324<variablelist>
325  <varlistentry>
326    <term>GAG Menu:</term>
327    <listitem>
328    The menus are to choose and run a GEANT4 executable file, to kill or exit
329    a GEANT4 process and to exit GAG. Upon the normal exit or an
330    unexpected death of the Geant4 process, GAG window are
331    automatically reset to accept another GEANT4 executable.   
332    </listitem>
333  </varlistentry>
334  <varlistentry>
335    <term>GEANT4 Command tree:</term>
336    <listitem>
337    Upon the establishment of the pipe with the GEANT4 process, GAG displays
338    the command menu tree whose look and feel is quite similar to
339    Windows' file browser. Disabled commands are shown opaque. GAG
340    doesn &amp;rsquo;t display commands that are just below the root of
341    the command hierarchy. Direct type-in field is available for such
342    input. Guidance of command categories and commands are displayed
343    upon focusing. GAG has a command history function. User can
344    re-execute a command with old parameters, edit the history, or save
345    the history to create a macro file.
346    </listitem>
347  </varlistentry>
348  <varlistentry>
349    <term>Command Parameter panel:</term>
350    <listitem>
351    GAG's parameter panel is the user-friendliest part. It displays parameter
352    name, its guidance, its type(s) (integer, double, Boolean or string),
353    omittable, default value(s), expression(s) of its range and candidate list(s)
354    (for example, of units). Range check is done by intercoms and
355    the error message from it is shown in the pop-up dialog box. When a
356    parameter component has a candidate list, a list box is
357    automatically displayed . When a file is requested by a command,
358    the file chooser is available.
359    </listitem>
360  </varlistentry>
361  <varlistentry>
362    <term>Logging:</term>
363    <listitem>
364    Log can be redirected to the terminal (xterm or cygwin
365    window) from which GAG is invoked. It can be interrupted as will,
366    in the middle of long session of execution. Log can be saved to a
367    file independent of the above redirection . GAG displays warning or
368    error messages from GEANT4 in a pop-up warning widget.
369    </listitem>
370  </varlistentry>
371</variablelist>
372</para>
373
374</sect3>
375</sect2>
376
377
378<!-- ******************* Section (Level#2) ****************** -->
379<sect2 id="sect.HowToSetUpInter.BuildLib">
380<title>
381Building the Interface Libraries
382</title>
383
384<para>
385The libraries that don't depend on external packages are made by default.
386They include <emphasis>G4UIterminal</emphasis>, <emphasis>G4UItcsh</emphasis>
387and <emphasis>G4UIGAG</emphasis> in libraries <emphasis>libG4UIbasic.a/so</emphasis> and
388<emphasis>libG4UIGAG.a/so</emphasis>. <emphasis>G4UIGainServer.o</emphasis> is packed in
389the <emphasis>libG4UIGAG</emphasis>.
390</para>
391
392<para>
393To make the libraries of <emphasis>G4UIXm</emphasis>, <emphasis>G4UIXaw</emphasis> and
394<emphasis>G4UIWin32</emphasis> , respective environment variables
395<emphasis role="bold">G4UI_BUILD_XM_SESSION</emphasis>,
396<emphasis role="bold">G4UI_BUILD_XAW_SESSION</emphasis> or
397<emphasis role="bold">G4UI_BUILD_WIN32_SESSION</emphasis> must be set
398explicitly.
399</para>
400
401<para>
402However, if the environment variable <emphasis role="bold">G4UI_NONE</emphasis> is
403set, no interface libraries are built at all.
404</para>
405
406<para>
407Build scheme of the user interface libraries is
408specified in "$G4INSTALL/config/G4UI_BUILD.gmk" makefile and the
409dependencies on the external packages are specified in
410"$G4INSTALL/config/interactivity.gmk".
411</para>
412
413</sect2>
414
415<!-- ******************* Section (Level#2) ****************** -->
416<sect2 id="sect.HowToSetUpInter.HowToUseInter">
417<title>
418How to Use the Interface
419</title>
420
421<para>
422To use a given interface
423(<literal>G4UIxxx</literal> where <literal>xxx = terminal,Xm, Xaw, Win32,
424GAG, GainServer</literal>) in a user's program, he has the following
425lines in his main program;
426
427<informalexample>
428<programlisting>
429// to include the class definition in his main program:
430   #include "G4Uixxx.hh"
431// to instantiate a session of his choice and start the session
432   G4UIsession* session = new G4UIxxx;
433   session-&gt;SessionStart();
434// the line next to the "SessionStart" is usually to finish the session
435   delete session;
436</programlisting>
437</informalexample>
438</para>
439
440<para>
441For a tcsh session, the second line must be :
442
443<informalexample>
444<programlisting>
445   G4UIsession* session = new G4UIterminal(new G4UItcsh);
446</programlisting>
447</informalexample>
448</para>
449
450<para>
451See the examples in "examples/novice/N0x" in which the terminal session
452is used.
453</para>
454
455<para>
456If the user wants to deactivate the default signal handler (soft abort)
457raised by "Ctr-C", the false flag can be set in the second argument
458of the <emphasis>G4UIterminal</emphasis> constructor like;
459
460<informalexample>
461<programlisting>
462   G4UIsession* session = new G4UIterminal(new G4UItcsh, false).
463</programlisting>
464</informalexample>
465</para>
466
467<para>
468Again, environment variable selects a given interface. But for your
469convenience, some of them are set defaults.
470
471<itemizedlist spacing="compact">
472   <listitem><para>
473   <emphasis>G4UIterminal</emphasis>, <emphasis>G4UItcsh</emphasis>,
474   <emphasis>G4UIGAG</emphasis> and <emphasis>G4UIGainServer</emphasis> 
475   can be used without any environment
476   variables. Sessions not needing external packages or libraries are
477   always built (see "G4UI_BUILD.gmk") and linked, so the user can
478   instantiate one of these sessions without rebuilding the libraries
479   and without setting any environment variables. For backwards
480   compatibility with user code, as typified by geant4/examples main
481   programs, the C-pre-processor variables corresponding to the
482   original environment variables for the above three (i.e.,
483   <emphasis role="bold">G4UI_USE_TERMINAL</emphasis>,
484   <emphasis role="bold">G4UI_USE_TCSH</emphasis> and
485   <emphasis role="bold">G4UI_USE_GAG</emphasis> ) are set. However,
486   if he/she sets no environment variables, then the C-pre-processor variable
487   <emphasis role="bold">G4UI_USE_TERMINAL</emphasis> is set by default,
488   although there is no need to use it.
489   </para></listitem>
490   <listitem><para>
491   The environment variable <emphasis role="bold">G4UI_USE_XM</emphasis>,
492   <emphasis role="bold">G4UI_USE_XAW</emphasis> or
493   <emphasis role="bold">G4UI_USE_WIN32</emphasis> must be set to use the
494   respective interface. The file "$G4INSTALL/config/interactivity.gmk"
495   resolves their dependencies on external packages.
496   </para></listitem>
497   <listitem><para>
498   If the environment variable <emphasis role="bold">G4UI_NONE</emphasis> is
499   set, no externa ibraries are selected. Also, for your convenience, if any
500   <emphasis role="bold">G4UI_USE_XXX</emphasis> environment variable is set,
501   then the corresponding C-pre-processor flag is also set. However, if the
502   environment variable <emphasis role="bold">G4UI_NONE</emphasis> is set,
503   no C-pre-processor flags are set.
504   </para></listitem>
505</itemizedlist>
506</para>
507
508</sect2>
509</sect1>
Note: See TracBrowser for help on using the repository browser.