Geant4  10.00.p01
G4VisExecutive.icc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisExecutive.icc 75567 2013-11-04 11:35:11Z gcosmo $
28 //
29 //
30 // John Allison 24th January 1998.
31 
32 #ifndef G4VISEXECUTIVE_ICC
33 #define G4VISEXECUTIVE_ICC
34 
35 // Supported drivers...
36 
37 // Not needing external packages or libraries...
38 #include "G4ASCIITree.hh"
39 #include "G4DAWNFILE.hh"
40 #include "G4HepRep.hh"
41 #include "G4HepRepFile.hh"
42 #include "G4RayTracer.hh"
43 #include "G4HitFilterFactories.hh"
44 #include "G4DigiFilterFactories.hh"
45 #include "G4TrajectoryFilterFactories.hh"
46 #include "G4TrajectoryModelFactories.hh"
47 #include "G4VRML1File.hh"
48 #include "G4VRML2File.hh"
49 #include "G4GMocrenFile.hh"
50 
51 // FIXME : avoid mix with QT/WT driver (should be done by cmake??)
52 #if defined(G4VIS_USE_OPENGLWT)
53  // do not want GL2P2 in WT case
54  #undef G4VIS_BUILD_OPENGL_GL2PS
55 #endif
56 
57 // Needing external packages or libraries...
58 
59 #ifdef G4VIS_USE_DAWN
60 #include "G4FukuiRenderer.hh"
61 #endif
62 
63 #ifdef G4VIS_USE_OPENGLX
64 #include "G4OpenGLImmediateX.hh"
65 #include "G4OpenGLStoredX.hh"
66 #endif
67 
68 #ifdef G4VIS_USE_OPENGLWIN32
69 #include "G4OpenGLImmediateWin32.hh"
70 #include "G4OpenGLStoredWin32.hh"
71 #endif
72 
73 #ifdef G4VIS_USE_OPENGLXM
74 #include "G4OpenGLImmediateXm.hh"
75 #include "G4OpenGLStoredXm.hh"
76 #endif
77 
78 #ifdef G4VIS_USE_OPENGLQT
79 #include "G4OpenGLImmediateQt.hh"
80 #include "G4OpenGLStoredQt.hh"
81 #endif
82 
83 #ifdef G4VIS_USE_OPENGLWT
84 #include "G4OpenGLImmediateWt.hh"
85 #endif
86 
87 #ifdef G4VIS_USE_OIX
88 #include "G4OpenInventorX.hh"
89 #include "G4OpenInventorXtExtended.hh"
90 #endif
91 
92 #ifdef G4VIS_USE_OIWIN32
93 #include "G4OpenInventorWin32.hh"
94 #endif
95 
96 #ifdef G4VIS_USE_RAYTRACERX
97 #include "G4RayTracerX.hh"
98 #endif
99 
100 #ifdef G4VIS_USE_VRML
101 #include "G4VRML1.hh"
102 #include "G4VRML2.hh"
103 #endif
104 
105 inline
106 G4VisExecutive::G4VisExecutive (const G4String& verbosityString):
107  G4VisManager(verbosityString)
108 {}
109 
110 // The inline keyword prevents the compiler making an external
111 // reference even though they cannot actually be inlined since they
112 // are virtual functions. This prevents a "multiple definition" error
113 // if it is included in more than one file. However, as explained in
114 // the class description in G4VisExecutive.hh, it should never be
115 // necessary to #include "G4VisExecutive.hh" in more than one file
116 // since after instantiation the object can be treated as a
117 // G4VisManager.
118 inline void
119 G4VisExecutive::RegisterGraphicsSystems () {
120 
121  // Graphics Systems not needing external packages or libraries...
122  RegisterGraphicsSystem (new G4ASCIITree);
123  RegisterGraphicsSystem (new G4DAWNFILE);
124  RegisterGraphicsSystem (new G4HepRep);
125  RegisterGraphicsSystem (new G4HepRepFile);
126  RegisterGraphicsSystem (new G4RayTracer);
127  RegisterGraphicsSystem (new G4VRML1File);
128  RegisterGraphicsSystem (new G4VRML2File);
129  RegisterGraphicsSystem (new G4GMocrenFile);
130  // Graphics systems needing external packages or libraries...
131 
132 #ifdef G4VIS_USE_DAWN
133  RegisterGraphicsSystem (new G4FukuiRenderer);
134 #endif
135 
136 // Register OGL graphics system with generic nicknames.
137 // Note: Any graphics system can be used with any UI session except
138 // OPENGLQT - this must have a UI Qt session unless in batch mode. This
139 // is handled in /vis/sceneHandler/create but a potential fallback is
140 // defined here.
141 #ifdef G4VIS_USE_OPENGL
142  G4VGraphicsSystem* ogl = 0;
143  G4VGraphicsSystem* ogli = 0;
144  G4VGraphicsSystem* ogls = 0;
145  G4VGraphicsSystem* ogl_fallback = 0;
146  G4VGraphicsSystem* ogli_fallback = 0;
147  G4VGraphicsSystem* ogls_fallback = 0;
148 #ifdef G4VIS_USE_OPENGLQT
149  ogl = new G4OpenGLStoredQt;
150  ogli = new G4OpenGLImmediateQt;
151  ogls = new G4OpenGLStoredQt;
152 #if defined G4VIS_USE_OPENGLXM
153  ogl_fallback = new G4OpenGLStoredXm;
154  ogli_fallback = new G4OpenGLImmediateXm;
155  ogls_fallback = new G4OpenGLStoredXm;
156 #elif defined G4VIS_USE_OPENGLX
157  ogl_fallback = new G4OpenGLStoredX;
158  ogli_fallback = new G4OpenGLImmediateX;
159  ogls_fallback = new G4OpenGLStoredX;
160 #elif defined G4VIS_USE_OPENGLWIN32
161  ogl_fallback = new G4OpenGLStoredWin32;
162  ogli_fallback = new G4OpenGLImmediateWin32;
163  ogls_fallback = new G4OpenGLStoredWin32;
164 #endif
165 #elif defined G4VIS_USE_OPENGLWT
166  ogl = new G4OpenGLImmediateWt;
167  ogli = new G4OpenGLImmediateWt;
168  ogls = new G4OpenGLImmediateWt;
169 #elif defined G4VIS_USE_OPENGLXM
170  ogl = new G4OpenGLStoredXm;
171  ogli = new G4OpenGLImmediateXm;
172  ogls = new G4OpenGLStoredXm;
173 #elif defined G4VIS_USE_OPENGLWIN32
174  ogl = new G4OpenGLStoredWin32;
175  ogli = new G4OpenGLImmediateWin32;
176  ogls = new G4OpenGLStoredWin32;
177 #elif defined G4VIS_USE_OPENGLX
178  ogl = new G4OpenGLStoredX;
179  ogli = new G4OpenGLImmediateX;
180  ogls = new G4OpenGLStoredX;
181 #endif
182  if (ogl) {
183  ogl->SetNickname("OGL");
184  RegisterGraphicsSystem (ogl);
185  }
186  if (ogli) {
187  ogli->SetNickname("OGLI");
188  RegisterGraphicsSystem (ogli);
189  }
190  if (ogls) {
191  ogls->SetNickname("OGLS");
192  RegisterGraphicsSystem (ogls);
193  }
194  if (ogl_fallback) {
195  ogl_fallback->SetNickname("OGL_FALLBACK");
196  RegisterGraphicsSystem (ogl_fallback);
197  }
198  if (ogli_fallback) {
199  ogli_fallback->SetNickname("OGLI_FALLBACK");
200  RegisterGraphicsSystem (ogli_fallback);
201  }
202  if (ogls_fallback) {
203  ogls_fallback->SetNickname("OGLS_FALLBACK");
204  RegisterGraphicsSystem (ogls_fallback);
205  }
206 #endif
207 
208 #ifdef G4VIS_USE_OPENGLX
209  RegisterGraphicsSystem (new G4OpenGLImmediateX);
210  RegisterGraphicsSystem (new G4OpenGLStoredX);
211 #endif
212 
213 #ifdef G4VIS_USE_OPENGLWIN32
214  RegisterGraphicsSystem (new G4OpenGLImmediateWin32);
215  RegisterGraphicsSystem (new G4OpenGLStoredWin32);
216 #endif
217 
218 #ifdef G4VIS_USE_OPENGLXM
219  RegisterGraphicsSystem (new G4OpenGLImmediateXm);
220  RegisterGraphicsSystem (new G4OpenGLStoredXm);
221 #endif
222 
223 #ifdef G4VIS_USE_OPENGLQT
224  G4VGraphicsSystem* gsi = new G4OpenGLImmediateQt;
225  G4VGraphicsSystem* gss = new G4OpenGLStoredQt;
226  RegisterGraphicsSystem (gsi);
227  RegisterGraphicsSystem (gss);
228  G4VGraphicsSystem* gsi_fallback = 0;
229  G4VGraphicsSystem* gss_fallback = 0;
230 #if defined G4VIS_USE_OPENGLXM
231  gsi_fallback = new G4OpenGLImmediateXm;
232  gss_fallback = new G4OpenGLStoredXm;
233 #elif defined G4VIS_USE_OPENGLX
234  gsi_fallback = new G4OpenGLImmediateX;
235  gss_fallback = new G4OpenGLStoredX;
236 #elif defined G4VIS_USE_OPENGLWIN32
237  gsi_fallback = new G4OpenGLImmediateWin32;
238  gss_fallback = new G4OpenGLStoredWin32;
239 #endif
240  if (gsi_fallback) {
241  gsi_fallback->SetNickname(gsi->GetNickname()+"_FALLBACK");
242  RegisterGraphicsSystem (gsi_fallback);
243  }
244  if (gss_fallback) {
245  gss_fallback->SetNickname(gss->GetNickname()+"_FALLBACK");
246  RegisterGraphicsSystem (gss_fallback);
247  }
248 #endif
249 
250 #ifdef G4VIS_USE_OPENGLWT
251  RegisterGraphicsSystem (new G4OpenGLImmediateWt);
252 #endif
253 
254 // Register OI graphics system with generic nickname
255 #ifdef G4VIS_USE_OI
256  G4VGraphicsSystem* oi = 0;
257 #ifdef G4VIS_USE_OIX
258  oi = new G4OpenInventorX;
259 #endif
260 #ifdef G4VIS_USE_OIWIN32
261  oi = new G4OpenInventorWin32;
262 #endif
263  if (oi) {
264  oi->SetNickname("OI");
265  RegisterGraphicsSystem (oi);
266  }
267 #endif
268 
269 #ifdef G4VIS_USE_OIX
270  RegisterGraphicsSystem (new G4OpenInventorX);
271  RegisterGraphicsSystem (new G4OpenInventorXtExtended);
272 #endif
273 
274 #ifdef G4VIS_USE_OIWIN32
275  RegisterGraphicsSystem (new G4OpenInventorWin32);
276 #endif
277 
278 #ifdef G4VIS_USE_RAYTRACERX
279  RegisterGraphicsSystem (new G4RayTracerX);
280 #endif
281 
282 #ifdef G4VIS_USE_VRML
283  RegisterGraphicsSystem (new G4VRML1);
284  RegisterGraphicsSystem (new G4VRML2);
285 #endif
286 
287 }
288 
289 // See comments about inlining above.
290 inline void
291 G4VisExecutive::RegisterModelFactories()
292 {
293  // Trajectory draw models
294  RegisterModelFactory(new G4TrajectoryGenericDrawerFactory());
295  RegisterModelFactory(new G4TrajectoryDrawByChargeFactory());
296  RegisterModelFactory(new G4TrajectoryDrawByParticleIDFactory());
297  RegisterModelFactory(new G4TrajectoryDrawByOriginVolumeFactory());
298  RegisterModelFactory(new G4TrajectoryDrawByAttributeFactory());
299 
300  // Trajectory filter models
301  RegisterModelFactory(new G4TrajectoryChargeFilterFactory());
302  RegisterModelFactory(new G4TrajectoryParticleFilterFactory());
303  RegisterModelFactory(new G4TrajectoryOriginVolumeFilterFactory());
304  RegisterModelFactory(new G4TrajectoryAttributeFilterFactory());
305 
306  // Hit filter models
307  RegisterModelFactory(new G4HitAttributeFilterFactory());
308 
309  // Digi filter models
310  RegisterModelFactory(new G4DigiAttributeFilterFactory());
311 }
312 
313 #endif