1 | <!-- ******************************************************** --> |
---|
2 | <!-- Docbook Version: For Toolkit Developers Guide --> |
---|
3 | <!-- ******************************************************** --> |
---|
4 | |
---|
5 | <!-- ******************* Section (Level#1) ****************** --> |
---|
6 | <sect1 id="sect.DsgnFuncVis"> |
---|
7 | <title> |
---|
8 | Visualisation |
---|
9 | </title> |
---|
10 | |
---|
11 | <!-- ******************* Section (Level#2) ****************** --> |
---|
12 | <sect2 id="sect.DsgnFuncVis.DsgPhlsp"> |
---|
13 | <title> |
---|
14 | Design Philosophy |
---|
15 | </title> |
---|
16 | |
---|
17 | <para> |
---|
18 | The visualisation category consists of the classes required to display |
---|
19 | detector geometry, particle trajectories, tracking steps, and hits. It also |
---|
20 | provides visualisation drivers, which are interfaces to external graphics |
---|
21 | systems. |
---|
22 | </para> |
---|
23 | |
---|
24 | <para> |
---|
25 | A wide variety of user requirements went into the design of the visualisation |
---|
26 | category, for example: |
---|
27 | |
---|
28 | <itemizedlist spacing="compact"> |
---|
29 | <listitem><para> |
---|
30 | very quick response in surveying successive events, |
---|
31 | </para></listitem> |
---|
32 | <listitem><para> |
---|
33 | high-quality output for presentation and documentation, |
---|
34 | </para></listitem> |
---|
35 | <listitem><para> |
---|
36 | flexible camera control for debugging detector geometry and physics, |
---|
37 | </para></listitem> |
---|
38 | <listitem><para> |
---|
39 | selection of visualisable objects, |
---|
40 | </para></listitem> |
---|
41 | <listitem><para> |
---|
42 | interactive picking of graphical objects for attribute editing or |
---|
43 | feedback to the associated data, |
---|
44 | </para></listitem> |
---|
45 | <listitem><para> |
---|
46 | highlighting incorrect intersections of physical volumes, |
---|
47 | </para></listitem> |
---|
48 | <listitem><para> |
---|
49 | co-working with graphical user interfaces. |
---|
50 | </para></listitem> |
---|
51 | </itemizedlist> |
---|
52 | </para> |
---|
53 | |
---|
54 | <para> |
---|
55 | Because it is very difficult to respond to all of these requirements |
---|
56 | with only one built-in visualiser, an abstract interface was developed |
---|
57 | which supports several complementary graphics systems. Here the term |
---|
58 | <emphasis role="bold">graphics system</emphasis> means either an |
---|
59 | application running as a process independent of Geant4 or a graphics |
---|
60 | library to be compiled with Geant4. A concrete implementation of the |
---|
61 | interface is called a <emphasis role="bold">visualisation driver</emphasis>, |
---|
62 | which can use a graphics library directly, communicate with an |
---|
63 | independent process via pipe or socket, or simply write an intermediate |
---|
64 | file for a separate viewer. |
---|
65 | </para> |
---|
66 | |
---|
67 | </sect2> |
---|
68 | |
---|
69 | <!-- ******************* Section (Level#2) ****************** --> |
---|
70 | <sect2 id="sect.DsgnFuncVis.GrphIntrf"> |
---|
71 | <title> |
---|
72 | The Graphics Interfaces |
---|
73 | </title> |
---|
74 | |
---|
75 | <para> |
---|
76 | <itemizedlist spacing="compact"> |
---|
77 | <listitem><para> |
---|
78 | <emphasis role="bold"></emphasis>G4VVisManager: |
---|
79 | All user code writes to the graphics systems |
---|
80 | through this pure abstract interface. It contains Draw methods for |
---|
81 | all the graphics primitives in the graphics_reps category |
---|
82 | (G4Polyline, G4Circle, etc.), geometry objects (through their base |
---|
83 | classes, G4VSolid, G4PhysicalVolume and G4LogicalVolume) and hits and |
---|
84 | trajectories (through their base classes, G4VHit and G4VTrajectory). |
---|
85 | </para> |
---|
86 | <para> |
---|
87 | Since this is an abstract interface, all user code must check that |
---|
88 | there exists a concrete instantiation of it. A static method is |
---|
89 | provided, so a typical user code fragment is: |
---|
90 | |
---|
91 | <informalexample><programlisting> |
---|
92 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
93 | if(pVVisManager) { |
---|
94 | pVVisManager->Draw(G4Circle... |
---|
95 | ... |
---|
96 | </programlisting></informalexample> |
---|
97 | </para> |
---|
98 | <para> |
---|
99 | Note that this allows the building an application without a concrete |
---|
100 | implementation, for example for a batch job, even if some code, like |
---|
101 | the above, is still included. Most of the novice examples can be |
---|
102 | built this way if G4VIS_NONE is specified. |
---|
103 | </para> |
---|
104 | <para> |
---|
105 | The concrete implementation of this interface is hereafter |
---|
106 | referred to as the <emphasis role="bold">visualisation manager</emphasis>. |
---|
107 | </para></listitem> |
---|
108 | <listitem><para> |
---|
109 | <emphasis role="bold">G4VGraphicsScene</emphasis>: |
---|
110 | The visualisation manager must also |
---|
111 | provide a concrete implementation of the subsidiary interface, |
---|
112 | G4VGraphicsScene. It is only for use by the kernel and the modeling |
---|
113 | category. It offers direct access to a ``scene handler'' through a |
---|
114 | reference provided by the visualisation manager. It is described in |
---|
115 | more detail in the section on extending the toolkit functionality. |
---|
116 | </para></listitem> |
---|
117 | </itemizedlist> |
---|
118 | </para> |
---|
119 | |
---|
120 | <para> |
---|
121 | The Geant4 distribution includes implementations of the above |
---|
122 | interfaces, namely <emphasis role="bold">G4VisManager</emphasis> |
---|
123 | and <emphasis role="bold">G4VSceneHandler</emphasis> |
---|
124 | respectively, and their associated classes. These define further |
---|
125 | abstract base classes for visualisation drivers. Together they form |
---|
126 | the <emphasis role="bold">Geant4 Visualisation System</emphasis>. |
---|
127 | A variety of concrete visualisation drivers are also included |
---|
128 | in the distribution. Details of how to implement a visualisation |
---|
129 | driver are given in <xref linkend="sect.ExtdFuncVis" />. |
---|
130 | Of course, it is always possible for |
---|
131 | a user to implement his or her own concrete implementations of |
---|
132 | G4VVisManager and G4VGraphicsScene replacing the Geant4 Visualisation |
---|
133 | System altogether. |
---|
134 | </para> |
---|
135 | |
---|
136 | </sect2> |
---|
137 | |
---|
138 | <!-- ******************* Section (Level#2) ****************** --> |
---|
139 | <sect2 id="sect.DsgnFuncVis.VisSystm"> |
---|
140 | <title> |
---|
141 | The Geant4 Visualisation System |
---|
142 | </title> |
---|
143 | |
---|
144 | <para> |
---|
145 | The Geant4 Visualisation System consists of |
---|
146 | |
---|
147 | <itemizedlist spacing="compact"> |
---|
148 | <listitem><para> |
---|
149 | <emphasis role="bold">G4VisManager</emphasis>: An implementation |
---|
150 | of the G4VVisManager |
---|
151 | interface. It manages multiple graphics systems and defines three |
---|
152 | more concepts -- the <emphasis role="bold">scene</emphasis> (G4Scene), |
---|
153 | the <emphasis role="bold">scene handler</emphasis> |
---|
154 | (base class G4VSceneHandler, itself a sub-class of G4VGraphicsScene) |
---|
155 | and the <emphasis role="bold">viewer</emphasis> (base class G4VViewer) |
---|
156 | -- see below. |
---|
157 | G4VisManager is a singleton and an abstract class, requiring the |
---|
158 | user to derive from it a concrete visualisation manager |
---|
159 | (G4VisExecutive is provided -- see below). Roles and structure of |
---|
160 | the visualisation manager are described in Chapter 8 of the User's |
---|
161 | Guide for Application Developers. |
---|
162 | </para></listitem> |
---|
163 | <listitem><para> |
---|
164 | <emphasis role="bold">G4VisExecutive</emphasis>: A concrete visualisation |
---|
165 | manager that implements the virtual functions RegisterGraphicsSystems and |
---|
166 | RegisterModelFactories. These functions must be in the users' |
---|
167 | domain, since the graphics systems and models that are instantiated |
---|
168 | by them are, in many cases, provided by the user (graphics |
---|
169 | libraries, etc.). It is therefore implemented as a .hh-.icc |
---|
170 | combination that is designed to be included in the users' code. Of |
---|
171 | course, the user may write his or her own. |
---|
172 | </para></listitem> |
---|
173 | <listitem><para> |
---|
174 | <emphasis role="bold">G4Scene</emphasis> The scene is a list if |
---|
175 | models for physical |
---|
176 | volumes, axes, hits, trajectories, etc. - see Section |
---|
177 | <xref linkend="sect.DsgnFuncVis.MdlCat" />. |
---|
178 | They are distinguished according to their |
---|
179 | lifetime -- ``run-duration'' for physical volumes, etc., |
---|
180 | ``end-of-event'' for hits and trajectories, etc. The end-of-event |
---|
181 | models are only to be used when the Geant4 state indicates the end |
---|
182 | of event has been reached. The scene has an |
---|
183 | <emphasis role="bold">extent</emphasis> (G4VisExtent), |
---|
184 | which is updated by the scene when a new model is |
---|
185 | added (each model itself has an extent), and a ``standard'' target |
---|
186 | point; these are used to define the standard view -- see |
---|
187 | below. In addition, the scene keeps flags which indicate whether |
---|
188 | end-of-event objects should be accumulated or refreshed for each |
---|
189 | event or run. |
---|
190 | </para></listitem> |
---|
191 | <listitem><para> |
---|
192 | <emphasis role="bold">G4VGraphicsSystem</emphasis>: This is an |
---|
193 | abstract base class for scene |
---|
194 | handler and viewer factories. It is used by the visualisation |
---|
195 | manager to create scene handlers and viewers on request. |
---|
196 | </para></listitem> |
---|
197 | <listitem><para> |
---|
198 | <emphasis role="bold">G4VSceneHandler</emphasis>: A sub-class of |
---|
199 | G4VGraphicsScene, itself an abstract base class for specific scene |
---|
200 | handlers, whose job is to |
---|
201 | convert the scene into graphics-system-specific code for the viewer. |
---|
202 | For example, the scene handler may create a graphical database, |
---|
203 | taking care to separate run-duration (persistent) and end-of-event |
---|
204 | (transient) information (this is described further in |
---|
205 | <xref linkend="sect.ExtdFuncVis.CrtGrpDrv.DlgTrnsObj" />. |
---|
206 | </para></listitem> |
---|
207 | <listitem><para> |
---|
208 | <emphasis role="bold">G4VViewer</emphasis>: An abstract base class |
---|
209 | for specific viewers. |
---|
210 | Its job is to create windows or files and identify where and how the |
---|
211 | final view should be rendered. It has |
---|
212 | <emphasis role="bold">view parameters</emphasis> |
---|
213 | (G4ViewParameters) which specify viewpoint direction, type of |
---|
214 | rendering (wireframe or surface), etc. It is the view's |
---|
215 | responsibility, noting the scene's extent and target point, to |
---|
216 | choose a camera position and magnification that ensures that the |
---|
217 | scene is automatically and comfortably rendered in the viewing |
---|
218 | window. This is then the <emphasis role="bold">standard view</emphasis>, |
---|
219 | and any further |
---|
220 | operations requested by the user - zoom, pan, etc. - are |
---|
221 | relative to this standard view. The class G4ViewParameters has |
---|
222 | utility routines to assist this procedure; it is strongly advised |
---|
223 | that toolkit developers writing a viewer should study the |
---|
224 | G4ViewParameters class, whose header file contains much useful |
---|
225 | information (also preserved in the Software Reference Manual). |
---|
226 | </para> |
---|
227 | <para> |
---|
228 | The viewer is messaged by the vis manager when the user issues |
---|
229 | commands, such as <literal>/vis/viewer/refresh</literal>. |
---|
230 | This invokes methods |
---|
231 | such as SetView, ClearView and DrawView. A detailed description of |
---|
232 | the call sequences is given in |
---|
233 | <xref linkend="sect.ExtdFuncVis.CrtGrpDrv.ImpCmdAct" />- |
---|
234 | <xref linkend="sect.ExtdFuncVis.CrtGrpDrv.WhtPrcScn" />. |
---|
235 | </para></listitem> |
---|
236 | </itemizedlist> |
---|
237 | </para> |
---|
238 | |
---|
239 | <para> |
---|
240 | Note there is no restriction on the number or type of scene handlers |
---|
241 | or viewers. There may be several scene handlers processing the same |
---|
242 | or different scenes, each with several viewers (for example, the same |
---|
243 | scene from differing viewpoints). |
---|
244 | </para> |
---|
245 | |
---|
246 | <para> |
---|
247 | By defining a set of three C++ classes inheriting from the virtual |
---|
248 | base classes - G4VGraphicsSystem, G4VSceneHandler and G4VViewer - an |
---|
249 | arbitrary graphics system can easily be plugged in to Geant4. |
---|
250 | The plugged-in graphics system is then available for visualising |
---|
251 | detector simulations. Together, this set of three concrete classes is |
---|
252 | called a "visualisation driver". The DAWN-File driver, for example, |
---|
253 | is the interface to the Fukui Renderer DAWN, and is implemented by the |
---|
254 | following set of classes: |
---|
255 | |
---|
256 | <orderedlist spacing="compact"> |
---|
257 | <listitem><para> |
---|
258 | G4DAWNFILE : public G4VGraphicsSystem for creation of the |
---|
259 | scene handlers and viewers |
---|
260 | </para></listitem> |
---|
261 | <listitem><para> |
---|
262 | G4DAWNFILESceneHandler : public G4VSceneHandler for |
---|
263 | modeling 3D scenes |
---|
264 | </para></listitem> |
---|
265 | <listitem><para> |
---|
266 | G4DAWNFILEView : public G4VView for rendering 3D scenes |
---|
267 | </para></listitem> |
---|
268 | </orderedlist> |
---|
269 | </para> |
---|
270 | |
---|
271 | <para> |
---|
272 | Several visualisation drivers are distributed with Geant4. They are |
---|
273 | complementary to each other in many aspects. For details, see Chapter 8 of |
---|
274 | the User's Guide for Application Developers. |
---|
275 | </para> |
---|
276 | |
---|
277 | </sect2> |
---|
278 | |
---|
279 | <!-- ******************* Section (Level#2) ****************** --> |
---|
280 | <sect2 id="sect.DsgnFuncVis.MdlCat"> |
---|
281 | <title> |
---|
282 | Modeling sub-category |
---|
283 | </title> |
---|
284 | |
---|
285 | <para> |
---|
286 | <itemizedlist spacing="compact"> |
---|
287 | <listitem><para> |
---|
288 | <emphasis role="bold">G4VModel</emphasis> - |
---|
289 | a base class for visualisation models. A model is a |
---|
290 | graphics-system-independent description of a Geant4 component. |
---|
291 | </para> |
---|
292 | <para> |
---|
293 | The sub-category visualisation/modeling defines how to model a 3D |
---|
294 | scene for visualisation. The term "3D scene" indicates a set of |
---|
295 | visualisable component objects put in a 3D world. A concrete class |
---|
296 | inheriting from the abstract base class G4VModel defines a "model", |
---|
297 | which describes how to visualise the corresponding component object |
---|
298 | belonging to a 3D scene. G4ModelingParameters defines various |
---|
299 | associated parameters. |
---|
300 | </para> |
---|
301 | <para> |
---|
302 | For example, G4PhysicalVolumeModel knows how to visualise |
---|
303 | a physical volume. It describes a physical volume |
---|
304 | and its daughters to any desired depth. G4HitsModel knows |
---|
305 | how to visualise hits. G4TrajectoriesModel |
---|
306 | knows how to visualise trajectories. |
---|
307 | </para> |
---|
308 | <para> |
---|
309 | The main task of a model is to describe itself to a 3D scene by |
---|
310 | giving a concrete implementation of the following virtual |
---|
311 | method of G4VModel: |
---|
312 | |
---|
313 | <informalexample><programlisting> |
---|
314 | virtual void DescribeYourselfTo (G4VGraphicsScene&) = 0; |
---|
315 | </programlisting></informalexample> |
---|
316 | </para> |
---|
317 | <para> |
---|
318 | The argument class G4VGraphicsScene is a minimal abstract |
---|
319 | interface of a 3D scene for the Geant4 kernel defined in the |
---|
320 | graphics_reps category. Since G4VSceneHandler and its concrete |
---|
321 | descendants inherit from G4VGraphicsScene, the |
---|
322 | method DescribeYourselfTo() can pass information of a 3D scene |
---|
323 | to a visualisation driver. |
---|
324 | </para> |
---|
325 | <para> |
---|
326 | It is easy for a toolkit developer of Geant4 to add a new kind |
---|
327 | of visualisable component object. It is done by implementing a |
---|
328 | new class inheriting from G4VModel. |
---|
329 | </para></listitem> |
---|
330 | <listitem><para> |
---|
331 | <emphasis role="bold">G4VTrajectoryModel</emphasis> - |
---|
332 | an abstract base class for trajectory drawing models. |
---|
333 | </para> |
---|
334 | <para> |
---|
335 | A trajectory model governs how an individual trajectory is drawn. |
---|
336 | Concrete models inheriting from G4VTrajectoryModel must implement |
---|
337 | two pure virtual functions: |
---|
338 | |
---|
339 | <informalexample><programlisting> |
---|
340 | virtual void Draw(const G4VTrajectory&, G4int i_mode = 0) const = 0; |
---|
341 | virtual void Print(std::ostream& ostr) const = 0; |
---|
342 | </programlisting></informalexample> |
---|
343 | </para> |
---|
344 | <para> |
---|
345 | See for example G4TrajectoryDrawByParticleID. |
---|
346 | </para></listitem> |
---|
347 | <listitem><para> |
---|
348 | <emphasis role="bold">G4VModelFactory</emphasis> - |
---|
349 | an abstract base class for factories creating models and associated |
---|
350 | messengers. |
---|
351 | </para> |
---|
352 | <para> |
---|
353 | It is not necessary to generate messengers for a trajectory model |
---|
354 | that will be constructed and configured directly in compiled code. |
---|
355 | If the user requires model creation and configuration features through |
---|
356 | interactive commands, however, there must be a mechanism to generate |
---|
357 | both models and their associated messengers. This is the role of |
---|
358 | G4VModelFactory. Concrete factories inheriting from G4VModelFactory |
---|
359 | are responsible for creating a concrete model and concrete messengers. |
---|
360 | To help ensure a type safe messenger to model interaction on the |
---|
361 | command line, the messengers should inherit from G4VModelCommand. |
---|
362 | </para> |
---|
363 | <para> |
---|
364 | Concrete factories must implement one pure virtual function: |
---|
365 | |
---|
366 | <informalexample><programlisting> |
---|
367 | virtual ModelAndMessengers |
---|
368 | Create(const G4String& placement, const G4String& modelName) = 0; |
---|
369 | </programlisting></informalexample> |
---|
370 | |
---|
371 | where placement indicates which directory space the commands should |
---|
372 | occupy. See for example G4TrajectoryDrawByParticleIDFactory. |
---|
373 | </para></listitem> |
---|
374 | </itemizedlist> |
---|
375 | </para> |
---|
376 | |
---|
377 | |
---|
378 | </sect2> |
---|
379 | |
---|
380 | <!-- ******************* Section (Level#2) ****************** --> |
---|
381 | <sect2 id="sect.DsgnFuncVis.ViewParam"> |
---|
382 | <title> |
---|
383 | View parameters |
---|
384 | </title> |
---|
385 | |
---|
386 | <para> |
---|
387 | View parameters such as camera parameters, drawing styles |
---|
388 | (wireframe/surface etc) are held by G4ViewParameters. Each |
---|
389 | viewer holds a view parameters object which can be changed |
---|
390 | interactively and a default object (for use in the |
---|
391 | <literal>/vis/viewer/reset</literal> command). |
---|
392 | </para> |
---|
393 | |
---|
394 | <para> |
---|
395 | If a toolkit developer of Geant4 wants to add entries of view |
---|
396 | parameters, he should add fields and methods to G4ViewParameters. |
---|
397 | </para> |
---|
398 | |
---|
399 | </sect2> |
---|
400 | |
---|
401 | <!-- ******************* Section (Level#2) ****************** --> |
---|
402 | <sect2 id="sect.DsgnFuncVis.VisAttr"> |
---|
403 | <title> |
---|
404 | Visualisation Attributes |
---|
405 | </title> |
---|
406 | |
---|
407 | <para> |
---|
408 | All drawable objects (should) have a method: |
---|
409 | |
---|
410 | <informalexample><programlisting> |
---|
411 | const G4VisAttributes* GetVisAttributes() const; |
---|
412 | </programlisting></informalexample> |
---|
413 | </para> |
---|
414 | |
---|
415 | <para> |
---|
416 | A drawable object might be: |
---|
417 | |
---|
418 | <itemizedlist spacing="compact"> |
---|
419 | <listitem><para> |
---|
420 | a "visible" (i.e., inheriting G4Visible), such as a polyhedron, |
---|
421 | polyline, circle, etc. (note that text is a slightly special case |
---|
422 | - see below) or |
---|
423 | </para></listitem> |
---|
424 | <listitem><para> |
---|
425 | a solid whose vis attributes are held in its logical volume. |
---|
426 | </para></listitem> |
---|
427 | </itemizedlist> |
---|
428 | </para> |
---|
429 | |
---|
430 | |
---|
431 | |
---|
432 | <!-- ******************* Section (Level#3) ****************** --> |
---|
433 | <sect3 id="sect.DsgnFuncVis.VisAttr.FndAppAtt"> |
---|
434 | <title> |
---|
435 | Finding the applicable vis attributes |
---|
436 | </title> |
---|
437 | |
---|
438 | <para> |
---|
439 | This is an issue for all scene handlers. The scene handler is where |
---|
440 | the colour, style, auxiliary edge visibility, marker size, etc., of |
---|
441 | individual drawable objects are needed. |
---|
442 | </para> |
---|
443 | |
---|
444 | |
---|
445 | <!-- ******************* Section (Level#4) ****************** --> |
---|
446 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.Vsbl"> |
---|
447 | <title> |
---|
448 | Visibles |
---|
449 | </title> |
---|
450 | |
---|
451 | <para> |
---|
452 | If the vis attributes pointer is zero, drivers should pick up the |
---|
453 | default vis attributes from the viewer: |
---|
454 | |
---|
455 | <informalexample><programlisting> |
---|
456 | const G4VisAttributes* pVisAtts = visible.GetVisAttributes(); |
---|
457 | if (!pVisAtts) |
---|
458 | pVisAtts = fpViewer->GetViewParameters().GetDefaultVisAttributes(); |
---|
459 | </programlisting></informalexample> |
---|
460 | |
---|
461 | where visible denotes any visible object (polyhedron, circle, etc.). |
---|
462 | </para> |
---|
463 | |
---|
464 | <para> |
---|
465 | There is a utility function G4VViewer::GetApplicableVisAttributes |
---|
466 | which does this, so an alternative is: |
---|
467 | |
---|
468 | <informalexample><programlisting> |
---|
469 | const G4VisAttributes* pVisAtts = |
---|
470 | fpViewer->GetApplicableVisAttributes(visible.GetVisAttributes()); |
---|
471 | </programlisting></informalexample> |
---|
472 | </para> |
---|
473 | |
---|
474 | <para> |
---|
475 | Confusingly, there is a utility function G4VSceneHandler::GetColour |
---|
476 | which also does this, so if it's only colour you need, the following |
---|
477 | suffices: |
---|
478 | |
---|
479 | <informalexample><programlisting> |
---|
480 | const G4Colour& colour GetColour(visible); |
---|
481 | </programlisting></informalexample> |
---|
482 | |
---|
483 | but equally well: |
---|
484 | |
---|
485 | <informalexample><programlisting> |
---|
486 | const G4VisAttributes* pVisAtts = |
---|
487 | fpViewer->GetApplicableVisAttributes(visible.GetVisAttributes()); |
---|
488 | const G4Colour& colour pVisAtts->GetColour(); |
---|
489 | </programlisting></informalexample> |
---|
490 | |
---|
491 | or even: |
---|
492 | |
---|
493 | <informalexample><programlisting> |
---|
494 | const G4VisAttributes* pVisAtts = visible.GetVisAttributes(); |
---|
495 | if (!pVisAtts) |
---|
496 | pVisAtts = fpViewer->GetViewParameters().GetDefaultVisAttributes(); |
---|
497 | const G4Colour& colour pVisAtts->GetColour(); |
---|
498 | </programlisting></informalexample> |
---|
499 | </para> |
---|
500 | |
---|
501 | </sect4> |
---|
502 | |
---|
503 | <!-- ******************* Section (Level#4) ****************** --> |
---|
504 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.Txt"> |
---|
505 | <title> |
---|
506 | Text |
---|
507 | </title> |
---|
508 | |
---|
509 | <para> |
---|
510 | Text is a special case because it has its own default vis attributes: |
---|
511 | |
---|
512 | <informalexample><programlisting> |
---|
513 | const G4VisAttributes* pVisAtts = text.GetVisAttributes(); |
---|
514 | if (!pVisAtts) |
---|
515 | pVisAtts = fpViewer->GetViewParameters().GetDefaultTextVisAttributes(); |
---|
516 | const G4Colour& colour pVisAtts->GetColour(); |
---|
517 | </programlisting></informalexample> |
---|
518 | |
---|
519 | and there is a utility function G4VSceneHandler::GetTextColour: |
---|
520 | |
---|
521 | <informalexample><programlisting> |
---|
522 | const G4Colour& colour GetTextColour(text); |
---|
523 | </programlisting></informalexample> |
---|
524 | </para> |
---|
525 | |
---|
526 | </sect4> |
---|
527 | |
---|
528 | <!-- ******************* Section (Level#4) ****************** --> |
---|
529 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.Slds"> |
---|
530 | <title> |
---|
531 | Solids |
---|
532 | </title> |
---|
533 | |
---|
534 | <para> |
---|
535 | For specific solids, the G4PhysicalVolumeModel that provides the |
---|
536 | solids also provides, via PreAddSolid, a pointer to its vis |
---|
537 | attributes. If the vis attribites pointer in the logical volume is |
---|
538 | zero, it provides a pointer to the default vis attributes in the |
---|
539 | model, which in turn is (currently) provided by the viewer's vis |
---|
540 | attributes (see G4VSceneHandler::CreateModelingParameters). So the |
---|
541 | vis attributes pointer is guaranteed to be pertinent. |
---|
542 | </para> |
---|
543 | |
---|
544 | <para> |
---|
545 | If the concrete driver does not implement AddSolid for any particular |
---|
546 | solid, the base class converts it to primitives (usually a |
---|
547 | G4Polyhedron) and again, the vis attributes pointer is guaranteed. |
---|
548 | </para> |
---|
549 | |
---|
550 | </sect4> |
---|
551 | |
---|
552 | <!-- ******************* Section (Level#4) ****************** --> |
---|
553 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.DrwStyl"> |
---|
554 | <title> |
---|
555 | Drawing style |
---|
556 | </title> |
---|
557 | |
---|
558 | <para> |
---|
559 | The drawing style is normally determined by the view parameters but |
---|
560 | for individual drawable objects it may be overridden by the forced |
---|
561 | drawing style flags in the vis attributes. A utility function |
---|
562 | G4ViewParameters::DrawingStyle G4VSceneHandler::GetDrawingStyle is |
---|
563 | provided: |
---|
564 | |
---|
565 | <informalexample><programlisting> |
---|
566 | G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle(pVisAtts); |
---|
567 | </programlisting></informalexample> |
---|
568 | </para> |
---|
569 | |
---|
570 | </sect4> |
---|
571 | |
---|
572 | <!-- ******************* Section (Level#4) ****************** --> |
---|
573 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.AxlEdg"> |
---|
574 | <title> |
---|
575 | Auxiliary edges |
---|
576 | </title> |
---|
577 | |
---|
578 | <para> |
---|
579 | Similarly, the visibility of auxiliary/soft edges is normally |
---|
580 | determined by the view parameters but may be overridden by the forced |
---|
581 | auxiliary edge visible flag in the vis attributes. Again, a utility |
---|
582 | function G4VSceneHandler::GetAuxEdgeVisible is provided: |
---|
583 | |
---|
584 | <informalexample><programlisting> |
---|
585 | G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVisAtts); |
---|
586 | </programlisting></informalexample> |
---|
587 | </para> |
---|
588 | |
---|
589 | </sect4> |
---|
590 | |
---|
591 | <!-- ******************* Section (Level#4) ****************** --> |
---|
592 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.LnSgmCrc"> |
---|
593 | <title> |
---|
594 | LineSegmentsPerCircle |
---|
595 | </title> |
---|
596 | |
---|
597 | <para> |
---|
598 | Also, the precision of rendering curved edges in the polyhedral |
---|
599 | representation of volumes is normally determined by the view |
---|
600 | parameters but may be overridden by a forced attribute. A utility |
---|
601 | function that respects this, G4VSceneHandler::GetNoOfSides, is |
---|
602 | provided. For example: |
---|
603 | |
---|
604 | <informalexample><programlisting> |
---|
605 | G4Polyhedron::SetNumberOfRotationSteps (GetNoOfSides (pVisAttribs)); |
---|
606 | </programlisting></informalexample> |
---|
607 | </para> |
---|
608 | |
---|
609 | </sect4> |
---|
610 | |
---|
611 | <!-- ******************* Section (Level#4) ****************** --> |
---|
612 | <sect4 id="sect.DsgnFuncVis.VisAttr.FndAppAtt.MrkSz"> |
---|
613 | <title> |
---|
614 | Marker size |
---|
615 | </title> |
---|
616 | |
---|
617 | <para> |
---|
618 | These have nothing to do with vis attributes; they are an extra |
---|
619 | property of markers, i.e., objects that inherit G4VMarker (circles, |
---|
620 | squares, text, etc.). However, the algorithm for the actual size is |
---|
621 | quite complicated and a utility function |
---|
622 | G4VSceneHandler::GetMarkerSize is provided: |
---|
623 | |
---|
624 | <informalexample><programlisting> |
---|
625 | MarkerSizeType sizeType; |
---|
626 | G4double size = GetMarkerSize (text, sizeType); |
---|
627 | </programlisting></informalexample> |
---|
628 | |
---|
629 | sizeType is world or screen, signifying that the size is in world |
---|
630 | coordinates or screen coordinates respectively. |
---|
631 | </para> |
---|
632 | |
---|
633 | </sect4> |
---|
634 | |
---|
635 | </sect3> |
---|
636 | </sect2> |
---|
637 | |
---|
638 | <!-- ******* Bridgehead ******* --> |
---|
639 | <bridgehead role="revisionHistory" renderas="sect4"> |
---|
640 | [Status of this chapter] |
---|
641 | </bridgehead> |
---|
642 | <para> |
---|
643 | <simplelist type="var"> |
---|
644 | <member> |
---|
645 | 27.06.05 partially re-organized and section on design philosophy added (from |
---|
646 | Geant4 general paper) by D.H. Wright |
---|
647 | </member> |
---|
648 | <member> |
---|
649 | 13.10.05 Section on vis attributes added by John Allison. |
---|
650 | </member> |
---|
651 | <member> |
---|
652 | 06.01.06 Re-write of ``Design Philosphy'' and introduction of ``The Graphics |
---|
653 | Interfaces'' and ``The Geant4 Visualisation System'' by John Allison. |
---|
654 | </member> |
---|
655 | <member> |
---|
656 | Dec. 2006 Conversion from latex to Docbook verson by K. Amako |
---|
657 | </member> |
---|
658 | </simplelist> |
---|
659 | </para> |
---|
660 | |
---|
661 | |
---|
662 | |
---|
663 | |
---|
664 | </sect1> |
---|