source: additional/UserDoc/G4QtTutorial.html @ 920

Last change on this file since 920 was 920, checked in by garnier, 15 years ago

ajout de tutorial

  • Property svn:executable set to *
File size: 19.8 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html>
4    <head>
5    <link rel="stylesheet" href="G4QtTutorial.css" type="text/css" media="screen" />
6      <title>Geant4 Vis Tutorial using the OpenGL event display with Qt Toolkit</title>
7    </head>
8
9    <body bgcolor="white" >
10      <div id="menu" class="leftMenu">
11        <a href="http://www.opengl.org/">
12          <img src="G4OpenGLQtTutorial_files/ogl.gif" alt="OpenGL logo" height="48" width="110"/></a>
13        <a href="http://www.trolltech.com/">
14          <img src="G4OpenGLQtTutorial_files/Qt4logo.jpg" alt="Qt logo" height="48"/></a>
15      <hr/>
16          <a href="#intro">Introduction</a><br/>&nbsp;<br/>
17          <a href="#features">Main features</a><br/>&nbsp;<br/>
18          <a href="#configuration">Running Geant4 with Qt driver</a><br/>&nbsp;<br/>
19          <a href="#interface">User Interface</a><br/>&nbsp;<br/>
20          <a href="#visu">Visualization driver</a><br/>
21          &nbsp;&nbsp;- <a href="#controlling">Controlling visualization</a><br/>
22          &nbsp;&nbsp;- <a href="#contextMenu">Context menu options</a><br/>
23          &nbsp;&nbsp;- <a href="#savingFile">Saving file</a><br/>
24          &nbsp;&nbsp;- <a href="#makingMovies">Making movies</a><br/>&nbsp;<br/>
25
26          <a href="#resources">Further Resources</a><br/>
27    </div>
28      <div class="Content">
29        <center>
30          <h1>        Geant4 Visualization Tutorial using the OpenGL Event Display with Qt Toolkit    </h1>
31        </center>
32      </div>       
33      <a name="intro">  &nbsp;</a>
34      <div class="Content">
35       
36        <h2>Introduction</h2>
37        This tutorial is designed for anyone who wants to learn
38        OpenGL Visualization for Geant4 with Qt powerfull toolkit.
39        <p>
40          This tutorial can be used on its own, but gives the most comprehensive introduction to
41          Geant4 visualization when used as part of the following full set of documents:
42        </p><ul>
43          <li><a href="http://geant4.slac.stanford.edu/installation">
44              Geant4 Installation Guides</a>
45          </li><li>Introduction to Geant4 Visualization
46            (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisIntroduction.ppt">ppt</a>,
47            <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisIntroduction.pdf">pdf</a>)
48          </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html">
49              Geant4 Visualization Tutorial using the HepRApp HepRep Browser</a>
50          </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html">
51              Geant4 Visualization Tutorial using the DAWN Event Display</a>
52          </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html">
53              Geant4 Visualization Tutorial using the OpenGL Event Display</a>
54          </li><li><a href="http://users.lal.in2p3.fr/garnier/G4QtTutorial.html">
55              Geant4 Visualization Tutorial using the OpenGL Event Display with Qt toolkit</a>
56          </li><li>Geant4 Visualization Commands
57            (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisCommands.ppt">ppt</a>,
58            <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisCommands.pdf">pdf</a>)
59          </li><li>Geant4 Advanced Visualization
60            (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisAdvanced.ppt">ppt</a>,
61            <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisAdvanced.pdf">pdf</a>)
62          </li></ul>
63       
64        <p>
65          While some Geant4 visualization drivers are always included by default in your Geant4 build (because they require no external libraries), Qt is not part of the default set. You have to specifically ask to include Qt.
66         
67        </p><p>
68          If you followed the Geant4 Installation Guides referenced above, you used the Geant4 Configuration script
69          and said "yes" to including Qt. Qt version should be Qt3 are above (Qt 4.4 is current version)
70         
71        </p><p>
72          If you are following some other set of build instructions, refer to them for how to include Qt driver.
73          This may involve explicitly setting environment variables.
74        </p>
75      </div>
76      <a name="features"> &nbsp;</a>
77    <div class="Content">
78     
79      <h2>Main features</h2>
80      <ul>
81        <li>Multi platforms thanks to <font color="blue"><b>Qt</b></font>
82          <ul>
83            <li>Windows</li>
84            <li>Mac OS X</li>
85            <li>Linux / X11</li>
86          </ul>
87        </li>
88        <li>Hight level and <font color="blue"><b>fast visualization</b></font> thanks to OpenGL</li>
89        <li><font color="blue"><b>Interactive</b></font> move/rotate scene</li>
90        <li><font color="blue"><b>Photorealistic</b></font> image</li>
91        <li>Export in many formats (pixel graphics, SVG graphics, <font color="blue"><b>ps</b></font>, <font color="blue"><b>eps</b></font>, <font color="blue"><b>pdf</b></font>)</li>
92        <li><font color="blue"><b>Full screen</b></font> mode</li>
93        <li>Easy to <font color="blue"><b>make movies !</b></font></li>
94        <li>Help tree (for User interface)</li>
95      </ul>
96    </div>
97      <a name="configuration"> &nbsp;</a>
98      <div class="Content">
99        <h2>Running Geant4 with Qt driver</h2>
100        <p>Since OpenGL runs directly from Geant4, you just start Geant4 and then issue a few visualization commands.
101          The Installation Guides listed above already showed you how to start Geant4 with OpenGL Qt driver included. They then showed you how to use a few simple commands to do the most minimal visualization of some detector geometry and some event data. This guide will show you some additional commands.
102        </p>
103        <p>
104          <b>Building User interface driver</b>
105        </p>
106        Set the following variables acording to your shell, then recompile <i>sources/interfaces</i>
107        <ul><li>G4UI_BUILD_QT_SESSION 1<br/>
108              G4UI_USE_QT 1
109          </li>
110        </ul>
111        <p><b>Building visualization driver</b></p>
112        Set the following variables acording to your shell, then recompile <i>sources/visualization</i>
113        <ul>
114          <li>G4VIS_BUILD_OPENGLQT_DRIVER 1<br/>
115              G4VIS_USE_OPENGLQT 1
116          </li>
117        </ul>
118        <p> <b>Note</b> : Remember to do the appropriate setup commands before you start Geant4 from a new windows (see the installation guides for details).</p>
119          <ul>
120          <li>You can build and set a lot of visualization drivers, but only <b>ONE</b> session (User Interface). Don't forget to <b>unset</b> your previous G4UI_USE flags</li> before building your example.
121          <li> Start a fresh Geant4 session.</li>
122            <li>Open the visualization driver <b>/vis/open OGLIQt</b> or <b>/vis/open OGLSQt</b>.
123              An empty graphics windows should appear
124            </li>
125            <li> Issue the first command to draw something:<br/>
126                /vis/drawVolume
127            </li>
128          </ul>
129      </div>
130      <a name="interface">  &nbsp;</a>
131      <div class="Content">
132        <h2>User Interface</h2>
133        <ul>
134          <li><a href="#UI">User Interface</a></li>
135          <li><a href="#helpWidget">Help widget</a></li>
136        </ul>
137        <h3><a name="UI">User Interface</a></h3>
138        <table border="0" cellpadding="20">
139          <tr>
140            <td valign="top"  width="50%">
141              <p>As others Graphic User Interfaces (Xm,Win32), Qt User Interface have the same look &amp; feel. A <b>output area</b>, <b>history area</b>, <b>command area</b>, <b>menu</b> are available.
142              </p>
143              <p>Building the menu is available by executing set of commands defined in a <b>macro file</b> or entering thoses commands in the <b>User Interface</b> (as other Graphics User Interfaces). For example :</p>
144                <pre>
145/gui/addMenu run Run
146/gui/addButton run "beamOn 1" "/run/beamOn 1"
147                </pre>
148                Theses command will build a new menu "Run" with a sub-menu "beamOn 1" calling /run/beamOn command
149            </td><td>
150              <img src="G4OpenGLQtTutorial_files/G4UIQt.png" alt="G4UIQt" width="100%"/>
151            </td>
152          </tr>
153        </table>
154        <h3><a name="helpWidget">Help widget</a></h3>
155        <table border="0" cellpadding="20">
156          <tr>
157            <td valign="top"  width="50%">
158              <p> A <b>New</b> command <b>"help"</b> has been set specialy for Qt. Invoke it, it will display the <b>help tree widget</b>. This help widget will display all commands already loaded from Geant4 and all your personnels commands if Geant4 already knows them.
159              </p>
160              <p>This widget is very useful to find quicly a command in the geant4 set of commands. Moreover, you could ouble-click on the command you have find to set it in User Interface command area.</p>
161              <p>This help widget is composed of :</p>
162            <ul>
163                  <li>A <b>search area</b>: Look in command definition the string you look for</li>
164                  <li>A <b>command tree browser</b></li>
165                  <li>A <b>command definition outup zone</b></li>
166                </ul>
167            </td><td>
168              <img src="G4OpenGLQtTutorial_files/G4UIQtHelp1.png" alt="Helper 1"  width="100%"/>
169                <p>&nbsp;</p>
170                <img src="G4OpenGLQtTutorial_files/G4UIQtHelp2.png" alt="Helper2" width="100%"/>
171            </td>
172          </tr>
173        </table>
174       
175      </div>
176      <a name="visu">&nbsp;</a>
177      <div class="Content">
178        <h2>  Visualization driver</h2>
179        <ul>
180          <li><a href="#controlling">Controlling visualization</a></li>
181          <li><a href="#contextMenu">Context menu options</a></li>
182          <li><a href="#savingFile">Saving file</a></li>
183          <li><a href="#makingMovies">Making movies</a></li>
184        </ul>
185        <h3><a name="controlling">Controlling visualization</a></h3>
186        <p>As OpenInventor driver, Qt driver is a real-time display. <br/>
187            There is three control modes availables thanks to context-menu (right mouse button) :</p>
188            <ul>
189              <li><b>Rotate</b> : rotate scene when left mouse click.</li>
190              <li><b>Move</b> : move scence when left mouse click </li>
191              <li><b>Pick</b> : Display picking information when click on volume</li>
192            </ul>
193      <p>As default, control is set to <b>rotate</b> mode. <br/>
194          If you release mouse press when moving mouse press (in rotate/move mode), you will
195        set the scene in an <b>auto rotate/move</b> mode. Press mouse will stop this auto move/rotate
196        mode. The speed of this auto rotation/move is control by the speed of your mouse move when
197        releasing mouse press.
198      </p>
199      <p>In addition controling visualization is alo available by keybord :</p>
200          <ul>
201            <li>Left/right arrows to move volume left/right</li>
202            <li>Up/down arrows to move volume up/down</li>
203            <li>ALT+up/down arrows to move volume toward/forward</li>
204            <li>SHIFT+left/right arrows to rotate volume left/right</li>
205            <li>SHIFT+up/down arrows to rotate volume up/down</li>
206            <li>ALT+/- to slow/speed auto rotation/move</li>
207          </ul>
208        <h3><a name="contextMenu">Context menu options</a></h3>
209        <img src="G4OpenGLQtTutorial_files/G4ContextMenu.png"  alt="ContextMenu "/>
210          <p> A context menu is available on right mouse button, it is a quick mean to set somes
211            geant4 main options and some Qt specific ones :
212          </p>
213          <table border="0"><tr>
214              <td valign="top">
215                <ul><li><b>Mouse actions</b>
216                    <ul>
217                      <li><u>Rotate</u></li>
218                      <li>Move</li>
219                      <li>Pick</li>
220                      <li>Show shortcuts</li>
221                    </ul>
222                  </li>
223                </ul></td>
224              <td valign="top"><ul>
225                  <li><b>Styles</b>
226                    <ul>
227                      <li>Representation
228                        <ul>
229                          <li><u>Polyhedron</u></li>
230                          <li>NURBS</li>
231                        </ul>
232                      </li>
233                      <li>Projections
234                        <ul>
235                          <li><u>Orthographic</u></li>
236                          <li>Perspective</li>
237                        </ul>
238                      </li>
239                      <li>Drawing
240                        <ul>
241                          <li><u>Wireframe</u></li>
242                          <li>Hidden line removal</li>
243                          <li>Hidden line and surface removal</li>
244                        </ul>
245                      </li>
246                      <li>Background
247                        <ul>
248                          <li>White</li>
249                          <li><u>Black</u></li>
250                        </ul>
251                      </li>
252                    </ul>
253                  </li>
254                </ul></td>
255            <td valign="top">
256              <ul>
257                <li><b>Actions</b>
258                  <ul>
259                    <li>Save as...</li>
260                    <li>Movies parameters...</li>
261                  </ul>
262                </li>
263              </ul>
264            </td>
265            <td valign="top"><ul>
266                  <li><b>Special</b>
267                    <ul>
268                      <li>Transparency (<u>On</u>/Off)</li>
269        <li>Antialiasing (On/<u>Off</u>)</li>
270        <li>Haloing (On/<u>Off</u>)</li>
271        <li>Auxiliairy edges (<u>On</u>/Off)</li>
272        <li>Full screen (On/<u>Off</u>)</li>
273      </ul>
274      </li>
275      </ul>
276      </td>
277      </tr>
278      </table>
279        <p>A <u>underline</u> item is set by default by Geant4.
280        </p>
281        <p>A word about Qt specific options. <br/>
282            These new options introduced by Qt driver are <b>Actions-&lt;Save as...</b>, <b>Movies parameters...</b>,
283            and full screen mode.
284        </p>
285        <h3><a name="savingFile">Saving file</a></h3>
286        <p>Thanks to Qt, a lot of export formats are available :</p>
287        <table border="0" width="100%" ><tr>
288            <td valign="top">
289              <ul>
290                <li>bmp</li>
291                <li>jpeg</li>
292                <li>jpg</li>
293              </ul>
294            </td><td>
295              <ul>
296                <li>png</li>
297                <li>ppm</li>
298                <li>tif</li>
299              </ul>
300            </td><td>
301              <ul>
302                <li>tiff</li>
303                <li>xbm</li>
304                <li>xpm (Qt4 only)</li>
305              </ul>
306            </td><td>
307              <ul>
308                <li>eps (Vectorial and non-vectorial)</li>
309                <li>ps</li>
310                <li>pdf</li>
311              </ul>
312            </td></tr>
313        </table>
314        <h3><a name="makingMovies">Making movies</a></h3>
315        <p>
316          A important feature of Qt driver is avaibility to make movies. To do this Qt driver rely on an
317          free external software call <b>mpeg_encode</b>. It is available here:
318          <a href="http://bmrc.berkeley.edu/frame/research/mpeg/">http://bmrc.berkeley.edu/frame/research/mpeg/</a>.</p>
319        <p><u>How does it works ?</u></p>
320          <ol>
321            <li>Qt driver record each frame on OpenGL scene</li>
322            <li>mpeg_encode will merge all picture in one movie file</li>
323          </ol>
324        <p><u><b>Caution</b></u> : This is not a time based saving, but a frame based !</p>
325        <table border="0">
326          <tr>
327            <td>
328              <p><u>What do I have to do ?</u></p>
329                <ol>
330                  <li>Download <b>mpeg_encoder</b></li>
331                  <li>Fill parameters in movie dialog box : <br/>
332
333                      <p>First of all, you have to set where is install <b>mpeg_encoder</b></p>
334                      <p>&nbsp;</p>
335                      <p>&nbsp;</p>
336                      <p>&nbsp;</p>
337                      <p>Then, set the temp folder (by default Qt should find the good one)</p>
338                      <p>&nbsp;</p>
339                      <p>&nbsp;</p>
340                      <p>&nbsp;</p>
341                      <p>Set the name of the movie file that will be created</p>
342                      <p>&nbsp;</p>
343                      <p>&nbsp;</p>
344                      <p>&nbsp;</p>
345                  <p>Then press <b>Start/Pause/Stop</b> to record/pause/stop movie<br/>
346                  When press <b>Save</b>, the movie will be created, it could take a while depending of frame number. </p>
347              </li>
348            </ol>
349            </td>
350            <td>
351              <img src="G4OpenGLQtTutorial_files/G4MovieDialog.png"  alt="MovieDialog" width="100%"/>
352            </td></tr>
353        </table>   
354      </div>
355      <a name="resources">&nbsp;</a>
356      <div class="Content">
357        <h2>  Further Resources</h2>
358      <p>Documents in this Visualization Tutorial Set:</p>
359      <ul>
360        <li><a href="http://geant4.slac.stanford.edu/installation">
361            Geant4 Installation Guides</a>
362        </li><li>Introduction to Geant4 Visualization
363          (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisIntroduction.ppt">ppt</a>,
364          <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisIntroduction.pdf">pdf</a>)
365         
366        </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html">
367            Geant4 Visualization Tutorial using the HepRApp HepRep Browser</a>
368        </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html">
369            Geant4 Visualization Tutorial using the DAWN Event Display</a>
370          </li><li><a href="http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html">
371            Geant4 Visualization Tutorial using the OpenGL Event Display</a>
372        </li><li>Geant4 Visualization Commands
373          (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisCommands.ppt">ppt</a>,
374          <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisCommands.pdf">pdf</a>)
375        </li><li>Geant4 Advanced Visualization
376          (<a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisAdvanced.ppt">ppt</a>,
377          <a href="http://geant4.slac.stanford.edu/Presentations/vis/G4VisAdvanced.pdf">pdf</a>)
378         
379        </li>
380      </ul>
381      <p>
382        Other Resources:</p>
383      <ul>
384        <li>
385          On-line documentation on Geant4 visualization:
386          <br/>
387            <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch08.html">
388              http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch08.html</a>
389          </li><li>
390          List of visualization commands:
391          <br/>
392            <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch08s04.html">
393                http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch08s04.html</a>
394        </li><li>
395         
396          Questions, comments about Geant4 Visualization -Contact us through the Geant4 Visualization online forum:
397          <br/>
398            <a href="http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/visualization.html">
399              http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/visualization.html</a>
400        </li>
401      </ul>
402    </div>
403    <hr/>
404      <address><a href="mailto:garnier@lal.in2p3.fr">Laurent Garnier</a></address>
405        <!-- Created: Fri Dec 12 16:27:51 CET 2008 -->
406        <!-- hhmts start -->
407Last modified: Tue Jan  6 12:18:15 CET 2009
408<!-- hhmts end -->
409
410    </body>
411</html>
Note: See TracBrowser for help on using the repository browser.