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

Last change on this file since 1211 was 921, checked in by garnier, 17 years ago

en test de gl2ps. Problemes de libraries

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