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

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

Suppression de Xaw. Sauf dans Configure et les fichier G4UIXaw.hh et cc

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