source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Visualization/enhanceddrawing.xml @ 1211

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

CVS update

File size: 16.3 KB
Line 
1<!-- ******************************************************** -->
2<!--                                                          -->
3<!--  [History]                                               -->
4<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
5<!--                                                          -->
6<!-- ******************************************************** -->
7
8
9<!-- ******************* Section (Level#1) ****************** -->
10<sect1 id="sect.VisEnhTrj">
11<title>
12Enhanced Trajectory Drawing
13</title>
14
15<!-- ******************* Section (Level#2) ****************** -->
16<sect2 id="sect.VisEnhTrj.DflCnfg">
17<title>
18Default Configuration
19</title>
20
21<para>
22Trajectory drawing styles are specified through trajectory drawing
23models. Each drawing model has a default configuration provided
24through a G4VisTrajContext object. The default context settings are
25shown below.
26
27<informaltable>
28  <tgroup cols="2">
29    <tbody>
30    <row>
31      <entry>
32        <emphasis role="bold">Property</emphasis>
33      </entry>
34      <entry>
35        <emphasis role="bold">Default Setting</emphasis>
36      </entry>
37    </row>
38    <row>
39      <entry>
40        Line colour
41      </entry>
42      <entry>
43        grey
44      </entry>
45    </row>
46    <row>
47      <entry>
48        Line visibility
49      </entry>
50      <entry>
51        true
52      </entry>
53    </row>
54    <row>
55      <entry>
56        Draw line
57      </entry>
58      <entry>
59        true
60      </entry>
61    </row>
62    <row>
63      <entry>
64        Draw auxiliary points
65      </entry>
66      <entry>
67        false
68      </entry>
69    </row>
70    <row>
71      <entry>
72        Auxiliary point type
73      </entry>
74      <entry>
75        squares
76      </entry>
77    </row>
78    <row>
79      <entry>
80        Auxiliary point size
81      </entry>
82      <entry>
83        2 pixels or mm*
84      </entry>
85    </row>
86    <row>
87      <entry>
88        Auxiliary point size type
89      </entry>
90      <entry>
91        screen
92      </entry>
93    </row>
94    <row>
95      <entry>
96        Auxiliary point fill style
97      </entry>
98      <entry>
99        filled
100      </entry>
101    </row>
102    <row>
103      <entry>
104        Auxiliary point colour
105      </entry>
106      <entry>
107        magenta
108      </entry>
109    </row>
110    <row>
111      <entry>
112        Auxiliary point visibility
113      </entry>
114      <entry>
115        true
116      </entry>
117    </row>
118    <row>
119      <entry>
120        Draw step point
121      </entry>
122      <entry>
123        false
124      </entry>
125    </row>
126    <row>
127      <entry>
128        Step point type
129      </entry>
130      <entry>
131        circles
132      </entry>
133    </row>
134    <row>
135      <entry>
136        Step point size
137      </entry>
138      <entry>
139        2 pixels or mm*
140      </entry>
141    </row>
142    <row>
143      <entry>
144        Step point size type
145      </entry>
146      <entry>
147        screen
148      </entry>
149    </row>
150    <row>
151      <entry>
152        Step point fill style
153      </entry>
154      <entry>
155        filled
156      </entry>
157    </row>
158    <row>
159      <entry>
160        Step point colour
161      </entry>
162      <entry>
163        yellow
164      </entry>
165    </row>
166    <row>
167      <entry>
168        Step point visibility
169      </entry>
170      <entry>
171        true
172      </entry>
173    </row>
174    <row>
175      <entry>
176        Time slice interval
177      </entry>
178      <entry>
179        0
180      </entry>
181    </row>
182    </tbody>
183  </tgroup>
184</informaltable>
185</para>
186
187<para>
188* Depending on size type.  If size type == screen, pixels are assumed and no unit need be supplied.  If size type == world, a unit must be supplied, e.g., 10 cm.
189</para>
190
191<para>
192Points to note:
193
194<itemizedlist spacing="compact">
195  <listitem><para>
196    The context approach is intended to replace the configuration
197    through the imode parameter. The use of imode is depreciated and
198    will be removed in Geant4 v10.0.
199  </para></listitem>
200  <listitem><para>
201    Different visualisation drivers handle trajectory configuration
202    in different ways, so trajectories may not necessarily get
203    displayed as you have configured them.
204  </para></listitem>
205</itemizedlist>
206</para>
207
208</sect2>
209
210
211<!-- ******************* Section (Level#2) ****************** -->
212<sect2 id="sect.VisEnhTrj.DrdMdl">
213<title>
214Trajectory Drawing Models
215</title>
216
217<para>
218A trajectory drawing model can override the default context
219according to the properties of a given trajectory. The following
220models are supplied with the Geant4 distribution:
221
222<itemizedlist spacing="compact">
223  <listitem><para>
224    G4TrajectoryGenericDrawer (generic)
225  </para></listitem>
226  <listitem><para>
227    G4TrajectoryDrawByCharge (drawByCharge)
228  </para></listitem>
229  <listitem><para>
230    G4TrajectoryDrawByParticleID (drawByParticleID)
231  </para></listitem>
232  <listitem><para>
233    G4TrajectoryDrawByOriginVolume (drawByOriginVolume)
234  </para></listitem>
235  <listitem><para>
236    G4TrajectoryDrawByAttribute (drawByAttribute)
237  </para></listitem>
238</itemizedlist>
239</para>
240
241<para>
242Both the context and model properties can be configured by the
243user. The models are described briefly below, followed by some
244example configuration commands.
245</para>
246
247<!-- ******* Bridgehead ******* -->
248<bridgehead renderas='sect4'>
249G4TrajectoryGenericDrawer
250</bridgehead>
251
252<para>
253This model simply draws all trajectories in the same style, with
254the properties provided by the context.
255</para>
256
257<!-- ******* Bridgehead ******* -->
258<bridgehead renderas='sect4'>
259G4TrajectoryDrawByCharge
260</bridgehead>
261
262<para>
263This is the default model - if no model is specified by the user,
264this model will be constructed automatically. The trajectory lines
265are coloured according to charge, with all other configuration
266parameters provided by the default context. The default colouring
267scheme is shown below.
268
269<informalexample>
270<programlisting>
271        Charge          Colour 
272        ----------------------
273        1               Blue
274        -1              Red
275        0               Green
276</programlisting>
277</informalexample>
278</para>
279
280<!-- ******* Bridgehead ******* -->
281<bridgehead renderas='sect4'>
282G4TrajectoryDrawByParticleID
283</bridgehead>
284
285<para>
286This model colours trajectory lines according to particle type. All
287other configuration parameters are provided by the default context.
288By default, all trajectories are coloured grey. Chosen particle
289types can be highlighted with specified colours.
290</para>
291
292<!-- ******* Bridgehead ******* -->
293<bridgehead renderas='sect4'>
294G4TrajectoryDrawByOriginVolume
295</bridgehead>
296
297<para>
298This model colours trajectory lines according to the trajectories
299originating volume name. The volume can be either a logical or
300physical volume. Physical volume takes precedence over logical
301volume. All trajectories are coloured grey by default.
302</para>
303
304<!-- ******* Bridgehead ******* -->
305<bridgehead renderas='sect4'>
306G4TrajectoryDrawByAttribute
307</bridgehead>
308
309<para>
310This model draws trajectories based on the HepRep style attributes
311associated with trajectories. Each attribute drawer can be configured
312with interval and/or single value data. A new context object is
313created for each interval/single value. This makes it possible to
314have different step point markers etc, as well as line colour for
315trajectory attributes falling into different intervals, or matching
316single values. The single value data should override the interval data,
317allowing specific values to be highlighted. Units should be specified
318on the command line if the attribute unit is specified either as a
319G4BestUnit or if the unit is part of the value string.
320</para>
321
322</sect2>
323
324
325<!-- ******************* Section (Level#2) ****************** -->
326<sect2 id="sect.VisEnhTrj.CntlComm">
327<title>
328Controlling from Commands
329</title>
330
331<para>
332Multiple trajectory models can be created and configured using
333commands in the "<literal>/vis/modeling/trajectories/</literal>" directory.
334It is then possible to list available models and select one to be
335current.
336</para>
337
338<para>
339Model configuration commands are generated dynamically when a
340model is instantiated. These commands apply directly to that
341instance. This makes it possible to have multiple instances of the
342drawByCharge model for example, each independently configurable
343through it's own set of commands.
344</para>
345
346<para>
347See the interactive help for more information on the available
348commands.
349</para>
350
351<!-- ******************* Section (Level#3) ****************** -->
352<sect3 id="sect.VisEnhTrj.CntlComm.ExpComm">
353<title>
354Example commands
355</title>
356
357<para>
358#Create a generic model named generic-0 by default
359
360<informalexample>
361<programlisting>
362/vis/modeling/trajectories/create/generic
363</programlisting>
364</informalexample>
365</para>
366
367<para>
368#Configure context to colour all trajectories red
369
370<informalexample>
371<programlisting>
372/vis/modeling/trajectories/generic-0/default/setLineColour red
373</programlisting>
374</informalexample>
375</para>
376
377<para>
378#Create a drawByCharge model named drawCharge-0 by default
379(Subsequent models will be named drawByCharge-1, drawByCharge-2,
380etc.)
381
382<informalexample>
383<programlisting>
384/vis/modeling/trajectories/create/drawByCharge
385</programlisting>
386</informalexample>
387</para>
388
389<para>
390#Create a drawByCharge model named testChargeModel
391
392<informalexample>
393<programlisting>
394/vis/modeling/trajectories/create/drawByCharge testChargeModel
395</programlisting>
396</informalexample>
397</para>
398
399<para>
400#Configure drawByCharge-0 model
401
402<informalexample>
403<programlisting>
404/vis/modeling/trajectories/drawByCharge-0/set 1 red
405/vis/modeling/trajectories/drawByCharge-0/set -1 red
406/vis/modeling/trajectories/drawByCharge-0/set 0 white
407</programlisting>
408</informalexample>
409</para>
410
411<para>
412#Configure testCharge model through G4Colour components
413
414<informalexample>
415<programlisting>
416/vis/modeling/trajectories/testChargeModel/setRGBA 1 0 1 1 1
417/vis/modeling/trajectories/testChargeModel/setRGBA -1 0.5 0.5 0.5 1
418/vis/modeling/trajectories/testChargeModel/setRGBA 0 1 1 0 1
419</programlisting>
420</informalexample>
421</para>
422
423<para>
424#Create a drawByParticleID model named drawByParticleID-0
425
426<informalexample>
427<programlisting>
428/vis/modeling/trajectories/create/drawByParticleID
429</programlisting>
430</informalexample>
431</para>
432
433<para>
434#Configure drawByParticleID-0 model
435
436<informalexample>
437<programlisting>
438/vis/modeling/trajectories/drawByParticleID-0/set gamma red
439/vis/modeling/trajectories/drawByParticleID-0/setRGBA e+ 1 0 1 1
440</programlisting>
441</informalexample>
442</para>
443
444<para>
445#List available models
446
447<informalexample>
448<programlisting>
449/vis/modeling/trajectories/list
450</programlisting>
451</informalexample>
452</para>
453
454<para>
455#select drawByParticleID-0 to be current
456
457<informalexample>
458<programlisting>
459/vis/modeling/trajectories/select drawByParticleID-0
460</programlisting>
461</informalexample>
462</para>
463
464<para>
465#Create a drawByAttribute model named drawByAttribute-0
466
467<informalexample>
468<programlisting>
469/vis/modeling/trajectories/create/drawByAttribute
470</programlisting>
471</informalexample>
472</para>
473
474<para>
475#Configure drawByAttribute-0 model
476
477<informalexample>
478<programlisting>
479/vis/modeling/trajectories/drawByAttribute-0/verbose true
480</programlisting>
481</informalexample>
482</para>
483
484<para>
485#Select attribute "CPN"
486
487<informalexample>
488<programlisting>
489/vis/modeling/trajectories/drawByAttribute-0/setAttribute CPN
490</programlisting>
491</informalexample>
492</para>
493
494<para>
495#Configure single value data
496
497<informalexample>
498<programlisting>
499/vis/modeling/trajectories/drawByAttribute-0/addValue brem_key  eBrem
500/vis/modeling/trajectories/drawByAttribute-0/addValue annihil_key annihil
501/vis/modeling/trajectories/drawByAttribute-0/addValue decay_key Decay
502/vis/modeling/trajectories/drawByAttribute-0/addValue muIon_key muIoni
503/vis/modeling/trajectories/drawByAttribute-0/addValue eIon_key  eIoni
504
505/vis/modeling/trajectories/drawByAttribute-0/brem_key/setLineColour     red
506/vis/modeling/trajectories/drawByAttribute-0/annihil_key/setLineColour  green
507/vis/modeling/trajectories/drawByAttribute-0/decay_key/setLineColour    cyan
508/vis/modeling/trajectories/drawByAttribute-0/eIon_key/setLineColour     yellow
509/vis/modeling/trajectories/drawByAttribute-0/muIon_key/setLineColour magenta
510</programlisting>
511</informalexample>
512</para>
513
514<para>
515#Create a drawByAttribute model named drawByAttribute-1
516
517<informalexample>
518<programlisting>
519/vis/modeling/trajectories/create/drawByAttribute
520</programlisting>
521</informalexample>
522</para>
523
524<para>
525#Select "IMag" attribute
526
527<informalexample>
528<programlisting>
529/vis/modeling/trajectories/drawByAttribute-1/setAttribute IMag
530</programlisting>
531</informalexample>
532</para>
533
534<para>
535#Configure interval data
536
537<informalexample>
538<programlisting>
539/vis/modeling/trajectories/drawByAttribute-1/addInterval interval1 0.0 keV 2.5MeV
540/vis/modeling/trajectories/drawByAttribute-1/addInterval interval2 2.5 MeV 5 MeV
541/vis/modeling/trajectories/drawByAttribute-1/addInterval interval3 5 MeV 7.5 MeV
542/vis/modeling/trajectories/drawByAttribute-1/addInterval interval4 7.5 MeV 10 MeV
543/vis/modeling/trajectories/drawByAttribute-1/addInterval interval5 10 MeV 12.5 MeV
544/vis/modeling/trajectories/drawByAttribute-1/addInterval interval6 12.5 MeV 10000 MeV
545
546/vis/modeling/trajectories/drawByAttribute-1/interval1/setLineColourRGBA 0.8 0 0.8 1
547/vis/modeling/trajectories/drawByAttribute-1/interval2/setLineColourRGBA 0.23 0.41 1 1
548/vis/modeling/trajectories/drawByAttribute-1/interval3/setLineColourRGBA 0 1 0 1
549/vis/modeling/trajectories/drawByAttribute-1/interval4/setLineColourRGBA 1 1 0 1
550/vis/modeling/trajectories/drawByAttribute-1/interval5/setLineColourRGBA 1 0.3 0 1
551/vis/modeling/trajectories/drawByAttribute-1/interval6/setLineColourRGBA 1 0 0 1
552</programlisting>
553</informalexample>
554</para>
555
556</sect3>
557</sect2>
558
559
560<!-- ******************* Section (Level#2) ****************** -->
561<sect2 id="sect.VisEnhTrj.CntlCmpl">
562<title>
563Controlling from Compiled Code
564</title>
565
566<para>
567It is possible to use the enhanced trajectory drawing functionality
568in compiled code as well as from commands. Multiple trajectory
569models can be instantiated, configured and registered with
570G4VisManager. Only one model may be current. For example:
571
572<informalexample>
573<programlisting>
574  G4VisManager* visManager = new G4VisExecutive;
575  visManager-&gt;Initialize();
576
577  G4TrajectoryDrawByParticleID* model = new G4TrajectoryDrawByParticleID;
578  G4TrajectoryDrawByParticleID* model2 = new G4TrajectoryDrawByParticleID("test");
579
580  model-&gt;SetDefault("cyan");
581  model-&gt;Set("gamma", "green");
582  model-&gt;Set("e+", "magenta");
583  model-&gt;Set("e-", G4Colour(0.3, 0.3, 0.3));
584
585  visManager-&gt;RegisterModel(model);
586  visManager-&gt;RegisterModel(model2);
587
588  visManager-&gt;SelectTrajectoryModel(model-&gt;Name());
589</programlisting>
590</informalexample>
591</para>
592
593</sect2>
594
595
596<!-- ******************* Section (Level#2) ****************** -->
597<sect2 id="sect.VisEnhTrj.DrwByTime">
598<title>
599Drawing by time
600</title>
601
602<para>
603To draw by time, you need to use G4RichTrajectory, for example:
604
605<informalexample>
606<programlisting>
607/vis/scene/add/trajectories rich
608</programlisting>
609</informalexample>
610
611or
612
613<informalexample>
614<programlisting>
615/vis/scene/add/trajectories rich smooth
616</programlisting>
617</informalexample>
618</para>
619
620<para>
621When you run, you need to create a trajectory model and set the
622time slice interval (remembering that paticles are often
623relativistic and travel 30 cm/ns):
624
625<informalexample>
626<programlisting>
627/vis/modeling/trajectories/create/drawByCharge
628/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
629/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 5
630/vis/modeling/trajectories/drawByCharge-0/default/setDrawAuxPts true
631/vis/modeling/trajectories/drawByCharge-0/default/setAuxPtsSize 5
632/vis/modeling/trajectories/drawByCharge-0/default/setTimeSliceInterval 0.1 ns
633/vis/modeling/trajectories/list
634</programlisting>
635</informalexample>
636
637and use a graphics driver that can display by time:
638
639<informalexample>
640<programlisting>
641/vis/open OGLSX
642/vis/drawVolume
643/vis/scene/add/trajectories rich
644/vis/ogl/set/startTime 0.5 ns
645/vis/ogl/set/endTime 0.8 ns
646/run/beamOn
647/vis/viewer/refresh
648</programlisting>
649</informalexample>
650</para>
651
652<para>
653A good way to see the particles moving through the detector is:
654
655<informalexample>
656<programlisting>
657/vis/ogl/set/fade 1
658/vis/ogl/set/displayHeadTime true
659/control/alias timeRange 1
660/control/loop movie.loop -{timeRange} 40 0.1
661</programlisting>
662</informalexample>
663
664where <literal>fade</literal> gives a vapour-trail effect,
665<literal>displayHeadTime</literal> displays the time of the leading edge as
6662D text, and <literal>movie.loop</literal> is a macro file:
667
668<informalexample>
669<programlisting>
670/vis/ogl/set/startTime {startTime} ns {timeRange} ns
671</programlisting>
672</informalexample>
673</para>
674
675<para>
676From there, it's straightforward to <xref linkend="sect.MkMovie" />
677make a movie.
678</para>
679
680
681</sect2>
682</sect1>
683
Note: See TracBrowser for help on using the repository browser.