1 | <!-- ******************************************************** --> |
---|
2 | <!-- --> |
---|
3 | <!-- [History] --> |
---|
4 | <!-- Proof read by: Joe Chuma, 5-Jul-1999 --> |
---|
5 | <!-- Changed by: Katsuya Dosanjh, 15-Jul-2000 --> |
---|
6 | <!-- Changed by: Dennis Wright, 27-Nov-2001 --> |
---|
7 | <!-- Changed by: Satoshi Tanaka, 8-Dec-2002 --> |
---|
8 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
9 | <!-- --> |
---|
10 | <!-- ******************************************************** --> |
---|
11 | |
---|
12 | |
---|
13 | <!-- ******************* Section (Level#1) ****************** --> |
---|
14 | <sect1 id="sect.VisAtt"> |
---|
15 | <title> |
---|
16 | Visualization Attributes |
---|
17 | </title> |
---|
18 | |
---|
19 | <para> |
---|
20 | Visualization attributes are extra pieces of information associated |
---|
21 | with the visualizable objects. This information is necessary only |
---|
22 | for visualization, and is not included in geometrical information |
---|
23 | such as shapes, position, and orientation. Typical examples of |
---|
24 | visualization attributes are Color, Visible/Invisible, |
---|
25 | Wireframe/Solid. For example, in visualizing a box, the |
---|
26 | Visualization Manager must know its colour. If an object to be |
---|
27 | visualized has not been assigned a set of visualization attributes, |
---|
28 | then an appropriate default set is used automatically. |
---|
29 | </para> |
---|
30 | |
---|
31 | <para> |
---|
32 | A set of visualization attributes is held by an instance of |
---|
33 | class <emphasis>G4VisAttributes</emphasis> defined in the |
---|
34 | <literal>graphics_reps</literal> category. In the following, we |
---|
35 | explain the main fields of the <emphasis>G4VisAttributes</emphasis> |
---|
36 | one by one. |
---|
37 | </para> |
---|
38 | |
---|
39 | <!-- ******************* Section (Level#2) ****************** --> |
---|
40 | <sect2 id="sect.VisAtt.Vsblty"> |
---|
41 | <title> |
---|
42 | Visibility |
---|
43 | </title> |
---|
44 | |
---|
45 | <para> |
---|
46 | Visibility is a boolean flag to control the visibility of objects |
---|
47 | that are passed to the Visualization Manager for visualization. |
---|
48 | Visibility is set with the following access function: |
---|
49 | |
---|
50 | <informalexample> |
---|
51 | <programlisting> |
---|
52 | void G4VisAttributes::SetVisibility (G4bool visibility); |
---|
53 | </programlisting> |
---|
54 | </informalexample> |
---|
55 | </para> |
---|
56 | |
---|
57 | <para> |
---|
58 | If you give <literal>false</literal> to the argument, and if culling is |
---|
59 | activated (see below), visualization is skipped for objects for |
---|
60 | which this set of visualization attributes is assigned. The default |
---|
61 | value of visibility is <literal>true</literal>. |
---|
62 | </para> |
---|
63 | |
---|
64 | <para> |
---|
65 | Note that whether an object is visible or not is also affected |
---|
66 | by the current culling policy, which can be tuned with |
---|
67 | visualization commands. |
---|
68 | </para> |
---|
69 | |
---|
70 | <para> |
---|
71 | By default the following public static function is defined: |
---|
72 | |
---|
73 | <informalexample> |
---|
74 | <programlisting> |
---|
75 | static const G4VisAttributes& GetInvisible(); |
---|
76 | </programlisting> |
---|
77 | </informalexample> |
---|
78 | |
---|
79 | which returns a reference to a const object in which visibility is |
---|
80 | set to <literal>false</literal>. It can be used as follows: |
---|
81 | |
---|
82 | <informalexample> |
---|
83 | <programlisting> |
---|
84 | experimentalHall_logical -> SetVisAttributes (G4VisAttributes::GetInvisible()); |
---|
85 | </programlisting> |
---|
86 | </informalexample> |
---|
87 | </para> |
---|
88 | |
---|
89 | <para> |
---|
90 | Direct access to the public static const data member |
---|
91 | <literal>G4VisAttributes::Invisible</literal> is also possible but deprecated |
---|
92 | on account of initialisation issues with dynamic libraries. |
---|
93 | </para> |
---|
94 | |
---|
95 | </sect2> |
---|
96 | |
---|
97 | |
---|
98 | <!-- ******************* Section (Level#2) ****************** --> |
---|
99 | <sect2 id="sect.VisAtt.Colr"> |
---|
100 | <title> |
---|
101 | Colour |
---|
102 | </title> |
---|
103 | |
---|
104 | |
---|
105 | <!-- ******************* Section (Level#3) ****************** --> |
---|
106 | <sect3 id="sect.VisAtt.Colr.Cnstr"> |
---|
107 | <title> |
---|
108 | Construction |
---|
109 | </title> |
---|
110 | |
---|
111 | <para> |
---|
112 | Class <emphasis>G4Colour</emphasis> (an equivalent class name, |
---|
113 | <emphasis>G4Color</emphasis>, is also available) has 4 fields, |
---|
114 | which represent the RGBA (red, green, |
---|
115 | blue, and alpha) components of colour. Each component takes a value |
---|
116 | between 0 and 1. If an irrelevant value, i.e., a value less than 0 |
---|
117 | or greater than 1, is given as an argument of the constructor, such |
---|
118 | a value is automatically clipped to 0 or 1. Alpha is opacity, which |
---|
119 | is not used at present. You can use its default value <literal>1</literal>, |
---|
120 | which means "opaque" in instantiation of <emphasis>G4Colour</emphasis>. |
---|
121 | </para> |
---|
122 | |
---|
123 | <para> |
---|
124 | A <emphasis>G4Colour</emphasis> object is instantiated by giving red, green, |
---|
125 | and blue components to its constructor, i.e., |
---|
126 | |
---|
127 | <informalexample> |
---|
128 | <programlisting> |
---|
129 | G4Colour::G4Colour ( G4double r = 1.0, |
---|
130 | G4double g = 1.0, |
---|
131 | G4double b = 1.0, |
---|
132 | G4double a = 1.0); |
---|
133 | // 0<=red, green, blue <= 1.0 |
---|
134 | </programlisting> |
---|
135 | </informalexample> |
---|
136 | </para> |
---|
137 | |
---|
138 | <para> |
---|
139 | The default value of each component is 1.0. That is to say, the |
---|
140 | default colour is "white" (opaque). |
---|
141 | </para> |
---|
142 | |
---|
143 | <para> |
---|
144 | For example, colours which are often used can be instantiated as |
---|
145 | follows: |
---|
146 | |
---|
147 | <informalexample> |
---|
148 | <programlisting> |
---|
149 | G4Colour white () ; // <emphasis role="color_white">white</emphasis> |
---|
150 | G4Colour white (1.0, 1.0, 1.0) ; // <emphasis role="color_white">white</emphasis> |
---|
151 | G4Colour gray (0.5, 0.5, 0.5) ; // <emphasis role="color_gray">gray</emphasis> |
---|
152 | G4Colour black (0.0, 0.0, 0.0) ; // <emphasis role="color_black">black</emphasis> |
---|
153 | G4Colour red (1.0, 0.0, 0.0) ; // <emphasis role="color_red">red</emphasis> |
---|
154 | G4Colour green (0.0, 1.0, 0.0) ; // <emphasis role="color_green">green</emphasis> |
---|
155 | G4Colour blue (0.0, 0.0, 1.0) ; // <emphasis role="color_blue">blue</emphasis> |
---|
156 | G4Colour cyan (0.0, 1.0, 1.0) ; // <emphasis role="color_cyan">cyan</emphasis> |
---|
157 | G4Colour magenta (1.0, 0.0, 1.0) ; // <emphasis role="color_magenta">magenta</emphasis> |
---|
158 | G4Colour yellow (1.0, 1.0, 0.0) ; // <emphasis role="color_yellow">yellow</emphasis> |
---|
159 | </programlisting> |
---|
160 | </informalexample> |
---|
161 | </para> |
---|
162 | |
---|
163 | <para> |
---|
164 | It is also possible to instantiate common colours through static |
---|
165 | public data member functions: |
---|
166 | |
---|
167 | <informalexample> |
---|
168 | <programlisting> |
---|
169 | static const G4Colour& White (); |
---|
170 | static const G4Colour& Gray (); |
---|
171 | static const G4Colour& Grey (); |
---|
172 | static const G4Colour& Black (); |
---|
173 | static const G4Colour& Red (); |
---|
174 | static const G4Colour& Green (); |
---|
175 | static const G4Colour& Blue (); |
---|
176 | static const G4Colour& Cyan (); |
---|
177 | static const G4Colour& Magenta (); |
---|
178 | static const G4Colour& Yellow (); |
---|
179 | </programlisting> |
---|
180 | </informalexample> |
---|
181 | </para> |
---|
182 | |
---|
183 | <para> |
---|
184 | For example, a local <emphasis>G4Colour</emphasis> could be constructed |
---|
185 | as: |
---|
186 | |
---|
187 | <informalexample> |
---|
188 | <programlisting> |
---|
189 | G4Colour myRed(G4Colour::Red()); |
---|
190 | </programlisting> |
---|
191 | </informalexample> |
---|
192 | </para> |
---|
193 | |
---|
194 | <para> |
---|
195 | After instantiation of a <emphasis>G4Colour</emphasis> object, you can access |
---|
196 | to its components with the following access functions: |
---|
197 | |
---|
198 | <informalexample> |
---|
199 | <programlisting> |
---|
200 | G4double G4Colour::GetRed () const ; // Get the red component. |
---|
201 | G4double G4Colour::GetGreen () const ; // Get the green component. |
---|
202 | G4double G4Colour::GetBlue () const ; // Get the blue component. |
---|
203 | </programlisting> |
---|
204 | </informalexample> |
---|
205 | </para> |
---|
206 | |
---|
207 | </sect3> |
---|
208 | |
---|
209 | <!-- ******************* Section (Level#3) ****************** --> |
---|
210 | <sect3 id="sect.VisAtt.Colr.ColrMap"> |
---|
211 | <title> |
---|
212 | Colour Map |
---|
213 | </title> |
---|
214 | |
---|
215 | <para> |
---|
216 | <emphasis>G4Colour</emphasis> also provides a static colour map, giving access to |
---|
217 | predefined <emphasis>G4Colour</emphasis>'s through a |
---|
218 | <emphasis>G4String</emphasis> |
---|
219 | key. The default mapping is: |
---|
220 | </para><para> |
---|
221 | |
---|
222 | <informalexample> |
---|
223 | <programlisting> |
---|
224 | G4String G4Colour |
---|
225 | --------------------------------------- |
---|
226 | white G4Colour::White () |
---|
227 | gray G4Colour::Gray () |
---|
228 | grey G4Colour::Grey () |
---|
229 | black G4Colour::Black () |
---|
230 | red G4Colour::Red () |
---|
231 | green G4Colour::Green () |
---|
232 | blue G4Colour::Blue () |
---|
233 | cyan G4Colour::Cyan () |
---|
234 | magenta G4Colour::Magenta () |
---|
235 | yellow G4Colour::Yellow () |
---|
236 | </programlisting> |
---|
237 | </informalexample> |
---|
238 | </para> |
---|
239 | |
---|
240 | <para> |
---|
241 | Colours can be retrieved through the GetColour method: |
---|
242 | |
---|
243 | <informalexample> |
---|
244 | <programlisting> |
---|
245 | bool G4Colour::GetColour(const G4String& key, G4Colour& result) |
---|
246 | </programlisting> |
---|
247 | </informalexample> |
---|
248 | </para> |
---|
249 | |
---|
250 | <para> |
---|
251 | For example: |
---|
252 | |
---|
253 | <informalexample> |
---|
254 | <programlisting> |
---|
255 | G4Colour myColour(G4Colour::Black()); |
---|
256 | if (G4Colour::GetColour("red", myColour)) { |
---|
257 | // Successfully retrieved colour "red". myColour is now red |
---|
258 | } |
---|
259 | else { |
---|
260 | // Colour did not exist in map. myColour is still black |
---|
261 | } |
---|
262 | </programlisting> |
---|
263 | </informalexample> |
---|
264 | </para> |
---|
265 | |
---|
266 | <para> |
---|
267 | If the key is not registered in the colour map, a warning |
---|
268 | message is printed and the input colour is not changed. The colour |
---|
269 | map is case insensitive. |
---|
270 | </para> |
---|
271 | |
---|
272 | <para> |
---|
273 | It is also possible to load user defined <emphasis>G4Colour</emphasis>'s into |
---|
274 | the map through the public AddToMap method. For example: |
---|
275 | |
---|
276 | <informalexample> |
---|
277 | <programlisting> |
---|
278 | G4Colour myColour(0.2, 0.2, 0.2, 1); |
---|
279 | G4Colour::AddToMap("custom", myColour); |
---|
280 | </programlisting> |
---|
281 | </informalexample> |
---|
282 | </para> |
---|
283 | |
---|
284 | <para> |
---|
285 | This loads a user defined <emphasis>G4Colour</emphasis> with key "custom" into |
---|
286 | the colour map. |
---|
287 | </para> |
---|
288 | |
---|
289 | </sect3> |
---|
290 | |
---|
291 | <!-- ******************* Section (Level#3) ****************** --> |
---|
292 | <sect3 id="sect.VisAtt.Colr.G4VisAtt"> |
---|
293 | <title> |
---|
294 | Colour and G4VisAttributes |
---|
295 | </title> |
---|
296 | |
---|
297 | <para> |
---|
298 | Class <emphasis>G4VisAttributes</emphasis> holds its colour entry as an object of |
---|
299 | class <emphasis>G4Colour</emphasis>. A <emphasis>G4Colour</emphasis> object is |
---|
300 | passed to a <emphasis>G4VisAttributes</emphasis> object with the following |
---|
301 | access |
---|
302 | functions: |
---|
303 | |
---|
304 | <informalexample> |
---|
305 | <programlisting> |
---|
306 | //----- Set functions of G4VisAttributes. |
---|
307 | void G4VisAttributes::SetColour (const G4Colour& colour); |
---|
308 | void G4VisAttributes::SetColor (const G4Color& color ); |
---|
309 | </programlisting> |
---|
310 | </informalexample> |
---|
311 | </para> |
---|
312 | |
---|
313 | <para> |
---|
314 | We can also set RGBA components directly: |
---|
315 | |
---|
316 | <informalexample> |
---|
317 | <programlisting> |
---|
318 | //----- Set functions of G4VisAttributes |
---|
319 | void G4VisAttributes::SetColour ( G4double red , |
---|
320 | G4double green , |
---|
321 | G4double blue , |
---|
322 | G4double alpha = 1.0); |
---|
323 | |
---|
324 | void G4VisAttributes::SetColor ( G4double red , |
---|
325 | G4double green , |
---|
326 | G4double blue , |
---|
327 | G4double alpha = 1.); |
---|
328 | </programlisting> |
---|
329 | </informalexample> |
---|
330 | </para> |
---|
331 | |
---|
332 | <para> |
---|
333 | The following constructor with <emphasis>G4Colour</emphasis> as its argument is |
---|
334 | also supported: |
---|
335 | |
---|
336 | <informalexample> |
---|
337 | <programlisting> |
---|
338 | //----- Constructor of G4VisAttributes |
---|
339 | G4VisAttributes::G4VisAttributes (const G4Colour& colour); |
---|
340 | </programlisting> |
---|
341 | </informalexample> |
---|
342 | </para> |
---|
343 | |
---|
344 | <para> |
---|
345 | Note that colour assigned to a <emphasis>G4VisAttributes</emphasis> object is |
---|
346 | not always the colour that ultimately appears in the visualization. |
---|
347 | The ultimate appearance may be affected by shading and lighting |
---|
348 | models applied in the selected visualization driver or stand-alone |
---|
349 | graphics system. |
---|
350 | </para> |
---|
351 | |
---|
352 | </sect3> |
---|
353 | </sect2> |
---|
354 | |
---|
355 | |
---|
356 | <!-- ******************* Section (Level#2) ****************** --> |
---|
357 | <sect2 id="sect.VisAtt.FrcAtt"> |
---|
358 | <title> |
---|
359 | Forcing attributes |
---|
360 | </title> |
---|
361 | |
---|
362 | <para> |
---|
363 | As you will see later, you can select a "drawing style" from |
---|
364 | various options. For example, you can select your detector |
---|
365 | components to be visualized in "wireframe" or with "surfaces". In |
---|
366 | the former, only the edges of your detector are drawn and so the |
---|
367 | detector looks transparent. In the latter, your detector looks |
---|
368 | opaque with shading effects. |
---|
369 | </para> |
---|
370 | |
---|
371 | <para> |
---|
372 | The forced wireframe and forced solid styles make it possible to |
---|
373 | mix the wireframe and surface visualization (if your selected |
---|
374 | graphics system supports such visualization). For example, you can |
---|
375 | make only the outer wall of your detector "wired" (transparent) and |
---|
376 | can see inside in detail. |
---|
377 | </para> |
---|
378 | |
---|
379 | <para> |
---|
380 | Forced wireframe style is set with the following access |
---|
381 | function: |
---|
382 | |
---|
383 | <informalexample> |
---|
384 | <programlisting> |
---|
385 | void G4VisAttributes::SetForceWireframe (G4bool force); |
---|
386 | </programlisting> |
---|
387 | </informalexample> |
---|
388 | </para> |
---|
389 | |
---|
390 | <para> |
---|
391 | If you give <literal>true</literal> as the argument, objects for which this |
---|
392 | set of visualization attributes is assigned are always visualized |
---|
393 | in wireframe even if in general, the surface drawing style has been |
---|
394 | requested. The default value of the forced wireframe style is |
---|
395 | <literal>false</literal>. |
---|
396 | </para> |
---|
397 | |
---|
398 | <para> |
---|
399 | Similarly, forced solid style, i.e., to force that objects are |
---|
400 | always visualized with surfaces, is set with: |
---|
401 | |
---|
402 | <informalexample> |
---|
403 | <programlisting> |
---|
404 | void G4VisAttributes::SetForceSolid (G4bool force); |
---|
405 | </programlisting> |
---|
406 | </informalexample> |
---|
407 | </para> |
---|
408 | |
---|
409 | <para> |
---|
410 | The default value of the forced solid style is <literal>false</literal>, too. |
---|
411 | </para> |
---|
412 | |
---|
413 | <para> |
---|
414 | You can also force auxiliary edges to be visible. Normally they |
---|
415 | are not visible unless you set the appropriate view parameter. |
---|
416 | Forcing the auxiliary edges to be visible means that auxiliary |
---|
417 | edges will be seen whatever the view parameters. |
---|
418 | </para> |
---|
419 | |
---|
420 | <para> |
---|
421 | Auxiliary edges are not genuine edges of the volume. They may be |
---|
422 | in a curved surface made out of polygons, for example, or in plane |
---|
423 | surface of complicated shape that has to be broken down into |
---|
424 | simpler polygons. HepPolyhedron breaks all surfaces into triangles |
---|
425 | or quadrilaterals. There will be auxiliary edges for any volumes |
---|
426 | with a curved surface, such as a tube or a sphere, or a volume |
---|
427 | resulting from a Boolean operation. Normally, they are not shown, |
---|
428 | but sometimes it is useful to see them. In particular, a sphere, |
---|
429 | because it has no egdes, will not be seen in wireframe mode in some |
---|
430 | graphics systems unless requested by the view parameters or forced, |
---|
431 | as described here. |
---|
432 | </para> |
---|
433 | |
---|
434 | <para> |
---|
435 | To force auxiliary edges to be visible, use: |
---|
436 | |
---|
437 | <informalexample> |
---|
438 | <programlisting> |
---|
439 | void G4VisAttributes::SetForceAuxEdgeVisible (G4bool force); |
---|
440 | </programlisting> |
---|
441 | </informalexample> |
---|
442 | </para> |
---|
443 | |
---|
444 | <para> |
---|
445 | The default value of the force auxiliary edges visible flag is |
---|
446 | <literal>false</literal>. |
---|
447 | </para> |
---|
448 | |
---|
449 | <para> |
---|
450 | For volumes with edges that are parts of a circle, such as a |
---|
451 | tube (G4Tubs), etc., it is possible to force the precision of |
---|
452 | polyhedral representation for visualisation. This is recommended |
---|
453 | for volumes containing only a small angle of circle, for example, a |
---|
454 | thin tube segment. |
---|
455 | </para> |
---|
456 | |
---|
457 | <para> |
---|
458 | For visualisation, a circle is represented by an N-sided |
---|
459 | polygon. The default is 24 sides or segments. The user may change |
---|
460 | this for all volumes in a particular viewer at run time with |
---|
461 | /vis/viewer/set/lineSegmentsPerCircle; alternatively it can be |
---|
462 | forced for a particular volume with: |
---|
463 | |
---|
464 | <informalexample> |
---|
465 | <programlisting> |
---|
466 | void G4VisAttributes::SetForceLineSegmentsPerCircle (G4int nSegments); |
---|
467 | </programlisting> |
---|
468 | </informalexample> |
---|
469 | </para> |
---|
470 | |
---|
471 | </sect2> |
---|
472 | |
---|
473 | |
---|
474 | <!-- ******************* Section (Level#2) ****************** --> |
---|
475 | <sect2 id="sect.VisAtt.CnstAtt"> |
---|
476 | <title> |
---|
477 | Constructors of G4VisAttributes |
---|
478 | </title> |
---|
479 | |
---|
480 | <para> |
---|
481 | The following constructors are supported for class |
---|
482 | <emphasis>G4VisAttributes</emphasis>: |
---|
483 | |
---|
484 | <informalexample> |
---|
485 | <programlisting> |
---|
486 | //----- Constructors of class G4VisAttributes |
---|
487 | G4VisAttributes (void); |
---|
488 | G4VisAttributes (G4bool visibility); |
---|
489 | G4VisAttributes (const G4Colour& colour); |
---|
490 | G4VisAttributes (G4bool visibility, const G4Colour& colour); |
---|
491 | </programlisting> |
---|
492 | </informalexample> |
---|
493 | </para> |
---|
494 | |
---|
495 | </sect2> |
---|
496 | |
---|
497 | |
---|
498 | <!-- ******************* Section (Level#2) ****************** --> |
---|
499 | <sect2 id="sect.VisAtt.AssgLgVol"> |
---|
500 | <title> |
---|
501 | How to assign G4VisAttributes to a logical volume |
---|
502 | </title> |
---|
503 | |
---|
504 | <para> |
---|
505 | In constructing your detector components, you may assign a set of |
---|
506 | visualization attributes to each "logical volume" in order to |
---|
507 | visualize them later (if you do not do this, the graphics system |
---|
508 | will use a default set). You cannot make a solid such as |
---|
509 | <emphasis>G4Box</emphasis> hold a set of visualization attributes; this is |
---|
510 | because a solid should hold only geometrical information. At |
---|
511 | present, you cannot make a physical volume hold one, but there are |
---|
512 | plans to design a memory-efficient way to do it; however, you can |
---|
513 | visualize a transient piece of solid or physical volume with a |
---|
514 | temporary assigned set of visualization attributes. |
---|
515 | </para> |
---|
516 | |
---|
517 | <para> |
---|
518 | Class <emphasis>G4LogicalVolume</emphasis> holds a pointer of |
---|
519 | <emphasis>G4VisAttributes.</emphasis> This field is set and referenced with the |
---|
520 | following access functions: |
---|
521 | |
---|
522 | <informalexample> |
---|
523 | <programlisting> |
---|
524 | //----- Set functions of G4VisAttributes |
---|
525 | void G4VisAttributes::SetVisAttributes (const G4VisAttributes* pVA); |
---|
526 | void G4VisAttributes::SetVisAttributes (const G4VisAttributes& VA); |
---|
527 | |
---|
528 | //----- Get functions of G4VisAttributes |
---|
529 | const G4VisAttributes* G4VisAttributes::GetVisAttributes () const; |
---|
530 | </programlisting> |
---|
531 | </informalexample> |
---|
532 | </para> |
---|
533 | |
---|
534 | <para> |
---|
535 | The following is sample C++ source codes for assigning a set of |
---|
536 | visualization attributes with cyan colour and forced wireframe |
---|
537 | style to a logical volume: |
---|
538 | |
---|
539 | <informalexample> |
---|
540 | <programlisting> |
---|
541 | //----- C++ source codes: Assigning G4VisAttributes to a logical volume |
---|
542 | ... |
---|
543 | // Instantiation of a logical volume |
---|
544 | myTargetLog = new G4LogicalVolume( myTargetTube,BGO, "TLog", 0, 0, 0); |
---|
545 | ... |
---|
546 | // Instantiation of a set of visualization attributes with cyan colour |
---|
547 | G4VisAttributes * calTubeVisAtt = new G4VisAttributes(G4Colour(0.,1.,1.)); |
---|
548 | // Set the forced wireframe style |
---|
549 | calTubeVisAtt->SetForceWireframe(true); |
---|
550 | // Assignment of the visualization attributes to the logical volume |
---|
551 | myTargetLog->SetVisAttributes(calTubeVisAtt); |
---|
552 | |
---|
553 | //----- end of C++ source codes |
---|
554 | </programlisting> |
---|
555 | </informalexample> |
---|
556 | </para> |
---|
557 | |
---|
558 | <para> |
---|
559 | Note that the life of the visualization attributes must be at |
---|
560 | least as long as the objects to which they are assigned; it is the |
---|
561 | users' responsibility to ensure this, and to delete the |
---|
562 | visualization attributes when they are no longer needed (or just |
---|
563 | leave them to die at the end of the job). |
---|
564 | </para> |
---|
565 | |
---|
566 | </sect2> |
---|
567 | |
---|
568 | |
---|
569 | <!-- ******************* Section (Level#2) ****************** --> |
---|
570 | <sect2 id="sect.VisAtt.AddUdefAtt"> |
---|
571 | <title> |
---|
572 | Additional User-Defined Attributes |
---|
573 | </title> |
---|
574 | |
---|
575 | <para> |
---|
576 | Geant4 Trajectories and Hits can be assigned additional arbitrary |
---|
577 | attributes that will be displayed when you click on the relevant |
---|
578 | object in the WIRED or FRED HepRep browsers. WIRED then lets you |
---|
579 | label objects by any of these attributes or cut visibility based on |
---|
580 | these attributes. |
---|
581 | </para> |
---|
582 | |
---|
583 | <para> |
---|
584 | Define the attributes with lines such as: |
---|
585 | |
---|
586 | <informalexample> |
---|
587 | <programlisting> |
---|
588 | std::map<G4String,G4AttDef>* store = G4AttDefStore::GetInstance("G4Trajectory",isNew); |
---|
589 | G4String PN("PN"); |
---|
590 | (*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String"); |
---|
591 | G4String IMom("IMom"); |
---|
592 | (*store)[IMom] = G4AttDef(IMom, "Momentum of track at start of trajectory", "Physics", "", |
---|
593 | "G4ThreeVector"); |
---|
594 | </programlisting> |
---|
595 | </informalexample> |
---|
596 | </para> |
---|
597 | |
---|
598 | <para> |
---|
599 | Then fill the attributes with lines such as: |
---|
600 | |
---|
601 | <informalexample> |
---|
602 | <programlisting> |
---|
603 | std::vector<G4AttValue>* values = new std::vector<G4AttValue>; |
---|
604 | values->push_back(G4AttValue("PN",ParticleName,"")); |
---|
605 | s.seekp(std::ios::beg); |
---|
606 | s << G4BestUnit(initialMomentum,"Energy") << std::ends; |
---|
607 | values->push_back(G4AttValue("IMom",c,"")); |
---|
608 | </programlisting> |
---|
609 | </informalexample> |
---|
610 | </para> |
---|
611 | |
---|
612 | <para> |
---|
613 | See geant4/source/tracking/src/G4Trajectory.cc for a good example. |
---|
614 | </para> |
---|
615 | |
---|
616 | <para> |
---|
617 | <emphasis>G4AttValue</emphasis> objects are light, containing just the value; |
---|
618 | for the long description and other sharable information the |
---|
619 | <emphasis>G4AttValue</emphasis> object refers to a <emphasis>G4AttDef</emphasis> |
---|
620 | object. They are based on the HepRep standard described at |
---|
621 | <ulink url="http://www.slac.stanford.edu/~perl/heprep/"> |
---|
622 | http://www.slac.stanford.edu/~perl/heprep/ |
---|
623 | </ulink>. |
---|
624 | Geant4 also provides an <emphasis>G4AttDefStore</emphasis>. |
---|
625 | </para> |
---|
626 | |
---|
627 | <para> |
---|
628 | Geant4 provides some default examples of the use of this |
---|
629 | facility in the trajectory classes in /source/tracking such as |
---|
630 | <emphasis>G4Trajectory</emphasis>, <emphasis>G4SmoothTrajectory</emphasis>. |
---|
631 | <emphasis>G4Trajectory::CreateAttValues</emphasis> shows how |
---|
632 | <emphasis>G4AttValue</emphasis> objects can be made and |
---|
633 | <emphasis>G4Trajectory::GetAttDefs</emphasis> shows how |
---|
634 | to make the corresponding <emphasis>G4AttDef</emphasis> objects and use the |
---|
635 | <emphasis>G4AttDefStore</emphasis>. Note that the "user" of CreateAttValues |
---|
636 | guarantees to destroy them; this is a way of allowing creation on |
---|
637 | demand and leaving the <emphasis>G4Trajectory</emphasis> object, for example, |
---|
638 | free of such objects in memory. The comments in |
---|
639 | <emphasis>G4VTrajectory.hh</emphasis> explain further and additional insights |
---|
640 | might be obtained by looking at two methods which use them, namely |
---|
641 | <emphasis>G4VTrajectory::DrawTrajectory</emphasis> and |
---|
642 | <emphasis>G4VTrajectory::ShowTrajectory</emphasis>. |
---|
643 | </para> |
---|
644 | |
---|
645 | <para> |
---|
646 | Hits classes in examples /extended/analysis/A01 and |
---|
647 | /extended/runAndEvent/RE01 show how to do the same for your hits. |
---|
648 | The base class no-action methods CreateAttValues and GetAttDefs |
---|
649 | should be overridden in your concrete class. The comments in |
---|
650 | <emphasis>G4VHit.hh</emphasis> explain further. |
---|
651 | </para> |
---|
652 | |
---|
653 | <para> |
---|
654 | In addition, the user is free to add a |
---|
655 | <emphasis>G4std::vector<G4AttValue>*</emphasis> and a |
---|
656 | <emphasis>G4std::vector<G4AttDef>*</emphasis> to a |
---|
657 | <emphasis>G4VisAttributes</emphasis> object as could, for example, |
---|
658 | be used by a <emphasis>G4LogicalVolume</emphasis> object. |
---|
659 | </para> |
---|
660 | |
---|
661 | <para> |
---|
662 | At the time of writing, only the HepRep graphics systems are |
---|
663 | capable of displaying the G4AttValue information, but this |
---|
664 | information will become useful for all Geant4 visualization systems |
---|
665 | through improvements in release 8.1 or later. |
---|
666 | </para> |
---|
667 | |
---|
668 | |
---|
669 | </sect2> |
---|
670 | </sect1> |
---|