1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title>2.8 How to specify a user interface</title> |
---|
5 | |
---|
6 | <style> |
---|
7 | v\:* {behavior:url(#default#VML);} |
---|
8 | o\:* {behavior:url(#default#VML);} |
---|
9 | w\:* {behavior:url(#default#VML);} |
---|
10 | .shape {behavior:url(#default#VML);} |
---|
11 | </style> <!-- Changed by: Katsuya Amako, 16-Nov-1998 --> <!-- Proof read by: Joe Chuma, 9-Jun-1999 --> |
---|
12 | <!-- Changed by: Hajime Yoshida 15-Nov-2001 --> <!-- Changed by: Dennis Wright, 29-Nov-2001 --> |
---|
13 | <!-- Changed by: Hajime Yoshida 15-Jun-2002 --> |
---|
14 | </head> |
---|
15 | <body> |
---|
16 | |
---|
17 | <table width="100%"> |
---|
18 | <tbody> |
---|
19 | <tr> |
---|
20 | <td> <a href="../../../../Overview/html/index.html"> <img src="../../../../resources/html/IconsGIF/Overview.gif" alt="Overview"> |
---|
21 | </a> <a href="index.html"> <img src="../../../../resources/html/IconsGIF/Contents.gif" alt="Contents"> |
---|
22 | </a> <a href="makeFile.html"> <img src="../../../../resources/html/IconsGIF/Previous.gif" alt="Previous"> |
---|
23 | </a> <a href="executeProgram.html"> <img src="../../../../resources/html/IconsGIF/Next.gif" alt="Next"> |
---|
24 | </a> </td> |
---|
25 | <td align="Right"> <font size="-1" color="#238e23"> <b>Geant4 User's Guide</b> |
---|
26 | <br> |
---|
27 | <b>For Application Developers</b> <br> |
---|
28 | <b>Getting Started with Geant4</b> </font> </td> |
---|
29 | </tr> |
---|
30 | </tbody> |
---|
31 | </table> |
---|
32 | <br> |
---|
33 | <br> |
---|
34 | |
---|
35 | <p align="Center"> <font size="+3" color="#238e23"> <b> 2.8 How to Set Up |
---|
36 | an Interactive Session </b> </font> <br> |
---|
37 | <br> |
---|
38 | </p> |
---|
39 | <hr align="Center" size="7"> |
---|
40 | <p> <a name="2.8.1"> |
---|
41 | <h2>2.8.1 Introduction</h2> |
---|
42 | </a> </p> |
---|
43 | <p> <b>Roles of the "intercoms" category</b> </p> |
---|
44 | <div class="MsoNormal"> The "intercoms" category provides an expandable |
---|
45 | command interpreter. It is the key mechanism of Geant4 to realize user interactions |
---|
46 | of all categories without being annoyed by the dependencies among categories. |
---|
47 | The direct use of Geant4 classes in a C++ program offers a first ground level |
---|
48 | of interactivity, i.e., the batch session. As seen in the examples/novice/N01, |
---|
49 | Geant4 commands and macros are to be hard-coded in the program.</div> |
---|
50 | |
---|
51 | <p> <b>User Interfaces to steer the simulation</b> </p> |
---|
52 | <div class="MsoNormal"> To avoid too much programming, the "intercoms" |
---|
53 | category provides the abstract class <i>G4UIsession </i>that captures interactive |
---|
54 | commands . The concrete implementation of the user interface and Graphical |
---|
55 | User Interfaces (GUI) is left to the interfaces category. This interfacing |
---|
56 | strategy opens an important door towards various user interface tools and |
---|
57 | allows Geant4 to utilize the state-of-the-art GUI tools such as Motif and |
---|
58 | Java, etc..The richness of the collaboration has permitted for different groups |
---|
59 | to offer various user interfaces to the Geant4 command system. Currently available |
---|
60 | are the following; |
---|
61 | <ol> |
---|
62 | |
---|
63 | <li> Character terminal (dumb terminal and tcsh(bash)-like terminal), the |
---|
64 | default user interface of Geant4,</li> |
---|
65 | |
---|
66 | <li> Xm, Xaw, Qt, Win32, variations of the upper terminal by using a Motif, |
---|
67 | Athena, Qt or Windows widget to retrieve commands, and</li> |
---|
68 | |
---|
69 | <li> GAG, a fully Graphical User Interface and its extension GainServer |
---|
70 | of the client/server type.</li> |
---|
71 | |
---|
72 | </ol> |
---|
73 | </div> |
---|
74 | |
---|
75 | <div class="MsoNormal">Full implementation of the character terminals (1 and |
---|
76 | 2) is included in the standard Geant4 distribution in the <tt>source/interfaces/basic</tt> |
---|
77 | directory. As for GAG with rich GUI functionalities, |
---|
78 | its front-end classes are included in the Geant4 distribution in the source/interfaces/GAG |
---|
79 | directory. The corresponding GUI package is available either from the author's |
---|
80 | Web pages (see URL below) or in the distributed package under the <tt>environments/MOMO</tt> |
---|
81 | directory.</div> |
---|
82 | |
---|
83 | <table border="0" cellpadding="0" style="mso-cellspacing:1.5pt;mso-padding-alt: |
---|
84 | 0cm 0cm 0cm 0cm"> |
---|
85 | <caption> </caption> <tbody> |
---|
86 | <tr> |
---|
87 | <td valign="Top" style="padding-top: 0.75pt; padding-right: 0.75pt; padding-bottom: 0.75pt; padding-left: 0.75pt; "> |
---|
88 | |
---|
89 | <div class="MsoNormal"><tt> |
---|
90 | GAG, GainServer's client GUI Gain </tt></div> |
---|
91 | </td> |
---|
92 | <td style="padding-top: 0.75pt; padding-right: 0.75pt; padding-bottom: 0.75pt; padding-left: 0.75pt; "> |
---|
93 | |
---|
94 | <div class="MsoNormal"><a href="http://erpc1.naruto-u.ac.jp/%7Egeant4"> |
---|
95 | http://erpc1.naruto-u.ac.jp/~geant4</a></div> |
---|
96 | </td> |
---|
97 | </tr> |
---|
98 | |
---|
99 | </tbody> |
---|
100 | </table> |
---|
101 | |
---|
102 | <div class="MsoNormal" style="text-align: center; "> |
---|
103 | <center> |
---|
104 | <hr size="2" width="100%" align="Center"></center> |
---|
105 | </div> |
---|
106 | <a name="2.8.2"> |
---|
107 | <h2>2.8.2 A Short Description of Available Interface Classes</h2> |
---|
108 | </a> |
---|
109 | <p> </p> |
---|
110 | <h3 style="margin-left: 36pt; text-indent: -18pt; "> 1. <i>G4U<b>I</b>terminal</i> |
---|
111 | and <i>G4UItcsh </i>classes</h3> |
---|
112 | |
---|
113 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> These |
---|
114 | interfaces open a session on the character terminal. <i>G4UIterminal</i> runs |
---|
115 | on all platform supported by Geant4, including <i>cygwin</i> on Windows, while |
---|
116 | <i>G4UItcsh</i> runs on Solaris and Linux. G4UItcsh supports user-friendly |
---|
117 | key bindings a-la-tcsh (or bash);</div> |
---|
118 | |
---|
119 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
120 | ^A move cursor to the top</div> |
---|
121 | |
---|
122 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
123 | ^B backward cursor ([LEFT] |
---|
124 | cursor)</div> |
---|
125 | |
---|
126 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
127 | ^D delete/exit/show matched list</div> |
---|
128 | |
---|
129 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
130 | ^E move cursor to the end</div> |
---|
131 | |
---|
132 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
133 | ^F forward |
---|
134 | cursor ([RIGHT] cursor)</div> |
---|
135 | |
---|
136 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
137 | ^K clear after the cursor</div> |
---|
138 | |
---|
139 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
140 | ^N next command ([DOWN] cursor)</div> |
---|
141 | |
---|
142 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
143 | ^P previous command |
---|
144 | ([UP] cursor)</div> |
---|
145 | |
---|
146 | <div class="MsoNormal" style="margin-left: 36pt; text-indent: 3pt; "> |
---|
147 | TAB command completion</div> |
---|
148 | |
---|
149 | <div class="MsoNormal"> |
---|
150 | DEL |
---|
151 | backspace</div> |
---|
152 | |
---|
153 | <div class="MsoNormal"> |
---|
154 | BS |
---|
155 | backspace</div> |
---|
156 | |
---|
157 | <div class="MsoNormal"> In addition, the following string substitutions |
---|
158 | are supported;</div> |
---|
159 | |
---|
160 | <div style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; "> |
---|
161 | %s current application status</div> |
---|
162 | |
---|
163 | <div class="MsoNormal"> |
---|
164 | %/ current working directory</div> |
---|
165 | |
---|
166 | <div class="MsoNormal"> |
---|
167 | %h history number</div> |
---|
168 | |
---|
169 | <h3 style="margin-left: 36pt; text-indent: -18pt; "> <b>2. <i>G4UIXm</i>, |
---|
170 | <i>G4UIXaw</i>, <i>G4UIQt</i> and <i>G4UIWin32</i> classes</b></h3> |
---|
171 | |
---|
172 | <div class="MsoNormal" style="margin-left: 36pt; "> These interfaces |
---|
173 | are versions of <i>G4UIterminal</i> implemented over libraries Motif, Athena |
---|
174 | and WIN32 respectively. <i>G4UIXm</i> uses the Motif XmCommand widget, <i> |
---|
175 | G4UIXaw</i> the Athena dialog widget, <i>G4UIQt</i> the Qt toolkit and <i>G4UIWin32</i> the Windows "edit" |
---|
176 | component to do the command capturing. These interfaces are useful if working |
---|
177 | in conjunction with visualization drivers that use the Xt library or the |
---|
178 | WIN32 one.</div> |
---|
179 | |
---|
180 | <div class="MsoNormal" style="margin-left: 36pt; "> A command box is |
---|
181 | at disposal for entering or recalling Geant4 commands. Command completion |
---|
182 | by typing &ldquo;TAB&rdquo; key is available on the command line. |
---|
183 | The shellcommands "exit, cont, help, ls, cd..." are also supported. |
---|
184 | A menu bar could be customized through the <i>AddMenu</i> and <i>AddButton</i> |
---|
185 | method.</div> |
---|
186 | |
---|
187 | <div class="MsoNormal" style="margin-left: 36pt; "> Ex:</div> |
---|
188 | |
---|
189 | <div class="MsoNormal" style="margin-left: 36pt; "> |
---|
190 | /gui/addMenu test Test</div> |
---|
191 | |
---|
192 | <div class="MsoNormal" style="margin-left: 36pt; "> |
---|
193 | /gui/addButton test Init /run/initialize</div> |
---|
194 | |
---|
195 | <div class="MsoNormal" style="margin-left: 36pt; "> |
---|
196 | /gui/addButton test "Set gun" |
---|
197 | "/control/execute gun.g4m"</div> |
---|
198 | |
---|
199 | <div class="MsoNormal" style="margin-left: 36pt; "> |
---|
200 | /gui/addButton test "Run one |
---|
201 | event" "/run/beamOn 1"</div> |
---|
202 | |
---|
203 | <div class="MsoNormal" style="margin-left: 36pt; "><i> G4UIXm </i>runs |
---|
204 | on Unix/Linux with Motif. <i>G4UIXaw</i>, less user friendly, runs on Unix |
---|
205 | with Athena widgets. <i>G4UIQt</i> run everywhere and <i>G4UIWin32</i> runs on Windows.</div> |
---|
206 | |
---|
207 | <h3 style="margin-left: 36pt; text-indent: -18pt; "> <b>3. <i>G4UIGAG</i> |
---|
208 | and G4UIGainServer classes</b></h3> |
---|
209 | |
---|
210 | <div style="margin-left: 36pt; text-indent: -18pt; ">They are the front-end |
---|
211 | classes of Geant4 which interface with their respective<br> |
---|
212 | graphical user interfaces, GAG (Geant4 Adaptive GUI) and Gain (Geant4 adaptive<br> |
---|
213 | interface for network). While GAG must run on the same system (Windows or |
---|
214 | Unixen) as a Geant4 application, Gain can run on a remote system (Windows, |
---|
215 | Linux, etc.) to which JVM (Java Virtual Machine) is installed. A Geant4 application |
---|
216 | is invoked on a Unix (Linux) system and behaves as a network server. It opens |
---|
217 | a port, waiting the connection from the Gain. Gain is capable to connect |
---|
218 | to multiple Geant4 "servers" on Unixen systems at different institutes.<br> |
---|
219 | <br> |
---|
220 | Client GUI, GAG and Gain have almost similar look-and-feel. So, GAG's functionalities |
---|
221 | are briefly introduced here. Please refer to the above URL for details and |
---|
222 | to download the client GUIs.<br> |
---|
223 | <br> |
---|
224 | GAG is a Graphical User Interface tool with which user can set |
---|
225 | parameters and execute commands. It is adaptive, since GAG reflects the internal |
---|
226 | states of Geant4 that is a state machine. GAG is based on the server-client |
---|
227 | model; GAG is the server, while Geant4 executables are clients. Hence, GAG |
---|
228 | does nothing by itself and it must invoke an executable simulation program. |
---|
229 | Geant4's front-end class <i>G4UIGAG </i>must be instantiated to communicate |
---|
230 | with GAG. This runs on Linux and Windows 2000.</div> |
---|
231 | |
---|
232 | <div style="margin-left: 36pt; "> GAG is written in Java and its Jar |
---|
233 | (Java Archive) file is available from the above URL. See the same pages to |
---|
234 | know how to install and run Java programs.</div> |
---|
235 | |
---|
236 | <p><br> |
---|
237 | GAG has following functions. </p> |
---|
238 | <div class="MsoNormal" style="margin-left: 72pt; text-indent: -18pt; "> |
---|
239 | <ul> |
---|
240 | <li> GAG Menu: <b> </b>The menus are to choose and |
---|
241 | run a GEANT4 executable file, to kill or exit a GEANT4 process |
---|
242 | and to exit GAG. Upon the normal exit or an unexpected death of the Geant4 |
---|
243 | process, GAG window are automatically reset to accept another GEANT4 executable.</li> |
---|
244 | |
---|
245 | <li> GEANT4 Command tree: <b> </b>Upon the |
---|
246 | establishment of the pipe with the GEANT4 process, GAG displays the command |
---|
247 | menu tree whose look and feel is quite similar to Windows' file browser. |
---|
248 | Disabled commands are shown opaque. GAG doesn&rsquo;t display commands |
---|
249 | that are just below the root of the command hierarchy. Direct type-in field |
---|
250 | is available for such input. Guidance of command categories and commands are |
---|
251 | displayed upon focusing . GAG has a command history function. User |
---|
252 | can re-execute a command with old parameters, edit the history, or save the |
---|
253 | history to create a macro file.</li> |
---|
254 | |
---|
255 | <li> Command Parameter panel:<b> </b>GAG's parameter panel is the user-friendliest |
---|
256 | part. It displays parameter name, its guidance, its type(s) (integer, double, |
---|
257 | Boolean or string), omittable, default value(s), expression(s) of its range |
---|
258 | and candidate list(s) (for example, of units). Range check is done by |
---|
259 | intercoms and the error message from it is shown in the pop-up dialog box. |
---|
260 | When a parameter component has a candidate list, a list box is automatically |
---|
261 | displayed . When a file is requested by a command, the file chooser is available.</li> |
---|
262 | |
---|
263 | <li> Logging:<b> </b>Log can be redirected to the terminal (xterm or cygwin |
---|
264 | window) from which GAG is invoked. It can be interrupted as will, in the middle |
---|
265 | of long session of execution. Log can be saved to a file independent of the |
---|
266 | above redirection . GAG displays warning or error messages from GEANT4 in |
---|
267 | a pop-up warning widget.</li> |
---|
268 | |
---|
269 | </ul> |
---|
270 | </div> |
---|
271 | |
---|
272 | <div class="MsoNormal" style="text-align: center; "> |
---|
273 | <center> |
---|
274 | <hr size="2" width="100%" align="Center"></center> |
---|
275 | </div> |
---|
276 | <a name="2.8.3"> |
---|
277 | <h2>2.8.3 Building the Interface Libraries</h2> |
---|
278 | </a> |
---|
279 | <p> The libraries that don't depend on external packages are made |
---|
280 | by default. They include <i>G4UIterminal</i>, <i>G4UItcsh</i> and <i>G4UIGAG</i> |
---|
281 | in libraries <i>libG4UIbasic.a/so </i>and <i>libG4UIGAG.a/so</i>. <i> |
---|
282 | G4UIGainServer.o</i> is packed in the <i>libG4UIGAG</i>.<br> |
---|
283 | To make the libraries of <i>G4UIXm</i>, <i>G4UIXaw</i>, <i>G4UIQt</i> and <i>G4UIWin32</i> |
---|
284 | , respective environment variables <b>G4UI_BUILD_XM_SESSION</b> , <b>G4UI_BUILD_XAW_SESSION</b>, <b>G4UI_BUILD_QT_SESSION</b> or <b>G4UI_BUILD_WIN32_SESSION</b> must be set explicitly. </p> |
---|
285 | <p> However, if the environment variable <b>G4UI_NONE</b> is set, no |
---|
286 | interface libraries are built at all. </p> |
---|
287 | <p> Build scheme of the user interface libraries is specified |
---|
288 | in "$G4INSTALL/config/G4UI_BUILD.gmk" makefile and the dependencies on the |
---|
289 | external packages are specified in "$G4INSTALL/config/interactivity.gmk". |
---|
290 | </p> |
---|
291 | <div class="MsoNormal" style="text-align: center; "> |
---|
292 | <center> |
---|
293 | <hr size="2" width="100%" align="Center"></center> |
---|
294 | </div> |
---|
295 | <a name="2.8.4"> |
---|
296 | <h2>2.8.4 How to Use the Interface</h2> |
---|
297 | </a> |
---|
298 | <p> </p> |
---|
299 | <div class="MsoNormal"> To use a given interface (<tt>G4UIxxx</tt> where |
---|
300 | <tt>xxx = terminal,Xm, Xaw, Qt, Win32, GAG, GainServer</tt>) in a user's program, |
---|
301 | he has the following lines in his main program;</div> |
---|
302 | |
---|
303 | <ul type="Disc"> |
---|
304 | |
---|
305 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
306 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
307 | // to include the class definition in his main program:</li> |
---|
308 | |
---|
309 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
310 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
311 | #include |
---|
312 | "G4Uixxx.hh"</li> |
---|
313 | |
---|
314 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
315 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
316 | // to instantiate a session of his choice and start the session</li> |
---|
317 | |
---|
318 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
319 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
320 | G4UIsession* |
---|
321 | session = new G4UIxxx;</li> |
---|
322 | |
---|
323 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
324 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
325 | session->SessionStart();</li> |
---|
326 | |
---|
327 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
328 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
329 | / /the line next to the "SessionStart" is usually to finish the session</li> |
---|
330 | |
---|
331 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
332 | mso-list:l0 level1 lfo9;tab-stops:list 36.0pt"> |
---|
333 | delete |
---|
334 | session;</li> |
---|
335 | |
---|
336 | </ul> |
---|
337 | |
---|
338 | <div style="margin-left: 36pt; text-indent: -18pt; "> For a tcsh session, |
---|
339 | the second line must be :</div> |
---|
340 | G4UIsession* |
---|
341 | session = new G4UIterminal(new G4UItcsh); |
---|
342 | <p style="tab-stops:list 36.0pt">See the examples in "examples/novice/N0x" |
---|
343 | in which the terminal session is used. </p> |
---|
344 | <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; |
---|
345 | tab-stops:list 36.0pt"> |
---|
346 | Again, environment variable selects a given interface. But for your convenience, |
---|
347 | some of them are set defaults. </p> |
---|
348 | <ul> |
---|
349 | |
---|
350 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> |
---|
351 | <i>G4UIterminal</i>, <i>G4UItcsh</i>, <i>G4UIGAG </i>and <i>G4UIGainServer</i> |
---|
352 | can be used without any environment variables. Sessions not needing external |
---|
353 | packages or libraries are always built (see "G4UI_BUILD.gmk") and linked, |
---|
354 | so the user can instantiate one of these sessions without rebuilding the |
---|
355 | libraries and without setting any environment variables. For backwards compatibility |
---|
356 | with user code, as typified by geant4/examples main programs, the C-pre-processor |
---|
357 | variables corresponding to the original environment variables for the above |
---|
358 | three (i.e., <b>G4UI_USE_TERMINAL</b>, <b>G4UI_USE_TCSH</b> and <b>G4UI_USE_GAG</b> |
---|
359 | ) are set. However, if he/she sets no environment variables, then the C-pre-processor |
---|
360 | variable <b>G4UI_USE_TERMINAL</b> is set by default, although there is no |
---|
361 | need to use it.</li> |
---|
362 | |
---|
363 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> |
---|
364 | The environment variable <b>G4UI_USE_XM</b>, <b>G4UI_USE_XAW</b>, <b>G4UI_USE_QT</b> or <b>G4UI_USE_WIN32</b> |
---|
365 | must be set to use the respective interface. The file |
---|
366 | "$G4INSTALL/config/interactivity.gmk" resolves their dependencies on external |
---|
367 | packages.</li> |
---|
368 | |
---|
369 | <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> |
---|
370 | If the environment variable <b>G4UI_NONE</b> is set, no externa ibraries |
---|
371 | are selected. Also, for your convenience, if any <b>G4UI_USE_XXX</b> environment |
---|
372 | variable is set, then the corresponding C-pre-processor flag is also set. |
---|
373 | However, if the environment variable <b>G4UI_NONE</b> is set, no C-pre-processor |
---|
374 | flags are set.</li> |
---|
375 | |
---|
376 | </ul> |
---|
377 | <a href="../../../../Authors/html/subjectsToAuthors.html"> <i>About the |
---|
378 | authors</i></a> |
---|
379 | </body> |
---|
380 | </html> |
---|