| [1208] | 1 | <HTML>
|
|---|
| 2 | <TITLE>Controlling Visualization from Commands</title>
|
|---|
| 3 | <BODY>
|
|---|
| 4 |
|
|---|
| 5 | <TABLE WIDTH="100%" >
|
|---|
| 6 | <TR>
|
|---|
| 7 | <TD>
|
|---|
| 8 | </A>
|
|---|
| 9 | <A HREF="index.html">
|
|---|
| 10 | <IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents" HEIGHT=16 WIDTH=59></A>
|
|---|
| 11 | <A HREF="visdrivers.html">
|
|---|
| 12 | <IMG SRC="../../../../resources/html/IconsGIF/Previous.gif" ALT="Previous" HEIGHT=16 WIDTH=59></A>
|
|---|
| 13 | <a href="compiledcontrol.html">
|
|---|
| 14 | <IMG SRC="../../../../resources/html/IconsGIF/Next.gif" ALT="Next" HEIGHT=16 WIDTH=59></a>
|
|---|
| 15 | </TD>
|
|---|
| 16 |
|
|---|
| 17 | <TD ALIGN="Right"><FONT COLOR="#238E23"><FONT SIZE=-1>
|
|---|
| 18 | <B>Geant4 User's Guide</B> <BR>
|
|---|
| 19 | <B>For Application Developers</B> <BR>
|
|---|
| 20 | <B>Visualization</B> </FONT></FONT> </TD>
|
|---|
| 21 | </TR>
|
|---|
| 22 | </TABLE>
|
|---|
| 23 |
|
|---|
| 24 | <CENTER><FONT COLOR="#238E23"><FONT SIZE=+3>
|
|---|
| 25 | <b>8.4 Controlling Visualization from Commands</b><BR>
|
|---|
| 26 | </FONT></FONT></CENTER>
|
|---|
| 27 | <BR>
|
|---|
| 28 |
|
|---|
| 29 | <HR ALIGN="Center" SIZE="7%"><BR>
|
|---|
| 30 | This section describes just a few of the more commonly used visualization commands.
|
|---|
| 31 | For the complete list of commands and options,
|
|---|
| 32 | see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A> section of this user guide.
|
|---|
| 33 | <P>
|
|---|
| 34 | For simplicity, this section assumes that the
|
|---|
| 35 | Geant4 executable was compiled incorporating the DAWNFILE and the
|
|---|
| 36 | OpenGL-Xlib drivers. For details on creating an executable for
|
|---|
| 37 | visualization see <a href="visexecutable.html">Section 8.2 </a>.
|
|---|
| 38 | <p>
|
|---|
| 39 |
|
|---|
| 40 | <h4>8.4.1 Scene, scene handler, and viewer</h4>
|
|---|
| 41 | In using the visualization commands, it is useful to know the concept
|
|---|
| 42 | of "scene", "scene handler", and "viewer".
|
|---|
| 43 | A "scene" is a set of visualizable raw 3D data.
|
|---|
| 44 | A "scene handler" is a graphics-data modeler,
|
|---|
| 45 | which processes raw data in a scene for later visualization.
|
|---|
| 46 | And a "viewer" generates images based on data processed by a scene handler.
|
|---|
| 47 | Roughly speaking, a set of a scene handler and a viewer
|
|---|
| 48 | corresponds to a visualization driver.
|
|---|
| 49 |
|
|---|
| 50 | <P>
|
|---|
| 51 | The steps of performing Geant4 visualization are explained below,
|
|---|
| 52 | though some of these steps may be done for you so that in practice you may
|
|---|
| 53 | use as few as just two commands (such as /vis/open OGLIX plus /vis/drawVolume)
|
|---|
| 54 | The seven steps of visualization are:
|
|---|
| 55 | :<BR>
|
|---|
| 56 | <BR>
|
|---|
| 57 | Step 1. Create a scene handler and a viewer.
|
|---|
| 58 | <BR>
|
|---|
| 59 | Step 2. Create an empty scene.
|
|---|
| 60 | <BR>
|
|---|
| 61 | Step 3. Add raw 3D data to the created scene.
|
|---|
| 62 | <BR>
|
|---|
| 63 | Step 4. Attach the current scene handler to the current scene.
|
|---|
| 64 | <BR>
|
|---|
| 65 | Step 5. Set camera parameters, drawing style (wireframe/surface), etc.
|
|---|
| 66 | <BR>
|
|---|
| 67 | Step 6. Make the viewer execute visualization.
|
|---|
| 68 | <BR>
|
|---|
| 69 | Step 7. Declare the end of visualization for flushing.
|
|---|
| 70 | <BR>
|
|---|
| 71 | <P>
|
|---|
| 72 | These seven steps can be controlled explicitly to create multiple scenes and multiple viewers,
|
|---|
| 73 | each with its own set of parameters, with easy switching from one scene to another.
|
|---|
| 74 | But for the most common case of just having one scene and one viewer,
|
|---|
| 75 | many steps are handled implicitly for you.
|
|---|
| 76 | <P>
|
|---|
| 77 |
|
|---|
| 78 | <h4>8.4.2 Create a scene handler and a viewer: <tt>/vis/open</tt> command</h4>
|
|---|
| 79 |
|
|---|
| 80 | Command "<tt>/vis/open</tt>" creates a scene handler and a viewer,
|
|---|
| 81 | which corresponds to Step 1.
|
|---|
| 82 |
|
|---|
| 83 | <UL>
|
|---|
| 84 | <LI><B>Command</B><BR>
|
|---|
| 85 | <TT>/vis/open [driver_tag_name]</TT>
|
|---|
| 86 | <LI><B>Argument</B><BR>
|
|---|
| 87 | A name of (a mode of) an available visualization driver.
|
|---|
| 88 | <LI><B>Action</B><BR>
|
|---|
| 89 | Create a visualization driver, i.e. a set of
|
|---|
| 90 | a scene hander and a viewer.
|
|---|
| 91 | <LI><B>Example: Create the OpenGL-Xlib driver with its immediate mode</B><BR>
|
|---|
| 92 | <TT>Idle> /vis/open OGLIX</TT>
|
|---|
| 93 | <LI><B>Additional notes</B>
|
|---|
| 94 | <BR>For immediate viewers, such as OGLIX, your geometry will immediately be
|
|---|
| 95 | rendered in the new GL window<BR><BR>
|
|---|
| 96 | <BR>How to list available driver_tag_name:<BR><BR>
|
|---|
| 97 | <TT>Idle> help /vis/open</TT><BR>
|
|---|
| 98 | or<BR>
|
|---|
| 99 | <TT>Idle> help /vis/sceneHandler/create</TT><BR><BR>
|
|---|
| 100 | The list is, for example, displayed as follows:<BR>
|
|---|
| 101 | .....<BR>
|
|---|
| 102 | <TT> Candidates : DAWNFILE OGLIX OGLSX </TT><BR>
|
|---|
| 103 | .....<BR>
|
|---|
| 104 | <LI>For additional options,
|
|---|
| 105 | see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A> section of this user guide.
|
|---|
| 106 | <BR>
|
|---|
| 107 | </UL>
|
|---|
| 108 | <BR>
|
|---|
| 109 |
|
|---|
| 110 | <h4>8.4.3 Create an empty scene: <tt>/vis/scene/create</tt> command</h4>
|
|---|
| 111 |
|
|---|
| 112 | Command "<tt>/vis/scene/create</tt>" creates an empty scene,
|
|---|
| 113 | which corresponds to Step 2.
|
|---|
| 114 |
|
|---|
| 115 | <UL>
|
|---|
| 116 | <LI><B>Command</B><BR>
|
|---|
| 117 | <TT>/vis/scene/create [scene_name]</TT>
|
|---|
| 118 | <LI><B>Argument</B><BR>
|
|---|
| 119 | A name for this scene. Created for you if you don't specify one.
|
|---|
| 120 | </UL>
|
|---|
| 121 | <BR>
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | <h4>8.4.4 Visualization of a physical volume:
|
|---|
| 125 | <tt>/vis/drawVolume</tt> command </h4>
|
|---|
| 126 |
|
|---|
| 127 | Command "<TT>/vis/drawVolume</TT>" adds a physical volume to the scene.
|
|---|
| 128 | It also does some of the other steps, if you haven't done them explicitly.
|
|---|
| 129 | It takes care of steps 2, 3, 4 and 6.
|
|---|
| 130 | Command "<tt>/vis/viewer/flush</tt>" should follow
|
|---|
| 131 | in order to do the final Step 7.
|
|---|
| 132 |
|
|---|
| 133 | <UL>
|
|---|
| 134 | <LI><B>Commands</B><BR>
|
|---|
| 135 | <TT>/vis/drawVolume [physical-volume-name]</TT><BR>
|
|---|
| 136 | <TT>.....</TT><BR>
|
|---|
| 137 | <TT>Idle> /vis/viewer/flush</TT>
|
|---|
| 138 | <LI><B>Argument</B><BR>
|
|---|
| 139 | A physical-volume name.
|
|---|
| 140 | The default value is "world", which is omittable.
|
|---|
| 141 | <LI><B>Action</B><BR>
|
|---|
| 142 | Creates a scene consisting of the given physical volume and asks the
|
|---|
| 143 | current viewer to draw it.
|
|---|
| 144 | The scene becomes current.
|
|---|
| 145 | Command "<tt>/vis/viewer/flush</tt>" should follow this command
|
|---|
| 146 | in order to declare end of visualization.
|
|---|
| 147 | <LI><B>Example: Visualization of the whole world with coordinate axes</B><BR>
|
|---|
| 148 | <TT>Idle> /vis/drawVolume</TT><BR>
|
|---|
| 149 | <TT>Idle> /vis/scene/add/axes 0 0 0 500 mm</TT><BR>
|
|---|
| 150 | <TT>Idle> /vis/viewer/flush</TT>
|
|---|
| 151 | </UL>
|
|---|
| 152 | <BR>
|
|---|
| 153 |
|
|---|
| 154 | <h4>8.4.5 Visualization of a logical volume:
|
|---|
| 155 | <tt>/vis/specify </tt> command </h4>
|
|---|
| 156 |
|
|---|
| 157 | Command "<TT>/vis/specify</TT>" visualizes a logical volume.
|
|---|
| 158 | If allows you to control how much details is shown and whether to show booleans, voxels and readout geometries.
|
|---|
| 159 | It also does some of the other steps, if you haven't done them explicitly.
|
|---|
| 160 | It takes care of steps 2, 3, 4 and 6.
|
|---|
| 161 | Command "<tt>/vis/viewer/flush</tt>" should follow the command
|
|---|
| 162 | in order to do the final Step 7.
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | <UL>
|
|---|
| 166 | <LI><B>Command</B><BR>
|
|---|
| 167 | <TT>/vis/specify [logical-volume-name][depth-of-descent] [booleans-flag] [voxels-flag] [readout-flag]</TT><BR>
|
|---|
| 168 | <LI><B>Argument</B><BR>
|
|---|
| 169 | A logical-volume name.
|
|---|
| 170 | <LI><B>Action</B><BR>
|
|---|
| 171 | Creates a scene consisting of the given logical volume and asks the
|
|---|
| 172 | current viewer to draw it.
|
|---|
| 173 | The scene becomes current.
|
|---|
| 174 | <LI><B>Example (visualization of a selected logical volume with coordinate axes)</B><BR>
|
|---|
| 175 | <TT>Idle> /vis/specify Absorber </TT><BR>
|
|---|
| 176 | <TT>Idle> /vis/scene/add/axes 0 0 0 500 mm</TT><BR>
|
|---|
| 177 | <TT>Idle> /vis/scene/add/text 0 0 0 mm 40 -100 -200 LogVol:Absorber </TT><BR>
|
|---|
| 178 | <TT>Idle> /vis/viewer/flush</TT>
|
|---|
| 179 | </UL>
|
|---|
| 180 | For more options,
|
|---|
| 181 | see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A> section of this user guide.
|
|---|
| 182 | <BR>
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | <h4>8.4.6 Visualization of trajectories: <TT>/vis/scene/add/trajectories </TT> command</h4>
|
|---|
| 186 |
|
|---|
| 187 | Command "<TT>/vis/scene/add/trajectories</TT>"
|
|---|
| 188 | adds trajectories to the current scene.
|
|---|
| 189 | Note that this automatically issues "<TT>/tracking/storeTrajectory 1</TT>" so
|
|---|
| 190 | that trajectories are stored (by default they are not).
|
|---|
| 191 | The visualization is performed with the command
|
|---|
| 192 | "<TT>/run/beamOn</TT>"
|
|---|
| 193 | unless you have non-default values for /vis/scene/endOfEventAction or /vis/scene/endOfRunAction
|
|---|
| 194 | (described below).
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | <UL>
|
|---|
| 198 | <LI><B>Command</B><BR>
|
|---|
| 199 | <TT>/vis/scene/add/trajectories [drawing-mode]</TT><BR>
|
|---|
| 200 | <LI><B>Action</B><BR>
|
|---|
| 201 | The command adds trajectories to the current scene.
|
|---|
| 202 | Trajectories are drawn at end of event when the scene
|
|---|
| 203 | in which they are added is current.
|
|---|
| 204 | <LI><B>Example: Visualization of trajectories </B><BR>
|
|---|
| 205 | <TT>Idle> /vis/scene/add/trajectories </TT><BR>
|
|---|
| 206 | <TT>Idle> /run/beamOn 10</TT><BR>
|
|---|
| 207 | <LI><B>Additional note 1</B><BR>
|
|---|
| 208 | See the section <A HREF="enhanceddrawing.html#commandcontrol">Enhanced Trajectory Drawing</a>
|
|---|
| 209 | for details on how to control how trajectories are color-coded.
|
|---|
| 210 | <LI><B>Additional note 2</B><BR>
|
|---|
| 211 | In examples/novice/N03,
|
|---|
| 212 | command "<TT>/vis/scene/add/trajectories</TT>"
|
|---|
| 213 | need not be executed, since
|
|---|
| 214 | the C++ method <tt>G4Trajectory::DrawTrajectory()</tt>
|
|---|
| 215 | is explicitly described in the event action.
|
|---|
| 216 | Therefore the command need not be executed though (G)UI.
|
|---|
| 217 | </UL>
|
|---|
| 218 | For more options,
|
|---|
| 219 | see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A> section of this user guide.
|
|---|
| 220 | <BR>
|
|---|
| 221 |
|
|---|
| 222 | <h4>8.4.7 Visualization of hits: <TT>/vis/scene/add/hits </TT> command</h4>
|
|---|
| 223 |
|
|---|
| 224 | Command "<TT>/vis/scene/add/hits</TT>"
|
|---|
| 225 | adds hits to the current scene, assuming that you have a hit class and that the hits
|
|---|
| 226 | have visualization information.
|
|---|
| 227 | The visualization is performed with the command
|
|---|
| 228 | "<TT>/run/beamOn</TT>"
|
|---|
| 229 | unless you have non-default values for /vis/scene/endOfEventAction or /vis/scene/endOfRunAction
|
|---|
| 230 | (described above).
|
|---|
| 231 |
|
|---|
| 232 | <h4>8.4.8 HepRep Attributes for Hits</h4>
|
|---|
| 233 | The HepRep file formats, HepRepFile and HepRepXML, attach various attributes to hits
|
|---|
| 234 | such that you can view these attributes, label trajectories by these attributes
|
|---|
| 235 | or make visibility cuts based on these attributes.
|
|---|
| 236 | Examples of adding HepRep attributes to hit classes can be found in examples
|
|---|
| 237 | /extended/analysis/A01 and /extended/runAndEvent/RE01.
|
|---|
| 238 | <P>
|
|---|
| 239 | For example, in example RE01's class RE01CalorimeterHit.cc,
|
|---|
| 240 | available attributes will be:
|
|---|
| 241 | <UL>
|
|---|
| 242 | <LI>Hit Type</li>
|
|---|
| 243 | <LI>Track ID</li>
|
|---|
| 244 | <LI>Z Cell ID</li>
|
|---|
| 245 | <LI>Phi Cell ID</li>
|
|---|
| 246 | <LI>Energy Deposited</li>
|
|---|
| 247 | <LI>Energy Deposited by Track</li>
|
|---|
| 248 | <LI>Position</li>
|
|---|
| 249 | <LI>Logical Volume</li>
|
|---|
| 250 | </UL>
|
|---|
| 251 | You can add additional attributes of your choosing by modifying the relevant part of the hit class
|
|---|
| 252 | (look for the methods GetAttDefs and CreateAttValues).
|
|---|
| 253 |
|
|---|
| 254 | <h4>8.4.9 Basic camera workings: <tt>/vis/viewer/</tt> commands</tt></h4>
|
|---|
| 255 |
|
|---|
| 256 | Commands in the command directory "<tt>/vis/viewer/</tt>"
|
|---|
| 257 | set camera parameters and drawing style of the
|
|---|
| 258 | current viewer, which corresponds to Step 5.
|
|---|
| 259 | Note that the camera parameters and the drawing style
|
|---|
| 260 | should be set separately for each viewer.
|
|---|
| 261 | They can be initialized to the default values
|
|---|
| 262 | with command "<tt>/vis/viewer/reset</tt>".
|
|---|
| 263 | Some visualization systems, such as the VRML and HepRep browsers also allow camera control
|
|---|
| 264 | from the standalone graphics application.
|
|---|
| 265 | <P>
|
|---|
| 266 | Just a few of the camera commands are described here.
|
|---|
| 267 | For more commands,
|
|---|
| 268 | see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A> section of this user guide.
|
|---|
| 269 |
|
|---|
| 270 | <UL>
|
|---|
| 271 | <LI><B>Command</B><BR>
|
|---|
| 272 | <TT>/vis/viewer/set/viewpointThetaPhi [theta] [phi] [deg|rad] </TT>
|
|---|
| 273 | <LI><B>Arguments</B><BR>
|
|---|
| 274 | Arguments "theta" and "phi" are polar and azimuthal camera angles,
|
|---|
| 275 | respectively. The default unit is "degree".
|
|---|
| 276 | <LI><B>Action</B><BR>
|
|---|
| 277 | Set a view point in direction of (theta, phi).
|
|---|
| 278 | <LI><B>Example: Set the viewpoint in direction of (70 deg, 20 deg)</B><BR>
|
|---|
| 279 | <TT>Idle> /vis/viewer/set/viewpointThetaPhi 70 20</TT>
|
|---|
| 280 | <LI><B>Additional notes</B><BR>
|
|---|
| 281 | Camera parameters should be set for each viewer.
|
|---|
| 282 | They are initialized with command "<tt>/vis/viewer/reset</tt>".
|
|---|
| 283 | </UL>
|
|---|
| 284 | <BR>
|
|---|
| 285 |
|
|---|
| 286 | <UL>
|
|---|
| 287 | <LI><B>Command</B><BR>
|
|---|
| 288 | <TT>/vis/viewer/zoom [scale_factor]</TT>
|
|---|
| 289 | <LI><B>Argument</B><BR>
|
|---|
| 290 | The scale factor.
|
|---|
| 291 | The command multiplies magnification of the view by this factor.
|
|---|
| 292 | <LI><B>Action</B><BR>
|
|---|
| 293 | Zoom up/down of view.
|
|---|
| 294 | <LI><B>Example: Zoom up by factor 1.5</B><BR>
|
|---|
| 295 | <TT>Idle> /vis/viewer/zoom 1.5</TT>
|
|---|
| 296 | <LI><B>Additional notes</B><BR>
|
|---|
| 297 | Camera parameters should be set for each viewer.
|
|---|
| 298 | They are initialized with command "<tt>/vis/viewer/reset</tt>".
|
|---|
| 299 | <BR>A similar pair of commands, scale and scaleTo allow non-uniform scaling
|
|---|
| 300 | (i.e., zoom differently along different axes).
|
|---|
| 301 | For details, see the <A HREF="../Control/UIcommands/_vis_.html">Control...UICommands</A>
|
|---|
| 302 | section of this user guide.
|
|---|
| 303 | </UL>
|
|---|
| 304 | <BR>
|
|---|
| 305 |
|
|---|
| 306 | <UL>
|
|---|
| 307 | <LI><B>Command</B><BR>
|
|---|
| 308 | <TT>/vis/viewer/set/style [style_name]</TT>
|
|---|
| 309 | <LI><B>Arguments</B><BR>
|
|---|
| 310 | Candidate values of the argument are "wireframe" and "surface".
|
|---|
| 311 | ("w" and "s" also work.)
|
|---|
| 312 | <LI><B>Action</B><BR>
|
|---|
| 313 | Set a drawing style to wireframe or surface.
|
|---|
| 314 | <LI><B>Example: Set the drawing style to "surface"</B><BR>
|
|---|
| 315 | <TT>Idle> /vis/viewer/set/style surface</TT>
|
|---|
| 316 | <LI><B>Additional notes</B><BR>
|
|---|
| 317 | <BR>The style of some geometry components may have been forced one way or the other through
|
|---|
| 318 | calls in compiled code. The set/style command will NOT override such force styles.
|
|---|
| 319 | <BR>Drawing style should be set for each viewer.
|
|---|
| 320 | The drawing style is initialized with
|
|---|
| 321 | command "<tt>/vis/viewer/reset</tt>".
|
|---|
| 322 | </UL>
|
|---|
| 323 | <BR>
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 | <h4>8.4.10 Declare the end of visualization for flushing: <tt>/vis/viewer/flush</tt> command</tt></h4>
|
|---|
| 327 |
|
|---|
| 328 | <UL>
|
|---|
| 329 | <LI><B>Command</B><BR>
|
|---|
| 330 | <TT>/vis/viewer/flush </TT><BR>
|
|---|
| 331 | <LI><B>Action</B><BR>
|
|---|
| 332 | Declare the end of visualization for flushing.
|
|---|
| 333 | <LI><B>Additional notes</B><BR>
|
|---|
| 334 | Command "<tt>/vis/viewer/flush</tt>" should follow
|
|---|
| 335 | "<tt>/vis/drawVolume</tt>", "<tt>/vis/specify</tt>", etc in order
|
|---|
| 336 | to complete visualization.
|
|---|
| 337 | It corresponds to Step 7.
|
|---|
| 338 | <BR>
|
|---|
| 339 | The flush is done automatically after every /run/beamOn command unless
|
|---|
| 340 | you have non-default values for /vis/scene/endOfEventAction or /vis/scene/endOfRunAction
|
|---|
| 341 | (described above).
|
|---|
| 342 | </UL>
|
|---|
| 343 |
|
|---|
| 344 | <h4>8.4.11 End of Event Action and End of Run Action: <tt>/vis/viewer/endOfEventAction</tt>
|
|---|
| 345 | and <tt>/vis/viewer/endOfEventAction</tt> commands</h4>
|
|---|
| 346 | By default, a separate picture is created for each event.
|
|---|
| 347 | You can change this behavior to accumulate multiple events, or even multiple runs, in a single picture.
|
|---|
| 348 | <UL>
|
|---|
| 349 | <LI><B>Command</B><BR>
|
|---|
| 350 | <TT>/vis/scene/endOfEventAction [refresh|accumulate]</TT><BR>
|
|---|
| 351 | <LI><B>Action</B><BR>
|
|---|
| 352 | Control how often the picture should be cleared.
|
|---|
| 353 | <BR>
|
|---|
| 354 | <tt>refresh</tt> means each event will be written to a new picture.
|
|---|
| 355 | <BR>
|
|---|
| 356 | <tt>accumulate</tt> means events will be accumulated into a single picture.
|
|---|
| 357 | Picture will be flushed at end of run, unless you have also set
|
|---|
| 358 | <tt>/vis/scene/endOfRunAction accumulate</tt>
|
|---|
| 359 | <LI><B>Additional note</B><BR>
|
|---|
| 360 | You may instead choose to use update commands from your BeginOfRunAction or
|
|---|
| 361 | EndOfEventAction, as in early examples, but now the vis manager
|
|---|
| 362 | ia able to do most of what most users require through the above commands.
|
|---|
| 363 | </UL>
|
|---|
| 364 | <UL>
|
|---|
| 365 | <LI><B>Command</B><BR>
|
|---|
| 366 | <TT>/vis/scene/endOfRunAction [refresh|accumulate]</TT><BR>
|
|---|
| 367 | <LI><B>Action</B><BR>
|
|---|
| 368 | Control how often the picture should be cleared.
|
|---|
| 369 | <BR>
|
|---|
| 370 | <tt>refresh</tt> means each run will be written to a new picture.
|
|---|
| 371 | <BR>
|
|---|
| 372 | <tt>accumulate</tt> means runs will be accumulated into a single picture.
|
|---|
| 373 | To start a new picture, you must explicitly issue
|
|---|
| 374 | <tt>/vis/viewer/refresh</tt>, <tt>/vis/viewer/update</tt> or <tt>/vis/viewer/flush</tt>
|
|---|
| 375 | </UL>
|
|---|
| 376 |
|
|---|
| 377 | <h4>8.4.12 HepRep Attributes for Trajectories</h4>
|
|---|
| 378 | The HepRep file formats, HepRepFile and HepRepXML, attach various attributes to trajectories
|
|---|
| 379 | such that you can view these attributes, label trajectories by these attributes
|
|---|
| 380 | or make visibility cuts based on these attributes.
|
|---|
| 381 | If you use the default Geant4 trajectory class, from /tracking/src/G4Trajectory.cc,
|
|---|
| 382 | available attributes will be:
|
|---|
| 383 | <UL>
|
|---|
| 384 | <LI>Track ID</li>
|
|---|
| 385 | <LI>Parent ID</li>
|
|---|
| 386 | <LI>Particle Name</li>
|
|---|
| 387 | <LI>Charge</li>
|
|---|
| 388 | <LI>PDG Encoding</li>
|
|---|
| 389 | <LI>Momentum 3-Vector</li>
|
|---|
| 390 | <LI>Momentum magnitude</li>
|
|---|
| 391 | <LI>Number of points</li>
|
|---|
| 392 | </UL>
|
|---|
| 393 | You can add additional attributes of your choosing by modifying the relevant part of G4Trajectory
|
|---|
| 394 | (look for the methods GetAttDefs and CreateAttValues).
|
|---|
| 395 | If you are using your own trajectory class,
|
|---|
| 396 | you may want to consider copying these methods from G4Trajectory.
|
|---|
| 397 |
|
|---|
| 398 | <h4>8.4.13 How to save a visualized views to PostScript files</h4>
|
|---|
| 399 |
|
|---|
| 400 | Most of the visualization drivers offer ways to save
|
|---|
| 401 | visualized views to PostScript files
|
|---|
| 402 | (or Encapsulated PostScript (EPS) files) by themselves.
|
|---|
| 403 | <P>
|
|---|
| 404 | The DAWNFILE driver, which co-works with Fukui Renderer DAWN,
|
|---|
| 405 | generates "vectorized" PostScript data
|
|---|
| 406 | with "analytical hidden-line/surface removal", and so it is
|
|---|
| 407 | well suited for technical high-quality outputs for presentation,
|
|---|
| 408 | documentation, and debugging geometry.
|
|---|
| 409 | In the default setting of the DAWNFILE drivers,
|
|---|
| 410 | EPS files named "<tt>g4_00.eps, g4_01.eps, g4_02.eps</tt>,..."
|
|---|
| 411 | are automatically generated in the current directory
|
|---|
| 412 | each time when visualization
|
|---|
| 413 | is performed, and then a PostScript viewer "<tt>gv</tt>"is
|
|---|
| 414 | automatically invoked to visualize the generated EPS files.
|
|---|
| 415 | <P>
|
|---|
| 416 | For large data sets, it may take time to generate
|
|---|
| 417 | the vectorized PostScript data.
|
|---|
| 418 | In such a case, visualize the 3D scene with a faster visualization driver
|
|---|
| 419 | beforehand for previewing, and then use the DAWNFILE drivers.
|
|---|
| 420 | For example,
|
|---|
| 421 | the following visualizes the whole detector with the OpenGL-Xlib driver
|
|---|
| 422 | (immediate mode) first, and then with the DAWNFILE driver to generate
|
|---|
| 423 | an EPS file <tt>g4_XX.eps</tt> to save the visualized view:
|
|---|
| 424 | <PRE>
|
|---|
| 425 | # Invoke the OpenGL visualization driver in its immediate mode
|
|---|
| 426 | /vis/open OGLIX
|
|---|
| 427 |
|
|---|
| 428 | # Camera setting
|
|---|
| 429 | /vis/viewer/set/viewpointThetaPhi 20 20
|
|---|
| 430 |
|
|---|
| 431 | # Camera setting
|
|---|
| 432 | /vis/drawVolume
|
|---|
| 433 | /vis/viewer/flush
|
|---|
| 434 |
|
|---|
| 435 | # Invoke the DAWNFILE visualization driver
|
|---|
| 436 | /vis/open DAWNFILE
|
|---|
| 437 |
|
|---|
| 438 | # Camera setting
|
|---|
| 439 | /vis/viewer/set/viewpointThetaPhi 20 20
|
|---|
| 440 |
|
|---|
| 441 | # Camera setting
|
|---|
| 442 | /vis/drawVolume
|
|---|
| 443 | /vis/viewer/flush
|
|---|
| 444 | </PRE>
|
|---|
| 445 | This is a good example to show that the visualization drivers
|
|---|
| 446 | are complementary to each other.
|
|---|
| 447 | <P>
|
|---|
| 448 | In the OpenInventor drivers , you can simply click the "Print" button
|
|---|
| 449 | on their GUI to generate a PostScript file as a hard copy of a visualized
|
|---|
| 450 | view.
|
|---|
| 451 | <P>
|
|---|
| 452 | The OpenGL-Motif driver also has a menu to generate PostScript files.
|
|---|
| 453 | It can generate either vectorized or rasterized PostScript data.
|
|---|
| 454 | In generating vectorized PostScript data, hidden-surface removal
|
|---|
| 455 | is performed, based on the painter's algorithm after dividing facets
|
|---|
| 456 | of shapes into small sub-triangles.
|
|---|
| 457 | <P>
|
|---|
| 458 | The WIRED3 HepRep Browser and WIRED4 JAS Plug-In can generate a wide variety
|
|---|
| 459 | of bitmap and vector output formats including PostScript and PDF.
|
|---|
| 460 | <p>
|
|---|
| 461 |
|
|---|
| 462 | <h4>8.4.14 Culling</h4>
|
|---|
| 463 |
|
|---|
| 464 | "Culling" means to skip visualizing parts of a 3D scene. Culling is useful
|
|---|
| 465 | for avoiding complexity of visualized views, keeping transparent features
|
|---|
| 466 | of the 3D scene, and for quick visualization.
|
|---|
| 467 | <P>
|
|---|
| 468 | Geant4 Visualization supports the following 3 kinds of culling:
|
|---|
| 469 | <UL>
|
|---|
| 470 | <LI>Culling of invisible physical volumes</LI>
|
|---|
| 471 | <LI>Culling of low density physical volumes.</LI>
|
|---|
| 472 | <LI>Culling of covered physical volumes by others</LI>
|
|---|
| 473 | </UL>
|
|---|
| 474 | In order that one or all types of the above culling are on, i.e., activated,
|
|---|
| 475 | the global culling flag should also be on.
|
|---|
| 476 | <P>
|
|---|
| 477 | Table 8.4.1 summarizes the default culling policies.
|
|---|
| 478 | <p>
|
|---|
| 479 | <CENTER><TABLE BORDER=2 cellpadding=8>
|
|---|
| 480 | <TR>
|
|---|
| 481 | <TD><B>Culling Type</B></TD>
|
|---|
| 482 | <TD><B>Default Value</B></TD>
|
|---|
| 483 | </TR>
|
|---|
| 484 | <TR>
|
|---|
| 485 | <TD>global</TD>
|
|---|
| 486 | <TD align=center>ON</TD>
|
|---|
| 487 | </TR>
|
|---|
| 488 | <TR>
|
|---|
| 489 | <TD>invisible</TD>
|
|---|
| 490 | <TD align=center>ON</TD>
|
|---|
| 491 | </TR>
|
|---|
| 492 | <TR>
|
|---|
| 493 | <TD>low density</TD>
|
|---|
| 494 | <TD align=center>OFF</TD>
|
|---|
| 495 | </TR>
|
|---|
| 496 | <TR>
|
|---|
| 497 | <TD>covered daughter</TD>
|
|---|
| 498 | <TD align=center>OFF</TD>
|
|---|
| 499 | </TR>
|
|---|
| 500 | <tr>
|
|---|
| 501 | <td align=center colspan=2>Table 8.4.1<BR>
|
|---|
| 502 | The default culling policies.
|
|---|
| 503 | </TABLE></CENTER>
|
|---|
| 504 | <p>
|
|---|
| 505 | The default threshold density of the low-density culling is 0.01 g/cm<sup>3</sup>.
|
|---|
| 506 | <P>
|
|---|
| 507 | The default culling policies can be modified with the following
|
|---|
| 508 | visualization commands.
|
|---|
| 509 | (Below the argument <tt>flag</tt> takes a value of <tt>true</tt>
|
|---|
| 510 | or <tt>false</tt>.)
|
|---|
| 511 | <PRE>
|
|---|
| 512 | # global
|
|---|
| 513 | /vis/viewer/set/culling global flag
|
|---|
| 514 |
|
|---|
| 515 | # invisible
|
|---|
| 516 | /vis/viewer/set/culling invisible flag
|
|---|
| 517 |
|
|---|
| 518 | # low density
|
|---|
| 519 | # "value" is a proper value of a treshold density
|
|---|
| 520 | # "unit" is either g/cm3, mg/cm3 or kg/m3
|
|---|
| 521 | /vis/viewer/set/culling density flag value unit
|
|---|
| 522 |
|
|---|
| 523 | # covered daughter
|
|---|
| 524 | /vis/viewer/set/culling coveredDaughters flag density
|
|---|
| 525 | </PRE>
|
|---|
| 526 | <p>
|
|---|
| 527 | The HepRepFile graphic system will, by default, include culled objects in the file so that they can
|
|---|
| 528 | still be made visible later from controls in the HepRep browser.
|
|---|
| 529 | If this behavior would cause files to be too large, you can instead choose to have culled objects be omitted from the
|
|---|
| 530 | HepRep file. See details in the HepRepFile Driver section of this user guide.
|
|---|
| 531 |
|
|---|
| 532 | <h4>8.4.15 Cut view</h4>
|
|---|
| 533 | <p>
|
|---|
| 534 |
|
|---|
| 535 | <h4>Sectioning</h4>
|
|---|
| 536 |
|
|---|
| 537 | "Sectioning" means to make a thin slice of a 3D scene around a given plane.
|
|---|
| 538 | At present, this function is supported by the OpenGL drivers.
|
|---|
| 539 | The sectioning is realized by setting a sectioning plane before performing visualization.
|
|---|
| 540 | The sectioning plane can be set by the command,
|
|---|
| 541 | <PRE>
|
|---|
| 542 | /vis/viewer/set/sectionPlane on x y z units nx ny nz
|
|---|
| 543 | </PRE>
|
|---|
| 544 | where the vector (x,y,z) defines a point on the sectioning plane, and the
|
|---|
| 545 | vector (nx,ny,nz) defines the normal vector of the sectioning plane. For
|
|---|
| 546 | example, the following sets a sectioning plane to a yz plane at x = 2 cm:
|
|---|
| 547 | <PRE>
|
|---|
| 548 | Idle> /vis/viewer/set/sectionPlane on 2.0 0.0 0.0 cm 1.0 0.0 0.0
|
|---|
| 549 | </PRE>
|
|---|
| 550 | <p>
|
|---|
| 551 |
|
|---|
| 552 | <h4>Cutting away</h4>
|
|---|
| 553 |
|
|---|
| 554 | "Cutting away" means to remove a half space, defined with a plane, from a
|
|---|
| 555 | 3D scene.
|
|---|
| 556 |
|
|---|
| 557 | <ul>
|
|---|
| 558 |
|
|---|
| 559 | <li> Cutting away is supported by the DAWNFILE driver "off-line".
|
|---|
| 560 | Do the following:
|
|---|
| 561 | <ul>
|
|---|
| 562 | <li>Perform visualization with the DAWNFILE driver
|
|---|
| 563 | to generate a file <tt>g4.prim</tt>, describing the whole 3D scene.
|
|---|
| 564 | <li>Make the application "DAWNCUT" read the generated file
|
|---|
| 565 | to make a view of cutting away.
|
|---|
| 566 | </ul>
|
|---|
| 567 | See the following WWW page for details:
|
|---|
| 568 | <A HREF="http://geant4.kek.jp/GEANT4/vis/DAWN/About_DAWNCUT.html">
|
|---|
| 569 | http://geant4.kek.jp/GEANT4/vis/DAWN/About_DAWNCUT.html</A>.
|
|---|
| 570 | <p>
|
|---|
| 571 | <li> Alternatively, add up to three cutaway planes:
|
|---|
| 572 | <PRE>
|
|---|
| 573 | /vis/viewer/addCutawayPlane 0 0 0 m 1 0 0
|
|---|
| 574 | /vis/viewer/addCutawayPlane 0 0 0 m 0 1 0
|
|---|
| 575 | ...
|
|---|
| 576 | </PRE>
|
|---|
| 577 | and, for more that one plane, you can change the mode to
|
|---|
| 578 | <ul>
|
|---|
| 579 | <li> (a) "add" or, equivalently, "union" (default) or
|
|---|
| 580 | <li> (b) "multiply" or, equivalently, "intersection":
|
|---|
| 581 | </ul>
|
|---|
| 582 | <PRE>
|
|---|
| 583 | /vis/viewer/set/cutawayMode multiply
|
|---|
| 584 | </PRE>
|
|---|
| 585 | To de-activate:
|
|---|
| 586 | <PRE>
|
|---|
| 587 | /vis/viewer/clearCutawayPlanes
|
|---|
| 588 | </PRE>
|
|---|
| 589 | OpenGL supports this feature.
|
|---|
| 590 |
|
|---|
| 591 | </ul>
|
|---|
| 592 | <p>
|
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 | <BR>
|
|---|
| 596 |
|
|---|
| 597 |
|
|---|
| 598 | <h4>8.4.16 Tutorial macros </h4>
|
|---|
| 599 |
|
|---|
| 600 | The followings are tutorial macros in the directory
|
|---|
| 601 | <tt>examples/novice/N03/visTutor/</tt>:
|
|---|
| 602 |
|
|---|
| 603 | <UL>
|
|---|
| 604 | <LI> <A HREF="visTutor/exN03Vis0_mac.html">
|
|---|
| 605 | exN03Vis0.mac:</A><BR>
|
|---|
| 606 | A basic macro for visualization of detector geometry and events
|
|---|
| 607 | using OpenGL in Immediate mode and DAWN.
|
|---|
| 608 | <LI> <A HREF="visTutor/exN03Vis1_mac.html">
|
|---|
| 609 | exN03Vis1.mac:</A><BR>
|
|---|
| 610 | A basic macro for visualization of detector geometry
|
|---|
| 611 | using OpenGL in Stored mode and DAWN.
|
|---|
| 612 | <LI> <A HREF="./visTutor/exN03Vis2_mac.html">
|
|---|
| 613 | exN03Vis2.mac:</A><BR>
|
|---|
| 614 | A basic macro for visualization of detector geometry and events
|
|---|
| 615 | using OpenGL in Stored mode and DAWN.
|
|---|
| 616 | <LI> <A HREF="./visTutor/exN03Vis3_mac.html">
|
|---|
| 617 | exN03Vis3.mac:</A><BR>
|
|---|
| 618 | A basic macro for demonstrating various drawing styles
|
|---|
| 619 | using OpenGL in Immediate mode and DAWN.
|
|---|
| 620 | <LI> <A HREF="./visTutor/exN03Vis4_mac.html">
|
|---|
| 621 | exN03Vis4.mac:</A><BR>
|
|---|
| 622 | An example of visualizing specific logical volumes
|
|---|
| 623 | using OpenGL in Immediate mode and DAWN.
|
|---|
| 624 | <LI> <A HREF="./visTutor/exN03Vis5_mac.html">
|
|---|
| 625 | exN03Vis5.mac:</A><BR>
|
|---|
| 626 | A basic macro for visualization of detector geometry and events
|
|---|
| 627 | using OpenInventor on Unix.
|
|---|
| 628 | <LI> <A HREF="./visTutor/exN03Vis6_mac.html">
|
|---|
| 629 | exN03Vis6.mac:</A><BR>
|
|---|
| 630 | A basic macro for visualization of detector geometry and events
|
|---|
| 631 | using VRML.
|
|---|
| 632 | <LI> <A HREF="./visTutor/exN03Vis7_mac.html">
|
|---|
| 633 | exN03Vis7.mac:</A><BR>
|
|---|
| 634 | A macro to demonstrate "batch" visualization to generate
|
|---|
| 635 | PostScript files with the DAWNFILE driver
|
|---|
| 636 | <LI> <A HREF="./visTutor/exN03Vis8_mac.html">
|
|---|
| 637 | exN03Vis8.mac:</A><BR>
|
|---|
| 638 | A macro to demonstrate creation of a "multi-page"
|
|---|
| 639 | PostScript file with the DAWNFILE driver
|
|---|
| 640 | <LI> <A HREF="./visTutor/exN03Vis9_mac.html">
|
|---|
| 641 | exN03Vis9.mac:</A><BR>
|
|---|
| 642 | A basic macro for visualization of detector geometry and events
|
|---|
| 643 | using OpenGL for Windows.
|
|---|
| 644 | <LI> <A HREF="./visTutor/exN03Vis10_mac.html">
|
|---|
| 645 | exN03Vis10.mac:</A><BR>
|
|---|
| 646 | A basic macro for visualization of detector geometry and events
|
|---|
| 647 | using OpenInventor on Windows.
|
|---|
| 648 | <LI> <A HREF="./visTutor/exN03Vis11_mac.html">
|
|---|
| 649 | exN03Vis11.mac:</A><BR>
|
|---|
| 650 | A basic macro for visualization of detector geometry and events
|
|---|
| 651 | using OpenGL in Stored Motif mode and DAWN.
|
|---|
| 652 | <LI> <A HREF="./visTutor/exN03Vis12_mac.html">
|
|---|
| 653 | exN03Vis12.mac</A> and <A HREF="./visTutor/exN03Vis12_loop.html">
|
|---|
| 654 | exN03Vis12.loop:</A><BR>
|
|---|
| 655 | A basic macro for demonstrating time slicing.
|
|---|
| 656 | <LI> <A HREF="./visTutor/exN03Vis13_mac.html">
|
|---|
| 657 | exN03Vis13.mac</A> and <A HREF="./visTutor/exN03Vis13_loop.html">
|
|---|
| 658 | exN03Vis13.loop:</A><BR>
|
|---|
| 659 | Time development of an electrmagnetic shower.
|
|---|
| 660 | <LI> <A HREF="./visTutor/exN03Tree0_mac.html">
|
|---|
| 661 | exN03Tree0.mac:</A><BR>
|
|---|
| 662 | A macro to demonstrate ASCII tree.
|
|---|
| 663 | <LI> <A HREF="./visTutor/exN03Tree1_mac.html">
|
|---|
| 664 | exN03Tree1.mac:</A><BR>
|
|---|
| 665 | A macro to demonstrate GAG tree.
|
|---|
| 666 | </UL>
|
|---|
| 667 |
|
|---|
| 668 | <HR>
|
|---|
| 669 | <A HREF="compiledcontrol.html">Next section</A><BR>
|
|---|
| 670 | <A HREF="index.html">Back to contents</A>
|
|---|
| 671 | </BODY>
|
|---|
| 672 | </HTML>
|
|---|
| 673 |
|
|---|